NEW Add Expense report to approve into workboard

NEW Selection of boxes is move on top
This commit is contained in:
Laurent Destailleur 2016-01-18 11:35:45 +01:00
parent 4b94c2ade7
commit 6bccac5691
10 changed files with 119 additions and 53 deletions

View File

@ -179,8 +179,8 @@ class modMyModule extends DolibarrModules
// Cronjobs // Cronjobs
$this->cronjobs = array(); // List of cron jobs entries to add $this->cronjobs = array(); // List of cron jobs entries to add
// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600), // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600) // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24)
// ); // );
// Permissions // Permissions

View File

@ -168,7 +168,28 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
} }
} }
/**
* Standard method to get content of a box
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
*
* @return string
*/
function outputBox($head = null, $contents = null)
{
global $langs, $user, $conf;
// Trick to get result into a var from a function that makes print instead of return
ob_start();
$result = $this->showBox($head, $contents);
$output = ob_get_contents();
ob_end_clean();
return $output;
}
/** /**
*Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function) *Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function)
* *
@ -177,7 +198,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
* *
* @return void * @return void
*/ */
function showBox($head, $contents) function showBox($head = null, $contents = null)
{ {
global $langs, $user, $conf; global $langs, $user, $conf;

View File

@ -967,7 +967,7 @@ class FormOther
* *
* @param User $user Object User * @param User $user Object User
* @param String $areacode Code of area for pages (0=value for Home page) * @param String $areacode Code of area for pages (0=value for Home page)
* @return int <0 if KO, Nb of boxes shown of OK (0 to n) * @return array array('selectboxlist'=>, 'boxactivated'=>, 'boxlist'=>)
*/ */
static function printBoxesArea($user,$areacode) static function printBoxesArea($user,$areacode)
{ {
@ -977,14 +977,15 @@ class FormOther
$confuserzone='MAIN_BOXES_'.$areacode; $confuserzone='MAIN_BOXES_'.$areacode;
$selectboxlist=$boxlist='';
$boxactivated=InfoBox::listBoxes($db,'activated',$areacode,(empty($user->conf->$confuserzone)?null:$user)); // Search boxes of common+user (or common only if user has no specific setup) $boxactivated=InfoBox::listBoxes($db,'activated',$areacode,(empty($user->conf->$confuserzone)?null:$user)); // Search boxes of common+user (or common only if user has no specific setup)
$boxidactivatedforuser=array(); $boxidactivatedforuser=array();
foreach($boxactivated as $box) foreach($boxactivated as $box)
{ {
if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user
} }
$selectboxlist='';
$arrayboxtoactivatelabel=array(); $arrayboxtoactivatelabel=array();
if (! empty($user->conf->$confuserzone)) if (! empty($user->conf->$confuserzone))
{ {
@ -1019,7 +1020,7 @@ class FormOther
// Javascript code for dynamic actions // Javascript code for dynamic actions
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
print '<script type="text/javascript" language="javascript"> $selectboxlist.='<script type="text/javascript" language="javascript">
// To update list of activated boxes // To update list of activated boxes
function updateBoxOrder(closing) { function updateBoxOrder(closing) {
@ -1058,8 +1059,8 @@ class FormOther
window.location.search=\'mainmenu='.GETPOST("mainmenu").'&leftmenu='.GETPOST('leftmenu').'&action=addbox&boxid=\'+boxid; window.location.search=\'mainmenu='.GETPOST("mainmenu").'&leftmenu='.GETPOST('leftmenu').'&action=addbox&boxid=\'+boxid;
} }
});'; });';
if (! count($arrayboxtoactivatelabel)) print 'jQuery("#boxcombo").hide();'; if (! count($arrayboxtoactivatelabel)) $selectboxlist.='jQuery("#boxcombo").hide();';
print ' $selectboxlist.='
jQuery("#left, #right").sortable({ jQuery("#left, #right").sortable({
/* placeholder: \'ui-state-highlight\', */ /* placeholder: \'ui-state-highlight\', */
@ -1084,12 +1085,11 @@ class FormOther
});'."\n"; });'."\n";
print '</script>'."\n"; $selectboxlist.='</script>'."\n";
} }
$nbboxactivated=count($boxidactivatedforuser); $nbboxactivated=count($boxidactivatedforuser);
//print load_fiche_titre(($nbboxactivated?$langs->trans("OtherInformationsBoxes"):''),$selectboxlist,'','','otherboxes');
print load_fiche_titre(($nbboxactivated?$langs->trans("OtherInformationsBoxes"):''),$selectboxlist,'','','otherboxes');
if ($nbboxactivated) if ($nbboxactivated)
{ {
@ -1098,13 +1098,13 @@ class FormOther
$emptybox=new ModeleBoxes($db); $emptybox=new ModeleBoxes($db);
print '<table width="100%" class="notopnoleftnoright">'; $boxlist.='<table width="100%" class="notopnoleftnoright">';
print '<tr><td class="notopnoleftnoright">'."\n"; $boxlist.='<tr><td class="notopnoleftnoright">'."\n";
print '<div class="fichehalfleft">'; $boxlist.='<div class="fichehalfleft">';
print "\n<!-- Box left container -->\n"; $boxlist.="\n<!-- Box left container -->\n";
print '<div id="left" class="connectedSortable">'."\n"; $boxlist.='<div id="left" class="connectedSortable">'."\n";
// Define $box_max_lines // Define $box_max_lines
$box_max_lines=5; $box_max_lines=5;
@ -1122,7 +1122,7 @@ class FormOther
//print 'box_order '.$boxactivated[$ii]->box_order.'<br>'; //print 'box_order '.$boxactivated[$ii]->box_order.'<br>';
// Affichage boite key // Affichage boite key
$box->loadBox($box_max_lines); $box->loadBox($box_max_lines);
$box->showBox(); $boxlist.= $box->outputBox();
} }
} }
@ -1131,15 +1131,15 @@ class FormOther
$emptybox->box_id='A'; $emptybox->box_id='A';
$emptybox->info_box_head=array(); $emptybox->info_box_head=array();
$emptybox->info_box_contents=array(); $emptybox->info_box_contents=array();
$emptybox->showBox(array(),array()); $boxlist.= $emptybox->outputBox(array(),array());
} }
print "</div>\n"; $boxlist.= "</div>\n";
print "<!-- End box left container -->\n"; $boxlist.= "<!-- End box left container -->\n";
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; $boxlist.= '</div><div class="fichehalfright"><div class="ficheaddleft">';
print "\n<!-- Box right container -->\n"; $boxlist.= "\n<!-- Box right container -->\n";
print '<div id="right" class="connectedSortable">'."\n"; $boxlist.= '<div id="right" class="connectedSortable">'."\n";
$ii=0; $ii=0;
foreach ($boxactivated as $key => $box) foreach ($boxactivated as $key => $box)
@ -1153,7 +1153,7 @@ class FormOther
//print 'box_order '.$boxactivated[$ii]->box_order.'<br>'; //print 'box_order '.$boxactivated[$ii]->box_order.'<br>';
// Affichage boite key // Affichage boite key
$box->loadBox($box_max_lines); $box->loadBox($box_max_lines);
$box->showBox(); $boxlist.= $box->outputBox();
} }
} }
@ -1162,19 +1162,19 @@ class FormOther
$emptybox->box_id='B'; $emptybox->box_id='B';
$emptybox->info_box_head=array(); $emptybox->info_box_head=array();
$emptybox->info_box_contents=array(); $emptybox->info_box_contents=array();
$emptybox->showBox(array(),array()); $boxlist.= $emptybox->outputBox(array(),array());
} }
print "</div>\n"; $boxlist.= "</div>\n";
print "<!-- End box right container -->\n"; $boxlist.= "<!-- End box right container -->\n";
print '</div></div>'; $boxlist.= '</div></div>';
print "\n"; $boxlist.= "\n";
print "</td></tr>"; $boxlist.= "</td></tr>";
print "</table>"; $boxlist.= "</table>";
} }
return count($boxactivated); return array('selectboxlist'=>$nbboxactivated?$selectboxlist:'', 'boxactivated'=>$boxactivated, 'boxlist'=>$boxlist);
} }

View File

@ -105,7 +105,19 @@ class modFacture extends DolibarrModules
2=>array('file'=>'box_graph_invoices_permonth.php','enabledbydefaulton'=>'Home') 2=>array('file'=>'box_graph_invoices_permonth.php','enabledbydefaulton'=>'Home')
); );
// Permissions // Cronjobs
$this->cronjobs = array(
0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'Facture', 'method'=>'generateRecurringInvoices', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600)
);
// List of cron jobs entries to add
// Example:
// $this->cronjobs=array(
// 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600)
// );
// Permissions
$this->rights = array(); $this->rights = array();
$this->rights_class = 'facture'; $this->rights_class = 'facture';
$r=0; $r=0;

View File

@ -1509,9 +1509,10 @@ class ExpenseReport extends CommonObject
* Load indicators for dashboard (this->nbtodo and this->nbtodolate) * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
* *
* @param User $user Objet user * @param User $user Objet user
* @param string $option 'topay' or 'toapprove'
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
*/ */
function load_board($user) function load_board($user, $option='topay')
{ {
global $conf, $langs; global $conf, $langs;
@ -1521,7 +1522,8 @@ class ExpenseReport extends CommonObject
$sql = "SELECT ex.rowid, ex.date_valid"; $sql = "SELECT ex.rowid, ex.date_valid";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex";
$sql.= " WHERE ex.fk_statut = 5"; if ($option == 'toapprove') $sql.= " WHERE ex.fk_statut = 2";
else $sql.= " WHERE ex.fk_statut = 5";
$sql.= " AND ex.entity IN (".getEntity('expensereport', 1).")"; $sql.= " AND ex.entity IN (".getEntity('expensereport', 1).")";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -1530,18 +1532,36 @@ class ExpenseReport extends CommonObject
$langs->load("members"); $langs->load("members");
$response = new WorkboardResponse(); $response = new WorkboardResponse();
$response->warning_delay=$conf->expensereport->payment->warning_delay/60/60/24; if ($option == 'toapprove')
$response->label=$langs->trans("ExpenseReportsToPay"); {
$response->url=DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&amp;statut=5'; $response->warning_delay=$conf->expensereport->approve->warning_delay/60/60/24;
$response->label=$langs->trans("ExpenseReportsToApprove");
$response->url=DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&amp;statut=2';
}
else
{
$response->warning_delay=$conf->expensereport->payment->warning_delay/60/60/24;
$response->label=$langs->trans("ExpenseReportsToPay");
$response->url=DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&amp;statut=5';
}
$response->img=img_object($langs->trans("ExpenseReports"),"trip"); $response->img=img_object($langs->trans("ExpenseReports"),"trip");
while ($obj=$this->db->fetch_object($resql)) while ($obj=$this->db->fetch_object($resql))
{ {
$response->nbtodo++; $response->nbtodo++;
if ($this->db->jdate($obj->datevalid) < ($now - $conf->expensereport->payment->warning_delay)) { if ($option == 'toapprove')
$response->nbtodolate++; {
} if ($this->db->jdate($obj->datevalid) < ($now - $conf->expensereport->approve->warning_delay)) {
$response->nbtodolate++;
}
}
else
{
if ($this->db->jdate($obj->datevalid) < ($now - $conf->expensereport->payment->warning_delay)) {
$response->nbtodolate++;
}
}
} }
return $response; return $response;

View File

@ -71,7 +71,11 @@ if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$langs->trans("HomeAr
llxHeader('',$title); llxHeader('',$title);
print load_fiche_titre($langs->trans("HomeArea"),'','title_home');
$resultboxes=FormOther::printBoxesArea($user,"0");
print load_fiche_titre($langs->trans("HomeArea"),$resultboxes['selectboxlist'],'title_home');
if (! empty($conf->global->MAIN_MOTD)) if (! empty($conf->global->MAIN_MOTD))
{ {
@ -417,13 +421,22 @@ if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire && ! $use
$dashboardlines[] = $board->load_board($user); $dashboardlines[] = $board->load_board($user);
} }
// Number of expense reports to pay // Number of expense reports to approve
if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->approve)
{ {
include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$board=new ExpenseReport($db); $board=new ExpenseReport($db);
$dashboardlines[] = $board->load_board($user); $dashboardlines[] = $board->load_board($user,'toapprove');
}
// Number of expense reports to pay
if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid)
{
include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$board=new ExpenseReport($db);
$dashboardlines[] = $board->load_board($user,'topay');
} }
// Calculate total nb of late // Calculate total nb of late
@ -491,13 +504,11 @@ print '</table>'; // End table array
print '</div></div></div><div class="fichecenter"><br>'; print '</div></div></div><div class="fichecenter"><br>';
/* /*
* Show boxes * Show boxes
*/ */
FormOther::printBoxesArea($user,"0"); print $resultboxes['boxlist'];
print '</div>'; print '</div>';

View File

@ -33,4 +33,5 @@ UPDATE llx_projet as p set opp_percent = (SELECT percent from llx_c_lead_status
ALTER TABLE llx_overwrite_trans ADD UNIQUE INDEX uk_overwrite_trans(lang, transkey); ALTER TABLE llx_overwrite_trans ADD UNIQUE INDEX uk_overwrite_trans(lang, transkey);
ALTER TABLE llx_cronjob MODIFY COLUMN unitfrequency varchar(255) NOT NULL DEFAULT '3600';

View File

@ -40,7 +40,7 @@ CREATE TABLE llx_cronjob
datelastresult datetime, -- date last run end datelastresult datetime, -- date last run end
lastresult text, lastresult text,
lastoutput text, lastoutput text,
unitfrequency integer NOT NULL DEFAULT 0, unitfrequency varchar(255) NOT NULL DEFAULT '3600',
frequency integer NOT NULL DEFAULT 0, frequency integer NOT NULL DEFAULT 0,
maxrun integer NOT NULL DEFAULT 0, -- set this to 1 for a job queued for on run only maxrun integer NOT NULL DEFAULT 0, -- set this to 1 for a job queued for on run only
nbrun integer, -- nb of run complete (failed or not) nbrun integer, -- nb of run complete (failed or not)

View File

@ -99,4 +99,5 @@ ConfirmSaveTrip=Are you sure you want to validate this expense report ?
NoTripsToExportCSV=No expense report to export for this period. NoTripsToExportCSV=No expense report to export for this period.
ExpenseReportPayment=Expense report payment ExpenseReportPayment=Expense report payment
ExpenseReportsToApprove=Expense reports to approve
ExpenseReportsToPay=Expense reports to pay ExpenseReportsToPay=Expense reports to pay

View File

@ -593,12 +593,12 @@ div.fichecenter {
} }
div.fichethirdleft { div.fichethirdleft {
<?php if ($conf->browser->layout != 'phone') { print "float: ".$left.";\n"; } ?> <?php if ($conf->browser->layout != 'phone') { print "float: ".$left.";\n"; } ?>
<?php if ($conf->browser->layout != 'phone') { print "width: 35%;\n"; } ?> <?php if ($conf->browser->layout != 'phone') { print "width: 50%;\n"; } ?>
<?php if ($conf->browser->layout == 'phone') { print "padding-bottom: 6px;\n"; } ?> <?php if ($conf->browser->layout == 'phone') { print "padding-bottom: 6px;\n"; } ?>
} }
div.fichetwothirdright { div.fichetwothirdright {
<?php if ($conf->browser->layout != 'phone') { print "float: ".$right.";\n"; } ?> <?php if ($conf->browser->layout != 'phone') { print "float: ".$right.";\n"; } ?>
<?php if ($conf->browser->layout != 'phone') { print "width: 65%;\n"; } ?> <?php if ($conf->browser->layout != 'phone') { print "width: 50%;\n"; } ?>
<?php if ($conf->browser->layout == 'phone') { print "padding-bottom: 6px\n"; } ?> <?php if ($conf->browser->layout == 'phone') { print "padding-bottom: 6px\n"; } ?>
} }
div.fichehalfleft { div.fichehalfleft {