dolibarr  13.0.2
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 
63  public function selectProposalStatus($selected = '', $short = 0, $excludedraft = 0, $showempty = 1, $mode = 'customer', $htmlname = 'propal_statut')
64  {
65  global $langs;
66 
67  $prefix = '';
68  $listofstatus = array();
69  if ($mode == 'supplier') {
70  $prefix = 'SupplierProposalStatus';
71 
72  $langs->load("supplier_proposal");
73  $listofstatus = array(
74  0=>array('id'=>0, 'code'=>'PR_DRAFT'),
75  1=>array('id'=>1, 'code'=>'PR_OPEN'),
76  2=>array('id'=>2, 'code'=>'PR_SIGNED'),
77  3=>array('id'=>3, 'code'=>'PR_NOTSIGNED'),
78  4=>array('id'=>4, 'code'=>'PR_CLOSED')
79  );
80  } else {
81  $prefix = "PropalStatus";
82 
83  $sql = "SELECT id, code, label, active FROM ".MAIN_DB_PREFIX."c_propalst";
84  $sql .= " WHERE active = 1";
85  dol_syslog(get_class($this)."::selectProposalStatus", LOG_DEBUG);
86  $resql = $this->db->query($sql);
87  if ($resql)
88  {
89  $num = $this->db->num_rows($resql);
90  $i = 0;
91  if ($num)
92  {
93  while ($i < $num)
94  {
95  $obj = $this->db->fetch_object($resql);
96  $listofstatus[$obj->id] = array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$obj->label);
97  $i++;
98  }
99  }
100  } else {
101  dol_print_error($this->db);
102  }
103  }
104 
105  print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
106  if ($showempty) print '<option value="-1">&nbsp;</option>';
107 
108  foreach ($listofstatus as $key => $obj)
109  {
110  if ($excludedraft)
111  {
112  if ($obj['code'] == 'Draft' || $obj['code'] == 'PR_DRAFT')
113  {
114  $i++;
115  continue;
116  }
117  }
118  if ($selected != '' && $selected == $obj['id'])
119  {
120  print '<option value="'.$obj['id'].'" selected>';
121  } else {
122  print '<option value="'.$obj['id'].'">';
123  }
124  $key = $obj['code'];
125  if ($langs->trans($prefix.$key.($short ? 'Short' : '')) != $prefix.$key.($short ? 'Short' : ''))
126  {
127  print $langs->trans($prefix.$key.($short ? 'Short' : ''));
128  } else {
129  $conv_to_new_code = array('PR_DRAFT'=>'Draft', 'PR_OPEN'=>'Validated', 'PR_CLOSED'=>'Closed', 'PR_SIGNED'=>'Signed', 'PR_NOTSIGNED'=>'NotSigned', 'PR_FAC'=>'Billed');
130  if (!empty($conv_to_new_code[$obj['code']])) $key = $conv_to_new_code[$obj['code']];
131 
132  print ($langs->trans($prefix.$key.($short ? 'Short' : '')) != $prefix.$key.($short ? 'Short' : '')) ? $langs->trans($prefix.$key.($short ? 'Short' : '')) : ($obj['label'] ? $obj['label'] : $obj['code']);
133  }
134  print '</option>';
135  $i++;
136  }
137  print '</select>';
138 
139  print ajax_combobox($htmlname);
140  }
141 }
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:391
Class to manage generation of HTML components for proposal management.
$conf db
API class for accounts.
Definition: inc.php:54
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
selectProposalStatus($selected= '', $short=0, $excludedraft=0, $showempty=1, $mode= 'customer', $htmlname= 'propal_statut')
Return combo list of differents status of a proposal Values are id of table c_propalst.
print
Draft customers invoices.
Definition: index.php:89
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.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
__construct($db)
Constructor.