26require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
 
   43  public $errors = array();
 
   82  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 = 
'', $morefilter = 
'')
 
   85    global $langs, $conf, $form;
 
   87    $selected_input_value = 
'';
 
   88    if (is_object($selected)) {
 
   89      $selected_input_value = $selected->ref;
 
   90      $selected = $selected->id;
 
   95    if (!empty($conf->use_javascript_ajax) && 
getDolGlobalString(
'PROJECT_USE_SEARCH_TO_SELECT')) {
 
   98      if ($selected && empty($selected_input_value)) {
 
   99        require_once DOL_DOCUMENT_ROOT . 
'/projet/class/project.class.php';
 
  100        $project = 
new Project($this->db);
 
  101        $project->fetch($selected);
 
  102        $selected_input_value = $project->ref;
 
  104      $urloption = 
'socid=' . ((int) $socid) . 
'&htmlname=' . urlencode($htmlname) . 
'&discardclosed=' . ((int) $discard_closed);
 
  105      if ($morefilter == 
'usage_organize_event=1') {
 
  106        $urloption .= 
'&usage_organize_event=1';
 
  108      $out .= 
'<input type="text" class="minwidth200' . ($morecss ? 
' ' . $morecss : 
'') . 
'" name="search_' . $htmlname . 
'" id="search_' . $htmlname . 
'" value="' . $selected_input_value . 
'"' . $placeholder . 
' />';
 
  110      $out .= 
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . 
'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array());
 
  112      $out .= $this->
select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, abs($discard_closed), $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid, $morecss, $morefilter);
 
  114    if ($discard_closed > 0) {
 
  116        $out .= $form->textwithpicto(
'', $langs->trans(
"ClosedProjectsAreHidden"));
 
  120    if (empty($nooutput)) {
 
 
  151  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', $morefilter = 
'')
 
  154    global $user, $conf, $langs;
 
  156    require_once DOL_DOCUMENT_ROOT . 
'/projet/class/project.class.php';
 
  158    if (empty($htmlid)) {
 
  165    $hideunselectables = 
false;
 
  167      $hideunselectables = 
true;
 
  170    $projectsListId = 
false;
 
  171    if (!$user->hasRight(
'projet', 
'all', 
'lire')) {
 
  172      $projectstatic = 
new Project($this->db);
 
  173      $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
 
  177    $sql = 
"SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name, s.name_alias";
 
  178    $sql .= 
" FROM " . $this->db->prefix() . 
"projet as p LEFT JOIN " . $this->db->prefix() . 
"societe as s ON s.rowid = p.fk_soc";
 
  179    $sql .= 
" WHERE p.entity IN (" . 
getEntity(
'project') . 
")";
 
  180    if ($projectsListId !== 
false) {
 
  181      $sql .= 
" AND p.rowid IN (" . $this->db->sanitize($projectsListId) . 
")";
 
  184      $sql .= 
" AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
 
  188        $sql .= 
" AND (p.fk_soc=" . ((int) $socid) . 
" OR p.fk_soc IS NULL)";
 
  190        $sql .= 
" AND (p.fk_soc IN (" . $this->db->sanitize(((
int) $socid) . 
", " . 
getDolGlobalString(
'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY')) . 
") OR p.fk_soc IS NULL)";
 
  193    if (!empty($filterkey)) {
 
  197      $sql .= 
' AND (' . $this->db->sanitize($morefilter, 0, 1) . 
')';
 
  199    $sql .= 
" ORDER BY p.ref ASC";
 
  201    $resql = $this->db->query($sql);
 
  203      if (!empty($conf->use_javascript_ajax)) {
 
  204        $morecss .= 
' minwidth100';
 
  206      if (empty($option_only)) {
 
  207        $out .= 
'<select class="flat' . ($morecss ? 
' ' . $morecss : 
'') . 
'"' . ($disabled ? 
' disabled="disabled"' : 
'') . 
' id="' . $htmlid . 
'" name="' . $htmlname . 
'">';
 
  209      if (!empty($show_empty)) {
 
  210        if (is_numeric($show_empty)) {
 
  211          $out .= 
'<option value="0"> </option>';
 
  213          $out .= 
'<option value="-1">'.$show_empty.
'</option>';
 
  216      $num = $this->db->num_rows($resql);
 
  220          $obj = $this->db->fetch_object($resql);
 
  222          if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->hasRight(
'societe', 
'lire')) {
 
  225            if ($discard_closed == 1 && $obj->fk_statut == 2 && $obj->rowid != $selected) { 
 
  233            $labeltoshow .= 
', ' . 
dol_trunc($obj->title, $maxlength);
 
  235              $labeltoshow .= 
' - ' . $obj->name;
 
  236              if ($obj->name_alias) {
 
  237                $labeltoshow .= 
' (' . $obj->name_alias . 
')';
 
  242            if ($obj->fk_statut == 0) {
 
  244              $labeltoshow .= 
' - ' . $langs->trans(
"Draft");
 
  245            } elseif ($obj->fk_statut == 2) {
 
  246              if ($discard_closed == 2) {
 
  249              $labeltoshow .= 
' - ' . $langs->trans(
"Closed");
 
  250            } elseif (!
getDolGlobalString(
'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY') && $socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
 
  252              $labeltoshow .= 
' - ' . $langs->trans(
"LinkedToAnotherCompany");
 
  255            if (!empty($selected) && $selected == $obj->rowid) {
 
  256              $out .= 
'<option value="' . $obj->rowid . 
'" selected';
 
  258              $out .= 
'>' . $labeltoshow . 
'</option>';
 
  260              if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
 
  263                $resultat = 
'<option value="' . $obj->rowid . 
'"';
 
  265                  $resultat .= 
' disabled';
 
  270                $resultat .= $labeltoshow;
 
  271                $resultat .= 
'</option>';
 
  276                'key' => (
int) $obj->rowid,
 
  277                'value' => $obj->ref,
 
  279                'labelx' => $labeltoshow,
 
  280                'label' => ($disabled ? 
'<span class="opacitymedium">' . $labeltoshow . 
'</span>' : $labeltoshow),
 
  281                'disabled' => (
bool) $disabled
 
  289      $this->db->free($resql);
 
  292        if (empty($option_only)) {
 
  297        if (!empty($conf->use_javascript_ajax)) {
 
  298          include_once DOL_DOCUMENT_ROOT . 
'/core/lib/ajax.lib.php';
 
  299          $comboenhancement = 
ajax_combobox($htmlid, array(), 0, $forcefocus);
 
  300          $out .= $comboenhancement;
 
  301          $morecss .= 
' minwidth100';
 
  304        if (empty($nooutput)) {
 
 
  337  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 = 
'', $showmore = 
'all', $usertofilter = 
null)
 
  339    global $user, $conf, $langs;
 
  341    require_once DOL_DOCUMENT_ROOT . 
'/projet/class/project.class.php';
 
  343    if (is_null($usertofilter)) {
 
  344      $usertofilter = $user;
 
  349    $hideunselectables = 
false;
 
  351      $hideunselectables = 
true;
 
  354    if (empty($projectsListId)) {
 
  355      if (!$usertofilter->hasRight(
'projet', 
'all', 
'lire')) {
 
  356        $projectstatic = 
new Project($this->db);
 
  357        $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
 
  362    $sql = 
"SELECT t.rowid, t.ref as tref, t.label as tlabel, t.progress,";
 
  363    $sql .= 
" p.rowid as pid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, p.usage_task,";
 
  364    $sql .= 
" s.nom as name";
 
  365    $sql .= 
" FROM " . $this->db->prefix() . 
"projet as p";
 
  366    $sql .= 
" LEFT JOIN " . $this->db->prefix() . 
"societe as s ON s.rowid = p.fk_soc,";
 
  367    $sql .= 
" " . $this->db->prefix() . 
"projet_task as t";
 
  368    $sql .= 
" WHERE p.entity IN (" . 
getEntity(
'project') . 
")";
 
  369    $sql .= 
" AND t.fk_projet = p.rowid";
 
  370    if ($projectsListId) {
 
  371      $sql .= 
" AND p.rowid IN (" . $this->db->sanitize($projectsListId) . 
")";
 
  374      $sql .= 
" AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
 
  377      $sql .= 
" AND (p.fk_soc=" . ((int) $socid) . 
" OR p.fk_soc IS NULL)";
 
  379    $sql .= 
" ORDER BY p.ref, t.ref ASC";
 
  381    $resql = $this->db->query($sql);
 
  384      if (empty($option_only) && !empty($conf->use_javascript_ajax)) {
 
  385        include_once DOL_DOCUMENT_ROOT . 
'/core/lib/ajax.lib.php';
 
  386        $comboenhancement = 
ajax_combobox($htmlname, 
'', 0, $forcefocus);
 
  387        $out .= $comboenhancement;
 
  388        $morecss .= 
' minwidth150imp';
 
  391      if (empty($option_only)) {
 
  392        $out .= 
'<select class="valignmiddle flat' . ($morecss ? 
' ' . $morecss : 
'') . 
'"' . ($disabled ? 
' disabled="disabled"' : 
'') . 
' id="' . $htmlname . 
'" name="' . $htmlname . 
'">';
 
  394      if (!empty($show_empty)) {
 
  395        $out .= 
'<option value="0" class="optiongrey">';
 
  396        if (!is_numeric($show_empty)) {
 
  406      $num = $this->db->num_rows($resql);
 
  410          $obj = $this->db->fetch_object($resql);
 
  412          if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$usertofilter->hasRight(
'societe', 
'lire')) {
 
  427              if ($discard_closed == 2) {
 
  430            } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
 
  434            if (preg_match(
'/all/', $showmore)) {
 
  435              $labeltoshow .= 
dol_trunc($obj->ref, 18); 
 
  438              $labeltoshow .= 
' ' . 
dol_trunc($obj->title, $maxlength);
 
  439              $titletoshow = $labeltoshow;
 
  442                $labeltoshow .= 
' (' . $obj->name . 
')';
 
  443                $titletoshow .= 
' <span class="opacitymedium">(' . $obj->name . 
')</span>';
 
  449                $labeltoshow .= 
' - ' . $langs->trans(
"Draft");
 
  450                $titletoshow .= 
' -  <span class="opacitymedium">' . $langs->trans(
"Draft") . 
'</span>';
 
  452                if ($discard_closed == 2) {
 
  455                $labeltoshow .= 
' - ' . $langs->trans(
"Closed");
 
  456                $titletoshow .= 
' - <span class="opacitymedium">' . $langs->trans(
"Closed") . 
'</span>';
 
  457              } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
 
  459                $labeltoshow .= 
' - ' . $langs->trans(
"LinkedToAnotherCompany");
 
  460                $titletoshow .= 
' - <span class="opacitymedium">' . $langs->trans(
"LinkedToAnotherCompany") . 
'</span>';
 
  462              $labeltoshow .= 
' - ';
 
  463              $titletoshow .= 
' - ';
 
  467            $labeltoshow .= $obj->tref . 
' ' . 
dol_trunc($obj->tlabel, $maxlength);
 
  468            $titletoshow .= $obj->tref . 
' ' . 
dol_trunc($obj->tlabel, $maxlength);
 
  469            if ($obj->usage_task && preg_match(
'/progress/', $showmore)) {
 
  470              $labeltoshow .= 
' <span class="opacitymedium">(' . $obj->progress . 
'%)</span>';
 
  471              $titletoshow .= 
' <span class="opacitymedium">(' . $obj->progress . 
'%)</span>';
 
  474            if (!empty($selected) && $selected == $obj->rowid) {
 
  475              $out .= 
'<option value="' . $obj->rowid . 
'" selected';
 
  478              $out .= 
'>' . $labeltoshow . 
'</option>';
 
  480              if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
 
  483                $resultat = 
'<option value="' . $obj->rowid . 
'"';
 
  485                  $resultat .= 
' disabled';
 
  491                $resultat .= $labeltoshow;
 
  492                $resultat .= 
'</option>';
 
  500      if (empty($option_only)) {
 
  504      $this->nboftasks = $num;
 
  508      $this->db->free($resql);
 
 
  530  public function select_element($table_element, $socid = 0, $morecss = 
'', $limitonstatus = -2, $projectkey = 
"fk_projet", $placeholder = 
'')
 
  533    global $conf, $langs;
 
  535    if ($table_element == 
'projet_task') {
 
  539    $linkedtothirdparty = 
false;
 
  545        'expensereport', 
'loan',
 
  553      $linkedtothirdparty = 
true;
 
  559    switch ($table_element) {
 
  561        $sql = 
"SELECT t.rowid, t.label as ref";
 
  564        $sql = 
"SELECT t.rowid, t.ref as ref";
 
  566      case "facture_fourn":
 
  567        $sql = 
"SELECT t.rowid, t.ref, t.ref_supplier";
 
  569      case "commande_fourn":
 
  570      case "commande_fournisseur":
 
  571        $sql = 
"SELECT t.rowid, t.ref, t.ref_supplier";
 
  574        $sql = 
"SELECT t.rowid, t.titre as ref";
 
  577        $sql = 
"SELECT t.id as rowid, t.label as ref";
 
  578        $projectkey = 
"fk_project";
 
  580      case "expensereport":
 
  582      case "expensereport_det":
 
  590        $sql = 
"SELECT t.rowid, t.ref";
 
  592      case 'stock_mouvement':
 
  593        $sql = 
"SELECT t.rowid, t.label as ref";
 
  594        $projectkey = 
'fk_origin';
 
  596      case "payment_salary":
 
  597        $sql = 
"SELECT t.rowid, t.num_payment as ref"; 
 
  599      case "payment_various":
 
  600        $sql = 
"SELECT t.rowid, t.num_payment as ref";
 
  602      case "chargesociales":
 
  604        $sql = 
"SELECT t.rowid, t.ref";
 
  607    if ($linkedtothirdparty) {
 
  608      $sql .= 
", s.nom as name";
 
  610    $sql .= 
" FROM " . $this->db->prefix() . $table_element . 
" as t";
 
  611    if ($linkedtothirdparty) {
 
  612      $sql .= 
", " . $this->db->prefix() . 
"societe as s";
 
  614    $sql .= 
" WHERE " . $projectkey . 
" is null";
 
  615    if (!empty($socid) && $linkedtothirdparty) {
 
  616      if (is_numeric($socid)) {
 
  617        $sql .= 
" AND t.fk_soc = " . ((int) $socid);
 
  619        $sql .= 
" AND t.fk_soc IN (" . $this->db->sanitize($socid) . 
")";
 
  622    if (!in_array($table_element, array(
'expensereport_det', 
'stock_mouvement'))) {
 
  623      $sql .= 
' AND t.entity IN (' . 
getEntity(
'project') . 
')';
 
  625    if ($linkedtothirdparty) {
 
  626      $sql .= 
" AND s.rowid = t.fk_soc";
 
  629      $sql .= 
" AND " . $sqlfilter;
 
  631    $sql .= 
" ORDER BY ref DESC";
 
  633    dol_syslog(get_class($this) . 
'::select_element', LOG_DEBUG);
 
  634    $resql = $this->db->query($sql);
 
  636      $num = $this->db->num_rows($resql);
 
  641        $sellist = 
'<select class="flat elementselect css' . $table_element . ($morecss ? 
' ' . $morecss : 
'') . 
'" name="elementselect">';
 
  642        $sellist .= 
'<option value="-1"' . ($placeholder ? 
' class="optiongrey"' : 
'') . 
'>' . $placeholder . 
'</option>';
 
  644          $obj = $this->db->fetch_object($resql);
 
  645          $ref = $obj->ref ? $obj->ref : $obj->rowid;
 
  646          if (!empty($obj->ref_supplier)) {
 
  647            $ref .= 
' (' . $obj->ref_supplier . 
')';
 
  649          if (!empty($obj->name)) {
 
  650            $ref .= 
' - ' . $obj->name;
 
  652          $sellist .= 
'<option value="' . $obj->rowid . 
'">' . $ref . 
'</option>';
 
  655        $sellist .= 
'</select>';
 
  663      $this->db->free($resql);
 
  668      $this->error = $this->db->lasterror();
 
  669      $this->errors[] = $this->db->lasterror();
 
  670      dol_syslog(get_class($this) . 
"::select_element " . $this->error, LOG_ERR);
 
 
  690  public function selectOpportunityStatus($htmlname, $preselected = 
'-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = 
'', $noadmininfo = 0, $addcombojs = 0)
 
  692    global $conf, $langs, $user;
 
  694    $sql = 
"SELECT rowid, code, label, percent";
 
  695    $sql .= 
" FROM " . $this->db->prefix() . 
'c_lead_status';
 
  696    $sql .= 
" WHERE active = 1";
 
  697    $sql .= 
" ORDER BY position";
 
  699    $resql = $this->db->query($sql);
 
  701      $num = $this->db->num_rows($resql);
 
  704        $sellist = 
'<select class="flat oppstatus' . ($morecss ? 
' ' . $morecss : 
'') . 
'" id="' . $htmlname . 
'" name="' . $htmlname . 
'">';
 
  707          $sellist .= 
'<option value="-1"> </option>';
 
  710          $sellist .= 
'<option value="all"' . ($preselected == 
'all' ? 
' selected="selected"' : 
'') . 
'>-- ' . $langs->trans(
"OnlyOpportunitiesShort") . 
'</option>';
 
  711          $sellist .= 
'<option value="openedopp"' . ($preselected == 
'openedopp' ? 
' selected="selected"' : 
'') . 
'>-- ' . $langs->trans(
"OpenedOpportunitiesShort") . 
'</option>';
 
  712          $sellist .= 
'<option value="notopenedopp"' . ($preselected == 
'notopenedopp' ? 
' selected="selected"' : 
'') . 
'>-- ' . $langs->trans(
"NotOpenedOpportunitiesShort") . 
'</option>';
 
  713          $sellist .= 
'<option value="none"' . ($preselected == 
'none' ? 
' selected="selected"' : 
'') . 
'>-- ' . $langs->trans(
"NotAnOpportunityShort") . 
'</option>';
 
  716          $obj = $this->db->fetch_object($resql);
 
  718          $sellist .= 
'<option value="' . $obj->rowid . 
'" defaultpercent="' . $obj->percent . 
'" elemcode="' . $obj->code . 
'"';
 
  719          if ($obj->rowid == $preselected) {
 
  720            $sellist .= 
' selected="selected"';
 
  723          if ($useshortlabel) {
 
  724            $finallabel = ($langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) != 
"OppStatus" . $obj->code ? $langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) : $obj->label);
 
  726            $finallabel = ($langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) != 
"OppStatus" . $obj->code ? $langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) : $obj->label);
 
  728              $finallabel .= 
' (' . $obj->percent . 
'%)';
 
  731          $sellist .= $finallabel;
 
  732          $sellist .= 
'</option>';
 
  735        $sellist .= 
'</select>';
 
  737        if ($user->admin && !$noadmininfo) {
 
  738          $sellist .= 
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
 
  751      $this->db->free($resql);
 
  755      $this->error = $this->db->lasterror();
 
  756      $this->errors[] = $this->db->lasterror();
 
  757      dol_syslog(get_class($this) . 
"::selectOpportunityStatus " . $this->error, LOG_ERR);
 
 
  775    $statustohow = array(
 
  781    $tmpproject = 
new Project($this->db);
 
  783    foreach ($statustohow as $key => $value) {
 
  784      $tmpproject->statut = $key;
 
  785      $options[$value] = $tmpproject->getLibStatut($short);
 
  788    if (is_array($selected)) {
 
  789      $selectedarray = $selected;
 
  790    } elseif ($selected == 99) {
 
  791      $selectedarray = array(0,1);
 
  793      $selectedarray = explode(
',', $selected);
 
 
  811  public function selectInvoiceAndLine($selectedInvoiceId = 0, $selectedLineId = 0, $htmlNameInvoice = 
'invoiceid', $htmlNameInvoiceLine = 
'invoicelineid', $morecss = 
'maxwidth500', $filters = array(), $lineOnly = 0)
 
  813    global $user, $conf, $langs;
 
  815    require_once DOL_DOCUMENT_ROOT . 
'/projet/class/project.class.php';
 
  818    if (empty($lineOnly)) {
 
  820      $sql = 
"SELECT f.rowid, f.ref as fref,";
 
  821      $sql .= 
' s.nom as name';
 
  822      $sql .= 
' FROM ' . $this->db->prefix() . 
'projet as p';
 
  823      $sql .= 
' INNER JOIN ' . $this->db->prefix() . 
'societe as s ON s.rowid = p.fk_soc';
 
  824      $sql .= 
' INNER JOIN ' . $this->db->prefix() . 
'facture as f ON f.fk_projet = p.rowid';
 
  825      $sql .= 
" WHERE p.entity IN (" . 
getEntity(
'project') . 
")";
 
  826      if (!empty($filters)) {
 
  827        foreach ($filters as $key => $value) {
 
  828          if ($key == 
'p.rowid') {
 
  829            $sql .= 
" AND p.rowid=" . (int) $value;
 
  831          if ($key == 
'f.rowid') {
 
  832            $sql .= 
" AND f.rowid=" . (int) $value;
 
  836      $sql .= 
" ORDER BY p.ref, f.ref ASC";
 
  838      $resql = $this->db->query($sql);
 
  841        if (!empty($conf->use_javascript_ajax)) {
 
  842          include_once DOL_DOCUMENT_ROOT . 
'/core/lib/ajax.lib.php';
 
  843          $comboenhancement = 
ajax_combobox($htmlNameInvoice, array(array(
'method'=>
'getLines', 
'url'=>
dol_buildpath(
'/core/ajax/ajaxinvoiceline.php', 1), 
'htmlname'=>$htmlNameInvoiceLine)), 0, 0);
 
  844          $out .= $comboenhancement;
 
  845          $morecss = 
'minwidth200imp maxwidth500';
 
  848        $out .= 
'<select class="valignmiddle flat' . ($morecss ? 
' ' . $morecss : 
'') . 
'" id="' . $htmlNameInvoice . 
'" name="' . $htmlNameInvoice . 
'">';
 
  849        $num = $this->db->num_rows($resql);
 
  851          while ($obj = $this->db->fetch_object($resql)) {
 
  852            $labeltoshow = $obj->fref; 
 
  854              $labeltoshow .= 
' - ' . $obj->name;
 
  857            $out .= 
'<option value="' . $obj->rowid . 
'" ';
 
  858            if (!empty($selectedInvoiceId) && $selectedInvoiceId == $obj->rowid) {
 
  859              $out .= 
' selected ';
 
  861            $out .= 
'>' . $labeltoshow . 
'</option>';
 
  872    $sql = 
"SELECT fd.rowid, fd.label, fd.description";
 
  873    $sql .= 
' FROM ' . $this->db->prefix() . 
'projet as p';
 
  874    $sql .= 
' INNER JOIN ' . $this->db->prefix() . 
'societe as s ON s.rowid = p.fk_soc';
 
  875    $sql .= 
' INNER JOIN ' . $this->db->prefix() . 
'facture as f ON f.fk_projet = p.rowid';
 
  876    $sql .= 
' INNER JOIN ' . $this->db->prefix() . 
'facturedet as fd ON fd.fk_facture = f.rowid';
 
  877    $sql .= 
" WHERE p.entity IN (" . 
getEntity(
'project') . 
")";
 
  878    if (!empty($filters)) {
 
  879      foreach ($filters as $key => $value) {
 
  880        if ($key == 
'p.rowid') {
 
  881          $sql .= 
" AND p.rowid=" . (int) $value;
 
  885    if (!empty($selectedInvoiceId)) {
 
  886      $sql .= 
" AND f.rowid=" . (int) $selectedInvoiceId;
 
  888    $sql .= 
" ORDER BY p.ref, f.ref ASC";
 
  889    $resql = $this->db->query($sql);
 
  892      if (empty($lineOnly)) {
 
  893        if (!empty($conf->use_javascript_ajax)) {
 
  894          include_once DOL_DOCUMENT_ROOT . 
'/core/lib/ajax.lib.php';
 
  895          $comboenhancement = 
ajax_combobox($htmlNameInvoiceLine, 
'', 0, 0);
 
  896          $out .= $comboenhancement;
 
  897          $morecss = 
'minwidth200imp maxwidth500';
 
  900        $out .= 
'<select class="valignmiddle flat' . ($morecss ? 
' ' . $morecss : 
'') . 
'" id="' . $htmlNameInvoiceLine . 
'" name="' . $htmlNameInvoiceLine . 
'">';
 
  902      $num = $this->db->num_rows($resql);
 
  904        while ($obj = $this->db->fetch_object($resql)) {
 
  905          $labeltoshow .= $obj->description; 
 
  907          $out .= 
'<option value="' . $obj->rowid . 
'" ';
 
  908          if (!empty($selectedLineId) && $selectedLineId == $obj->rowid) {
 
  909            $out .= 
' selected ';
 
  911          $out .= 
'>' . $labeltoshow . 
'</option>';
 
  914      if (empty($lineOnly)) {
 
 
 
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', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
 
Class to manage projects.
 
const STATUS_CLOSED
Closed status.
 
const STATUS_DRAFT
Draft status.
 
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
 
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...
 
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
 
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
 
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.
 
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
 
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
 
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
 
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...