Skip to content

Commit

Permalink
Merge pull request #97 from delcroip/develop
Browse files Browse the repository at this point in the history
4.0.17
  • Loading branch information
delcroip authored Jun 11, 2019
2 parents 8d27aa6 + 8d9e7b7 commit ba1a7e9
Show file tree
Hide file tree
Showing 11 changed files with 400 additions and 393 deletions.
2 changes: 1 addition & 1 deletion build/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
volumes:
- ../htdocs:/var/www/html/custom:rw
ports:
- 801:80
- 8080:80
env_file:
.env
links:
Expand Down
48 changes: 33 additions & 15 deletions htdocs/timesheet/TimesheetProjectInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
//get param
$staticProject = new Project($db);
$projectId = GETPOST('projectid', 'int');
Expand Down Expand Up @@ -276,23 +277,24 @@
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$htmlother = new FormOther($db);
$sqlTail = '';
if(!$user->admin) {
$sqlTailJoin = ' JOIN '.MAIN_DB_PREFIX.'element_contact AS ec ON t.rowid = element_id ';
$sqlTailJoin .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_contact as ctc ON ctc.rowid = ec.fk_c_type_contact';
$sqlTailWhere = ' ((ctc.element in (\'project_task\') AND ctc.code LIKE \'%EXECUTIVE%\')OR (ctc.element in (\'project\') AND ctc.code LIKE \'%LEADER%\')) AND ctc.active = \'1\' ';
$sqlTailWhere .= ' AND fk_socpeople = \''.$userid.'\' and t.fk_statut = \'1\'';
}
//if(!$user->admin) {
// $sqlTailJoin = ' JOIN '.MAIN_DB_PREFIX.'element_contact AS ec ON t.rowid = element_id ';
// $sqlTailJoin .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_contact as ctc ON ctc.rowid = ec.fk_c_type_contact';
// $sqlTailWhere = ' ((ctc.element in (\'project_task\') AND ctc.code LIKE \'%EXECUTIVE%\')OR (ctc.element in (\'project\') AND ctc.code LIKE \'%LEADER%\')) AND ctc.active = \'1\' ';
// $sqlTailWhere .= ' AND fk_socpeople = \''.$userid.'\' and t.fk_statut = \'1\'';
//}
$Form = '<form name = "settings" action="?step=2" method = "POST" >'."\n\t";
$Form .= '<table class = "noborder" width = "100%">'."\n\t\t";
$Form .= '<tr class = "liste_titre" width = "100%" ><th colspan = "2">'.$langs->trans('generalInvoiceProjectParam').'</th></tr>';
$invoicingMethod = $conf->global->TIMESHEET_INVOICE_METHOD;
$Form .= '<tr class = "oddeven"><th align = "left" width = "80%">'.$langs->trans('Project').'</th><th align = "left" width = "80%" >';
//$Form .= '<tr class = "oddeven"><th align = "left" width = "80%">'.$langs->trans('Project').'</th><th align = "left" width = "80%" >';
//select_generic($table, $fieldValue, $htmlName, $fieldToShow1, $fieldToShow2 = '', $selected = '', $separator = ' - ', $sqlTailWhere = '', $selectparam = '', $addtionnalChoices = array('NULL'=>'NULL'), $sqlTailTable = '', $ajaxUrl = '')
$ajaxNbChar = $conf->global->PROJECT_USE_SEARCH_TO_SELECT;
//$ajaxNbChar = $conf->global->PROJECT_USE_SEARCH_TO_SELECT;
//$Form .= select_generic('projet', 'rowid', 'projectid', 'ref', 'title', $projectId, ' - ', $sqlTailWhere, '', null, , $ajaxNbChar);
$htmlProjectArray = array('name'=>'projectid', 'ajaxNbChar'=>$ajaxNbChar, 'otherparam'=>' onchange = "reload(this.form)"');
$sqlProjectArray = array('table'=>'projet', 'keyfield'=>'t.rowid', 'fields'=>'t.ref, t.title ', 'join'=>$sqlTailJoin, 'where'=>$sqlTailWhere, 'separator' => ' - ');
$Form .= select_sellist($sqlProjectArray, $htmlProjectArray, $projectId);
//$htmlProjectArray = array('name'=>'projectid', 'ajaxNbChar'=>$ajaxNbChar, 'otherparam'=>' onchange = "reload(this.form)"');
//$sqlProjectArray = array('table'=>'projet', 'keyfield'=>'t.rowid', 'fields'=>'t.ref, t.title ', 'join'=>$sqlTailJoin, 'where'=>$sqlTailWhere, 'separator' => ' - ');
//$Form .= select_sellist($sqlProjectArray, $htmlProjectArray, $projectId);
$Form .= '<input type = "hidden" name = "projectid" value = "'.$projectId.'">';
$Form .= '<tr class = "oddeven"><th align = "left" width = "80%">'.$langs->trans('DateStart').'</th>';
$Form .= '<th align = "left" width = "80%">'.$form->select_date($dateStart, 'dateStart', 0, 0, 0, "", 1, 1, 1)."</th></tr>";
$Form .= '<tr class = "oddeven"><th align = "left" width = "80%">'.$langs->trans('DateEnd').'</th>';
Expand Down Expand Up @@ -337,6 +339,11 @@
****************************************************/
$morejs = array("/timesheet/core/js/jsparameters.php", "/timesheet/core/js/timesheet.js?".$conf->global->TIMESHEET_VERSION);
llxHeader('', $langs->trans('TimesheetToInvoice'), '', '', '', '', $morejs);
print "<div> <!-- module body-->";
$project= new Project($db);
$project->fetch($projectId);
$headProject=project_prepare_head($project);
dol_fiche_head($headProject, 'invoice', $langs->trans("Project"), 0, 'project');
print $Form;
//javascript to reload the page with the poject selected
print '
Expand Down Expand Up @@ -370,16 +377,27 @@ function reload(form)
*/
function htmlPrintServiceChoice($user, $task, $class, $duration, $tasktimelist, $seller, $buyer)
{
global $form, $langs, $conf;
global $form, $langs, $conf, $db;
$taskLabel = '';
$userName = ($user == 'any')?(' - '):print_generic('user', 'rowid', $user, 'lastname', 'firstname', ' ');
$taskLabel = ($task == 'any')?(' - '):print_generic('projet_task', 'rowid', $task, 'ref', 'label', ' ');
if($task == 'any'){
$taskLabel = ' - ';
$taskHTML = ' - ';
} else {
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
$objtemp = new Task($db);
$objtemp->fetch($task);
$taskLabel = $objtemp->label ;
$taskHTML .= str_replace('classfortooltip', 'classfortooltip colTasks', $objtemp->getNomUrl(0, "withproject", "task", $conf->global->TIMESHEET_HIDE_REF));
}

$html = '<tr class = "'.$class.'"><th align = "left" width = "20%">'.$userName;
$html .= '</th><th align = "left" width = "20%">'.$taskLabel;
$html .= '</th><th align = "left" width = "20%">'.$taskHTML;
$html .= '<input type = "hidden" name = "userTask['.$user.']['.$task.'][userName]" value = "'.$userName.'">';
$html .= '<input type = "hidden" name = "userTask['.$user.']['.$task.'][taskLabel]" value = "'. $taskLabel.'">';
$html .= '<input type = "hidden" name = "userTask['.$user.']['.$task.'][taskTimeList]" value = "'. $tasktimelist.'">';
$defaultService = getDefaultService($user, $task);
$addchoices = array('-999'=> $langs->transnoentities('not2invoice'), -1=> $langs->transnoentities('Custom'));
$addchoices = array(0 => $langs->transnoentities('Custom').': '.$taskLabel, '-999'=> $langs->transnoentities('not2invoice'));
$ajaxNbChar = $conf->global->PRODUIT_USE_SEARCH_TO_SELECT;
$html .= '</th><th >';
$html .= select_sellist(array('table'=> 'product', 'keyfield'=> 'rowid', 'fields'=>'ref,label', 'where'=>' tosell = 1 AND fk_product_type = 1'),
Expand Down
8 changes: 4 additions & 4 deletions htdocs/timesheet/TimesheetReportProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@
}
$Form .= "<div id='quicklinks'>";
//This week quick link
$Form .= "<a class='tab' href ='?action=reportUser&projectSelected=".$projectSelectedId."&dateStart=".dol_print_date(strtotime("first day of this week"), 'dayxcard');
$Form .= "&dateEnd=".dol_print_date(strtotime("last day of this week"), 'dayxcard')."'>".$langs->trans('thisWeek')."</a>";
$Form .= "<a class='tab' href ='?action=reportUser&projectSelected=".$projectSelectedId."&dateStart=".dol_print_date(strtotime("monday this week"), 'dayxcard');
$Form .= "&dateEnd=".dol_print_date(strtotime("sunday this week"), 'dayxcard')."'>".$langs->trans('thisWeek')."</a>";
//This month quick link
$Form .= "<a class='tab' href ='?action=reportUser&projectSelected=".$projectSelectedId."&dateStart=".dol_print_date(strtotime("first day of this month"), 'dayxcard');
$Form .= "&dateEnd=".dol_print_date(strtotime("last day of this month"), 'dayxcard')."'>".$langs->trans('thisMonth')."</a>";
//last week quick link
$Form .= "<a class='tab' href ='?action=reportUser&projectSelected=".$projectSelectedId."&dateStart=".dol_print_date(strtotime("first day of previous week"), 'dayxcard');
$Form .= "&dateEnd=".dol_print_date(strtotime("last day of previous week"), 'dayxcard')."'>".$langs->trans('lastWeek')."</a>";
$Form .= "<a class='tab' href ='?action=reportUser&projectSelected=".$projectSelectedId."&dateStart=".dol_print_date(strtotime("monday last week"), 'dayxcard');
$Form .= "&dateEnd=".dol_print_date(strtotime("sunday last week"), 'dayxcard')."'>".$langs->trans('lastWeek')."</a>";
//Last month quick link
$Form .= "<a class='tab' href ='?action=reportUser&projectSelected=".$projectSelectedId."&dateStart=".dol_print_date(strtotime("first day of previous month"), 'dayxcard');
$Form .= "&dateEnd=".dol_print_date(strtotime("last day of previous month"), 'dayxcard')."'>".$langs->trans('lastMonth')."</a>";
Expand Down
8 changes: 4 additions & 4 deletions htdocs/timesheet/TimesheetReportUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@
llxHeader('', $langs->trans('userReport'), '');
$Form .= "<div id='quicklinks'>";
//This week quick link
$Form .= "<a class='tab' href ='?action=reportUser&userSelected=".$user->id."&dateStart=".dol_print_date(strtotime("first day of this week"), 'dayxcard');
$Form .= "&dateEnd=".dol_print_date(strtotime("last day of this week"), 'dayxcard')."'>".$langs->trans('thisWeek')."</a>";
$Form .= "<a class='tab' href ='?action=reportUser&userSelected=".$user->id."&dateStart=".dol_print_date(strtotime("monday this week"), 'dayxcard');
$Form .= "&dateEnd=".dol_print_date(strtotime("sunday this week"), 'dayxcard')."'>".$langs->trans('thisWeek')."</a>";
//This month quick link
$Form .= "<a class='tab' href ='?action=reportUser&userSelected=".$user->id."&dateStart=".dol_print_date(strtotime("first day of this month"), 'dayxcard');
$Form .= "&dateEnd=".dol_print_date(strtotime("last day of this month"), 'dayxcard')."'>".$langs->trans('thisMonth')."</a>";
//last week quick link
$Form .= "<a class='tab' href ='?action=reportUser&userSelected=".$user->id."&dateStart=".dol_print_date(strtotime("first day of previous week"), 'dayxcard');
$Form .= "&dateEnd=".dol_print_date(strtotime("last day of previous week"), 'dayxcard')."'>".$langs->trans('lastWeek')."</a>";
$Form .= "<a class='tab' href ='?action=reportUser&userSelected=".$user->id."&dateStart=".dol_print_date(strtotime("monday last week"), 'dayxcard');
$Form .= "&dateEnd=".dol_print_date(strtotime("sunday last week"), 'dayxcard')."'>".$langs->trans('lastWeek')."</a>";
//Last month quick link
$Form .= "<a class='tab' href ='?action=reportUser&userSelected=".$user->id."&dateStart=".dol_print_date(strtotime("first day of previous month"), 'dayxcard');
$Form .= "&dateEnd=".dol_print_date(strtotime("last day of previous month"), 'dayxcard')."'>".$langs->trans('lastMonth')."</a>";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/timesheet/core/lib/includeMain.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
}
if (! $res) die("Include of main fails") ;

if ($user->admin && version_compare("4.0.8", $conf->global->TIMESHEET_VERSION) > 0){
if ($user->admin && version_compare("4.0.16", $conf->global->TIMESHEET_VERSION) > 0){
setEventMessage("Version of timesheet updated, please deactivate then reactivate the module", 'warnings');
}
10 changes: 7 additions & 3 deletions htdocs/timesheet/core/modules/modtimesheet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct($db)
// Module description, used if translation string 'ModuleXXXDesc' not found(where XXX is value of numeric property 'numero' of module)
$this->description = "TimesheetView";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = '4.0.16';
$this->version = '4.0.17';
// Key used in llx_const table to save module status enabled/disabled(where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page(0=common, 1=interface, 2=others, 3=very specific)
Expand Down Expand Up @@ -205,6 +205,10 @@ public function __construct($db)
// 'categories_x' to add a tab in category view(replace 'x' by type of category(0=product, 1=supplier, 2=customer, 3=member)
// 'opensurveypoll' to add a tab in opensurvey poll view
$this->tabs = array();
// Example:
// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@project_cost:$user->rights->project_cost->read:/project_cost/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
$this->tabs[] = array('data'=>'project:+invoice:projectInvoice:timesheet@timesheet:$user->rights->facture->creer:/timesheet/TimesheetProjectInvoice.php?projectid=__ID__'); // To add a new tab identified by code tabname1
$this->tabs[] = array('data'=>'project:+report:projectReport:timesheet@timesheet:true:/timesheet/TimesheetReportProject.php?projectSelected=__ID__'); // To add a new tab identified by code tabname1
// Dictionaries
if(! isset($conf->mymodule->enabled)) {
$conf->mymodule=new stdClass();
Expand Down Expand Up @@ -395,7 +399,7 @@ public function __construct($db)
'target'=>'',
'user'=>2);
$r++;
$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=project,fk_leftmenu=projects', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx, fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
/* $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=project,fk_leftmenu=projects', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx, fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry
'titre'=>'projectInvoice',
'mainmenu'=>'project',
Expand All @@ -406,7 +410,7 @@ public function __construct($db)
'enabled'=>'$conf->timesheet->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu == \'system\'' to show if leftmenu system is selected.
'perms'=>'$user->rights->facture->creer', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2);
'user'=>2);*/
$r++;
$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=timesheet', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx, fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry
Expand Down
Loading

0 comments on commit ba1a7e9

Please sign in to comment.