dolibarr  7.0.0-beta
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 {
30  var $db;
31  var $error;
32 
33 
39  public function __construct($db)
40  {
41  $this->db = $db;
42  }
43 
56  function selectProposalStatus($selected='',$short=0, $excludedraft=0, $showempty=1, $mode='customer',$htmlname='propal_statut')
57  {
58  global $langs;
59 
60  $prefix='';
61  $listofstatus=array();
62  if ($mode == 'supplier')
63  {
64  $prefix='SupplierProposalStatus';
65 
66  $langs->load("supplier_proposal");
67  $listofstatus=array(
68  0=>array('id'=>0, 'code'=>'PR_DRAFT'),
69  1=>array('id'=>1, 'code'=>'PR_OPEN'),
70  2=>array('id'=>2, 'code'=>'PR_SIGNED'),
71  3=>array('id'=>3, 'code'=>'PR_NOTSIGNED'),
72  4=>array('id'=>4, 'code'=>'PR_CLOSED')
73  );
74  }
75  else
76  {
77  $prefix="PropalStatus";
78 
79  $sql = "SELECT id, code, label, active FROM ".MAIN_DB_PREFIX."c_propalst";
80  $sql .= " WHERE active = 1";
81  dol_syslog(get_class($this)."::selectProposalStatus", LOG_DEBUG);
82  $resql=$this->db->query($sql);
83  if ($resql)
84  {
85  $num = $this->db->num_rows($resql);
86  $i = 0;
87  if ($num)
88  {
89  while ($i < $num)
90  {
91  $obj = $this->db->fetch_object($resql);
92  $listofstatus[$obj->id]=array('id'=>$obj->id,'code'=>$obj->code,'label'=>$obj->label);
93  $i++;
94  }
95  }
96  }
97  else
98  {
99  dol_print_error($this->db);
100  }
101  }
102 
103  print '<select class="flat" name="'.$htmlname.'">';
104  if ($showempty) print '<option value="-1">&nbsp;</option>';
105 
106  foreach($listofstatus as $key => $obj)
107  {
108  if ($excludedraft)
109  {
110  if ($obj['code'] == 'Draft' || $obj['code'] == 'PR_DRAFT')
111  {
112  $i++;
113  continue;
114  }
115  }
116  if ($selected != '' && $selected == $obj['id'])
117  {
118  print '<option value="'.$obj['id'].'" selected>';
119  }
120  else
121  {
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  }
129  else
130  {
131  $conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Validated','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed');
132  if (! empty($conv_to_new_code[$obj['code']])) $key=$conv_to_new_code[$obj['code']];
133 
134  print ($langs->trans($prefix.$key.($short?'Short':''))!=$prefix.$key.($short?'Short':''))?$langs->trans($prefix.$key.($short?'Short':'')):($obj['label']?$obj['label']:$obj['code']);
135  }
136  print '</option>';
137  $i++;
138  }
139  print '</select>';
140  }
141 }
142 
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.
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:1013
__construct($db)
Constructor.