74 public function select_projects($socid = -1, $selected =
'', $htmlname =
'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey =
'', $nooutput = 0, $forceaddid = 0, $morecss =
'', $htmlid =
'')
77 global $langs, $conf, $form;
81 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT))
85 if ($selected && empty($selected_input_value))
87 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
89 $project->fetch($selected);
90 $selected_input_value = $project->ref;
92 $urloption =
'socid='.$socid.
'&htmlname='.$htmlname.
'&discardclosed='.$discard_closed;
93 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array(
99 $out .=
'<input type="text" class="minwidth200'.($morecss ?
' '.$morecss :
'').
'" name="search_'.$htmlname.
'" id="search_'.$htmlname.
'" value="'.$selected_input_value.
'"'.$placeholder.
' />';
101 $out .= $this->
select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, abs($discard_closed), $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid, $morecss);
103 if ($discard_closed > 0)
105 if (class_exists(
'Form'))
107 if (!is_object($form)) $form =
new Form($this->
db);
108 $out .= $form->textwithpicto(
'', $langs->trans(
"ClosedProjectsAreHidden"));
112 if (empty($nooutput))
140 public function select_projects_list($socid = -1, $selected =
'', $htmlname =
'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey =
'', $nooutput = 0, $forceaddid = 0, $htmlid =
'', $morecss =
'maxwidth500')
143 global $user, $conf, $langs;
145 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
147 if (empty($htmlid)) $htmlid = $htmlname;
152 $hideunselectables =
false;
153 if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables =
true;
155 $projectsListId =
false;
156 if (empty($user->rights->projet->all->lire))
159 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
163 $sql =
'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name, s.name_alias';
164 $sql .=
' FROM '.MAIN_DB_PREFIX.
'projet as p LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON s.rowid = p.fk_soc';
165 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
166 if ($projectsListId !==
false) $sql .=
" AND p.rowid IN (".$projectsListId.
")";
167 if ($socid == 0) $sql .=
" AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
170 if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql .=
" AND (p.fk_soc=".$socid.
" OR p.fk_soc IS NULL)";
171 elseif ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY !=
'all')
173 $sql .=
" AND (p.fk_soc IN (".$socid.
", ".((int) $conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY).
") OR p.fk_soc IS NULL)";
176 if (!empty($filterkey)) $sql .=
natural_search(array(
'p.title',
'p.ref'), $filterkey);
177 $sql .=
" ORDER BY p.ref ASC";
183 if (!empty($conf->use_javascript_ajax))
185 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
186 $comboenhancement =
ajax_combobox($htmlid, array(), 0, $forcefocus);
187 $out .= $comboenhancement;
188 $morecss .=
' minwidth100';
191 if (empty($option_only)) {
192 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'"'.($disabled ?
' disabled="disabled"' :
'').
' id="'.$htmlid.
'" name="'.$htmlname.
'">';
194 if (!empty($show_empty)) {
195 $out .=
'<option value="0"> </option>';
203 $obj = $this->
db->fetch_object(
$resql);
205 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->rights->societe->lire)
209 if ($discard_closed == 1 && $obj->fk_statut == 2 && $obj->rowid != $selected)
218 $labeltoshow .=
', '.dol_trunc($obj->title, $maxlength);
221 $labeltoshow .=
' - '.$obj->name;
222 if ($obj->name_alias) $labeltoshow .=
' ('.$obj->name_alias.
')';
226 if ($obj->fk_statut == 0)
229 $labeltoshow .=
' - '.$langs->trans(
"Draft");
230 } elseif ($obj->fk_statut == 2)
232 if ($discard_closed == 2) $disabled = 1;
233 $labeltoshow .=
' - '.$langs->trans(
"Closed");
234 } elseif (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid))
237 $labeltoshow .=
' - '.$langs->trans(
"LinkedToAnotherCompany");
240 if (!empty($selected) && $selected == $obj->rowid)
242 $out .=
'<option value="'.$obj->rowid.
'" selected';
244 $out .=
'>'.$labeltoshow.
'</option>';
246 if ($hideunselectables && $disabled && ($selected != $obj->rowid))
250 $resultat =
'<option value="'.$obj->rowid.
'"';
251 if ($disabled) $resultat .=
' disabled';
255 $resultat .= $labeltoshow;
256 $resultat .=
'</option>';
261 'key' => (
int) $obj->rowid,
262 'value' => $obj->ref,
264 'labelx' => $labeltoshow,
265 'label' => ((
bool) $disabled) ?
'<span class="opacitymedium">'.$labeltoshow.
'</span>' : $labeltoshow,
266 'disabled' => (
bool) $disabled
277 if (empty($option_only)) $out .=
'</select>';
278 if (empty($nooutput))
310 public function selectTasks($socid = -1, $selected =
'', $htmlname =
'taskid', $maxlength = 24, $option_only = 0, $show_empty =
'1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss =
'maxwidth500', $projectsListId =
'', $showproject =
'all', $usertofilter = null)
312 global $user, $conf, $langs;
314 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
316 if (is_null($usertofilter))
318 $usertofilter = $user;
323 $hideunselectables =
false;
324 if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables =
true;
326 if (empty($projectsListId))
328 if (empty($usertofilter->rights->projet->all->lire))
331 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
336 $sql =
'SELECT t.rowid, t.ref as tref, t.label as tlabel, p.rowid as pid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public,';
337 $sql .=
' s.nom as name';
338 $sql .=
' FROM '.MAIN_DB_PREFIX.
'projet as p';
339 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON s.rowid = p.fk_soc,';
340 $sql .=
' '.MAIN_DB_PREFIX.
'projet_task as t';
341 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
342 $sql .=
" AND t.fk_projet = p.rowid";
343 if ($projectsListId) $sql .=
" AND p.rowid IN (".$projectsListId.
")";
344 if ($socid == 0) $sql .=
" AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
345 if ($socid > 0) $sql .=
" AND (p.fk_soc=".$socid.
" OR p.fk_soc IS NULL)";
346 $sql .=
" ORDER BY p.ref, t.ref ASC";
352 if (empty($option_only) && !empty($conf->use_javascript_ajax))
354 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
355 $comboenhancement =
ajax_combobox($htmlname,
'', 0, $forcefocus);
356 $out .= $comboenhancement;
357 $morecss =
'minwidth200 maxwidth500';
360 if (empty($option_only)) {
361 $out .=
'<select class="valignmiddle flat'.($morecss ?
' '.$morecss :
'').
'"'.($disabled ?
' disabled="disabled"' :
'').
' id="'.$htmlname.
'" name="'.$htmlname.
'">';
363 if (!empty($show_empty)) {
364 $out .=
'<option value="0" class="optiongrey">';
365 if (!is_numeric($show_empty)) {
369 }
else $out .=
' ';
379 $obj = $this->
db->fetch_object(
$resql);
381 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($usertofilter->rights->societe->lire))
391 $labeltoshow =
''; $titletoshow =
'';
399 if ($discard_closed == 2) $disabled = 1;
400 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid))
405 if ($showproject ==
'all')
407 $labeltoshow .=
dol_trunc($obj->ref, 18);
410 $labeltoshow .=
' '.dol_trunc($obj->title, $maxlength);
411 $titletoshow = $labeltoshow;
414 $labeltoshow .=
' ('.$obj->name.
')';
415 $titletoshow .=
' <span class="opacitymedium">('.$obj->name.
')</span>';
421 $labeltoshow .=
' - '.$langs->trans(
"Draft");
422 $titletoshow .=
' - <span class="opacitymedium">'.$langs->trans(
"Draft").
'</span>';
424 if ($discard_closed == 2) $disabled = 1;
425 $labeltoshow .=
' - '.$langs->trans(
"Closed");
426 $titletoshow .=
' - <span class="opacitymedium">'.$langs->trans(
"Closed").
'</span>';
427 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
429 $labeltoshow .=
' - '.$langs->trans(
"LinkedToAnotherCompany");
430 $titletoshow .=
' - <span class="opacitymedium">'.$langs->trans(
"LinkedToAnotherCompany").
'</span>';
432 $labeltoshow .=
' - ';
433 $titletoshow .=
' - ';
437 $labeltoshow .= $obj->tref.
' '.
dol_trunc($obj->tlabel, $maxlength);
438 $titletoshow .= $obj->tref.
' '.
dol_trunc($obj->tlabel, $maxlength);
440 if (!empty($selected) && $selected == $obj->rowid)
442 $out .=
'<option value="'.$obj->rowid.
'" selected';
443 $out .=
' data-html="'.dol_escape_htmltag($titletoshow).
'"';
445 $out .=
'>'.$labeltoshow.
'</option>';
447 if ($hideunselectables && $disabled && ($selected != $obj->rowid))
451 $resultat =
'<option value="'.$obj->rowid.
'"';
452 if ($disabled) $resultat .=
' disabled';
455 $resultat .=
' data-html="'.dol_escape_htmltag($titletoshow).
'"';
457 $resultat .= $labeltoshow;
458 $resultat .=
'</option>';
466 if (empty($option_only)) {
492 public function select_element($table_element, $socid = 0, $morecss =
'', $limitonstatus = -2, $projectkey =
"fk_projet")
495 global $conf, $langs;
497 if ($table_element ==
'projet_task')
return '';
499 $linkedtothirdparty =
false;
500 if (!in_array($table_element, array(
'don',
'expensereport_det',
'expensereport',
'loan',
'stock_mouvement',
'payment_salary',
'payment_various',
'chargesociales'))) $linkedtothirdparty =
true;
505 switch ($table_element)
508 $sql =
"SELECT t.rowid, t.label as ref";
511 $sql =
"SELECT t.rowid, t.ref as ref";
513 case "facture_fourn":
514 $sql =
"SELECT t.rowid, t.ref, t.ref_supplier";
516 case "commande_fourn":
517 case "commande_fournisseur":
518 $sql =
"SELECT t.rowid, t.ref, t.ref_supplier";
521 $sql =
"SELECT t.rowid, t.titre as ref";
524 $sql =
"SELECT t.id as rowid, t.label as ref";
525 $projectkey =
"fk_project";
527 case "expensereport":
529 case "expensereport_det":
537 $sql =
"SELECT t.rowid, t.ref";
539 case 'stock_mouvement':
540 $sql =
'SELECT t.rowid, t.label as ref';
541 $projectkey =
'fk_origin';
543 case "payment_salary":
544 $sql =
"SELECT t.rowid, t.num_payment as ref";
546 case "payment_various":
547 $sql =
"SELECT t.rowid, t.num_payment as ref";
549 case "chargesociales":
551 $sql =
"SELECT t.rowid, t.ref";
554 if ($linkedtothirdparty) $sql .=
", s.nom as name";
555 $sql .=
" FROM ".MAIN_DB_PREFIX.$table_element.
" as t";
556 if ($linkedtothirdparty) $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
557 $sql .=
" WHERE ".$projectkey.
" is null";
558 if (!empty($socid) && $linkedtothirdparty)
560 if (is_numeric($socid)) $sql .=
" AND t.fk_soc=".$socid;
561 else $sql .=
" AND t.fk_soc IN (".$socid.
")";
563 if (!in_array($table_element, array(
'expensereport_det',
'stock_mouvement'))) $sql .=
' AND t.entity IN ('.getEntity(
'project').
')';
564 if ($linkedtothirdparty) $sql .=
" AND s.rowid = t.fk_soc";
565 if ($sqlfilter) $sql .=
" AND ".$sqlfilter;
566 $sql .=
" ORDER BY ref DESC";
568 dol_syslog(get_class($this).
'::select_element', LOG_DEBUG);
576 $sellist =
'<select class="flat elementselect css'.$table_element.($morecss ?
' '.$morecss :
'').
'" name="elementselect">';
577 $sellist .=
'<option value="-1"></option>';
580 $obj = $this->
db->fetch_object(
$resql);
581 $ref = $obj->ref ? $obj->ref : $obj->rowid;
582 if (!empty($obj->ref_supplier)) $ref .=
' ('.$obj->ref_supplier.
')';
583 if (!empty($obj->name)) $ref .=
' - '.$obj->name;
584 $sellist .=
'<option value="'.$obj->rowid.
'">'.$ref.
'</option>';
587 $sellist .=
'</select>';
600 $this->error = $this->
db->lasterror();
601 $this->errors[] = $this->
db->lasterror();
602 dol_syslog(get_class($this).
"::select_element ".$this->error, LOG_ERR);
622 public function selectOpportunityStatus($htmlname, $preselected =
'-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss =
'', $noadmininfo = 0, $addcombojs = 0)
624 global $conf, $langs, $user;
626 $sql =
"SELECT rowid, code, label, percent";
627 $sql .=
" FROM ".MAIN_DB_PREFIX.
'c_lead_status';
628 $sql .=
" WHERE active = 1";
629 $sql .=
" ORDER BY position";
638 $sellist =
'<select class="flat oppstatus'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.
'">';
641 $sellist .=
'<option value="-1"> </option>';
644 $sellist .=
'<option value="all"'.($preselected ==
'all' ?
' selected="selected"' :
'').
'>-- '.$langs->trans(
"OnlyOpportunitiesShort").
' --</option>';
645 $sellist .=
'<option value="openedopp"'.($preselected ==
'openedopp' ?
' selected="selected"' :
'').
'>-- '.$langs->trans(
"OpenedOpportunitiesShort").
' --</option>';
646 $sellist .=
'<option value="notopenedopp"'.($preselected ==
'notopenedopp' ?
' selected="selected"' :
'').
'>-- '.$langs->trans(
"NotOpenedOpportunitiesShort").
' --</option>';
647 $sellist .=
'<option value="none"'.($preselected ==
'none' ?
' selected="selected"' :
'').
'>-- '.$langs->trans(
"NotAnOpportunityShort").
' --</option>';
651 $obj = $this->
db->fetch_object(
$resql);
653 $sellist .=
'<option value="'.$obj->rowid.
'" defaultpercent="'.$obj->percent.
'" elemcode="'.$obj->code.
'"';
654 if ($obj->rowid == $preselected) $sellist .=
' selected="selected"';
658 $finallabel = ($langs->transnoentitiesnoconv(
"OppStatus".$obj->code) !=
"OppStatus".$obj->code ? $langs->transnoentitiesnoconv(
"OppStatus".$obj->code) : $obj->label);
660 $finallabel = ($langs->transnoentitiesnoconv(
"OppStatus".$obj->code) !=
"OppStatus".$obj->code ? $langs->transnoentitiesnoconv(
"OppStatus".$obj->code) : $obj->label);
661 if ($showpercent) $finallabel .=
' ('.$obj->percent.
'%)';
663 $sellist .= $finallabel;
664 $sellist .=
'</option>';
667 $sellist .=
'</select>';
669 if ($user->admin && !$noadmininfo) $sellist .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
683 $this->error = $this->
db->lasterror();
684 $this->errors[] = $this->
db->lasterror();
685 dol_syslog(get_class($this).
"::selectOpportunityStatus ".$this->error, LOG_ERR);
ajax_autocompleter($selected, $htmlname, $url, $urloption= '', $minLength=2, $autoselect=0, $ajaxoptions=array(), $moreparams= '')
Generic function that return javascript to add to a page to transform a common input field into an au...
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
const STATUS_CLOSED
Closed status.
$conf db
API class for accounts.
Class to manage projects.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
const STATUS_DRAFT
Draft status.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.