dolibarr  9.0.0
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 <http://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  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  {
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  }
82  else
83  {
84  $prefix="PropalStatus";
85 
86  $sql = "SELECT id, code, label, active FROM ".MAIN_DB_PREFIX."c_propalst";
87  $sql .= " WHERE active = 1";
88  dol_syslog(get_class($this)."::selectProposalStatus", LOG_DEBUG);
89  $resql=$this->db->query($sql);
90  if ($resql)
91  {
92  $num = $this->db->num_rows($resql);
93  $i = 0;
94  if ($num)
95  {
96  while ($i < $num)
97  {
98  $obj = $this->db->fetch_object($resql);
99  $listofstatus[$obj->id]=array('id'=>$obj->id,'code'=>$obj->code,'label'=>$obj->label);
100  $i++;
101  }
102  }
103  }
104  else
105  {
106  dol_print_error($this->db);
107  }
108  }
109 
110  print '<select class="flat" name="'.$htmlname.'">';
111  if ($showempty) print '<option value="-1">&nbsp;</option>';
112 
113  foreach($listofstatus as $key => $obj)
114  {
115  if ($excludedraft)
116  {
117  if ($obj['code'] == 'Draft' || $obj['code'] == 'PR_DRAFT')
118  {
119  $i++;
120  continue;
121  }
122  }
123  if ($selected != '' && $selected == $obj['id'])
124  {
125  print '<option value="'.$obj['id'].'" selected>';
126  }
127  else
128  {
129  print '<option value="'.$obj['id'].'">';
130  }
131  $key=$obj['code'];
132  if ($langs->trans($prefix.$key.($short?'Short':'')) != $prefix.$key.($short?'Short':''))
133  {
134  print $langs->trans($prefix.$key.($short?'Short':''));
135  }
136  else
137  {
138  $conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Validated','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed');
139  if (! empty($conv_to_new_code[$obj['code']])) $key=$conv_to_new_code[$obj['code']];
140 
141  print ($langs->trans($prefix.$key.($short?'Short':''))!=$prefix.$key.($short?'Short':''))?$langs->trans($prefix.$key.($short?'Short':'')):($obj['label']?$obj['label']:$obj['code']);
142  }
143  print '</option>';
144  $i++;
145  }
146  print '</select>';
147  }
148 }
print
Draft customers invoices.
Definition: index.php:91
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->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) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
Class to manage generation of HTML components for proposal management.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
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.
__construct($db)
Constructor.