dolibarr  17.0.4
html.formpropal.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
29 {
33  public $db;
34 
38  public $error = '';
39 
40 
46  public function __construct($db)
47  {
48  $this->db = $db;
49  }
50 
64  public function selectProposalStatus($selected = '', $short = 0, $excludedraft = 0, $showempty = 1, $mode = 'customer', $htmlname = 'propal_statut', $morecss = '')
65  {
66  global $langs;
67 
68  $prefix = '';
69  $listofstatus = array();
70  if ($mode == 'supplier') {
71  $prefix = 'SupplierProposalStatus';
72 
73  $langs->load("supplier_proposal");
74  $listofstatus = array(
75  0=>array('id'=>0, 'code'=>'PR_DRAFT'),
76  1=>array('id'=>1, 'code'=>'PR_OPEN'),
77  2=>array('id'=>2, 'code'=>'PR_SIGNED'),
78  3=>array('id'=>3, 'code'=>'PR_NOTSIGNED'),
79  4=>array('id'=>4, 'code'=>'PR_CLOSED')
80  );
81  } else {
82  $prefix = "PropalStatus";
83 
84  $sql = "SELECT id, code, label, active FROM ".$this->db->prefix()."c_propalst";
85  $sql .= " WHERE active = 1";
86  dol_syslog(get_class($this)."::selectProposalStatus", LOG_DEBUG);
87  $resql = $this->db->query($sql);
88  if ($resql) {
89  $num = $this->db->num_rows($resql);
90  $i = 0;
91  if ($num) {
92  while ($i < $num) {
93  $obj = $this->db->fetch_object($resql);
94  $listofstatus[$obj->id] = array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$obj->label);
95  $i++;
96  }
97  }
98  } else {
99  dol_print_error($this->db);
100  }
101  }
102 
103  print '<select id="'.$htmlname.'" name="'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">';
104  if ($showempty) {
105  print '<option value="-1">&nbsp;</option>';
106  }
107 
108  $i = 0;
109  foreach ($listofstatus as $key => $obj) {
110  if ($excludedraft) {
111  if ($obj['code'] == 'Draft' || $obj['code'] == 'PR_DRAFT') {
112  $i++;
113  continue;
114  }
115  }
116  if ($selected != '' && $selected == $obj['id']) {
117  print '<option value="'.$obj['id'].'" selected>';
118  } else {
119  print '<option value="'.$obj['id'].'">';
120  }
121  $key = $obj['code'];
122  if ($langs->trans($prefix.$key.($short ? 'Short' : '')) != $prefix.$key.($short ? 'Short' : '')) {
123  print $langs->trans($prefix.$key.($short ? 'Short' : ''));
124  } else {
125  $conv_to_new_code = array('PR_DRAFT'=>'Draft', 'PR_OPEN'=>'Validated', 'PR_CLOSED'=>'Closed', 'PR_SIGNED'=>'Signed', 'PR_NOTSIGNED'=>'NotSigned', 'PR_FAC'=>'Billed');
126  if (!empty($conv_to_new_code[$obj['code']])) {
127  $key = $conv_to_new_code[$obj['code']];
128  }
129 
130  print ($langs->trans($prefix.$key.($short ? 'Short' : '')) != $prefix.$key.($short ? 'Short' : '')) ? $langs->trans($prefix.$key.($short ? 'Short' : '')) : ($obj['label'] ? $obj['label'] : $obj['code']);
131  }
132  print '</option>';
133  $i++;
134  }
135  print '</select>';
136 
137  print ajax_combobox($htmlname, array(), 0, 0, 'resolve', ($showempty < 0 ? (string) $showempty : '-1'), $morecss);
138  }
139 }
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:449
Class to manage generation of HTML components for proposal management.
selectProposalStatus($selected='', $short=0, $excludedraft=0, $showempty=1, $mode='customer', $htmlname='propal_statut', $morecss='')
Return combo list of differents status of a proposal Values are id of table c_propalst.
__construct($db)
Constructor.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.
Definition: inc.php:41