--- /tmp/dsg/dolibarr/htdocs/projet/github_card.php +++ /tmp/dsg/dolibarr/htdocs/projet/client_card.php @@ -39,7 +39,7 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'aZ09'); @@ -102,7 +102,9 @@ { header("Location: index.php"); exit; - } else { + } + else + { dol_syslog($object->error, LOG_DEBUG); setEventMessages($langs->trans("CantRemoveProject", $langs->transnoentitiesnoconv("ProjectOverview")), null, 'errors'); } @@ -119,14 +121,14 @@ if ($action == 'add' && $user->rights->projet->creer) { $error = 0; - if (!GETPOST('ref')) + if (empty($_POST["ref"])) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); $error++; } - if (!GETPOST('title')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ProjectLabel")), null, 'errors'); + if (empty($_POST["title"])) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); $error++; } @@ -148,13 +150,13 @@ $db->begin(); - $object->ref = GETPOST('ref', 'alphanohtml'); - $object->title = GETPOST('title', 'alphanohtml'); + $object->ref = GETPOST('ref', 'alpha'); + $object->title = GETPOST('title', 'none'); // Do not use 'alpha' here, we want field as it is $object->socid = GETPOST('socid', 'int'); - $object->description = GETPOST('description', 'restricthtml'); // Do not use 'alpha' here, we want field as it is - $object->public = GETPOST('public', 'alphanohtml'); - $object->opp_amount = price2num(GETPOST('opp_amount', 'alphanohtml')); - $object->budget_amount = price2num(GETPOST('budget_amount', 'alphanohtml')); + $object->description = GETPOST('description', 'none'); // Do not use 'alpha' here, we want field as it is + $object->public = GETPOST('public', 'alpha'); + $object->opp_amount = price2num(GETPOST('opp_amount', 'alpha')); + $object->budget_amount = price2num(GETPOST('budget_amount', 'alpha')); $object->date_c = dol_now(); $object->date_start = $date_start; $object->date_end = $date_end; @@ -174,17 +176,18 @@ if (!$error && $result > 0) { // Add myself as project leader - $typeofcontact = 'PROJECTLEADER'; // TODO If use rename this code in dictionary, the add_contact will generate an error. - $result = $object->add_contact($user->id, $typeofcontact, 'internal'); + $result = $object->add_contact($user->id, 'PROJECTLEADER', 'internal'); if ($result < 0) { $langs->load("errors"); - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($langs->trans($object->error), null, 'errors'); $error++; } - } else { + } + else + { $langs->load("errors"); - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($langs->trans($object->error), null, 'errors'); $error++; } if (!$error && !empty($object->id) > 0) @@ -209,16 +212,22 @@ $backtopage = $backtopage.'&projectid='.$object->id; // Old method header("Location: ".$backtopage); exit; - } else { + } + else + { header("Location:card.php?id=".$object->id); exit; } - } else { + } + else + { $db->rollback(); $action = 'create'; } - } else { + } + else + { $action = 'create'; } } @@ -237,7 +246,7 @@ { $error++; //$_GET["id"]=$_POST["id"]; // We return on the project card - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ProjectLabel")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } $db->begin(); @@ -249,10 +258,10 @@ $old_start_date = $object->date_start; $object->ref = GETPOST('ref', 'alpha'); - $object->title = GETPOST('title', 'alphanohtml'); // Do not use 'alpha' here, we want field as it is + $object->title = GETPOST('title', 'none'); // Do not use 'alpha' here, we want field as it is $object->statut = GETPOST('status', 'int'); $object->socid = GETPOST('socid', 'int'); - $object->description = GETPOST('description', 'restricthtml'); // Do not use 'alpha' here, we want field as it is + $object->description = GETPOST('description', 'none'); // Do not use 'alpha' here, we want field as it is $object->public = GETPOST('public', 'alpha'); $object->date_start = (!GETPOST('projectstart')) ? '' : $date_start; $object->date_end = (!GETPOST('projectend')) ? '' : $date_end; @@ -325,7 +334,9 @@ { $db->rollback(); $action = 'edit'; - } else { + } + else + { $db->commit(); if (GETPOST('socid', 'int') > 0) $object->fetch_thirdparty(GETPOST('socid', 'int')); @@ -345,7 +356,7 @@ $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09')); } - $result = $object->generateDocument($object->model_pdf, $outputlangs); + $result = $object->generateDocument($object->modelpdf, $outputlangs); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -366,7 +377,8 @@ $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); + else + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); $action = ''; } } @@ -408,7 +420,9 @@ setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); header("Location: list.php?restore_lastsearch_values=1"); exit; - } else { + } + else + { dol_syslog($object->error, LOG_DEBUG); setEventMessages($object->error, $object->errors, 'errors'); } @@ -428,7 +442,9 @@ if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); - } else { + } + else + { // Load new object $newobject = new Project($db); $newobject->fetch($result); @@ -466,7 +482,8 @@ $titleboth = $langs->trans("LeadsOrProjects"); $titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default -if ($conf->global->PROJECT_USE_OPPORTUNITIES == 0) { +if ($conf->global->PROJECT_USE_OPPORTUNITIES == 0) +{ $titleboth = $langs->trans("Projects"); $titlenew = $langs->trans("NewProject"); } @@ -491,7 +508,7 @@ print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; - print dol_get_fiche_head(); + dol_fiche_head(); print '<table class="border centpercent tableforfieldcreate">'; @@ -529,17 +546,18 @@ print '</td></tr>'; // Label - print '<tr><td><span class="fieldrequired">'.$langs->trans("ProjectLabel").'</span></td><td><input class="minwidth500" type="text" name="title" value="'.dol_escape_htmltag(GETPOST("title", 'alphanohtml')).'" autofocus></td></tr>'; + print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td><td><input class="minwidth500" type="text" name="title" value="'.dol_escape_htmltag(GETPOST("title", 'none')).'" autofocus></td></tr>'; // Usage (opp, task, bill time, ...) print '<tr><td class="tdtop">'; print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { print '<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ' checked="checked"').'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); - print '<label for="usage_opportunity">'.$form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext).'</label>'; + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<script>'; print '$( document ).ready(function() { jQuery("#usage_opportunity").change(function() { @@ -559,14 +577,14 @@ { print '<input type="checkbox" id="usage_task" name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ' checked="checked"').'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); - print '<label for="usage_task">'.$form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext).'</label>'; + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" id="usage_bill_time" name="usage_bill_time"'.(GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '').'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); - print '<label for="usage_bill_time">'.$form->textwithpicto($langs->trans("BillTime"), $htmltext).'</label>'; + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '<br>'; } /* @@ -586,12 +604,13 @@ print '</td><td class="maxwidthonsmartphone">'; $filteronlist = ''; if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; - $text = img_picto('', 'company').$form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 widthcentpercentminusxx'); + $text = img_picto('', 'company').$form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 widthcentpercentminusx'); if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1); - } else print $text; + } + else print $text; if (!GETPOSTISSET('backtopage')) print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddThirdParty").'"></span></a>'; print '</td></tr>'; } @@ -610,7 +629,7 @@ $array = array(); if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject"); if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject"); - print $form->selectarray('public', $array, GETPOST('public') ?GETPOST('public') : $object->public, 0, 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray('public', $array, GETPOST('public') ?GETPOST('public') : $object->public); print '</td></tr>'; // Date start @@ -628,7 +647,7 @@ // Opportunity status print '<tr class="classuseopportunity"><td>'.$langs->trans("OpportunityStatus").'</td>'; print '<td class="maxwidthonsmartphone">'; - print $formproject->selectOpportunityStatus('opp_status', GETPOST('opp_status') ?GETPOST('opp_status') : $object->opp_status, 1, 0, 0, 0, '', 0, 1); + print $formproject->selectOpportunityStatus('opp_status', GETPOST('opp_status') ?GETPOST('opp_status') : $object->opp_status); print '</tr>'; // Opportunity probability @@ -652,7 +671,7 @@ // Description print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>'; print '<td>'; - $doleditor = new DolEditor('description', GETPOST("description", 'restricthtml'), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_3, '90%'); + $doleditor = new DolEditor('description', GETPOST("description", 'none'), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_3, '90%'); $doleditor->Create(); print '</td></tr>'; @@ -671,22 +690,24 @@ print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'create'); + print $object->showOptionals($extrafields, 'edit'); } print '</table>'; - print dol_get_fiche_end(); + dol_fiche_end(); print '<div class="center">'; print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">'; if (!empty($backtopage)) { print ' '; - print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; - } else { + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; + } + else + { print ' '; - print '<input type="button" class="button button-cancel" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; + print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; } print '</div>'; @@ -722,7 +743,8 @@ }); }); </script>'; -} elseif ($object->id > 0) +} +elseif ($object->id > 0) { /* * Show or edit @@ -791,7 +813,7 @@ if ($action == 'edit' && $userWrite > 0) { - print dol_get_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public ? 'projectpub' : 'project')); + dol_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public ? 'projectpub' : 'project')); print '<table class="border centpercent">'; @@ -803,8 +825,9 @@ print '</td></tr>'; // Label - print '<tr><td class="fieldrequired">'.$langs->trans("ProjectLabel").'</td>'; + print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>'; print '<td><input class="quatrevingtpercent" name="title" value="'.dol_escape_htmltag($object->title).'"></td></tr>'; + // Status print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td><td>'; @@ -872,7 +895,8 @@ { $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1, 0, '', '', 2); - } else print $text; + } + else print $text; print '</td></tr>'; } @@ -881,7 +905,7 @@ $array = array(); if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject"); if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject"); - print $form->selectarray('public', $array, $object->public, 0, 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray('public', $array, $object->public); print '</td></tr>'; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) @@ -890,7 +914,7 @@ // Opportunity status print '<tr class="classuseopportunity'.$classfortr.'"><td>'.$langs->trans("OpportunityStatus").'</td>'; print '<td>'; - print $formproject->selectOpportunityStatus('opp_status', $object->opp_status, 1, 0, 0, 0, 'inline-block valignmiddle', 0, 1); + print $formproject->selectOpportunityStatus('opp_status', $object->opp_status, 1, 0, 0, 0, 'inline-block valignmiddle'); print '<div id="divtocloseproject" class="inline-block valign" style="display: none;"> '; print '<input type="checkbox" id="inputcloseproject" name="closeproject" /> '; print $langs->trans("AlsoCloseAProject"); @@ -898,18 +922,18 @@ print '</td>'; print '</tr>'; - // Opportunity probability - print '<tr class="classuseopportunity'.$classfortr.'"><td>'.$langs->trans("OpportunityProbability").'</td>'; - print '<td><input size="5" type="text" id="opp_percent" name="opp_percent" value="'.(GETPOSTISSET('opp_percent') ? GETPOST('opp_percent') : (strcmp($object->opp_percent, '') ?vatrate($object->opp_percent) : '')).'"> %'; - print '<span id="oldopppercent"></span>'; - print '</td>'; - print '</tr>'; - - // Opportunity amount - print '<tr class="classuseopportunity'.$classfortr.'"><td>'.$langs->trans("OpportunityAmount").'</td>'; - print '<td><input size="5" type="text" name="opp_amount" value="'.(GETPOSTISSET('opp_amount') ? GETPOST('opp_amount') : (strcmp($object->opp_amount, '') ? price2num($object->opp_amount) : '')).'"></td>'; - print '</tr>'; - } + // Opportunity probability + print '<tr class="classuseopportunity'.$classfortr.'"><td>'.$langs->trans("OpportunityProbability").'</td>'; + print '<td><input size="5" type="text" id="opp_percent" name="opp_percent" value="'.(GETPOSTISSET('opp_percent') ? GETPOST('opp_percent') : (strcmp($object->opp_percent, '') ?vatrate($object->opp_percent) : '')).'"> %'; + print '<span id="oldopppercent"></span>'; + print '</td>'; + print '</tr>'; + + // Opportunity amount + print '<tr class="classuseopportunity'.$classfortr.'"><td>'.$langs->trans("OpportunityAmount").'</td>'; + print '<td><input size="5" type="text" name="opp_amount" value="'.(GETPOSTISSET('opp_amount') ? GETPOST('opp_amount') : (strcmp($object->opp_amount, '') ? price2num($object->opp_amount) : '')).'"></td>'; + print '</tr>'; + } // Date start print '<tr><td>'.$langs->trans("DateStart").'</td><td>'; @@ -960,8 +984,10 @@ } print '</table>'; - } else { - print dol_get_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); + } + else + { + dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); // Project card @@ -969,7 +995,7 @@ $morehtmlref = '<div class="refidno">'; // Title - $morehtmlref .= dol_escape_htmltag($object->title); + $morehtmlref .= $object->title; // Thirdparty $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '; if ($object->thirdparty->id > 0) @@ -1050,10 +1076,10 @@ if (strcmp($object->opp_amount, '')) print price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); print '</td></tr>'; - // Opportunity Weighted Amount - print '<tr><td>'.$langs->trans('OpportunityWeightedAmount').'</td><td>'; - if (strcmp($object->opp_amount, '') && strcmp($object->opp_percent, '')) print price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency); - print '</td></tr>'; + // Opportunity Weighted Amount + print '<tr><td>'.$langs->trans('OpportunityWeightedAmount').'</td><td>'; + if (strcmp($object->opp_amount, '') && strcmp($object->opp_percent, '')) print price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency); + print '</td></tr>'; } // Date start - end @@ -1086,7 +1112,7 @@ // Description print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; - print dol_htmlentitiesbr($object->description); + print nl2br($object->description); print '</td></tr>'; // Categories @@ -1105,13 +1131,13 @@ print '<div class="clearboth"></div>'; } - print dol_get_fiche_end(); + dol_fiche_end(); if ($action == 'edit' && $userWrite > 0) { print '<div class="center">'; print '<input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> '; - print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '</div>'; } @@ -1181,7 +1207,7 @@ } /* - * Actions Buttons + * Boutons actions */ print '<div class="tabsAction">'; $parameters = array(); @@ -1213,7 +1239,9 @@ if ($userWrite > 0) { print '<a class="butAction" href="card.php?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'; - } else { + } + else + { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Modify').'</a>'; } } @@ -1224,7 +1252,9 @@ if ($userWrite > 0) { print '<a class="butAction" href="card.php?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>'; - } else { + } + else + { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Validate').'</a>'; } } @@ -1235,7 +1265,9 @@ if ($userWrite > 0) { print '<a class="butAction" href="card.php?id='.$object->id.'&action=close">'.$langs->trans("Close").'</a>'; - } else { + } + else + { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Close').'</a>'; } } @@ -1246,7 +1278,9 @@ if ($userWrite > 0) { print '<a class="butAction" href="card.php?id='.$object->id.'&action=reopen">'.$langs->trans("ReOpen").'</a>'; - } else { + } + else + { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('ReOpen').'</a>'; } } @@ -1312,7 +1346,9 @@ if ($userWrite > 0) { print '<a class="butAction" href="card.php?id='.$object->id.'&action=clone">'.$langs->trans('ToClone').'</a>'; - } else { + } + else + { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('ToClone').'</a>'; } } @@ -1322,8 +1358,10 @@ { if ($userDelete > 0 || ($object->statut == 0 && $user->rights->projet->creer)) { - print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a>'; - } else { + print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>'; + } + else + { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Delete').'</a>'; } } @@ -1350,7 +1388,7 @@ $genallowed = ($user->rights->projet->lire && $userAccess > 0); $delallowed = ($user->rights->projet->creer && $userWrite > 0); - print $formfile->showdocuments('project', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf); + print $formfile->showdocuments('project', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf); print '</div><div class="fichehalfright"><div class="ficheaddleft">'; @@ -1380,7 +1418,9 @@ // Hook to add more things on page $parameters = array(); $reshook = $hookmanager->executeHooks('mainCardTabAddMore', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -} else { +} +else +{ print $langs->trans("RecordNotFound"); } --- /tmp/dsg/dolibarr/htdocs/projet/github_comment.php +++ /tmp/dsg/dolibarr/htdocs/projet/client_comment.php @@ -41,7 +41,7 @@ $idcomment = GETPOST('idcomment', 'int'); $ref = GETPOST("ref", 'alpha', 1); // task ref $objectref = GETPOST("taskref", 'alpha'); // task ref -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $withproject = GETPOST('withproject', 'int'); $project_ref = GETPOST('project_ref', 'alpha'); @@ -89,7 +89,7 @@ // Tabs for project $tab = 'project_comment'; $head = project_prepare_head($object); -print dol_get_fiche_head($head, $tab, $langs->trans("Project"), - 1, ($object->public ? 'projectpub' : 'project')); +dol_fiche_head($head, $tab, $langs->trans("Project"), - 1, ($object->public ? 'projectpub' : 'project')); $param = ($mode == 'mine' ? '&mode=mine' : ''); @@ -123,7 +123,8 @@ // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; if ($object->public) print $langs->trans('SharedProject'); -else print $langs->trans('PrivateProject'); +else + print $langs->trans('PrivateProject'); print '</td></tr>'; // Date start - end @@ -176,7 +177,7 @@ print '<div class="clearboth"></div>'; -print dol_get_fiche_end(); +dol_fiche_end(); print '<br>'; --- /tmp/dsg/dolibarr/htdocs/projet/github_contact.php +++ /tmp/dsg/dolibarr/htdocs/projet/client_contact.php @@ -36,7 +36,7 @@ $ref = GETPOST('ref', 'alpha'); $lineid = GETPOST('lineid', 'int'); $socid = GETPOST('socid', 'int'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $mine = GETPOST('mode') == 'mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects @@ -63,40 +63,45 @@ $result = 0; $result = $object->fetch($id); - if ($result > 0 && $id > 0) - { + if ($result > 0 && $id > 0) + { $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); - } + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } else { + } + else + { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); } } } -// Change contact's status +// bascule du statut d'un contact if ($action == 'swapstatut' && $user->rights->projet->creer) { if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne', 'int')); - } else { + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); + } + else + { dol_print_error($db); } } -// Delete a contact +// Efface un contact if (($action == 'deleteline' || $action == 'deletecontact') && $user->rights->projet->creer) { $object->fetch($id); @@ -106,7 +111,9 @@ { header("Location: contact.php?id=".$object->id); exit; - } else { + } + else + { dol_print_error($db); } } @@ -129,7 +136,7 @@ /* *************************************************************************** */ /* */ -/* Edition and view mode */ +/* Mode vue et edition */ /* */ /* *************************************************************************** */ @@ -143,66 +150,66 @@ //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; $head = project_prepare_head($object); - print dol_get_fiche_head($head, 'contact', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); - - - // Project card - - $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; - - $morehtmlref = '<div class="refidno">'; - // Title - $morehtmlref .= $object->title; - // Thirdparty - if ($object->thirdparty->id > 0) - { - $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); - } - $morehtmlref .= '</div>'; - - // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { - $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; - } - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - - print '<div class="fichecenter">'; - print '<div class="fichehalfleft">'; - print '<div class="underbanner clearboth"></div>'; - - print '<table class="border tableforfield centpercent">'; - - // Usage - print '<tr><td class="tdtop">'; - print $langs->trans("Usage"); - print '</td>'; - print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { - print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowOpportunity"); - print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); - print '<br>'; - } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { - print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowTasks"); - print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); - print '<br>'; - } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { - print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectBillTimeDescription"); - print $form->textwithpicto($langs->trans("BillTime"), $htmltext); - print '<br>'; - } - print '</td></tr>'; + dol_fiche_head($head, 'contact', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); + + + // Project card + + $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; + + $morehtmlref = '<div class="refidno">'; + // Title + $morehtmlref .= $object->title; + // Thirdparty + if ($object->thirdparty->id > 0) + { + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '</div>'; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) + { + $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '<div class="fichecenter">'; + print '<div class="fichehalfleft">'; + print '<div class="underbanner clearboth"></div>'; + + print '<table class="border tableforfield centpercent">'; + + // Usage + print '<tr><td class="tdtop">'; + print $langs->trans("Usage"); + print '</td>'; + print '<td>'; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '<br>'; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) + { + print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '<br>'; + } + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '<br>'; + } + print '</td></tr>'; // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; @@ -210,36 +217,36 @@ else print $langs->trans('PrivateProject'); print '</td></tr>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && $object->opp_status) - { - // Opportunity status - print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>'; - $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) print $langs->trans("OppStatus".$code); - print '</td></tr>'; - - // Opportunity percent - print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>'; - if (strcmp($object->opp_percent, '')) print price($object->opp_percent, '', $langs, 1, 0).' %'; - print '</td></tr>'; - - // Opportunity Amount - print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>'; - if (strcmp($object->opp_amount, '')) print price($object->opp_amount, '', $langs, 0, 0, 0, $conf->currency); - print '</td></tr>'; - } - - // Date start - end - print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && $object->opp_status) + { + // Opportunity status + print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>'; + $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); + if ($code) print $langs->trans("OppStatus".$code); + print '</td></tr>'; + + // Opportunity percent + print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>'; + if (strcmp($object->opp_percent, '')) print price($object->opp_percent, '', $langs, 1, 0).' %'; + print '</td></tr>'; + + // Opportunity Amount + print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>'; + if (strcmp($object->opp_amount, '')) print price($object->opp_amount, '', $langs, 0, 0, 0, $conf->currency); + print '</td></tr>'; + } + + // Date start - end + print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; $start = dol_print_date($object->date_start, 'day'); print ($start ? $start : '?'); $end = dol_print_date($object->date_end, 'day'); print ' - '; print ($end ? $end : '?'); if ($object->hasDelay()) print img_warning("Late"); - print '</td></tr>'; - - // Budget + print '</td></tr>'; + + // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 0, 0, 0, $conf->currency); print '</td></tr>'; @@ -250,36 +257,36 @@ print "</table>"; - print '</div>'; - print '<div class="fichehalfright">'; - print '<div class="ficheaddleft">'; - print '<div class="underbanner clearboth"></div>'; - - print '<table class="border tableforfield" width="100%">'; - - // Description - print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; - print nl2br($object->description); - print '</td></tr>'; - - // Categories - if ($conf->categorie->enabled) { - print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>'; - print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1); - print "</td></tr>"; - } - - print '</table>'; - - print '</div>'; - print '</div>'; - print '</div>'; - - print '<div class="clearboth"></div>'; - - print dol_get_fiche_end(); - - print '<br>'; + print '</div>'; + print '<div class="fichehalfright">'; + print '<div class="ficheaddleft">'; + print '<div class="underbanner clearboth"></div>'; + + print '<table class="border tableforfield" width="100%">'; + + // Description + print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; + print nl2br($object->description); + print '</td></tr>'; + + // Categories + if ($conf->categorie->enabled) { + print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>'; + print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1); + print "</td></tr>"; + } + + print '</table>'; + + print '</div>'; + print '</div>'; + print '</div>'; + + print '<div class="clearboth"></div>'; + + dol_fiche_end(); + + print '<br>'; // Contacts lines (modules that overwrite templates must declare this into descriptor) $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); --- /tmp/dsg/dolibarr/htdocs/projet/github_document.php +++ /tmp/dsg/dolibarr/htdocs/projet/client_document.php @@ -102,7 +102,7 @@ //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; $head = project_prepare_head($object); - print dol_get_fiche_head($head, 'document', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); + dol_fiche_head($head, 'document', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); // Files list constructor $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); @@ -151,13 +151,15 @@ print '</div>'; - print dol_get_fiche_end(); + dol_fiche_end(); $modulepart = 'project'; $permission = ($userWrite > 0); $permtoedit = ($userWrite > 0); include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} else { +} +else +{ dol_print_error('', 'NoRecordFound'); } --- /tmp/dsg/dolibarr/htdocs/projet/github_element.php +++ /tmp/dsg/dolibarr/htdocs/projet/client_element.php @@ -72,14 +72,15 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $datesrfc = GETPOST('datesrfc'); $dateerfc = GETPOST('dateerfc'); $dates = dol_mktime(0, 0, 0, GETPOST('datesmonth'), GETPOST('datesday'), GETPOST('datesyear')); $datee = dol_mktime(23, 59, 59, GETPOST('dateemonth'), GETPOST('dateeday'), GETPOST('dateeyear')); if (empty($dates) && !empty($datesrfc)) $dates = dol_stringtotime($datesrfc); if (empty($datee) && !empty($dateerfc)) $datee = dol_stringtotime($dateerfc); -if (!GETPOSTISSET('datesrfc') && !GETPOSTISSET('datesday') && !empty($conf->global->PROJECT_LINKED_ELEMENT_DEFAULT_FILTER_YEAR)) { +if (!isset($_POST['datesrfc']) && !isset($_POST['datesday']) && !empty($conf->global->PROJECT_LINKED_ELEMENT_DEFAULT_FILTER_YEAR)) +{ $new = dol_now(); $tmp = dol_getdate($new); //$datee=$now @@ -128,7 +129,7 @@ $userAccess = $object->restrictedProjectArea($user); $head = project_prepare_head($object); -print dol_get_fiche_head($head, 'element', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); +dol_fiche_head($head, 'element', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); // Project card @@ -141,15 +142,15 @@ // Thirdparty if ($object->thirdparty->id > 0) { - $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { - $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " te.rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); + $object->next_prev_filter = " te.rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -197,21 +198,21 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - // Opportunity status - print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>'; - $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) print $langs->trans("OppStatus".$code); - print '</td></tr>'; - - // Opportunity percent - print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>'; - if (strcmp($object->opp_percent, '')) print price($object->opp_percent, '', $langs, 1, 0).' %'; - print '</td></tr>'; - - // Opportunity Amount - print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>'; - if (strcmp($object->opp_amount, '')) print price($object->opp_amount, '', $langs, 1, 0, 0, $conf->currency); - print '</td></tr>'; + // Opportunity status + print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>'; + $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); + if ($code) print $langs->trans("OppStatus".$code); + print '</td></tr>'; + + // Opportunity percent + print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>'; + if (strcmp($object->opp_percent, '')) print price($object->opp_percent, '', $langs, 1, 0).' %'; + print '</td></tr>'; + + // Opportunity Amount + print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>'; + if (strcmp($object->opp_amount, '')) print price($object->opp_amount, '', $langs, 1, 0, 0, $conf->currency); + print '</td></tr>'; } // Date start - end @@ -249,9 +250,9 @@ // Categories if ($conf->categorie->enabled) { - print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>'; - print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1); - print "</td></tr>"; + print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>'; + print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1); + print "</td></tr>"; } print '</table>'; @@ -262,7 +263,7 @@ print '<div class="clearboth"></div>'; -print dol_get_fiche_end(); +dol_fiche_end(); print '<br>'; @@ -276,11 +277,11 @@ 'title'=>"ListProposalsAssociatedProject", 'class'=>'Propal', 'table'=>'propal', - 'datefieldname'=>'datep', - 'urlnew'=>DOL_URL_ROOT.'/comm/propal/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, - 'lang'=>'propal', - 'buttonnew'=>'AddProp', - 'testnew'=>$user->rights->propal->creer, + 'datefieldname'=>'datep', + 'urlnew'=>DOL_URL_ROOT.'/comm/propal/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, + 'lang'=>'propal', + 'buttonnew'=>'AddProp', + 'testnew'=>$user->rights->propal->creer, 'test'=>$conf->propal->enabled && $user->rights->propale->lire), 'order'=>array( 'name'=>"CustomersOrders", @@ -288,11 +289,11 @@ 'class'=>'Commande', 'table'=>'commande', 'datefieldname'=>'date_commande', - 'urlnew'=>DOL_URL_ROOT.'/commande/card.php?action=create&projectid='.$id.'&socid='.$socid, - 'lang'=>'orders', - 'buttonnew'=>'CreateOrder', - 'testnew'=>$user->rights->commande->creer, - 'test'=>$conf->commande->enabled && $user->rights->commande->lire), + 'urlnew'=>DOL_URL_ROOT.'/commande/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'lang'=>'orders', + 'buttonnew'=>'CreateOrder', + 'testnew'=>$user->rights->commande->creer, + 'test'=>$conf->commande->enabled && $user->rights->commande->lire), 'invoice'=>array( 'name'=>"CustomersInvoices", 'title'=>"ListInvoicesAssociatedProject", @@ -300,22 +301,22 @@ 'margin'=>'add', 'table'=>'facture', 'datefieldname'=>'datef', - 'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid, - 'lang'=>'bills', - 'buttonnew'=>'CreateBill', - 'testnew'=>$user->rights->facture->creer, - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), + 'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'lang'=>'bills', + 'buttonnew'=>'CreateBill', + 'testnew'=>$user->rights->facture->creer, + 'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'invoice_predefined'=>array( 'name'=>"PredefinedInvoices", 'title'=>"ListPredefinedInvoicesAssociatedProject", 'class'=>'FactureRec', 'table'=>'facture_rec', 'datefieldname'=>'datec', - 'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid, - 'lang'=>'bills', - 'buttonnew'=>'CreateBill', - 'testnew'=>$user->rights->facture->creer, - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), + 'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'lang'=>'bills', + 'buttonnew'=>'CreateBill', + 'testnew'=>$user->rights->facture->creer, + 'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'proposal_supplier'=>array( 'name'=>"SuppliersProposals", 'title'=>"ListSupplierProposalsAssociatedProject", @@ -323,21 +324,21 @@ 'table'=>'supplier_proposal', 'datefieldname'=>'date_valid', 'urlnew'=>DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object - 'lang'=>'supplier_proposal', - 'buttonnew'=>'AddSupplierProposal', - 'testnew'=>$user->rights->supplier_proposal->creer, - 'test'=>$conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire), + 'lang'=>'supplier_proposal', + 'buttonnew'=>'AddSupplierProposal', + 'testnew'=>$user->rights->supplier_proposal->creer, + 'test'=>$conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire), 'order_supplier'=>array( 'name'=>"SuppliersOrders", 'title'=>"ListSupplierOrdersAssociatedProject", 'class'=>'CommandeFournisseur', 'table'=>'commande_fournisseur', 'datefieldname'=>'date_commande', - 'urlnew'=>DOL_URL_ROOT.'/fourn/commande/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object - 'lang'=>'suppliers', - 'buttonnew'=>'AddSupplierOrder', - 'testnew'=>$user->rights->fournisseur->commande->creer, - 'test'=>$conf->supplier_order->enabled && $user->rights->fournisseur->commande->lire), + 'urlnew'=>DOL_URL_ROOT.'/fourn/commande/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object + 'lang'=>'suppliers', + 'buttonnew'=>'AddSupplierOrder', + 'testnew'=>$user->rights->fournisseur->commande->creer, + 'test'=>$conf->supplier_order->enabled && $user->rights->fournisseur->commande->lire), 'invoice_supplier'=>array( 'name'=>"BillsSuppliers", 'title'=>"ListSupplierInvoicesAssociatedProject", @@ -346,21 +347,21 @@ 'table'=>'facture_fourn', 'datefieldname'=>'datef', 'urlnew'=>DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object - 'lang'=>'suppliers', - 'buttonnew'=>'AddSupplierInvoice', - 'testnew'=>$user->rights->fournisseur->facture->creer, - 'test'=>$conf->supplier_invoice->enabled && $user->rights->fournisseur->facture->lire), + 'lang'=>'suppliers', + 'buttonnew'=>'AddSupplierInvoice', + 'testnew'=>$user->rights->fournisseur->facture->creer, + 'test'=>$conf->supplier_invoice->enabled && $user->rights->fournisseur->facture->lire), 'contract'=>array( 'name'=>"Contracts", 'title'=>"ListContractAssociatedProject", 'class'=>'Contrat', 'table'=>'contrat', 'datefieldname'=>'date_contrat', - 'urlnew'=>DOL_URL_ROOT.'/contrat/card.php?action=create&projectid='.$id.'&socid='.$socid, - 'lang'=>'contracts', - 'buttonnew'=>'AddContract', - 'testnew'=>$user->rights->contrat->creer, - 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), + 'urlnew'=>DOL_URL_ROOT.'/contrat/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'lang'=>'contracts', + 'buttonnew'=>'AddContract', + 'testnew'=>$user->rights->contrat->creer, + 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), 'intervention'=>array( 'name'=>"Interventions", 'title'=>"ListFichinterAssociatedProject", @@ -369,13 +370,13 @@ 'datefieldname'=>'date_valid', 'disableamount'=>0, 'margin'=>'minus', - 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, - 'lang'=>'interventions', - 'buttonnew'=>'AddIntervention', - 'testnew'=>$user->rights->ficheinter->creer, - 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), + 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, + 'lang'=>'interventions', + 'buttonnew'=>'AddIntervention', + 'testnew'=>$user->rights->ficheinter->creer, + 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), 'shipping'=>array( - 'name'=>"Shippings", + 'name'=>"Shippings", 'title'=>"ListShippingAssociatedProject", 'class'=>'Expedition', 'table'=>'expedition', @@ -405,11 +406,11 @@ 'datefieldname'=>'dated', 'margin'=>'minus', 'disableamount'=>1, - 'urlnew'=>DOL_URL_ROOT.'/deplacement/card.php?action=create&projectid='.$id.'&socid='.$socid, - 'lang'=>'trips', - 'buttonnew'=>'AddTrip', - 'testnew'=>$user->rights->deplacement->creer, - 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), + 'urlnew'=>DOL_URL_ROOT.'/deplacement/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'lang'=>'trips', + 'buttonnew'=>'AddTrip', + 'testnew'=>$user->rights->deplacement->creer, + 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), 'expensereport'=>array( 'name'=>"ExpenseReports", 'title'=>"ListExpenseReportsAssociatedProject", @@ -418,11 +419,11 @@ 'datefieldname'=>'date', 'margin'=>'minus', 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/expensereport/card.php?action=create&projectid='.$id.'&socid='.$socid, - 'lang'=>'trips', - 'buttonnew'=>'AddTrip', - 'testnew'=>$user->rights->expensereport->creer, - 'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire), + 'urlnew'=>DOL_URL_ROOT.'/expensereport/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'lang'=>'trips', + 'buttonnew'=>'AddTrip', + 'testnew'=>$user->rights->expensereport->creer, + 'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire), 'donation'=>array( 'name'=>"Donation", 'title'=>"ListDonationsAssociatedProject", @@ -431,11 +432,11 @@ 'table'=>'don', 'datefieldname'=>'datedon', 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/don/card.php?action=create&projectid='.$id.'&socid='.$socid, - 'lang'=>'donations', - 'buttonnew'=>'AddDonation', - 'testnew'=>$user->rights->don->creer, - 'test'=>$conf->don->enabled && $user->rights->don->lire), + 'urlnew'=>DOL_URL_ROOT.'/don/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'lang'=>'donations', + 'buttonnew'=>'AddDonation', + 'testnew'=>$user->rights->don->creer, + 'test'=>$conf->don->enabled && $user->rights->don->lire), 'loan'=>array( 'name'=>"Loan", 'title'=>"ListLoanAssociatedProject", @@ -444,24 +445,24 @@ 'table'=>'loan', 'datefieldname'=>'datestart', 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/loan/card.php?action=create&projectid='.$id.'&socid='.$socid, - 'lang'=>'loan', - 'buttonnew'=>'AddLoan', - 'testnew'=>$user->rights->loan->write, - 'test'=>$conf->loan->enabled && $user->rights->loan->read), + 'urlnew'=>DOL_URL_ROOT.'/loan/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'lang'=>'loan', + 'buttonnew'=>'AddLoan', + 'testnew'=>$user->rights->loan->write, + 'test'=>$conf->loan->enabled && $user->rights->loan->read), 'chargesociales'=>array( - 'name'=>"SocialContribution", - 'title'=>"ListSocialContributionAssociatedProject", - 'class'=>'ChargeSociales', - 'margin'=>'minus', - 'table'=>'chargesociales', - 'datefieldname'=>'date_ech', - 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$id, - 'lang'=>'compta', - 'buttonnew'=>'AddSocialContribution', - 'testnew'=>$user->rights->tax->charges->lire, - 'test'=>$conf->tax->enabled && $user->rights->tax->charges->lire), + 'name'=>"SocialContribution", + 'title'=>"ListSocialContributionAssociatedProject", + 'class'=>'ChargeSociales', + 'margin'=>'minus', + 'table'=>'chargesociales', + 'datefieldname'=>'date_ech', + 'disableamount'=>0, + 'urlnew'=>DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$id, + 'lang'=>'compta', + 'buttonnew'=>'AddSocialContribution', + 'testnew'=>$user->rights->tax->charges->lire, + 'test'=>$conf->tax->enabled && $user->rights->tax->charges->lire), 'project_task'=>array( 'name'=>"TaskTimeSpent", 'title'=>"ListTaskTimeUserProject", @@ -470,10 +471,10 @@ 'table'=>'projet_task', 'datefieldname'=>'task_date', 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id, - 'buttonnew'=>'AddTimeSpent', - 'testnew'=>$user->rights->projet->creer, - 'test'=>($conf->projet->enabled && $user->rights->projet->lire && empty($conf->global->PROJECT_HIDE_TASKS))), + 'urlnew'=>DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id, + 'buttonnew'=>'AddTimeSpent', + 'testnew'=>$user->rights->projet->creer, + 'test'=>($conf->projet->enabled && $user->rights->projet->lire && empty($conf->global->PROJECT_HIDE_TASKS))), 'stock_mouvement'=>array( 'name'=>"MouvementStockAssociated", 'title'=>"ListMouvementStockProject", @@ -504,11 +505,11 @@ 'datefieldname'=>'datev', 'margin'=>'minus', 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&projectid='.$id, - 'lang'=>'banks', - 'buttonnew'=>'AddVariousPayment', - 'testnew'=>$user->rights->banque->modifier, - 'test'=>$conf->banque->enabled && $user->rights->banque->lire && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)), + 'urlnew'=>DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&projectid='.$id, + 'lang'=>'banks', + 'buttonnew'=>'AddVariousPayment', + 'testnew'=>$user->rights->banque->modifier, + 'test'=>$conf->banque->enabled && $user->rights->banque->lire && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)), /* No need for this, available on dedicated tab "Agenda/Events" 'agenda'=>array( 'name'=>"Agenda", @@ -526,26 +527,26 @@ ); // Change rules for profit/benefit calculation -if (!empty($conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN)) { - foreach ($listofreferent as $key => $element) { +if (! empty($conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN)) { + foreach($listofreferent as $key => $element) { if ($listofreferent[$key]['margin'] == 'add') { unset($listofreferent[$key]['margin']); } } $newelementforplusmargin = explode(',', $conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN); - foreach ($newelementforplusmargin as $value) { - $listofreferent[trim($value)]['margin'] = 'add'; + foreach($newelementforplusmargin as $value) { + $listofreferent[trim($value)]['margin']='add'; } } -if (!empty($conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN)) { - foreach ($listofreferent as $key => $element) { +if (! empty($conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN)) { + foreach($listofreferent as $key => $element) { if ($listofreferent[$key]['margin'] == 'minus') { unset($listofreferent[$key]['margin']); } } $newelementforminusmargin = explode(',', $conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN); - foreach ($newelementforminusmargin as $value) { - $listofreferent[trim($value)]['margin'] = 'minus'; + foreach($newelementforminusmargin as $value) { + $listofreferent[trim($value)]['margin']='minus'; } } @@ -567,10 +568,11 @@ { setEventMessages($object->error, $object->errors, 'errors'); } -} elseif ($action == "unlink") +} +elseif ($action == "unlink") { $tablename = GETPOST("tablename", "aZ09"); - $projectField = GETPOSTISSET('projectfield') ? GETPOST('projectfield', 'aZ09') : 'fk_projet'; + $projectField = GETPOSTISSET('projectfield') ? GETPOST('projectfield', 'aZ09') : 'fk_projet'; $elementselectid = GETPOST("elementselect", "int"); $result = $object->remove_element($tablename, $elementselectid, $projectField); @@ -589,19 +591,21 @@ if (!$showdatefilter) { print '<div class="center centpercent">'; - print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">'; - print '<input type="hidden" name="token" value="'.newToken().'">'; - print '<input type="hidden" name="tablename" value="'.$tablename.'">'; + print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; + print '<input type="hidden" name="token" value="'.newToken().'">'; + print '<input type="hidden" name="tablename" value="'.$tablename.'">'; print '<input type="hidden" name="action" value="view">'; - print '<div class="inline-block">'; - print $form->selectDate($dates, 'dates', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); - print '</div>'; - print '<div class="inline-block">'; - print $form->selectDate($datee, 'datee', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); - print '</div>'; - print '<div class="inline-block">'; + print '<table class="center"><tr>'; + print '<td>'.$langs->trans("From").' '; + print $form->selectDate($dates, 'dates', 0, 0, 1, '', 1, 0); + print '</td>'; + print '<td>'.$langs->trans("to").' '; + print $form->selectDate($datee, 'datee', 0, 0, 1, '', 1, 0); + print '</td>'; + print '<td>'; print '<input type="submit" name="refresh" value="'.$langs->trans("Refresh").'" class="button">'; - print '</div>'; + print '</td>'; + print '</tr></table>'; print '</form>'; print '</div>'; @@ -623,7 +627,7 @@ print '<td class="left" width="200">'; $tooltiponprofit = $langs->trans("ProfitIsCalculatedWith")."<br>\n"; $tooltiponprofitplus = $tooltiponprofitminus = ''; -foreach ($listofreferent as $key => $value) +foreach($listofreferent as $key => $value) { $name = $langs->trans($value['name']); $qualified = $value['test']; @@ -631,10 +635,10 @@ if ($qualified && isset($margin)) // If this element must be included into profit calculation ($margin is 'minus' or 'add') { if ($margin == 'add') { - $tooltiponprofitplus .= ' > '.$name." (+)<br>\n"; + $tooltiponprofitplus.=' > '.$name." (+)<br>\n"; } if ($margin == 'minus') { - $tooltiponprofitminus .= ' > '.$name." (-)<br>\n"; + $tooltiponprofitminus.=' > '.$name." (-)<br>\n"; } } } @@ -648,28 +652,9 @@ print '</tr>'; $total_revenue_ht = 0; -$balance_ht = 0; -$balance_ttc = 0; foreach ($listofreferent as $key => $value) { - $parameters = array( - 'total_revenue_ht' =>& $total_revenue_ht, - 'balance_ht' =>& $balance_ht, - 'balance_ttc' =>& $balance_ttc, - 'key' => $key, - 'value' =>& $value, - 'dates' => $dates, - 'datee' => $datee - ); - $reshook = $hookmanager->executeHooks('printOverviewProfit', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } elseif ($reshook > 0) { - print $hookmanager->resPrint; - continue; - } - $name = $langs->trans($value['name']); $title = $value['title']; $classname = $value['class']; @@ -678,17 +663,20 @@ $qualified = $value['test']; $margin = $value['margin']; $project_field = $value['project_field']; - if ($qualified && isset($margin)) { // If this element must be included into profit calculation ($margin is 'minus' or 'add') + if ($qualified && isset($margin)) // If this element must be included into profit calculation ($margin is 'minus' or 'add') + { $element = new $classname($db); $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field : 'fk_projet'); - if (is_array($elementarray) && count($elementarray) > 0) { + if (is_array($elementarray) && count($elementarray) > 0) + { $total_ht = 0; $total_ttc = 0; $num = count($elementarray); - for ($i = 0; $i < $num; $i++) { + for ($i = 0; $i < $num; $i++) + { $tmp = explode('_', $elementarray[$i]); $idofelement = $tmp[0]; $idofelementuser = $tmp[1]; @@ -698,11 +686,13 @@ // Define if record must be used for total or not $qualifiedfortotal = true; - if ($key == 'invoice') { + if ($key == 'invoice') + { if (!empty($element->close_code) && $element->close_code == 'replaced') $qualifiedfortotal = false; // Replacement invoice, do not include into total if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $element->type == Facture::TYPE_DEPOSIT) $qualifiedfortotal = false; // If hidden option to use deposits as payment (deprecated, not recommended to use this), deposits are not included } - if ($key == 'propal') { + if ($key == 'propal') + { if ($element->status != Propal::STATUS_SIGNED && $element->status != Propal::STATUS_BILLED) $qualifiedfortotal = false; // Only signed proposal must not be included in total } @@ -712,77 +702,93 @@ if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ht_by_line = $element->amount; elseif ($tablename == 'fichinter') $total_ht_by_line = $element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ht_by_line = $element->price * abs($element->qty); - elseif ($tablename == 'projet_task') { - if ($idofelementuser) { + elseif ($tablename == 'projet_task') + { + if ($idofelementuser) + { $tmp = $element->getSumOfAmount($elementuser, $dates, $datee); $total_ht_by_line = price2num($tmp['amount'], 'MT'); - } else { + } + else + { $tmp = $element->getSumOfAmount('', $dates, $datee); $total_ht_by_line = price2num($tmp['amount'], 'MT'); } - } elseif ($key == 'loan') { - if ((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)) { - // Get total loan - $total_ht_by_line = -$element->capital; - } else { - // Get loan schedule according to date filter - $total_ht_by_line = 0; - $loanScheduleStatic = new LoanSchedule($element->db); - $loanScheduleStatic->fetchAll($element->id); - if (!empty($loanScheduleStatic->lines)) { - foreach ($loanScheduleStatic->lines as $loanSchedule) { - /** - * @var $loanSchedule LoanSchedule - */ - if (($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee) // dates filter is defined - || !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <= dol_now() - || empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee - ) { - $total_ht_by_line -= $loanSchedule->amount_capital; - } - } - } - } - } else $total_ht_by_line = $element->total_ht; + } + elseif ($key == 'loan') { + if ((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)) { + // Get total loan + $total_ht_by_line = -$element->capital; + } + else { + // Get loan schedule according to date filter + $total_ht_by_line = 0; + $loanScheduleStatic = new LoanSchedule($element->db); + $loanScheduleStatic->fetchAll($element->id); + if (!empty($loanScheduleStatic->lines)) { + foreach ($loanScheduleStatic->lines as $loanSchedule) { + /** + * @var $loanSchedule LoanSchedule + */ + if (($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee) // dates filter is defined + || !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <= dol_now() + || empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee + ) { + $total_ht_by_line = -$loanSchedule->amount_capital; + } + } + } + } + } + else $total_ht_by_line = $element->total_ht; // Define $total_ttc_by_line if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ttc_by_line = $element->amount; elseif ($tablename == 'fichinter') $total_ttc_by_line = $element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ttc_by_line = $element->price * abs($element->qty); - elseif ($tablename == 'projet_task') { + elseif ($tablename == 'projet_task') + { $defaultvat = get_default_tva($mysoc, $mysoc); $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT'); - } elseif ($key == 'loan') { - $total_ttc_by_line = $total_ht_by_line; // For loan there is actually no taxe managed in Dolibarr - } else $total_ttc_by_line = $element->total_ttc; + } + elseif ($key == 'loan') { + $total_ttc_by_line = $total_ht_by_line; // For loan there is actually no taxe managed in Dolibarr + } + else $total_ttc_by_line = $element->total_ttc; // Change sign of $total_ht_by_line and $total_ttc_by_line for some cases - if ($tablename == 'payment_various') { - if ($element->sens == 1) { - $total_ht_by_line = -$total_ht_by_line; - $total_ttc_by_line = -$total_ttc_by_line; - } + if ($tablename == 'payment_various') + { + if ($element->sens == 1) + { + $total_ht_by_line = -$total_ht_by_line; + $total_ttc_by_line = -$total_ttc_by_line; + } } // Add total if we have to - if ($qualifiedfortotal) { - $total_ht = $total_ht + $total_ht_by_line; - $total_ttc = $total_ttc + $total_ttc_by_line; + if ($qualifiedfortotal) + { + $total_ht = $total_ht + $total_ht_by_line; + $total_ttc = $total_ttc + $total_ttc_by_line; } } // Each element with at least one line is output $qualifiedforfinalprofit = true; if ($key == 'intervention' && empty($conf->global->PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT)) $qualifiedforfinalprofit = false; + if ($key == 'propal' && $element->status != Propal::STATUS_SIGNED && $element->status != Propal::STATUS_BILLED) $qualifiedforfinalprofit = false; //var_dump($key.' '.$qualifiedforfinalprofit); // Calculate margin - if ($qualifiedforfinalprofit) { + if ($qualifiedforfinalprofit) + { if ($margin == 'add') { $total_revenue_ht += $total_ht; } - if ($margin != "add") { // Revert sign + if ($margin != "add") // Revert sign + { $total_ht = -$total_ht; $total_ttc = -$total_ttc; } @@ -843,20 +849,6 @@ // Detail foreach ($listofreferent as $key => $value) { - $parameters = array( - 'key' => $key, - 'value' =>& $value, - 'dates' => $dates, - 'datee' => $datee - ); - $reshook = $hookmanager->executeHooks('printOverviewDetail', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } elseif ($reshook > 0) { - print $hookmanager->resPrint; - continue; - } - $title = $value['title']; $classname = $value['class']; $tablename = $value['table']; @@ -865,17 +857,18 @@ $langtoload = $value['lang']; $urlnew = $value['urlnew']; $buttonnew = $value['buttonnew']; - $testnew = $value['testnew']; + $testnew = $value['testnew']; $project_field = $value['project_field']; $exclude_select_element = array('payment_various'); if (!empty($value['exclude_select_element'])) $exclude_select_element[] = $value['exclude_select_element']; - if ($qualified) { + if ($qualified) + { // If we want the project task array to have details of users //if ($key == 'project_task') $key = 'project_task_time'; - if ($langtoload) $langs->load($langtoload); + if ($langtoload) $langs->load($langtoload); $element = new $classname($db); @@ -885,23 +878,24 @@ $array_of_element_linkable_with_different_thirdparty = array('facture_fourn', 'commande_fournisseur'); if (!in_array($tablename, $array_of_element_linkable_with_different_thirdparty)) { - $idtofilterthirdparty = $object->thirdparty->id; - if (!empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) $idtofilterthirdparty .= ','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS; + $idtofilterthirdparty = $object->thirdparty->id; + if (!empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) $idtofilterthirdparty .= ','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS; } - if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element)) - { + if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element)) + { $selectList = $formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300 minwidth75imp', -2, !empty($project_field) ? $project_field : 'fk_projet'); if ($selectList < 0) { setEventMessages($formproject->error, $formproject->errors, 'errors'); - } elseif ($selectList) + } + elseif ($selectList) { // Define form with the combo list of elements to link - $addform .= '<div class="inline-block valignmiddle">'; - $addform .= '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; - $addform .= '<input type="hidden" name="token" value="'.newToken().'">'; - $addform .= '<input type="hidden" name="tablename" value="'.$tablename.'">'; + $addform .= '<div class="inline-block valignmiddle">'; + $addform .= '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; + $addform .= '<input type="hidden" name="token" value="'.newToken().'">'; + $addform .= '<input type="hidden" name="tablename" value="'.$tablename.'">'; $addform .= '<input type="hidden" name="action" value="addelement">'; $addform .= '<input type="hidden" name="datesrfc" value="'.dol_print_date($dates, 'dayhourrfc').'">'; $addform .= '<input type="hidden" name="dateerfc" value="'.dol_print_date($datee, 'dayhourrfc').'">'; @@ -920,7 +914,7 @@ elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { $addform .= '<a class="buttonxxx buttonRefused" disabled="disabled" href="#"><span class="valignmiddle text-plus-circle hideonsmartphone">'.($buttonnew ? $langs->trans($buttonnew) : $langs->trans("Create")).'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>'; } - $addform .= '<div>'; + $addform .= '<div>'; } print load_fiche_titre($langs->trans($title), $addform, ''); @@ -946,9 +940,9 @@ elseif (in_array($tablename, array('expensereport_det', 'don', 'projet_task', 'stock_mouvement', 'payment_salary'))) print $langs->trans("User"); else print $langs->trans("ThirdParty"); print '</td>'; - // Duration of intervention + // Duration of intervention if ($tablename == 'fichinter') - { + { print '<td>'; print $langs->trans("TotalDuration"); $total_duration = 0; @@ -957,13 +951,13 @@ // Amount HT //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td class="right" width="120">'.$langs->trans("AmountHT").'</td>'; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print '<td class="right" width="120">'.$langs->trans("Amount").'</td>'; - if ($key == 'loan') print '<td class="right" width="120">'.$langs->trans("LoanCapital").'</td>'; + if ($key == 'loan') print '<td class="right" width="120">'.$langs->trans("LoanCapital").'</td>'; elseif (empty($value['disableamount'])) print '<td class="right" width="120">'.$langs->trans("AmountHT").'</td>'; else print '<td width="120"></td>'; // Amount TTC //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td class="right" width="120">'.$langs->trans("AmountTTC").'</td>'; - if ($key == 'loan') print '<td class="right" width="120">'.$langs->trans("RemainderToPay").'</td>'; - elseif (empty($value['disableamount'])) print '<td class="right" width="120">'.$langs->trans("AmountTTC").'</td>'; + if ($key == 'loan') print '<td class="right" width="120">'.$langs->trans("RemainderToPay").'</td>'; + elseif (empty($value['disableamount'])) print '<td class="right" width="120">'.$langs->trans("AmountTTC").'</td>'; else print '<td width="120"></td>'; // Status if (in_array($tablename, array('projet_task'))) print '<td class="right" width="200">'.$langs->trans("ProgressDeclared").'</td>'; @@ -1002,7 +996,9 @@ if ($tablename != 'expensereport_det') { if (method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty(); - } else { + } + else + { $expensereport = new ExpenseReport($db); $expensereport->fetch($element->fk_expensereport); } @@ -1047,16 +1043,20 @@ if ($tablename == 'expensereport_det') { print $expensereport->getNomUrl(1); - } else { + } + else + { // Show ref with link if ($element instanceof Task) { print $element->getNomUrl(1, 'withproject', 'time'); print ' - '.dol_trunc($element->label, 48); - } elseif ($key == 'loan') { - print $element->getNomUrl(1); - print ' - '.dol_trunc($element->label, 48); - } else print $element->getNomUrl(1); + } + elseif ($key == 'loan') { + print $element->getNomUrl(1); + print ' - '.dol_trunc($element->label, 48); + } + else print $element->getNomUrl(1); $element_doc = $element->element; $filename = dol_sanitizeFileName($element->ref); @@ -1065,7 +1065,8 @@ if ($element_doc === 'order_supplier') { $element_doc = 'commande_fournisseur'; $filedir = $conf->fournisseur->commande->multidir_output[$element->entity].'/'.dol_sanitizeFileName($element->ref); - } elseif ($element_doc === 'invoice_supplier') { + } + elseif ($element_doc === 'invoice_supplier') { $element_doc = 'facture_fournisseur'; $filename = get_exdir($element->id, 2, 0, 0, $element, 'product').dol_sanitizeFileName($element->ref); $filedir = $conf->fournisseur->facture->multidir_output[$element->entity].'/'.get_exdir($element->id, 2, 0, 0, $element, 'invoice_supplier').dol_sanitizeFileName($element->ref); @@ -1089,65 +1090,73 @@ elseif ($tablename == 'chargesociales') $date = $element->date_ech; elseif (!empty($element->status) || !empty($element->statut) || !empty($element->fk_status)) { - if ($tablename == 'don') $date = $element->datedon; - if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') + if ($tablename == 'don') $date = $element->datedon; + if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') + { + $date = ($element->date_commande ? $element->date_commande : $element->date_valid); + } + elseif ($tablename == 'supplier_proposal') $date = $element->date_validation; // There is no other date for this + elseif ($tablename == 'fichinter') $date = $element->datev; // There is no other date for this + elseif ($tablename == 'projet_task') $date = ''; // We show no date. Showing date of beginning of task make user think it is date of time consumed + else { - $date = ($element->date_commande ? $element->date_commande : $element->date_valid); - } elseif ($tablename == 'supplier_proposal') $date = $element->date_validation; // There is no other date for this - elseif ($tablename == 'fichinter') $date = $element->datev; // There is no other date for this - elseif ($tablename == 'projet_task') $date = ''; // We show no date. Showing date of beginning of task make user think it is date of time consumed - else { - $date = $element->date; // invoice, ... - if (empty($date)) $date = $element->date_contrat; - if (empty($date)) $date = $element->datev; - if (empty($date) && !empty($datefieldname)) { - $date = $element->$datefieldname; - } - } - } elseif ($key == 'loan') { - $date = $element->datestart; - } + $date = $element->date; // invoice, ... + if (empty($date)) $date = $element->date_contrat; + if (empty($date)) $date = $element->datev; + if (empty($date) && !empty($datefieldname)) { + $date = $element->$datefieldname; + } + } + } + elseif ($key == 'loan') { + $date = $element->datestart; + } print '<td class="center">'; if ($tablename == 'actioncomm') { - print dol_print_date($element->datep, 'dayhour'); - if ($element->datef && $element->datef > $element->datep) print " - ".dol_print_date($element->datef, 'dayhour'); - } elseif (in_array($tablename, array('projet_task'))) - { - $tmpprojtime = $element->getSumOfAmount($elementuser, $dates, $datee); // $element is a task. $elementuser may be empty - print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$idofelement.'&withproject=1">'; - print convertSecondToTime($tmpprojtime['nbseconds'], 'allhourmin'); - print '</a>'; - $total_time_by_line = $tmpprojtime['nbseconds']; - } else print dol_print_date($date, 'day'); + print dol_print_date($element->datep, 'dayhour'); + if ($element->datef && $element->datef > $element->datep) print " - ".dol_print_date($element->datef, 'dayhour'); + } + elseif (in_array($tablename, array('projet_task'))) + { + $tmpprojtime = $element->getSumOfAmount($elementuser, $dates, $datee); // $element is a task. $elementuser may be empty + print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$idofelement.'&withproject=1">'; + print convertSecondToTime($tmpprojtime['nbseconds'], 'allhourmin'); + print '</a>'; + $total_time_by_line = $tmpprojtime['nbseconds']; + } + else print dol_print_date($date, 'day'); print '</td>'; // Third party or user - print '<td class="left">'; - if (is_object($element->thirdparty)) { - print $element->thirdparty->getNomUrl(1, '', 48); - } elseif ($tablename == 'expensereport_det') { - $tmpuser = new User($db); - $tmpuser->fetch($expensereport->fk_user_author); - print $tmpuser->getNomUrl(1, '', 48); - } elseif ($tablename == 'payment_salary') + print '<td class="left">'; + if (is_object($element->thirdparty)) { + print $element->thirdparty->getNomUrl(1, '', 48); + } elseif ($tablename == 'expensereport_det') { + $tmpuser = new User($db); + $tmpuser->fetch($expensereport->fk_user_author); + print $tmpuser->getNomUrl(1, '', 48); + } + elseif ($tablename == 'payment_salary') { $tmpuser = new User($db); $tmpuser->fetch($element->fk_user); print $tmpuser->getNomUrl(1, '', 48); - } elseif ($tablename == 'don' || $tablename == 'stock_mouvement') - { - if ($element->fk_user_author > 0) - { - $tmpuser2 = new User($db); - $tmpuser2->fetch($element->fk_user_author); - print $tmpuser2->getNomUrl(1, '', 48); - } - } elseif ($tablename == 'projet_task' && $key == 'project_task_time') // if $key == 'project_task', we don't want details per user - { - print $elementuser->getNomUrl(1); - } + } + elseif ($tablename == 'don' || $tablename == 'stock_mouvement') + { + if ($element->fk_user_author > 0) + { + $tmpuser2 = new User($db); + $tmpuser2->fetch($element->fk_user_author); + print $tmpuser2->getNomUrl(1, '', 48); + } + } + elseif ($tablename == 'projet_task' && $key == 'project_task_time') // if $key == 'project_task', we don't want details per user + { + print $elementuser->getNomUrl(1); + } print '</td>'; // Add duration and store it in counter for fichinter @@ -1159,41 +1168,45 @@ print '</td>'; } - // Amount without tax + // Amount without tax $warning = ''; if (empty($value['disableamount'])) { - $total_ht_by_line = null; - $othermessage = ''; + $total_ht_by_line = null; + $othermessage = ''; if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ht_by_line = $element->amount; elseif ($tablename == 'fichinter') $total_ht_by_line = $element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ht_by_line = $element->price * abs($element->qty); elseif (in_array($tablename, array('projet_task'))) { - if (!empty($conf->salaries->enabled)) - { - // TODO Permission to read daily rate to show value - $total_ht_by_line = price2num($tmpprojtime['amount'], 'MT'); - if ($tmpprojtime['nblinesnull'] > 0) - { - $langs->load("errors"); - $warning = $langs->trans("WarningSomeLinesWithNullHourlyRate", $conf->currency); - } - } else { - $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); - } - } elseif ($key == 'loan') $total_ht_by_line = $element->capital; - else { + if (!empty($conf->salaries->enabled)) + { + // TODO Permission to read daily rate to show value + $total_ht_by_line = price2num($tmpprojtime['amount'], 'MT'); + if ($tmpprojtime['nblinesnull'] > 0) + { + $langs->load("errors"); + $warning = $langs->trans("WarningSomeLinesWithNullHourlyRate", $conf->currency); + } + } + else + { + $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); + } + } + elseif ($key == 'loan') $total_ht_by_line = $element->capital; + else + { $total_ht_by_line = $element->total_ht; } // Change sign of $total_ht_by_line and $total_ttc_by_line for some cases if ($tablename == 'payment_various') { - if ($element->sens == 0) - { - $total_ht_by_line = -$total_ht_by_line; - } + if ($element->sens == 0) + { + $total_ht_by_line = -$total_ht_by_line; + } } print '<td class="right">'; @@ -1206,37 +1219,42 @@ } if ($warning) print ' '.img_warning($warning); print '</td>'; - } else print '<td></td>'; - - // Amount inc tax + } + else print '<td></td>'; + + // Amount inc tax if (empty($value['disableamount'])) { - $total_ttc_by_line = null; + $total_ttc_by_line = null; if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ttc_by_line = $element->amount; elseif ($tablename == 'fichinter') $total_ttc_by_line = $element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ttc_by_line = $element->price * abs($element->qty); elseif ($tablename == 'projet_task') { - if (!empty($conf->salaries->enabled)) - { - // TODO Permission to read daily rate - $defaultvat = get_default_tva($mysoc, $mysoc); - $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT'); - } else { - $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); - } - } elseif ($key == 'loan') $total_ttc_by_line = $element->capital - $element->getSumPayment(); - else { + if (!empty($conf->salaries->enabled)) + { + // TODO Permission to read daily rate + $defaultvat = get_default_tva($mysoc, $mysoc); + $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT'); + } + else + { + $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); + } + } + elseif ($key == 'loan') $total_ttc_by_line = $element->capital - $element->getSumPayment(); + else + { $total_ttc_by_line = $element->total_ttc; } // Change sign of $total_ht_by_line and $total_ttc_by_line for some cases if ($tablename == 'payment_various') { - if ($element->sens == 0) - { - $total_ttc_by_line = -$total_ttc_by_line; - } + if ($element->sens == 0) + { + $total_ttc_by_line = -$total_ttc_by_line; + } } print '<td class="right">'; @@ -1249,27 +1267,33 @@ } if ($warning) print ' '.img_warning($warning); print '</td>'; - } else print '<td></td>'; + } + else print '<td></td>'; // Status print '<td class="right">'; if ($tablename == 'expensereport_det') { print $expensereport->getLibStatut(5); - } elseif ($element instanceof CommonInvoice) + } + elseif ($element instanceof CommonInvoice) { //This applies for Facture and FactureFournisseur print $element->getLibStatut(5, $element->getSommePaiement()); - } elseif ($element instanceof Task) + } + elseif ($element instanceof Task) { if ($element->progress != '') { print $element->progress.' %'; } - } elseif ($tablename == 'stock_mouvement') + } + elseif ($tablename == 'stock_mouvement') { print $element->getLibStatut(3); - } else { + } + else + { print $element->getLibStatut(5); } print '</td>'; @@ -1315,21 +1339,21 @@ print '<tr class="liste_total"><td colspan="'.$colspan.'">'.$langs->trans("Number").': '.$i.'</td>'; if (in_array($tablename, array('projet_task'))) { - print '<td class="center">'; - print convertSecondToTime($total_time, 'allhourmin'); - print '</td>'; - print '<td>'; - print '</td>'; + print '<td class="center">'; + print convertSecondToTime($total_time, 'allhourmin'); + print '</td>'; + print '<td>'; + print '</td>'; } //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td class="right" width="100">'.$langs->trans("TotalHT").' : '.price($total_ht).'</td>'; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print '<td class="right" width="100">'.$langs->trans("Total").' : '.price($total_ht).'</td>'; - // If fichinter add the total_duration - if ($tablename == 'fichinter') print '<td class="left">'.convertSecondToTime($total_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'</td>'; + // If fichinter add the total_duration + if ($tablename == 'fichinter') print '<td class="left">'.convertSecondToTime($total_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'</td>'; print '<td class="right">'; if (empty($value['disableamount'])) { - if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("LoanCapital").' : '.price($total_ttc); - elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); + if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("LoanCapital").' : '.price($total_ttc); + elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); } print '</td>'; //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td class="right" width="100">'.$langs->trans("TotalTTC").' : '.price($total_ttc).'</td>'; @@ -1337,13 +1361,15 @@ print '<td class="right">'; if (empty($value['disableamount'])) { - if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("RemainderToPay").' : '.price($total_ttc); - elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); + if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("RemainderToPay").' : '.price($total_ttc); + elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); } print '</td>'; print '<td> </td>'; print '</tr>'; - } else { + } + else + { if (!is_array($elementarray)) // error { print $elementarray; @@ -1360,6 +1386,7 @@ { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox('.elementselect'); + $out .= $comboenhancement; print $comboenhancement; } --- /tmp/dsg/dolibarr/htdocs/projet/github_ganttchart.inc.php +++ /tmp/dsg/dolibarr/htdocs/projet/client_ganttchart.inc.php @@ -126,14 +126,9 @@ $projecttmp = new Project($db); $projecttmp->fetch($t['task_project_id']); $tmpt = array( - 'task_id'=> '-'.$t['task_project_id'], - 'task_alternate_id'=> '-'.$t['task_project_id'], - 'task_name'=>$projecttmp->ref.' '.$projecttmp->title, - 'task_resources'=>'', - 'task_start_date'=>'', - 'task_end_date'=>'', - 'task_is_group'=>1, 'task_position'=>0, 'task_css'=>'ggroupblack', 'task_milestone'=> 0, 'task_parent'=>0, 'task_parent_alternate_id'=>0, - 'task_notes'=>'', + 'task_id'=> '-'.$t['task_project_id'], 'task_alternate_id'=> '-'.$t['task_project_id'], 'task_name'=>$projecttmp->ref.' '.$projecttmp->title, 'task_resources'=>'', + 'task_start_date'=>'', 'task_end_date'=>'', + 'task_is_group'=>1, 'task_position'=>0, 'task_css'=>'ggroupblack', 'task_milestone'=> 0, 'task_parent'=>0, 'task_parent_alternate_id'=>0, 'task_notes'=>'', 'task_planned_workload'=>0 ); constructGanttLine($tasks, $tmpt, array(), 0, $t['task_project_id']); @@ -185,7 +180,6 @@ $end_date = dol_print_date($end_date, $dateformatinput2); // Resources $resources = $task["task_resources"]; - // Define depend (ex: "", "4,13", ...) $depend = ''; $count = 0; @@ -201,7 +195,9 @@ if ($project_id && $level < 0) { $parent = '-'.$project_id; - } else { + } + else + { $parent = $task["task_parent_alternate_id"]; //$parent = $task["task_parent"]; } @@ -212,7 +208,9 @@ { //$link=DOL_URL_ROOT.'/projet/tasks.php?withproject=1&id='.abs($task["task_id"]); $link = ''; - } else { + } + else + { $link = DOL_URL_ROOT.'/projet/tasks/contact.php?withproject=1&id='.$task["task_id"]; } --- /tmp/dsg/dolibarr/htdocs/projet/github_ganttview.php +++ /tmp/dsg/dolibarr/htdocs/projet/client_ganttview.php @@ -96,130 +96,130 @@ //$userDelete = $object->restrictedProjectArea($user,'delete'); //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; - $tab = 'tasks'; - - $head = project_prepare_head($object); - print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); - - $param = ($mode == 'mine' ? '&mode=mine' : ''); - - - - // Project card - - $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; - - $morehtmlref = '<div class="refidno">'; - // Title - $morehtmlref .= $object->title; - // Thirdparty - if ($object->thirdparty->id > 0) - { - $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); - } - $morehtmlref .= '</div>'; - - // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { - $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; - } - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - - print '<div class="fichecenter">'; - print '<div class="fichehalfleft">'; - print '<div class="underbanner clearboth"></div>'; - - print '<table class="border tableforfield centpercent">'; - - // Usage - print '<tr><td class="tdtop">'; - print $langs->trans("Usage"); - print '</td>'; - print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { - print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowOpportunity"); - print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); - print '<br>'; - } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { - print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowTasks"); - print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); - print '<br>'; - } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { - print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectBillTimeDescription"); - print $form->textwithpicto($langs->trans("BillTime"), $htmltext); - print '<br>'; - } - print '</td></tr>'; - - // Visibility - print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; - if ($object->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); - print '</td></tr>'; - - // Date start - end - print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; + $tab = 'tasks'; + + $head = project_prepare_head($object); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); + + + + // Project card + + $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; + + $morehtmlref = '<div class="refidno">'; + // Title + $morehtmlref .= $object->title; + // Thirdparty + if ($object->thirdparty->id > 0) + { + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '</div>'; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) + { + $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '<div class="fichecenter">'; + print '<div class="fichehalfleft">'; + print '<div class="underbanner clearboth"></div>'; + + print '<table class="border tableforfield centpercent">'; + + // Usage + print '<tr><td class="tdtop">'; + print $langs->trans("Usage"); + print '</td>'; + print '<td>'; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '<br>'; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) + { + print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '<br>'; + } + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '<br>'; + } + print '</td></tr>'; + + // Visibility + print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; + if ($object->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '</td></tr>'; + + // Date start - end + print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; $start = dol_print_date($object->date_start, 'day'); print ($start ? $start : '?'); $end = dol_print_date($object->date_end, 'day'); print ' - '; print ($end ? $end : '?'); if ($object->hasDelay()) print img_warning("Late"); - print '</td></tr>'; - - // Budget - print '<tr><td>'.$langs->trans("Budget").'</td><td>'; - if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); - print '</td></tr>'; - - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '</table>'; - - print '</div>'; - print '<div class="fichehalfright">'; - print '<div class="ficheaddleft">'; - print '<div class="underbanner clearboth"></div>'; - - print '<table class="border tableforfield centpercent">'; - - // Description - print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; - print nl2br($object->description); - print '</td></tr>'; - - // Categories - if ($conf->categorie->enabled) { - print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>'; - print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1); - print "</td></tr>"; - } - - print '</table>'; - - print '</div>'; - print '</div>'; - print '</div>'; - - print '<div class="clearboth"></div>'; - - print dol_get_fiche_end(); - - print '<br>'; + print '</td></tr>'; + + // Budget + print '<tr><td>'.$langs->trans("Budget").'</td><td>'; + if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + print '</td></tr>'; + + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '</table>'; + + print '</div>'; + print '<div class="fichehalfright">'; + print '<div class="ficheaddleft">'; + print '<div class="underbanner clearboth"></div>'; + + print '<table class="border tableforfield centpercent">'; + + // Description + print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; + print nl2br($object->description); + print '</td></tr>'; + + // Categories + if ($conf->categorie->enabled) { + print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>'; + print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1); + print "</td></tr>"; + } + + print '</table>'; + + print '</div>'; + print '</div>'; + print '</div>'; + + print '<div class="clearboth"></div>'; + + dol_fiche_end(); + + print '<br>'; } // Link to create task @@ -227,19 +227,18 @@ $linktocreatetaskUserRight = false; if ($user->rights->projet->all->creer || $user->rights->projet->creer) { if ($object->public || $userWrite > 0) { - $linktocreatetaskUserRight = true; + $linktocreatetaskUserRight = true; } else { - $linktocreatetaskParam['attr']['title'] = $langs->trans("NotOwnerOfProject"); + $linktocreatetaskParam['attr']['title'] = $langs->trans("NotOwnerOfProject"); } } $linktocreatetask = dolGetButtonTitle($langs->trans('AddTask'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id.'&action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id), '', $linktocreatetaskUserRight, $linktocreatetaskParam); -$linktotasks = dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt paddingleft imgforviewmode', DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id, '', 1, array('morecss'=>'reposition')); -$linktotasks .= dolGetButtonTitle($langs->trans('ViewGantt'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1', '', 1, array('morecss'=>'reposition marginleftonly btnTitleSelected')); +$linktolist = dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt paddingleft imgforviewmode', DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id, '', 1, array('morecss'=>'reposition')); //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'generic', 0, '', '', 0, 1); -print load_fiche_titre($title, $linktotasks.' '.$linktocreatetask, 'projecttask'); +print load_fiche_titre($title, $linktolist.' '.$linktocreatetask, 'generic'); // Get list of tasks in tasksarray and taskarrayfiltered @@ -262,32 +261,33 @@ $tasks = array(); $task_dependencies = array(); $taskcursor = 0; - foreach ($tasksarray as $key => $val) // Task array are sorted by "project, position, date" + foreach ($tasksarray as $key => $val) // Task array are sorted by "project, position, dateo" { $task->fetch($val->id, ''); $idparent = ($val->fk_parent ? $val->fk_parent : '-'.$val->fk_project); // If start with -, id is a project id $tasks[$taskcursor]['task_id'] = $val->id; - $tasks[$taskcursor]['task_alternate_id'] = ($taskcursor + 1); // An id that has same order than position (required by ganttchart) + $tasks[$taskcursor]['task_alternate_id'] = ($taskcursor + 1); // An id that has same order than position (requird by ganttchart) $tasks[$taskcursor]['task_project_id'] = $val->fk_project; $tasks[$taskcursor]['task_parent'] = $idparent; $tasks[$taskcursor]['task_is_group'] = 0; - $tasks[$taskcursor]['task_css'] = 'gtaskblue'; - $tasks[$taskcursor]['task_position'] = $val->rang; - $tasks[$taskcursor]['task_planned_workload'] = $val->planned_workload; - - if ($val->fk_parent != 0 && $task->hasChildren() > 0) { - $tasks[$taskcursor]['task_is_group'] = 1; - $tasks[$taskcursor]['task_css'] = 'ggroupblack'; - //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; - } elseif ($task->hasChildren() > 0) { - $tasks[$taskcursor]['task_is_group'] = 1; - //$tasks[$taskcursor]['task_is_group'] = 0; - $tasks[$taskcursor]['task_css'] = 'ggroupblack'; - //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; - } + $tasks[$taskcursor]['task_css'] = 'gtaskblue'; + $tasks[$taskcursor]['task_position'] = $val->rang; + $tasks[$taskcursor]['task_planned_workload'] = $val->planned_workload; + + if ($val->fk_parent != 0 && $task->hasChildren() > 0) { + $tasks[$taskcursor]['task_is_group'] = 1; + $tasks[$taskcursor]['task_css'] = 'ggroupblack'; + //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; + } + elseif ($task->hasChildren() > 0) { + $tasks[$taskcursor]['task_is_group'] = 1; + //$tasks[$taskcursor]['task_is_group'] = 0; + $tasks[$taskcursor]['task_css'] = 'ggroupblack'; + //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; + } $tasks[$taskcursor]['task_milestone'] = '0'; $tasks[$taskcursor]['task_percent_complete'] = $val->progress; //$tasks[$taskcursor]['task_name']=$task->getNomUrl(1); @@ -334,13 +334,12 @@ } } } - + //if ($s) $tasks[$taskcursor]['task_resources']='<a href="'.DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$val->id.'&withproject=1" title="'.dol_escape_htmltag($s).'">'.$langs->trans("List").'</a>'; /* For JSGanttImproved */ //if ($s) $tasks[$taskcursor]['task_resources']=implode(',',$idofusers); - $tasks[$taskcursor]['task_resources'] = $s; - if ($s) $tasks[$taskcursor]['task_resources'] = '<a href="'.DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$val->id.'&withproject=1" title="'.dol_escape_htmltag($s).'">'.$langs->trans("List").'</a>'; + $tasks[$taskcursor]['task_resources'] = $s; //print "xxx".$val->id.$tasks[$taskcursor]['task_resources']; - $tasks[$taskcursor]['note'] = $task->note_public; + $tasks[$taskcursor]['note'] = $task->note_public; $taskcursor++; } @@ -362,39 +361,33 @@ if (!empty($conf->use_javascript_ajax)) { - //var_dump($_SESSION); + //var_dump($_SESSION); // How the date for data are formated (format used bu jsgantt) - $dateformatinput = 'yyyy-mm-dd'; - // How the date for data are formated (format used by dol_print_date) - $dateformatinput2 = 'standard'; - //var_dump($dateformatinput); + $dateformatinput = 'yyyy-mm-dd'; + // How the date for data are formated (format used by dol_print_date) + $dateformatinput2 = 'standard'; + //var_dump($dateformatinput); //var_dump($dateformatinput2); - $moreforfilter = '<div class="liste_titre liste_titre_bydiv centpercent">'; - - $moreforfilter .= '<div class="divsearchfield">'; - //$moreforfilter .= $langs->trans("TasksAssignedTo").': '; - //$moreforfilter .= $form->select_dolusers($tmpuser->id > 0 ? $tmpuser->id : '', 'search_user_id', 1); - $moreforfilter .= ' '; - $moreforfilter .= '</div>'; - - $moreforfilter .= '</div>'; - - print $moreforfilter; - - print '<div class="div-table-responsive">'; - - print '<div id="tabs" class="gantt" style="width: 80vw;">'."\n"; + print '<br>'; + + print '<div class="div-table-responsive">'; + + print '<div id="tabs" class="gantt" style="width: 80vw;">'."\n"; include_once DOL_DOCUMENT_ROOT.'/projet/ganttchart.inc.php'; print '</div>'."\n"; print '</div>'; - } else { + } + else + { $langs->load("admin"); print $langs->trans("AvailableOnlyIfJavascriptAndAjaxNotDisabled"); } -} else { +} +else +{ print '<div class="opacitymedium">'.$langs->trans("NoTasks").'</div>'; } --- /tmp/dsg/dolibarr/htdocs/projet/github_graph_opportunities.inc.php +++ /tmp/dsg/dolibarr/htdocs/projet/client_graph_opportunities.inc.php @@ -1,27 +1,10 @@ <?php -/* Copyright (C) 2013-2020 Laurent Destailleur <eldy@users.sourceforge.net> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -// variable $listofopplabel and $listofoppstatus should be defined - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { $sql = "SELECT p.fk_opp_status as opp_status, cls.code, COUNT(p.rowid) as nb, SUM(p.opp_amount) as opp_amount, SUM(p.opp_amount * p.opp_percent) as ponderated_opp_amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls ON p.fk_opp_status = cls.rowid"; // If lead status has been removed, we must show it in stats as unknown + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."c_lead_status as cls"; $sql .= " WHERE p.entity IN (".getEntity('project').")"; + $sql .= " AND p.fk_opp_status = cls.rowid"; $sql .= " AND p.fk_statut = 1"; // Opend projects only if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; @@ -30,101 +13,94 @@ if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - $totalnb = 0; - $totaloppnb = 0; - $totalamount = 0; - $ponderated_opp_amount = 0; - $valsnb = array(); - $valsamount = array(); - $dataseries = array(); - // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) - while ($i < $num) - { - $obj = $db->fetch_object($resql); - if ($obj) - { - $valsnb[$obj->opp_status] = $obj->nb; - $valsamount[$obj->opp_status] = $obj->opp_amount; - $totalnb += $obj->nb; - if ($obj->opp_status) $totaloppnb += $obj->nb; + $totalnb = 0; + $totaloppnb = 0; + $totalamount = 0; + $ponderated_opp_amount = 0; + $valsnb = array(); + $valsamount = array(); + $dataseries = array(); + // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) + while ($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj) + { + $valsnb[$obj->opp_status] = $obj->nb; + $valsamount[$obj->opp_status] = $obj->opp_amount; + $totalnb += $obj->nb; + if ($obj->opp_status) $totaloppnb += $obj->nb; if (!in_array($obj->code, array('WON', 'LOST'))) { $totalamount += $obj->opp_amount; $ponderated_opp_amount += $obj->ponderated_opp_amount; } - $total += $obj->nb; - } - $i++; - } - $db->free($resql); + $total += $obj->nb; + } + $i++; + } + $db->free($resql); - $ponderated_opp_amount = $ponderated_opp_amount / 100; + $ponderated_opp_amount = $ponderated_opp_amount / 100; print '<div class="div-table-responsive-no-min">'; print '<table class="noborder nohover centpercent">'; print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("OpportunitiesStatusForOpenedProjects").'</th></tr>'."\n"; - $listofstatus = array_keys($listofoppstatus); - // Complete with values found into database and not into the dictionary - foreach ($valsamount as $key => $val) { - if (!in_array($key, $listofstatus) && $key) { - $listofstatus[] = $key; - } - } - foreach ($listofstatus as $status) { $labelStatus = ''; $code = dol_getIdFromCode($db, $status, 'c_lead_status', 'rowid', 'code'); - if ($code) $labelStatus = $langs->transnoentitiesnoconv("OppStatus".$code); + if ($code) $labelStatus = $langs->trans("OppStatus".$code); if (empty($labelStatus)) $labelStatus = $listofopplabel[$status]; - if (empty($labelStatus)) $labelStatus = $langs->transnoentitiesnoconv('OldValue', $status); // When id is id of an entry no more in dictionary for example. - //$labelStatus .= ' ('.$langs->trans("Coeff").': '.price2num($listofoppstatus[$status]).')'; - //$labelStatus .= ' - '.price2num($listofoppstatus[$status]).'%'; + //$labelStatus .= ' ('.$langs->trans("Coeff").': '.price2num($listofoppstatus[$status]).')'; + //$labelStatus .= ' - '.price2num($listofoppstatus[$status]).'%'; - $dataseries[] = array($labelStatus, (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0)); - if (!$conf->use_javascript_ajax) - { - print '<tr class="oddeven">'; - print '<td>'.$labelStatus.'</td>'; - print '<td class="right"><a href="list.php?statut='.$status.'">'.price((isset($valsamount[$status]) ? (float) $valsamount[$status] : 0), 0, '', 1, -1, -1, $conf->currency).'</a></td>'; - print "</tr>\n"; - } - } - if ($conf->use_javascript_ajax) - { - print '<tr><td class="center nopaddingleftimp nopaddingrightimp" colspan="2">'; + $dataseries[] = array($labelStatus, (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0)); + if (!$conf->use_javascript_ajax) + { + print '<tr class="oddeven">'; + print '<td>'.$labelStatus.'</td>'; + print '<td class="right"><a href="list.php?statut='.$status.'">'.price((isset($valsamount[$status]) ? (float) $valsamount[$status] : 0), 0, '', 1, -1, -1, $conf->currency).'</a></td>'; + print "</tr>\n"; + } + } + if ($conf->use_javascript_ajax) + { + print '<tr><td class="center nopaddingleftimp nopaddingrightimp" colspan="2">'; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - //$dolgraph->setWidth('100%'); - $dolgraph->SetHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($totaloppnb ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + //$dolgraph->setWidth('100%'); + $dolgraph->SetHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($totaloppnb ? 0 : 1); - print '</td></tr>'; - } - //if ($totalinprocess != $total) - //print '<tr class="liste_total"><td>'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')</td><td class="right">'.$totalinprocess.'</td></tr>'; - print '<tr class="liste_total"><td class="maxwidth200 tdoverflow">'.$langs->trans("OpportunityTotalAmount").' ('.$langs->trans("WonLostExcluded").')</td><td class="right">'.price($totalamount, 0, '', 1, -1, -1, $conf->currency).'</td></tr>'; - print '<tr class="liste_total"><td class="minwidth200 tdoverflow">'; - //print $langs->trans("OpportunityPonderatedAmount").' ('.$langs->trans("WonLostExcluded").')'; - print $form->textwithpicto($langs->trans("OpportunityPonderatedAmount").' ('.$langs->trans("WonLostExcluded").')', $langs->trans("OpportunityPonderatedAmountDesc"), 1); - print '</td><td class="right">'.price(price2num($ponderated_opp_amount, 'MT'), 0, '', 1, -1, -1, $conf->currency).'</td></tr>'; - print "</table>"; - print "</div>"; + print '</td></tr>'; + } + //if ($totalinprocess != $total) + //print '<tr class="liste_total"><td>'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')</td><td class="right">'.$totalinprocess.'</td></tr>'; + print '<tr class="liste_total"><td class="maxwidth200 tdoverflow">'.$langs->trans("OpportunityTotalAmount").' ('.$langs->trans("WonLostExcluded").')</td><td class="right">'.price($totalamount, 0, '', 1, -1, -1, $conf->currency).'</td></tr>'; + print '<tr class="liste_total"><td class="minwidth200 tdoverflow">'; + //print $langs->trans("OpportunityPonderatedAmount").' ('.$langs->trans("WonLostExcluded").')'; + print $form->textwithpicto($langs->trans("OpportunityPonderatedAmount").' ('.$langs->trans("WonLostExcluded").')', $langs->trans("OpportunityPonderatedAmountDesc"), 1); + print '</td><td class="right">'.price(price2num($ponderated_opp_amount, 'MT'), 0, '', 1, -1, -1, $conf->currency).'</td></tr>'; + print "</table>"; + print "</div>"; - print "<br>"; - } else { - dol_print_error($db); + print "<br>"; + } + else + { + dol_print_error($db); } } --- /tmp/dsg/dolibarr/htdocs/projet/github_index.php +++ /tmp/dsg/dolibarr/htdocs/projet/client_index.php @@ -39,10 +39,8 @@ // Load translation files required by the page $langs->loadLangs(array('projects', 'companies')); -$action = GETPOST('action', 'aZ09'); $search_project_user = GETPOST('search_project_user', 'int'); $mine = GETPOST('mode', 'aZ09') == 'mine' ? 1 : 0; -if ($mine == 0 && $search_project_user === '') $search_project_user = $user->conf->MAIN_SEARCH_PROJECT_USER_PROJECTSINDEX; if ($search_project_user == $user->id) $mine = 1; // Security check @@ -53,25 +51,7 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; - - -/* - * Actions - */ - -$parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -if (empty($reshook)) { - if ($action == 'refresh_search_project_user') { - $search_project_user = GETPOST('search_project_user', 'int'); - $tabparam = array("MAIN_SEARCH_PROJECT_USER_PROJECTSINDEX" => $search_project_user); - - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $result = dol_set_user_param($db, $conf, $user, $tabparam); - } -} +$max = 3; /* @@ -101,16 +81,16 @@ $morehtml = ''; $morehtml .= '<form name="projectform" method="POST">'; $morehtml .= '<input type="hidden" name="token" value="'.newToken().'">'; -$morehtml .= '<input type="hidden" name="action" value="refresh_search_project_user">'; $morehtml .= '<SELECT name="search_project_user">'; $morehtml .= '<option name="all" value="0"'.($mine ? '' : ' selected').'>'.$titleall.'</option>'; $morehtml .= '<option name="mine" value="'.$user->id.'"'.(($search_project_user == $user->id) ? ' selected' : '').'>'.$langs->trans("ProjectsImContactFor").'</option>'; $morehtml .= '</SELECT>'; -$morehtml .= '<input type="submit" class="button smallpaddingimp" name="refresh" value="'.$langs->trans("Refresh").'">'; +$morehtml .= '<input type="submit" class="button" name="refresh" value="'.$langs->trans("Refresh").'">'; $morehtml .= '</form>'; if ($mine) $tooltiphelp = $langs->trans("MyProjectsDesc"); -else { +else +{ if (!empty($user->rights->projet->all->lire) && !$socid) $tooltiphelp = $langs->trans("ProjectsDesc"); else $tooltiphelp = $langs->trans("ProjectsPublicDesc"); } @@ -161,7 +141,8 @@ } $i++; } -} else dol_print_error($db); +} +else dol_print_error($db); //var_dump($listofoppcode); @@ -170,33 +151,33 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { - // Search project - if (!empty($conf->projet->enabled) && $user->rights->projet->lire) - { - $listofsearchfields['search_project'] = array('text'=>'Project'); - } - - if (count($listofsearchfields)) - { - print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; - print '<input type="hidden" name="token" value="'.newToken().'">'; - print '<div class="div-table-responsive-no-min">'; - print '<table class="noborder nohover centpercent">'; - $i = 0; - foreach ($listofsearchfields as $key => $value) - { - if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; - print '<tr>'; - print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; - if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; - print '</tr>'; - $i++; - } - print '</table>'; - print '</div>'; - print '</form>'; - print '<br>'; - } + // Search project + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) + { + $listofsearchfields['search_project'] = array('text'=>'Project'); + } + + if (count($listofsearchfields)) + { + print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; + print '<input type="hidden" name="token" value="'.newToken().'">'; + print '<div class="div-table-responsive-no-min">'; + print '<table class="noborder nohover centpercent">'; + $i = 0; + foreach ($listofsearchfields as $key => $value) + { + if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; + print '<tr>'; + print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; + if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; + print '</tr>'; + $i++; + } + print '</table>'; + print '</div>'; + print '</form>'; + print '<br>'; + } } @@ -213,12 +194,8 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; // Latest modified projects -$sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.tms as datem"; -$sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; -$sql .= ", s.code_client, s.code_compta, s.client"; -$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; -$sql .= ", s.logo, s.email, s.entity"; -$sql .= ", s.canvas, s.status as thirdpartystatus"; +$sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.tms as datem,"; +$sql .= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.canvas, s.status as thirdpartystatus"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql .= " WHERE p.entity IN (".getEntity('project').")"; @@ -230,17 +207,16 @@ $resql = $db->query($sql); if ($resql) { - print '<div class="div-table-responsive-no-min">'; + print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; - print '<th colspan="4">'.$langs->trans("LatestModifiedProjects", $max).'</th>'; - print '</tr>'; + print '<th colspan="4">'.$langs->trans("LatestModifiedProjects", $max).'</th></tr>'; $num = $db->num_rows($resql); - if ($num) { $i = 0; + $var = true; while ($i < $num) { $obj = $db->fetch_object($resql); @@ -258,16 +234,11 @@ $companystatic->id = $obj->socid; $companystatic->name = $obj->name; - //$companystatic->name_alias = $obj->name_alias; - //$companystatic->code_client = $obj->code_client; - $companystatic->code_compta = $obj->code_compta; + $companystatic->email = $obj->email; $companystatic->client = $obj->client; - //$companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; $companystatic->fournisseur = $obj->fournisseur; - $companystatic->logo = $obj->logo; - $companystatic->email = $obj->email; - $companystatic->entity = $obj->entity; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas = $obj->canvas; $companystatic->status = $obj->thirdpartystatus; @@ -300,29 +271,32 @@ print '</tr>'; $i++; } - } else { - print '<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>'; } - print "</table></div>"; -} else dol_print_error($db); + print "</table></div><br>"; +} +else dol_print_error($db); $companystatic = new Societe($db); // We need a clean new object for next loop because current one has some properties set. +// Open project per thirdparty +print '<div class="div-table-responsive-no-min">'; +print '<table class="noborder centpercent">'; +print '<tr class="liste_titre">'; +print_liste_field_titre("OpenedProjectsByThirdparties", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder); +print_liste_field_titre("NbOfProjects", $_SERVER["PHP_SELF"], "nb", "", "", '', $sortfield, $sortorder, 'right '); +print "</tr>\n"; + $sql = "SELECT COUNT(p.rowid) as nb, SUM(p.opp_amount)"; -$sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; -$sql .= ", s.code_client, s.code_compta, s.client"; -$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; -$sql .= ", s.logo, s.email, s.entity"; -$sql .= ", s.canvas, s.status"; +$sql .= ", s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.canvas, s.status"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql .= " WHERE p.entity IN (".getEntity('project').")"; $sql .= " AND p.fk_statut = 1"; if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; -$sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur, s.logo, s.email, s.entity, s.canvas, s.status"; +$sql .= " GROUP BY s.rowid, s.nom, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.canvas, s.status"; $sql .= $db->order($sortfield, $sortorder); //$sql .= $db->plimit($max + 1, 0); @@ -332,18 +306,6 @@ $num = $db->num_rows($resql); $i = 0; $othernb = 0; - - if ($num) { - print '<br>'; - - // Open project per thirdparty - print '<div class="div-table-responsive-no-min">'; - print '<table class="noborder centpercent">'; - print '<tr class="liste_titre">'; - print_liste_field_titre("OpenedProjectsByThirdparties", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder); - print_liste_field_titre("NbOfProjects", $_SERVER["PHP_SELF"], "nb", "", "", '', $sortfield, $sortorder, 'right '); - print "</tr>\n"; - } while ($i < $num) { @@ -357,25 +319,17 @@ print '<tr class="oddeven">'; print '<td class="nowraponall tdoverflowmax100">'; - if ($obj->socid > 0) + if ($obj->socid) { $companystatic->id = $obj->socid; $companystatic->name = $obj->name; - $companystatic->name_alias = $obj->name_alias; - $companystatic->code_client = $obj->code_client; - $companystatic->code_compta = $obj->code_compta; - $companystatic->client = $obj->client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; - $companystatic->fournisseur = $obj->fournisseur; - $companystatic->logo = $obj->logo; $companystatic->email = $obj->email; - $companystatic->entity = $obj->entity; - $companystatic->canvas = $obj->canvas; $companystatic->status = $obj->status; print $companystatic->getNomUrl(1); - } else { + } + else + { print $langs->trans("OthersNotLinkedToThirdParty"); } print '</td>'; @@ -390,7 +344,7 @@ if ($othernb) { print '<tr class="oddeven">'; print '<td class="nowrap">'; - print '<span class="opacitymedium">...</span>'; + print '...'; print '</td>'; print '<td class="nowrap right">'; print $othernb; @@ -398,24 +352,23 @@ print "</tr>\n"; } - if ($num) { - print "</table>"; - print '</div>'; - } - $db->free($resql); -} else { +} +else +{ dol_print_error($db); } +print "</table>"; +print '</div>'; if (empty($conf->global->PROJECT_HIDE_PROJECT_LIST_ON_PROJECT_AREA)) { - // This list can be very long, so we allow to hide it to prefer to use the list page. - // Add constant PROJECT_HIDE_PROJECT_LIST_ON_PROJECT_AREA to hide this list - - print '<br>'; - - print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 1, $listofoppstatus, array()); + // This list can be very long, so we allow to hide it to prefer to use the list page. + // Add constant PROJECT_HIDE_PROJECT_LIST_ON_PROJECT_AREA to hide this list + + print '<br>'; + + print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 1, $listofoppstatus, array()); } print '</div></div></div>'; --- /tmp/dsg/dolibarr/htdocs/projet/github_info.php +++ /tmp/dsg/dolibarr/htdocs/projet/client_info.php @@ -37,8 +37,8 @@ $action = GETPOST('action', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", "aZ09comma"); -$sortorder = GETPOST("sortorder", 'aZ09comma'); +$sortfield = GETPOST("sortfield", "alpha"); +$sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; @@ -52,7 +52,9 @@ { $actioncode = GETPOST('actioncode', 'array', 3); if (!count($actioncode)) $actioncode = '0'; -} else { +} +else +{ $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -61,7 +63,7 @@ $id = GETPOST("id", 'int'); $socid = 0; //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -$result = restrictedArea($user, 'projet', $id, 'projet&project'); +$result = restrictedArea($user, 'projet', $id, ''); if (!$user->rights->projet->lire) accessforbidden(); @@ -93,10 +95,10 @@ if ($id > 0 || !empty($ref)) { - $object->fetch($id, $ref); - $object->fetch_thirdparty(); + $object->fetch($id, $ref); + $object->fetch_thirdparty(); if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); - $object->info($object->id); + $object->info($object->id); } $title = $langs->trans("Project").' - '.$object->ref.' '.$object->name; @@ -106,7 +108,7 @@ $head = project_prepare_head($object); -print dol_get_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); +dol_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); // Project card @@ -119,15 +121,15 @@ // Thirdparty if ($object->thirdparty->id > 0) { - $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { - $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -142,7 +144,7 @@ print '<div class="clearboth"></div>'; -print dol_get_fiche_end(); +dol_fiche_end(); // Actions buttons @@ -151,7 +153,7 @@ $permok = $user->rights->agenda->myactions->create; if ($permok) { - $out .= '&projectid='.$object->id; + $out .= '&projectid='.$object->id; } @@ -159,8 +161,8 @@ $morehtmlcenter = ''; if (!empty($conf->agenda->enabled)) { - $addActionBtnRight = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create); - $morehtmlcenter .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&socid='.$object->socid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight); + $addActionBtnRight = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create); + $morehtmlcenter .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight); } //print '</div>'; @@ -170,15 +172,15 @@ print '<br>'; $param = '&id='.$object->id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; - print_barre_liste($langs->trans("ActionsOnProject"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); + print_barre_liste($langs->trans("ActionsOnProject"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); - // List of all actions - $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); } // End of page --- /tmp/dsg/dolibarr/htdocs/projet/github_list.php +++ /tmp/dsg/dolibarr/htdocs/projet/client_list.php @@ -7,7 +7,6 @@ * Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop> * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2019 Juanjo Menent <jmenent@2byte.es> - * Copyright (C) 2020 Tobias Sean <tobias.sekan@startmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,16 +34,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -if (!empty($conf->categorie->enabled)) -{ - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php'; - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -} - // Load translation files required by the page $langs->loadLangs(array('projects', 'companies', 'commercial')); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); @@ -67,10 +60,11 @@ $diroutputmassaction = $conf->projet->dir_output.'/temp/massgeneration/'.$user->id; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", "aZ09comma"); -$sortorder = GETPOST("sortorder", 'aZ09comma'); +$sortfield = GETPOST("sortfield", "alpha"); +$sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters +$page = is_numeric($page) ? $page : 0; +$page = $page == -1 ? 0 : $page; if (!$sortfield) $sortfield = "p.ref"; if (!$sortorder) $sortorder = "ASC"; $offset = $limit * $page; @@ -78,6 +72,7 @@ $pagenext = $page + 1; $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); +$search_categ = GETPOST("search_categ", 'alpha'); $search_ref = GETPOST("search_ref", 'alpha'); $search_label = GETPOST("search_label", 'alpha'); $search_societe = GETPOST("search_societe", 'alpha'); @@ -106,11 +101,6 @@ if ($search_status == '') $search_status = -1; // -1 or 1 -if (!empty($conf->categorie->enabled)) -{ - $search_category_array = GETPOST("search_category_".Categorie::TYPE_PROJECT."_list", "array"); -} - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Project($db); $hookmanager->initHooks(array('projectlist')); @@ -122,46 +112,43 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" -$fieldstosearchall = array(); -foreach ($object->fields as $key => $val) { - if (empty($val['searchall'])) { - continue; +$fieldstosearchall = array( + 'p.ref'=>"Ref", + 'p.title'=>"Label", + 's.nom'=>"ThirdPartyName", + "p.note_public"=>"NotePublic" +); +if (empty($user->socid)) $fieldstosearchall["p.note_private"] = "NotePrivate"; + +$arrayfields = array( + 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'p.title'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'enabled'=>(empty($conf->societe->enabled) ? 0 : 1)), + 'commercial'=>array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0), + 'p.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), + 'p.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101), + 'p.public'=>array('label'=>$langs->trans("Visibility"), 'checked'=>1, 'position'=>102), + 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>103), + 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>104), + 'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>105), + 'opp_weighted_amount'=>array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>106), + 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), + 'p.usage_opportunity'=>array('label'=>$langs->trans("UsageOpportunity"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>115), + 'p.usage_task'=>array('label'=>$langs->trans("UsageTasks"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_HIDE_TASKS ? 0 : 1), 'position'=>116), + 'p.usage_bill_time'=>array('label'=>$langs->trans("UsageBillTimeShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_HIDE_TASKS ? 0 : 1), 'position'=>117), + 'p.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500), + 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), +); +// Extra fields +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } - - // Don't allow search in private notes for external users when doing "search in all" - if (!empty($user->socid) && $key == "note_private") { - continue; - } - - $fieldstosearchall['p.'.$key] = $val['label']; -} - -// Add name object fields to "search in all" -$fieldstosearchall['s.nom'] = "ThirdPartyName"; - -// Definition of array of fields for columns -$arrayfields = array(); -foreach ($object->fields as $key => $val) { - // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) { - $visible = dol_eval($val['visible'], 1); - $arrayfields['p.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)), - 'position'=>$val['position'], - 'help'=>$val['help'] - ); - } -} -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - -// Add none object fields to fields for list -$arrayfields['s.nom'] = array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>21, 'enabled'=>(empty($conf->societe->enabled) ? 0 : 1)); -$arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23); -$arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'position'=> 116, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106); - +} $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -187,6 +174,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { $search_all = ''; + $search_categ = ''; $search_ref = ""; $search_label = ""; $search_societe = ""; @@ -209,7 +197,6 @@ $search_usage_bill_time = ''; $toselect = ''; $search_array_options = array(); - $search_category_array = array(); } @@ -221,47 +208,51 @@ $uploaddir = $conf->projet->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - // Close records - if (!$error && $massaction == 'close' && $user->rights->projet->creer) - { - $db->begin(); - - $objecttmp = new $objectclass($db); - $nbok = 0; - foreach ($toselect as $toselectid) - { - $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { - $userWrite = $object->restrictedProjectArea($user, 'write'); - if ($userWrite > 0 && $objecttmp->statut == 1) { - $result = $objecttmp->setClose($user); - if ($result <= 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } else $nbok++; - } elseif ($userWrite <= 0) { - setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings'); - } else { - setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings'); - } - } else { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } - } - - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - } - } + // Close records + if (!$error && $massaction == 'close' && $user->rights->projet->creer) + { + $db->begin(); + + $objecttmp = new $objectclass($db); + $nbok = 0; + foreach ($toselect as $toselectid) + { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) + { + $userWrite = $object->restrictedProjectArea($user, 'write'); + if ($userWrite > 0 && $objecttmp->statut == 1) { + $result = $objecttmp->setClose($user); + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; + } elseif ($userWrite <= 0) { + setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings'); + } else { + setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings'); + } + } + else + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (!$error) + { + if ($nbok > 1) setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); + $db->commit(); + } + else + { + $db->rollback(); + } + } } @@ -274,18 +265,17 @@ $formother = new FormOther($db); $formproject = new FormProjets($db); -$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; $title = $langs->trans("Projects"); -// Get list of project id allowed to user (in a string list separated by comma) +// Get list of project id allowed to user (in a string list separated by coma) $projectsListId = ''; if (!$user->rights->projet->all->lire) $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid); // Get id of types of contacts for projects (This list never contains a lot of elements) $listofprojectcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; -$sql .= " WHERE ctc.element = '".$db->escape($object->element)."'"; +$sql .= " WHERE ctc.element = '".$object->element."'"; $sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) @@ -294,7 +284,8 @@ { $listofprojectcontacttype[$obj->rowid] = $obj->code; } -} else dol_print_error($db); +} +else dol_print_error($db); if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found $distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. @@ -302,23 +293,22 @@ $sql .= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_update, p.budget_amount, p.usage_opportunity, p.usage_task, p.usage_bill_time"; $sql .= ", s.rowid as socid, s.nom as name, s.email"; $sql .= ", cls.code as opp_status_code"; +// We'll need these fields in order to filter by categ +if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); -$sql = preg_replace('/,\s*$/', '', $sql); -$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as p"; -if (!empty($conf->categorie->enabled)) -{ - $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_PROJECT, "p.rowid"); -} +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; +// We'll need this table joined to the select in order to filter by categ +if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ // We'll need this table joined to the select in order to filter by sale // No check is done on company permission because readability is managed by public status of project and assignement. //if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; @@ -328,13 +318,11 @@ $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp"; } $sql .= " WHERE p.entity IN (".getEntity('project').')'; -if (!empty($conf->categorie->enabled)) -{ - $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_PROJECT, "p.rowid", $search_category_array); -} if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users // No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser if ($socid > 0) $sql .= " AND (p.fk_soc = ".$socid.")"; // This filter if when we use a hard coded filter on company on url (not related to filter for external users) +if ($search_categ > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ); +if ($search_categ == -2) $sql .= " AND cs.fk_categorie IS NULL"; if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_label) $sql .= natural_search('p.title', $search_label); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); @@ -372,36 +360,37 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); -// Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { $page = 0; $offset = 0; } } -// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { - $num = $nbtotalofrecords; -} else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } - - $num = $db->num_rows($resql); -} - -// Direct jump if only one record found + +$sql .= $db->plimit($limit + 1, $offset); + +dol_syslog("list allowed project", LOG_DEBUG); + +$resql = $db->query($sql); +if (!$resql) +{ + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + +$arrayofselected = is_array($toselect) ? $toselect : array(); + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); @@ -409,59 +398,53 @@ exit; } - -// Output page -// -------------------------------------------------------------------- - -dol_syslog("list allowed project", LOG_DEBUG); - -llxHeader('', $title, $help_url); - -$arrayofselected = is_array($toselect) ? $toselect : array(); +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +llxHeader("", $title, $help_url); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if ($search_all != '') $param .= '&search_all='.urlencode($search_all); -if ($search_sday) $param .= '&search_sday='.urlencode($search_sday); -if ($search_smonth) $param .= '&search_smonth='.urlencode($search_smonth); -if ($search_syear) $param .= '&search_syear='.urlencode($search_syear); -if ($search_eday) $param .= '&search_eday='.urlencode($search_eday); -if ($search_emonth) $param .= '&search_emonth='.urlencode($search_emonth); -if ($search_eyear) $param .= '&search_eyear='.urlencode($search_eyear); -if ($socid) $param .= '&socid='.urlencode($socid); -if ($search_categ) $param .= '&search_categ='.urlencode($search_categ); -if ($search_ref != '') $param .= '&search_ref='.urlencode($search_ref); -if ($search_label != '') $param .= '&search_label='.urlencode($search_label); -if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe); -if ($search_status >= 0) $param .= '&search_status='.urlencode($search_status); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($search_all != '') $param .= '&search_all='.$search_all; +if ($search_sday) $param .= '&search_sday='.$search_sday; +if ($search_smonth) $param .= '&search_smonth='.$search_smonth; +if ($search_syear) $param .= '&search_syear='.$search_syear; +if ($search_eday) $param .= '&search_eday='.$search_eday; +if ($search_emonth) $param .= '&search_emonth='.$search_emonth; +if ($search_eyear) $param .= '&search_eyear='.$search_eyear; +if ($socid) $param .= '&socid='.$socid; +if ($search_ref != '') $param .= '&search_ref='.$search_ref; +if ($search_label != '') $param .= '&search_label='.$search_label; +if ($search_societe != '') $param .= '&search_societe='.$search_societe; +if ($search_status >= 0) $param .= '&search_status='.$search_status; if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) $param .= '&search_opp_status='.urlencode($search_opp_status); if ($search_opp_percent != '') $param .= '&search_opp_percent='.urlencode($search_opp_percent); -if ($search_public != '') $param .= '&search_public='.urlencode($search_public); -if ($search_project_user != '') $param .= '&search_project_user='.urlencode($search_project_user); -if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); -if ($search_opp_amount != '') $param .= '&search_opp_amount='.urlencode($search_opp_amount); -if ($search_budget_amount != '') $param .= '&search_budget_amount='.urlencode($search_budget_amount); -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); +if ($search_public != '') $param .= '&search_public='.$search_public; +if ($search_project_user != '') $param .= '&search_project_user='.$search_project_user; +if ($search_sale > 0) $param .= '&search_sale='.$search_sale; +if ($search_opp_amount != '') $param .= '&search_opp_amount='.$search_opp_amount; +if ($search_budget_amount != '') $param .= '&search_budget_amount='.$search_budget_amount; +if ($optioncss != '') $param .= '&optioncss='.$optioncss; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), - //'builddoc'=>$langs->trans("PDFMerge"), - //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->projet->creer) $arrayofmassactions['close'] = $langs->trans("Close"); -if ($user->rights->projet->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$url = DOL_URL_ROOT.'/projet/card.php?action=create'; -if (!empty($socid)) $url .= '&socid='.$socid; -$newcardbutton = dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer); +$newcardbutton = ''; +if ($user->rights->projet->creer) +{ + $newcardbutton .= dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create'); +} print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -470,14 +453,16 @@ print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; +print '<input type="hidden" name="type" value="'.$type.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; // Show description of content $texthelp = ''; if ($search_project_user == $user->id) $texthelp .= $langs->trans("MyProjectsDesc"); -else { - if ($user->rights->projet->all->lire && !$socid) $texthelp .= $langs->trans("ProjectsDesc"); - else $texthelp .= $langs->trans("ProjectsPublicDesc"); +else +{ + if ($user->rights->projet->all->lire && !$socid) $texthelp .= $langs->trans("ProjectsDesc"); + else $texthelp .= $langs->trans("ProjectsPublicDesc"); } print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -486,7 +471,7 @@ $topicmail = "Information"; $modelmail = "project"; $objecttmp = new Project($db); -$trackid = 'proj'.$object->id; +$trackid = 'prj'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) @@ -498,17 +483,19 @@ $moreforfilter = ''; // Filter on categories -if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) -{ - $formcategory = new FormCategory($db); - $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array); +if (!empty($conf->categorie->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('ProjectCategories').': '; + $moreforfilter .= $formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300'); + $moreforfilter .= '</div>'; } // If the user can view user other than himself $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').': '; -//$includeonly = 'hierarchyme'; -$includeonly = ''; +$includeonly = 'hierarchyme'; if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); $moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '</div>'; @@ -535,13 +522,11 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '<div class="div-table-responsive">'; print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; -// Fields title search -// -------------------------------------------------------------------- print '<tr class="liste_titre_filter">'; // Project ref if (!empty($arrayfields['p.ref']['checked'])) @@ -621,8 +606,8 @@ } if (!empty($arrayfields['opp_weighted_amount']['checked'])) { - print '<td class="liste_titre nowrap right">'; - print '</td>'; + print '<td class="liste_titre nowrap right">'; + print '</td>'; } if (!empty($arrayfields['p.budget_amount']['checked'])) { @@ -674,7 +659,7 @@ $arrayofstatus = array(); foreach ($object->statuts_short as $key => $val) $arrayofstatus[$key] = $langs->trans($val); $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')'; - print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'minwidth75imp maxwidth150 selectarrowonleft'); + print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 selectarrowonleft'); print ajax_combobox('search_status'); print '</td>'; } @@ -690,7 +675,7 @@ if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['commercial']['checked'])) print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, 'tdoverflowmax100imp '); +if (!empty($arrayfields['commercial']['checked'])) print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder); @@ -716,8 +701,8 @@ $i = 0; $totalarray = array( - 'nbfield' => 0, - 'val' => array(), + 'nbfield' => 0, + 'val' => array(), ); while ($i < min($num, $limit)) { @@ -737,16 +722,16 @@ $userAccess = $object->restrictedProjectArea($user); // why this ? if ($userAccess >= 0) { - $socstatic->id = $obj->socid; - $socstatic->name = $obj->name; - $socstatic->email = $obj->email; + $socstatic->id = $obj->socid; + $socstatic->name = $obj->name; + $socstatic->email = $obj->email; print '<tr class="oddeven">'; // Project url if (!empty($arrayfields['p.ref']['checked'])) { - print '<td class="nowraponall">'; + print '<td class="nowrap">'; print $object->getNomUrl(1); if ($object->hasDelay()) print img_warning($langs->trans('Late')); print '</td>'; @@ -767,7 +752,9 @@ if ($obj->socid) { print $socstatic->getNomUrl(1); - } else { + } + else + { print ' '; } print '</td>'; @@ -786,7 +773,8 @@ if ($nbofsalesrepresentative > 3) // We print only number { print $nbofsalesrepresentative; - } elseif ($nbofsalesrepresentative > 0) + } + elseif ($nbofsalesrepresentative > 0) { $userstatic = new User($db); $j = 0; @@ -799,14 +787,16 @@ $userstatic->statut = $val['statut']; $userstatic->entity = $val['entity']; $userstatic->photo = $val['photo']; - print $userstatic->getNomUrl(1, '', 0, 0, 12); - //print $userstatic->getNomUrl(-2); + //print $userstatic->getNomUrl(1, '', 0, 0, 12); + print $userstatic->getNomUrl(-2); $j++; if ($j < $nbofsalesrepresentative) print ' '; } } //else print $langs->trans("NoSalesRepresentativeAffected"); - } else { + } + else + { print ' '; } print '</td>'; @@ -867,19 +857,19 @@ print '</td>'; if (!$i) $totalarray['nbfield']++; } - // Opp weighted amount - if (!empty($arrayfields['opp_weighted_amount']['checked'])) - { - if (!isset($totalarray['val']['opp_weighted_amount'])) $totalarray['val']['opp_weighted_amount'] = 0; - print '<td align="right">'; - if ($obj->opp_weighted_amount) { - print price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, ''); - $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount; - } - print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount'; - } + // Opp weighted amount + if (!empty($arrayfields['opp_weighted_amount']['checked'])) + { + if (!isset($totalarray['val']['opp_weighted_amount'])) $totalarray['val']['opp_weighted_amount'] = 0; + print '<td align="right">'; + if ($obj->opp_weighted_amount) { + print price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, ''); + $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount; + } + print '</td>'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount'; + } // Budget if (!empty($arrayfields['p.budget_amount']['checked'])) { --- /tmp/dsg/dolibarr/htdocs/projet/github_note.php +++ /tmp/dsg/dolibarr/htdocs/projet/client_note.php @@ -79,7 +79,7 @@ //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; $head = project_prepare_head($object); - print dol_get_fiche_head($head, 'notes', $langs->trans('Project'), -1, ($object->public ? 'projectpub' : 'project')); + dol_fiche_head($head, 'notes', $langs->trans('Project'), -1, ($object->public ? 'projectpub' : 'project')); // Project card @@ -92,15 +92,15 @@ // Thirdparty if ($object->thirdparty->id > 0) { - $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { - $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -116,7 +116,7 @@ print '<div class="clearboth"></div>'; - print dol_get_fiche_end(); + dol_fiche_end(); } // End of page --- /tmp/dsg/dolibarr/htdocs/projet/github_tasks.php +++ /tmp/dsg/dolibarr/htdocs/projet/client_tasks.php @@ -36,7 +36,7 @@ // Load translation files required by the page $langs->loadLangs(array('projects', 'users', 'companies')); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); @@ -45,16 +45,6 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $taskref = GETPOST('taskref', 'alpha'); - -// Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; $backtopage = GETPOST('backtopage', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); @@ -93,12 +83,6 @@ $extrafields->fetch_name_optionals_label($taskstatic->table_element); $search_array_options = $extrafields->getOptionalsFromPost($taskstatic->table_element, '', 'search_'); - -// Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) { reset($object->fields); $sortfield="t.".key($object->fields); } // Set here default search field. By default 1st field in definition. Reset is required to avoid key() to return null. -if (!$sortorder) $sortorder = "ASC"; - - // Security check $socid = 0; //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. @@ -111,7 +95,7 @@ $progress = GETPOST('progress', 'int'); $label = GETPOST('label', 'alpha'); -$description = GETPOST('description', 'restricthtml'); +$description = GETPOST('description', 'none'); $planned_workloadhour = (GETPOST('planned_workloadhour', 'int') ?GETPOST('planned_workloadhour', 'int') : 0); $planned_workloadmin = (GETPOST('planned_workloadmin', 'int') ?GETPOST('planned_workloadmin', 'int') : 0); $planned_workload = $planned_workloadhour * 3600 + $planned_workloadmin * 60; @@ -122,7 +106,7 @@ 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>2), 't.description'=>array('label'=>$langs->trans("Description"), 'checked'=>0, 'position'=>3), 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>4), - 't.datee'=>array('label'=>$langs->trans("Deadline"), 'checked'=>1, 'position'=>5), + 't.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>5), 't.planned_workload'=>array('label'=>$langs->trans("PlannedWorkload"), 'checked'=>1, 'position'=>6), 't.duration_effective'=>array('label'=>$langs->trans("TimeSpent"), 'checked'=>1, 'position'=>7), 't.progress_calculated'=>array('label'=>$langs->trans("ProgressCalculated"), 'checked'=>1, 'position'=>8), @@ -135,8 +119,14 @@ } // Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - +if (is_array($extrafields->attributes[$taskstatic->table_element]['label']) && count($extrafields->attributes[$taskstatic->table_element]['label']) > 0) +{ + foreach ($extrafields->attributes[$taskstatic->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$taskstatic->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$taskstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$taskstatic->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$taskstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$taskstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$taskstatic->table_element]['perms'][$key])); + } +} $arrayfields = dol_sort_array($arrayfields, 'position'); $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; @@ -230,8 +220,8 @@ // If we use user timezone, we must change also view/list to use user timezone everywhere //$date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear'],'user'); //$date_end = dol_mktime($_POST['dateehour'],$_POST['dateemin'],0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear'],'user'); - $date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int')); - $date_end = dol_mktime(GETPOST('dateehour', 'int'), GETPOST('dateemin', 'int'), 0, GETPOST('dateemonth', 'int'), GETPOST('dateeday', 'int'), GETPOST('dateeyear', 'int')); + $date_start = dol_mktime($_POST['dateohour'], $_POST['dateomin'], 0, $_POST['dateomonth'], $_POST['dateoday'], $_POST['dateoyear']); + $date_end = dol_mktime($_POST['dateehour'], $_POST['dateemin'], 0, $_POST['dateemonth'], $_POST['dateeday'], $_POST['dateeyear']); if (!$cancel) { @@ -246,7 +236,8 @@ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); $action = 'create'; $error++; - } elseif (empty($_POST['task_parent'])) + } + elseif (empty($_POST['task_parent'])) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ChildOfProjectTask")), null, 'errors'); $action = 'create'; @@ -255,7 +246,7 @@ if (!$error) { - $tmparray = explode('_', GETPOST('task_parent')); + $tmparray = explode('_', $_POST['task_parent']); $projectid = $tmparray[0]; if (empty($projectid)) $projectid = $id; // If projectid is '' $task_parent = $tmparray[1]; @@ -282,13 +273,17 @@ if ($taskid > 0) { $result = $task->add_contact($_POST["userid"], 'TASKEXECUTIVE', 'internal'); - } else { + } + else + { if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("projects"); setEventMessages($langs->trans('NewTaskRefSuggested'), '', 'warnings'); $duplicate_code_error = true; - } else { + } + else + { setEventMessages($task->error, $task->errors, 'errors'); } $action = 'create'; @@ -302,19 +297,23 @@ { header("Location: ".$backtopage); exit; - } elseif (empty($projectid)) + } + elseif (empty($projectid)) { header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode)); exit; } $id = $projectid; } - } else { + } + else + { if (!empty($backtopage)) { header("Location: ".$backtopage); exit; - } elseif (empty($id)) + } + elseif (empty($id)) { // We go back on task list header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode)); @@ -339,7 +338,6 @@ $title = $langs->trans("Project").' - '.$langs->trans("Tasks").' - '.$object->ref.' '.$object->name; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Tasks"); $help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; - llxHeader("", $title, $help_url); @@ -356,10 +354,10 @@ //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; - $tab = (GETPOSTISSET('tab') ? GETPOST('tab') : 'tasks'); + $tab = GETPOST('tab') ?GETPOST('tab') : 'tasks'; $head = project_prepare_head($object); - print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); $param = '&id='.$object->id; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); @@ -493,7 +491,7 @@ print '<div class="clearboth"></div>'; - print dol_get_fiche_end(); + dol_fiche_end(); } @@ -503,120 +501,121 @@ print load_fiche_titre($langs->trans("NewTask"), '', 'projecttask'); - if ($object->id > 0 && $object->statut == Project::STATUS_CLOSED) { + if ($object->statut == Project::STATUS_CLOSED) + { print '<div class="warning">'; $langs->load("errors"); print $langs->trans("WarningProjectClosed"); print '</div>'; } - - if ($object->id > 0 && $object->statut == Project::STATUS_DRAFT) { - print '<div class="warning">'; - $langs->load("errors"); - print $langs->trans("WarningProjectDraft"); + else + { + print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'; + print '<input type="hidden" name="token" value="'.newToken().'">'; + print '<input type="hidden" name="action" value="createtask">'; + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; + if (!empty($object->id)) print '<input type="hidden" name="id" value="'.$object->id.'">'; + + dol_fiche_head(''); + + print '<table class="border centpercent">'; + + $defaultref = ''; + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) + { + require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; + $modTask = new $obj; + $defaultref = $modTask->getNextValue($object->thirdparty, null); + } + + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; + + // Ref + print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td>'; + if (empty($duplicate_code_error)) + { + print (GETPOSTISSET("ref") ?GETPOST("ref", 'alpha') : $defaultref); + } + else + { + print $defaultref; + } + print '<input type="hidden" name="taskref" value="'.($_POST["ref"] ? $_POST["ref"] : $defaultref).'">'; + print '</td></tr>'; + + print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>'; + print '<input type="text" name="label" autofocus class="minwidth500" value="'.$label.'">'; + print '</td></tr>'; + + // List of projects + print '<tr><td class="fieldrequired">'.$langs->trans("ChildOfProjectTask").'</td><td>'; + print $formother->selectProjectTasks(GETPOST('task_parent'), $projectid ? $projectid : $object->id, 'task_parent', 0, 0, 1, 1, 0, '0,1', 'maxwidth500'); + print '</td></tr>'; + + print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>'; + $contactsofproject = (!empty($object->id) ? $object->getListContactId('internal') : ''); + if (is_array($contactsofproject) && count($contactsofproject)) + { + print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300'); + } + else + { + print $langs->trans("NoUserAssignedToTheProject"); + } + print '</td></tr>'; + + // Date start + print '<tr><td>'.$langs->trans("DateStart").'</td><td>'; + print $form->selectDate(($date_start ? $date_start : ''), 'dateo', 1, 1, 0, '', 1, 1); + print '</td></tr>'; + + // Date end + print '<tr><td>'.$langs->trans("DateEnd").'</td><td>'; + print $form->selectDate(($date_end ? $date_end : -1), 'datee', -1, 1, 0, '', 1, 1); + print '</td></tr>'; + + // Planned workload + print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>'; + print $form->select_duration('planned_workload', $planned_workload ? $planned_workload : 0, 0, 'text'); + print '</td></tr>'; + + // Progress + print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">'; + print $formother->select_percent($progress, 'progress', 0, 5, 0, 100, 1); + print '</td></tr>'; + + // Description + print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>'; + print '<td>'; + print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_4.'">'.$description.'</textarea>'; + print '</td></tr>'; + + // Other options + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + if (empty($reshook) && !empty($extrafields->attributes[$taskstatic->table_element]['label'])) + { + print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic + } + + print '</table>'; + + dol_fiche_end(); + + print '<div class="center">'; + print '<input type="submit" class="button" name="add" value="'.$langs->trans("Add").'">'; + print ' '; + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '</div>'; - } - - print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'; - print '<input type="hidden" name="token" value="'.newToken().'">'; - print '<input type="hidden" name="action" value="createtask">'; - print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; - if (!empty($object->id)) print '<input type="hidden" name="id" value="'.$object->id.'">'; - - print dol_get_fiche_head(''); - - print '<table class="border centpercent">'; - - $defaultref = ''; - $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; - if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) - { - require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; - $modTask = new $obj; - $defaultref = $modTask->getNextValue($object->thirdparty, null); - } - - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; - - // Ref - print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td>'; - if (empty($duplicate_code_error)) - { - print (GETPOSTISSET("ref") ? GETPOST("ref", 'alpha') : $defaultref); - } else { - print $defaultref; - } - print '<input type="hidden" name="taskref" value="'.(GETPOSTISSET("ref") ? GETPOST("ref", 'alpha') : $defaultref).'">'; - print '</td></tr>'; - - print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>'; - print '<input type="text" name="label" autofocus class="minwidth500 maxwidthonsmartphone" value="'.$label.'">'; - print '</td></tr>'; - - // List of projects - print '<tr><td class="fieldrequired">'.$langs->trans("ChildOfProjectTask").'</td><td>'; - print img_picto('', 'project'); - $formother->selectProjectTasks(GETPOST('task_parent'), $projectid ? $projectid : $object->id, 'task_parent', 0, 0, 1, 1, 0, '0,1', 'maxwidth500'); - print '</td></tr>'; - - print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>'; - $contactsofproject = (!empty($object->id) ? $object->getListContactId('internal') : ''); - if (is_array($contactsofproject) && count($contactsofproject)) - { - print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300'); - } else { - print $langs->trans("NoUserAssignedToTheProject"); - } - print '</td></tr>'; - - // Date start - print '<tr><td>'.$langs->trans("DateStart").'</td><td>'; - print $form->selectDate(($date_start ? $date_start : ''), 'dateo', 1, 1, 0, '', 1, 1); - print '</td></tr>'; - - // Date end - print '<tr><td>'.$langs->trans("DateEnd").'</td><td>'; - print $form->selectDate(($date_end ? $date_end : -1), 'datee', -1, 1, 0, '', 1, 1); - print '</td></tr>'; - - // Planned workload - print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>'; - print $form->select_duration('planned_workload', $planned_workload ? $planned_workload : 0, 0, 'text'); - print '</td></tr>'; - - // Progress - print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">'; - print $formother->select_percent($progress, 'progress', 0, 5, 0, 100, 1); - print '</td></tr>'; - - // Description - print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>'; - print '<td>'; - print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_4.'">'.$description.'</textarea>'; - print '</td></tr>'; - - // Other options - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - if (empty($reshook) && !empty($extrafields->attributes[$taskstatic->table_element]['label'])) - { - print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic - } - - print '</table>'; - - print dol_get_fiche_end(); - - print '<div class="center">'; - print '<input type="submit" class="button" name="add" value="'.$langs->trans("Add").'">'; - print ' '; - print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; - print '</div>'; - - print '</form>'; -} elseif ($id > 0 || !empty($ref)) { + + print '</form>'; + } +} +elseif ($id > 0 || !empty($ref)) +{ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields /* @@ -649,17 +648,15 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; $title = $langs->trans("ListOfTasks"); - $linktotasks = dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id, '', 1, array('morecss'=>'reposition btnTitleSelected')); - $linktotasks .= dolGetButtonTitle($langs->trans('ViewGantt'), '', 'fa fa-stream imgforviewmode', DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1', '', 1, array('morecss'=>'reposition marginleftonly')); + $linktotasks = dolGetButtonTitle($langs->trans('ViewGantt'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1', '', 1, array('morecss'=>'reposition')); //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'generic', 0, '', '', 0, 1); - print load_fiche_titre($title, $linktotasks.' '.$linktocreatetask, 'projecttask'); + print load_fiche_titre($title, $linktotasks.' '.$linktocreatetask, 'generic'); // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). $filteronthirdpartyid = $socid; $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, $extrafields, 1, $search_array_options); - // We load also tasks limited to a particular user $tmpuser = new User($db); if ($search_user_id > 0) $tmpuser->fetch($search_user_id); @@ -715,16 +712,16 @@ if (!empty($arrayfields['t.dateo']['checked'])) { print '<td class="liste_titre center">'; - print '<span class="nowraponall"><input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtstartday" value="'.$search_dtstartday.'">'; - print '<input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtstartmonth" value="'.$search_dtstartmonth.'"></span>'; + print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_dtstartday" value="'.$search_dtstartday.'">'; + print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_dtstartmonth" value="'.$search_dtstartmonth.'">'; $formother->select_year($search_dtstartyear ? $search_dtstartyear : -1, 'search_dtstartyear', 1, 20, 5); print '</td>'; } if (!empty($arrayfields['t.datee']['checked'])) { print '<td class="liste_titre center">'; - print '<span class="nowraponall"><input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtendday" value="'.$search_dtendday.'">'; - print '<input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtendmonth" value="'.$search_dtendmonth.'"></span>'; + print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_dtendday" value="'.$search_dtendday.'">'; + print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_dtendmonth" value="'.$search_dtendmonth.'">'; $formother->select_year($search_dtendyear ? $search_dtendyear : -1, 'search_dtendyear', 1, 20, 5); print '</td>'; } @@ -788,11 +785,11 @@ if (!empty($arrayfields['t.description']['checked'])) print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, ''); if (!empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1); - if (!empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1); - if (!empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1); - if (!empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1); - if (!empty($arrayfields['t.progress_summary']['checked'])) print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '', 1); + if (!empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['t.progress_summary']['checked'])) print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center '); if ($object->usage_bill_time) { if (!empty($arrayfields['t.tobill']['checked'])) print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); @@ -814,7 +811,9 @@ // Show all lines in taskarray (recursive function to go down on tree) $j = 0; $level = 0; $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields); - } else { + } + else + { $colspan = 10; if ($object->usage_bill_time) $colspan += 2; print '<tr class="oddeven nobottom"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoTasks").'</span></td></tr>'; @@ -837,7 +836,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; cleanCorruptedTree($db, 'projet_task', 'fk_task_parent'); } - } else { + } + else + { if ($nboftaskshown < count($tasksarray) && !GETPOST('search_user_id', 'int')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';