phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] rostering inc/class.borostering.inc.php inc/cla...


From: Dave Hall
Subject: [Phpgroupware-cvs] rostering inc/class.borostering.inc.php inc/cla...
Date: Tue, 13 Feb 2007 13:50:17 +0000

CVSROOT:        /cvsroot/phpgroupware
Module name:    rostering
Changes by:     Dave Hall <skwashd>     07/02/13 13:50:17

Modified files:
        inc            : class.borostering.inc.php 
                         class.sorostering.inc.php 
                         class.uirostering.inc.php 
        js/base        : site_view.js 
        templates/base : app_data.xsl 

Log message:
        getting closer

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/rostering/inc/class.borostering.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/rostering/inc/class.sorostering.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/rostering/inc/class.uirostering.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/rostering/js/base/site_view.js?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/rostering/templates/base/app_data.xsl?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2

Patches:
Index: inc/class.borostering.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/rostering/inc/class.borostering.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.borostering.inc.php       25 Sep 2006 17:30:33 -0000      1.1.1.1
+++ inc/class.borostering.inc.php       13 Feb 2007 13:50:17 -0000      1.2
@@ -53,11 +53,11 @@
                        (
                                'end_hr'        => $_POST['end_hr'],
                                'end_min'       => $_POST['end_min'],
-                               'roster_d'      => $_POST['roster_d'],
-                               'roster_m'      => $_POST['roster_m'],
-                               'roster_y'      => $_POST['roster_y'],
-                               'site_id'       => $_POST['site_id'],
-                               'staff_id'      => $_POST['staff_id'],
+                               'roster_d'      => $_POST['a_roster_d'],
+                               'roster_m'      => $_POST['a_roster_m'],
+                               'roster_y'      => $_POST['a_roster_y'],
+                               'site_id'       => $_POST['a_site_id'],
+                               'staff_id'      => $_POST['a_staff_id'],
                                'start_hr'      => $_POST['start_hr'],
                                'start_min'     => $_POST['start_min']
                        );
@@ -70,12 +70,12 @@
 
                        if ( $entry['shift_s'] = @mktime($entry['start_hr'], 
$entry['start_min'], 0, $entry['roster_m'], $entry['roster_d'], 
$entry['roster_y']) <= 0 )
                        {
-                               $invalid['start_date'] = true;
+                               $invalid['start_date'] = 'Start time is 
invalid';
                        }
 
                        if ( $entry['shift_e'] = @mktime($entry['end_hr'], 
$entry['end_min'], 0, $entry['roster_m'], $entry['roster_d'], 
$entry['roster_y']) <= 0 )
                        {
-                               $invalid['end_date'] = true;
+                               $invalid['end_date'] = 'End time is invalid';
                        }
 
                        if ( count($invalid) || !($entry = 
$this->so->add_shift($entry) ) )
@@ -138,8 +138,6 @@
                        {
                                $site_id = $_GET['site_id'];
                        }
-                       //FIXME remove this once testing is done
-                       $site_id = 21;
                        $persons = array();
 
                        $fields = array ('contact_id', 'per_first_name', 
'per_last_name', 'per_title');

Index: inc/class.sorostering.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/rostering/inc/class.sorostering.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.sorostering.inc.php       25 Sep 2006 17:30:34 -0000      1.1.1.1
+++ inc/class.sorostering.inc.php       13 Feb 2007 13:50:17 -0000      1.2
@@ -32,8 +32,14 @@
                        {
                                $entry[$key] = (int) $val;
                        }
-
-                       $sql = 'INSERT INTO phpgw_roster_shifts(site_id, 
staff_id, shift_s, shift_e, lastmod, lastmod_user)';
+                       $start = mktime($entry['roster_m'], $entry['roster_d'], 
$entry['roster_y'], $entry['start_hr'], $entry['start_min']);
+                       $end = mktime($entry['roster_m'], $entry['roster_d'], 
$entry['roster_y'], $entry['end_hr'], $entry['end_min']);
+                       $now = time();
+
+                       $sql = 'INSERT INTO phpgw_roster_shifts(site_id, 
staff_id, shift_s, shift_e, lastmod, lastmod_user)'
+                               . "VALUES({$entry['site_id']}, 
{$entry['staff_id']}, $start, $end, $now, 
{$GLOBALS['phpgw_info']['user']['account_id']})";
+                       $this->db->query($sql, __LINE__. __FILE__);
+                       return 
$this->db->get_last_insert_id('phpgw_rostering_shifts', 'shift_id');
                }
 
                /**
@@ -193,7 +199,7 @@
                        $this->db->query('INSERT INTO 
phpgw_roster_shifts(site_id, staff_id, shift_s, shift_e, lastmod, lastmod_id)'
                                                . "VALUES($site_id, $staff_id, 
$start, $end, $ts, $ts_id)", __LINE__, __FILE__);
 
-                       return 
$this->db->last_insert_id('phpgw_rostering_shifts, shift_id');
+                       return 
$this->db->get_last_insert_id('phpgw_rostering_shifts', 'shift_id');
                }
 
                /**

Index: inc/class.uirostering.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/rostering/inc/class.uirostering.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- inc/class.uirostering.inc.php       26 Sep 2006 13:17:00 -0000      1.2
+++ inc/class.uirostering.inc.php       13 Feb 2007 13:50:17 -0000      1.3
@@ -187,7 +187,26 @@
                */
                function _access_denied()
                {
-                       die('the computer says no!');
+                       if ( 
isset($GLOBALS['phpgw_info']['user']['apps']['admin']) )
+                       {
+                               $content = array
+                               (
+                                       'lang_no_cats'  => lang('No work sites 
available'),
+                                       'lang_setup'    => lang('create a work 
site'),
+                                       'url_setup'             => 
$GLOBALS['phpgw']->link('/index.php', 
+                                               array
+                                               (
+                                                       'menuaction'    => 
'admin.uicategories.index',
+                                                       'appname'               
=> 'rostering'
+                                               ))
+                               );
+                               $this->t->set_var('phpgw', array('denied_admin' 
=> $content));
+                       }
+                       else
+                       {
+                               $content = array('lang_denied' => lang('you do 
have access to any categories, please contact your system administrator'));
+                               $this->t->set_var('phpgw', array('denied_user' 
=> $content));
+                       }
                }
 
                function _get_footer($args, $can_edit = false)
@@ -242,10 +261,12 @@
                                'roster_m'              => date('m', $start),
                                'roster_y'              => date('Y', $start),
                                'site_id'               => (int) $site_id,
+                               'staff'                 => 
$this->bo->get_staff_list($site_id),
                                'header'                => 
$this->_get_header('site_view', $site_id, $start),
                                'shifts'                => 
$this->bo->get_site_roster($site_id, $start, $end),
                                'footer'                => 
$this->_get_footer($this->bo->has_rights($site_id, PHPGW_ACL_EDIT)),
-                               'form_action'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'rostering.borostering.add_shift', 'phpgw_return_as' => 'json') ),
+                               'form_action_add'       => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'rostering.borostering.add_shift', 'phpgw_return_as' => 'json') ),
+                               'form_action_edit'      => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'rostering.borostering.edit_shift', 'phpgw_return_as' => 'json') ),
                                'lang'                  => array
                                                                (
                                                                        'add'   
                => lang('add'),

Index: js/base/site_view.js
===================================================================
RCS file: /cvsroot/phpgroupware/rostering/js/base/site_view.js,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- js/base/site_view.js        28 Dec 2006 04:55:42 -0000      1.2
+++ js/base/site_view.js        13 Feb 2007 13:50:17 -0000      1.3
@@ -5,7 +5,80 @@
 
 function submitCallback(obj)
 {
-       alert(obj.responseText);
+       var response = eval(obj.responseText);
+       if ( isNaN(response) )
+       {
+               alert('Invalid shift, try again');
+               dlg.render();
+               return false;
+       }
+       var oFormElms = {
+                                               roster_d:       
document.getElementById('a_roster_d').value,
+                                               roster_m:       
document.getElementById('a_roster_m').value,
+                                               roster_y:       
document.getElementById('a_roster_y').value,
+                                               start_h:        
document.getElementById('start_hr').value,
+                                               start_m:        
document.getElementById('start_min').value,
+                                               end_h:          
document.getElementById('end_hr').value,
+                                               end_m:          
document.getElementById('end_min').value,
+                                               staff_id:       
document.getElementById('a_staff_id').options[document.getElementById('a_staff_id').selectedIndex].value,
+                                               staff_name:     
document.getElementById('a_staff_id').options[document.getElementById('a_staff_id').selectedIndex].text
+                                       };
+
+       var dStart = new Date(oFormElms.roster_y, oFormElms.roster_m, 
oFormElms.roster_m, oFormElms.start_h, oFormElms.start_m, 0);
+       var dEnd = new Date(oFormElms.roster_y, oFormElms.roster_m, 
oFormElms.roster_m, oFormElms.end_h, oFormElms.end_m, 0);
+
+       var oTBody = document.getElementById('roster_contents')
+
+       var oTR = document.createElement('tr');
+       oTR.id = 'shift_' + response;
+       oTR.ondbclick = 'editEntry(this.id)';
+       oTR.className = oTBody.childNodes.length % 2 ? 'row_on' : 'row_off';
+
+       var oTD = document.createElement('td');
+       oTD.className = "staff_name";
+       oTD.appendChild(document.createTextNode(oFormElms.staff_name));
+       
+       var oHidden = document.createElement('input');
+       oHidden.id = 'shift_start_' + response;
+       oHidden.name = oHidden.id;
+       oHidden.type = 'hidden';
+       oHidden.className = 'hidden';
+       oHidden.value = dStart;
+       oTD.appendChild(oHidden);
+
+       var oHidden = document.createElement('input');
+       oHidden.id = 'shift_end_' + response;
+       oHidden.name = oHidden.id;
+       oHidden.type = 'hidden';
+       oHidden.className = 'hidden';
+       oHidden.value = dEnd;
+       oTD.appendChild(oHidden);
+
+       oTR.appendChild(oTD);
+       oTBody.appendChild(oTR);
+
+       var iStart = (oFormElms.start_h * 2) + (oFormElms.start_m == 30 ? 1 : 
0);
+       var iEnd = (oFormElms.end_h * 2) + (oFormElms.end_m == 30 ? 1 : 0);
+       var i = 0;
+       while ( i < 48 )
+       {
+               oTD = document.createElement('td');
+               if ( iStart <= i && iEnd > i )
+               {
+                       oTD.className = 'shift_on';
+                       oTD.appendChild(document.createTextNode('X'));
+               }
+               else
+               {
+                       oTD.appendChild(document.createTextNode(' '));
+               }
+               oTR.appendChild(oTD);
+               ++i;
+       }
+       oTD = document.createElement('td');
+       oTD.className = 'total';
+       oTD.appendChild(document.createTextNode( (Math.round( ( 
(dEnd.getTime()/1000) - (dStart.getTime()/1000) ) / 60 / 6) / 10) + 'hrs' )); 
// round (time in seconds / seconds / (min * 10) ) / 10 for the right decimal 
places :)
+       oTR.appendChild(oTD);
 }
 
 function submitFailure(obj)
@@ -38,12 +111,6 @@
        
        dlg.callback.success = submitCallback;
        dlg.callback.failure = submitFailure;
-       
-       var handleManual = function(type, args, obj)
-       {
-               alert("RECVd\n type: '" + type + "'\nargs: '" + args + "'\nobj: 
'" + obj + "'");
-       }
-       
        dlg.render();
 }
 

Index: templates/base/app_data.xsl
===================================================================
RCS file: /cvsroot/phpgroupware/rostering/templates/base/app_data.xsl,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- templates/base/app_data.xsl 25 Sep 2006 17:30:36 -0000      1.1.1.1
+++ templates/base/app_data.xsl 13 Feb 2007 13:50:17 -0000      1.2
@@ -1,4 +1,4 @@
-<!-- $Id: app_data.xsl,v 1.1.1.1 2006/09/25 17:30:36 skwashd Exp $ -->
+<!-- $Id: app_data.xsl,v 1.2 2007/02/13 13:50:17 skwashd Exp $ -->
 
 <xsl:template name="app_data">
        <xsl:choose>
@@ -8,9 +8,24 @@
                        <xsl:when test="select_site">
                                        <xsl:call-template name="select_site"/>
                        </xsl:when>
+                       <xsl:when test="denied_admin">
+                               <xsl:apply-templates select="denied_admin"/>
+                       </xsl:when>
+                       <xsl:when test="denied_user">
+                               <xsl:apply-templates select="denied_user"/>
+                       </xsl:when>
        </xsl:choose>
 </xsl:template>
 
+<xsl:template match="denied_admin">
+       <h2><xsl:value-of select="lang_no_cats" /></h2>
+       <p><a href="{url_setup}"><xsl:value-of select="lang_setup" /></a></p>
+</xsl:template>
+
+<xsl:template match="denied_user">
+       <h2><xsl:value-of select="lang_denied" /></h2>
+</xsl:template>
+
 <xsl:template match="view_site_roster">
        <h1><xsl:value-of select="lang/title" /></h1>
        <h2><xsl:value-of select="roster_date" /></h2>
@@ -70,7 +85,7 @@
                                        <th class="total"><xsl:value-of 
select="lang/hours" /></th>
                                </tr>
                        </thead>
-                       <tbody>
+                       <tbody id="roster_contents">
                                <xsl:for-each select="shifts">
                                        <xsl:call-template 
name="shift_site_view" />
                                </xsl:for-each>
@@ -82,7 +97,39 @@
        <div id="add_shift_dialog" class="panel">
                        <div class="hd"><div 
class="lt"></div><span><xsl:value-of select="lang/enter_hours" /></span><div 
class="rt"></div></div>
                                <div class="bd">
-                                       <form method="post" 
action="{form_action}" id="add_shiftForm" name="add_shiftForm">
+                       <form method="post" action="{form_action_add}" 
id="add_shiftForm" name="add_shiftForm">
+                               <div> <!-- STFU validator -->
+                                       <input type="hidden" class="hidden" 
name="a_roster_d" id="a_roster_d" value="{roster_d}" />
+                                       <input type="hidden" class="hidden" 
name="a_roster_m" id="a_roster_m" value="{roster_m}" />
+                                       <input type="hidden" class="hidden" 
name="a_roster_y" id="a_roster_y" value="{roster_y}" />
+                                       <input type="hidden" class="hidden" 
name="a_site_id" id="a_site_id" value="{site_id}" />
+                                       <label for="a_staff"><xsl:value-of 
select="lang/team_member" /></label>
+                                       <select name="a_staff_id" 
id="a_staff_id">
+                                               <xsl:apply-templates 
select="staff" />
+                                       </select><br />
+                                       
+                                       <label for="start_hr"><xsl:value-of 
select="lang/start_time" /></label>
+                                       <input type="text" name="start_hr" 
id="start_hr" />
+                                       <select name="start_min" id="start_min">
+                                               <option value="00">00</option>
+                                               <option value="30">30</option>
+                                       </select><br />
+
+                                       <label for="end_hr"><xsl:value-of 
select="lang/end_time" /></label>
+                                       <input type="text" name="end_hr" 
id="end_hr" />
+                                       <select name="end_min" id="end_min">
+                                               <option value="00">00</option>
+                                               <option value="30">30</option>
+                                       </select>
+                               </div>
+                       </form>
+               </div>
+       </div>
+
+       <div id="edit_shift_dialog" class="panel">
+               <div class="hd"><div class="lt"></div><span><xsl:value-of 
select="lang/enter_hours" /></span><div class="rt"></div></div>
+               <div class="bd">
+                       <form method="post" action="{form_action_edit}" 
id="add_shiftForm" name="add_shiftForm">
                                                <div> <!-- STFU validator -->
                                                        <input type="hidden" 
class="hidden" name="roster_d" id="roster_d" value="{roster_d}" />
                                                        <input type="hidden" 
class="hidden" name="roster_m" id="roster_m" value="{roster_m}" />
@@ -90,7 +137,7 @@
                                                        <input type="hidden" 
class="hidden" name="site_id" id="site_id" value="{site_id}" />
                                                        <label 
for="staff"><xsl:value-of select="lang/team_member" /></label>
                                                        <select name="staff_id" 
id="staff_id">
-                                                               <option 
value="1">TODO Add staff list</option>
+                                               <xsl:apply-templates 
select="staff" />
                                                        </select><br />
                                                        
                                                        <label 
for="start_hr"><xsl:value-of select="lang/start_time" /></label>
@@ -203,5 +250,8 @@
                </xsl:attribute>
                <a href="{link}"><xsl:value-of select="name" /></a>
        </li>
+</xsl:template>
                        
+<xsl:template match="staff">
+       <option value="{id}"><xsl:value-of select="name" /><xsl:value-of 
select="staff_id" /></option>
 </xsl:template>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]