@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; |
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
32 | -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent |
|
32 | +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent |
|
33 | 33 | |
34 | 34 | |
35 | 35 | /** |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @var string Error code (or message) |
42 | 42 | */ |
43 | - public $error=''; |
|
43 | + public $error = ''; |
|
44 | 44 | |
45 | 45 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
46 | 46 | /** |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | * @param integer $maxfilenamelength Max length of value to show |
51 | 51 | * @return array List of templates |
52 | 52 | */ |
53 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
53 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
54 | 54 | { |
55 | 55 | // phpcs:enable |
56 | 56 | global $conf; |
57 | 57 | |
58 | - $type='invoice'; |
|
59 | - $liste=array(); |
|
58 | + $type = 'invoice'; |
|
59 | + $liste = array(); |
|
60 | 60 | |
61 | 61 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
62 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
62 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
63 | 63 | |
64 | 64 | return $liste; |
65 | 65 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * @var string Error code (or message) |
75 | 75 | */ |
76 | - public $error=''; |
|
76 | + public $error = ''; |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Return if a module can be used or not |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param Facture $facture Objet facture |
128 | 128 | * @return string Value |
129 | 129 | */ |
130 | - function getNextValue($objsoc,$facture) |
|
130 | + function getNextValue($objsoc, $facture) |
|
131 | 131 | { |
132 | 132 | global $langs; |
133 | 133 | return $langs->trans("NotAvailable"); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \ingroup facture |
23 | 23 | * \brief File containing class for numbering module Terre |
24 | 24 | */ |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/facture/modules_facture.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; |
|
26 | 26 | |
27 | 27 | /** \class mod_facture_terre |
28 | 28 | * \brief Classe du modele de numerotation de reference de facture Terre |
@@ -33,18 +33,18 @@ discard block |
||
33 | 33 | * Dolibarr version of the loaded document |
34 | 34 | * @public string |
35 | 35 | */ |
36 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
36 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | 37 | |
38 | - public $prefixinvoice='FA'; |
|
38 | + public $prefixinvoice = 'FA'; |
|
39 | 39 | |
40 | - public $prefixcreditnote='AV'; |
|
40 | + public $prefixcreditnote = 'AV'; |
|
41 | 41 | |
42 | - public $prefixdeposit='AC'; |
|
42 | + public $prefixdeposit = 'AC'; |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @var string Error code (or message) |
46 | 46 | */ |
47 | - public $error=''; |
|
47 | + public $error = ''; |
|
48 | 48 | |
49 | 49 | |
50 | 50 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | function __construct() |
54 | 54 | { |
55 | - if (! empty($conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX)) |
|
55 | + if (!empty($conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX)) |
|
56 | 56 | { |
57 | 57 | $this->prefixinvoice = $conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX; |
58 | 58 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | global $langs; |
69 | 69 | $langs->load("bills"); |
70 | - return $langs->trans('TerreNumRefModelDesc1',$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit); |
|
70 | + return $langs->trans('TerreNumRefModelDesc1', $this->prefixinvoice, $this->prefixcreditnote, $this->prefixdeposit); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -88,71 +88,71 @@ discard block |
||
88 | 88 | */ |
89 | 89 | function canBeActivated() |
90 | 90 | { |
91 | - global $langs,$conf,$db; |
|
91 | + global $langs, $conf, $db; |
|
92 | 92 | |
93 | 93 | $langs->load("bills"); |
94 | 94 | |
95 | 95 | // Check invoice num |
96 | - $fayymm=''; $max=''; |
|
96 | + $fayymm = ''; $max = ''; |
|
97 | 97 | |
98 | - $posindice=8; |
|
99 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
100 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture"; |
|
101 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'"; |
|
102 | - $sql.= " AND entity = ".$conf->entity; |
|
98 | + $posindice = 8; |
|
99 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
100 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture"; |
|
101 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'"; |
|
102 | + $sql .= " AND entity = ".$conf->entity; |
|
103 | 103 | |
104 | - $resql=$db->query($sql); |
|
104 | + $resql = $db->query($sql); |
|
105 | 105 | if ($resql) |
106 | 106 | { |
107 | 107 | $row = $db->fetch_row($resql); |
108 | - if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; } |
|
108 | + if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
109 | 109 | } |
110 | - if ($fayymm && ! preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i',$fayymm)) |
|
110 | + if ($fayymm && !preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i', $fayymm)) |
|
111 | 111 | { |
112 | 112 | $langs->load("errors"); |
113 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
113 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | |
117 | 117 | // Check credit note num |
118 | - $fayymm=''; |
|
118 | + $fayymm = ''; |
|
119 | 119 | |
120 | - $posindice=8; |
|
121 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
122 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture"; |
|
123 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'"; |
|
124 | - $sql.= " AND entity = ".$conf->entity; |
|
120 | + $posindice = 8; |
|
121 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
122 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture"; |
|
123 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'"; |
|
124 | + $sql .= " AND entity = ".$conf->entity; |
|
125 | 125 | |
126 | - $resql=$db->query($sql); |
|
126 | + $resql = $db->query($sql); |
|
127 | 127 | if ($resql) |
128 | 128 | { |
129 | 129 | $row = $db->fetch_row($resql); |
130 | - if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; } |
|
130 | + if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
131 | 131 | } |
132 | - if ($fayymm && ! preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i',$fayymm)) |
|
132 | + if ($fayymm && !preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i', $fayymm)) |
|
133 | 133 | { |
134 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
134 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
135 | 135 | return false; |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Check deposit num |
139 | - $fayymm=''; |
|
139 | + $fayymm = ''; |
|
140 | 140 | |
141 | - $posindice=8; |
|
142 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
143 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture"; |
|
144 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'"; |
|
145 | - $sql.= " AND entity = ".$conf->entity; |
|
141 | + $posindice = 8; |
|
142 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
143 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture"; |
|
144 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'"; |
|
145 | + $sql .= " AND entity = ".$conf->entity; |
|
146 | 146 | |
147 | - $resql=$db->query($sql); |
|
147 | + $resql = $db->query($sql); |
|
148 | 148 | if ($resql) |
149 | 149 | { |
150 | 150 | $row = $db->fetch_row($resql); |
151 | - if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; } |
|
151 | + if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
152 | 152 | } |
153 | - if ($fayymm && ! preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i',$fayymm)) |
|
153 | + if ($fayymm && !preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i', $fayymm)) |
|
154 | 154 | { |
155 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
155 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | |
@@ -167,28 +167,28 @@ discard block |
||
167 | 167 | * @param string $mode 'next' for next value or 'last' for last value |
168 | 168 | * @return string Value |
169 | 169 | */ |
170 | - function getNextValue($objsoc, $invoice, $mode='next') |
|
170 | + function getNextValue($objsoc, $invoice, $mode = 'next') |
|
171 | 171 | { |
172 | 172 | global $db; |
173 | 173 | |
174 | - if ($invoice->type == 2) $prefix=$this->prefixcreditnote; |
|
175 | - else if ($invoice->type == 3) $prefix=$this->prefixdeposit; |
|
176 | - else $prefix=$this->prefixinvoice; |
|
174 | + if ($invoice->type == 2) $prefix = $this->prefixcreditnote; |
|
175 | + else if ($invoice->type == 3) $prefix = $this->prefixdeposit; |
|
176 | + else $prefix = $this->prefixinvoice; |
|
177 | 177 | |
178 | 178 | // D'abord on recupere la valeur max |
179 | - $posindice=8; |
|
180 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
181 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture"; |
|
182 | - $sql.= " WHERE ref LIKE '".$prefix."____-%'"; |
|
183 | - $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; |
|
179 | + $posindice = 8; |
|
180 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
181 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture"; |
|
182 | + $sql .= " WHERE ref LIKE '".$prefix."____-%'"; |
|
183 | + $sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; |
|
184 | 184 | |
185 | - $resql=$db->query($sql); |
|
185 | + $resql = $db->query($sql); |
|
186 | 186 | dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
187 | 187 | if ($resql) |
188 | 188 | { |
189 | 189 | $obj = $db->fetch_object($resql); |
190 | 190 | if ($obj) $max = intval($obj->max); |
191 | - else $max=0; |
|
191 | + else $max = 0; |
|
192 | 192 | } |
193 | 193 | else |
194 | 194 | { |
@@ -197,17 +197,17 @@ discard block |
||
197 | 197 | |
198 | 198 | if ($mode == 'last') |
199 | 199 | { |
200 | - if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
201 | - else $num = sprintf("%04s",$max); |
|
200 | + if ($max >= (pow(10, 4) - 1)) $num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
201 | + else $num = sprintf("%04s", $max); |
|
202 | 202 | |
203 | - $ref=''; |
|
203 | + $ref = ''; |
|
204 | 204 | $sql = "SELECT ref as ref"; |
205 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture"; |
|
206 | - $sql.= " WHERE ref LIKE '".$prefix."____-".$num."'"; |
|
207 | - $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; |
|
205 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture"; |
|
206 | + $sql .= " WHERE ref LIKE '".$prefix."____-".$num."'"; |
|
207 | + $sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; |
|
208 | 208 | |
209 | 209 | dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
210 | - $resql=$db->query($sql); |
|
210 | + $resql = $db->query($sql); |
|
211 | 211 | if ($resql) |
212 | 212 | { |
213 | 213 | $obj = $db->fetch_object($resql); |
@@ -219,16 +219,16 @@ discard block |
||
219 | 219 | } |
220 | 220 | else if ($mode == 'next') |
221 | 221 | { |
222 | - $date=$invoice->date; // This is invoice date (not creation date) |
|
223 | - $yymm = strftime("%y%m",$date); |
|
222 | + $date = $invoice->date; // This is invoice date (not creation date) |
|
223 | + $yymm = strftime("%y%m", $date); |
|
224 | 224 | |
225 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
226 | - else $num = sprintf("%04s",$max+1); |
|
225 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
226 | + else $num = sprintf("%04s", $max + 1); |
|
227 | 227 | |
228 | 228 | dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
229 | 229 | return $prefix.$yymm."-".$num; |
230 | 230 | } |
231 | - else dol_print_error('','Bad parameter for getNextValue'); |
|
231 | + else dol_print_error('', 'Bad parameter for getNextValue'); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | * @param string $mode 'next' for next value or 'last' for last value |
240 | 240 | * @return string Next free value |
241 | 241 | */ |
242 | - function getNumRef($objsoc,$objforref,$mode='next') |
|
242 | + function getNumRef($objsoc, $objforref, $mode = 'next') |
|
243 | 243 | { |
244 | - return $this->getNextValue($objsoc,$objforref,$mode); |
|
244 | + return $this->getNextValue($objsoc, $objforref, $mode); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \ingroup dav |
24 | 24 | * \brief Description and activation file for module dav |
25 | 25 | */ |
26 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
26 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function __construct($db) |
40 | 40 | { |
41 | - global $langs,$conf; |
|
41 | + global $langs, $conf; |
|
42 | 42 | |
43 | 43 | $this->db = $db; |
44 | 44 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); |
58 | 58 | |
59 | 59 | // Module label (no space allowed), used if translation string 'ModuledavName' not found (MyModue is name of module). |
60 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
60 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
61 | 61 | // Module description, used if translation string 'ModuledavDesc' not found (MyModue is name of module). |
62 | 62 | $this->description = "davDescription"; |
63 | 63 | // Used only if file README.md and README-LL.md not found. |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | // Name of image file used for this module. |
71 | 71 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
72 | 72 | // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' |
73 | - $this->picto='generic'; |
|
73 | + $this->picto = 'generic'; |
|
74 | 74 | |
75 | 75 | // Defined all module parts (triggers, login, substitutions, menus, css, etc...) |
76 | 76 | // for default path (eg: /dav/core/xxxxx) (0=disable, 1=enable) |
@@ -80,21 +80,21 @@ discard block |
||
80 | 80 | |
81 | 81 | // Data directories to create when module is enabled. |
82 | 82 | // Example: this->dirs = array("/dav/temp","/dav/subdir"); |
83 | - $this->dirs = array("/dav/temp","/dav/public","/dav/private"); |
|
83 | + $this->dirs = array("/dav/temp", "/dav/public", "/dav/private"); |
|
84 | 84 | |
85 | 85 | // Config pages. Put here list of php page, stored into dav/admin directory, to use to setup module. |
86 | 86 | $this->config_page_url = array("dav.php"); |
87 | 87 | |
88 | 88 | // Dependencies |
89 | - $this->hidden = false; // A condition to hide module |
|
90 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
91 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
92 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
89 | + $this->hidden = false; // A condition to hide module |
|
90 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
91 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
92 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
93 | 93 | $this->langfiles = array("admin"); |
94 | - $this->phpmin = array(5,6); // Minimum version of PHP required by module |
|
95 | - $this->need_dolibarr_version = array(7,0); // Minimum version of Dolibarr required by module |
|
96 | - $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) |
|
97 | - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) |
|
94 | + $this->phpmin = array(5, 6); // Minimum version of PHP required by module |
|
95 | + $this->need_dolibarr_version = array(7, 0); // Minimum version of Dolibarr required by module |
|
96 | + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) |
|
97 | + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) |
|
98 | 98 | //$this->automatic_activation = array('FR'=>'davWasAutomaticallyActivatedBecauseOfYourCountryChoice'); |
99 | 99 | //$this->always_enabled = true; // If true, can't be disabled |
100 | 100 | |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | ); |
109 | 109 | |
110 | 110 | |
111 | - if (! isset($conf->dav) || ! isset($conf->dav->enabled)) |
|
111 | + if (!isset($conf->dav) || !isset($conf->dav->enabled)) |
|
112 | 112 | { |
113 | - $conf->dav=new stdClass(); |
|
114 | - $conf->dav->enabled=0; |
|
113 | + $conf->dav = new stdClass(); |
|
114 | + $conf->dav->enabled = 0; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | |
147 | 147 | // Dictionaries |
148 | - $this->dictionaries=array(); |
|
148 | + $this->dictionaries = array(); |
|
149 | 149 | /* Example: |
150 | 150 | $this->dictionaries=array( |
151 | 151 | 'langs'=>'mylangfile@dav', |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | |
184 | 184 | // Permissions |
185 | - $this->rights = array(); // Permission array used by this module |
|
185 | + $this->rights = array(); // Permission array used by this module |
|
186 | 186 | |
187 | 187 | /* |
188 | 188 | $r=0; |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | */ |
209 | 209 | |
210 | 210 | // Main menu entries |
211 | - $this->menu = array(); // List of menus to add |
|
212 | - $r=0; |
|
211 | + $this->menu = array(); // List of menus to add |
|
212 | + $r = 0; |
|
213 | 213 | |
214 | 214 | // Add here entries to declare new menus |
215 | 215 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | |
260 | 260 | // Exports |
261 | - $r=1; |
|
261 | + $r = 1; |
|
262 | 262 | |
263 | 263 | /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ |
264 | 264 | /* |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @param string $options Options when enabling module ('', 'noboxes') |
288 | 288 | * @return int 1 if OK, 0 if KO |
289 | 289 | */ |
290 | - public function init($options='') |
|
290 | + public function init($options = '') |
|
291 | 291 | { |
292 | 292 | //$this->_load_tables('/dav/sql/'); |
293 | 293 |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | ); |
116 | 116 | |
117 | 117 | // Cronjobs |
118 | - $arraydate=dol_getdate(dol_now()); |
|
119 | - $datestart=dol_mktime(23, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); |
|
118 | + $arraydate = dol_getdate(dol_now()); |
|
119 | + $datestart = dol_mktime(23, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); |
|
120 | 120 | $this->cronjobs = array( |
121 | 121 | 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600 * 24, 'priority'=>50, 'status'=>1, 'test'=>'$conf->facture->enabled', 'datestart'=>$datestart), |
122 | 122 | ); |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone', |
278 | 278 | 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', |
279 | 279 | 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra', |
280 | - 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', |
|
280 | + 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', |
|
281 | 281 | 'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT", |
282 | 282 | 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'none.rest'=>'Rest', 'f.paye'=>"InvoicePaid", 'f.fk_statut'=>'InvoiceStatus', |
283 | 283 | 'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', |
@@ -305,23 +305,23 @@ discard block |
||
305 | 305 | $this->export_dependencies_array[$r] = array('payment'=>'p.rowid', 'none.rest'=>array('f.rowid', 'f.total_ttc')); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
306 | 306 | $keyforselect = 'facture'; $keyforelement = 'invoice'; $keyforaliasextra = 'extra'; |
307 | 307 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
308 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
309 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; |
|
310 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
311 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,'; |
|
312 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture as f'; |
|
313 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; |
|
314 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON f.fk_user_author = uc.rowid'; |
|
315 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON f.fk_user_valid = uv.rowid'; |
|
316 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_extrafields as extra ON f.rowid = extra.fk_object'; |
|
317 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; |
|
318 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON pf.fk_paiement = p.rowid'; |
|
319 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pt ON pt.id = p.fk_paiement'; |
|
320 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON b.rowid = p.fk_bank'; |
|
321 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account'; |
|
322 | - $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; |
|
323 | - $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('invoice').')'; |
|
324 | - if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
308 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
309 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s'; |
|
310 | + if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
311 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,'; |
|
312 | + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture as f'; |
|
313 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; |
|
314 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON f.fk_user_author = uc.rowid'; |
|
315 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON f.fk_user_valid = uv.rowid'; |
|
316 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_extrafields as extra ON f.rowid = extra.fk_object'; |
|
317 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; |
|
318 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON pf.fk_paiement = p.rowid'; |
|
319 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pt ON pt.id = p.fk_paiement'; |
|
320 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON b.rowid = p.fk_bank'; |
|
321 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account'; |
|
322 | + $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid'; |
|
323 | + $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')'; |
|
324 | + if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; |
|
325 | 325 | $r++; |
326 | 326 | } |
327 | 327 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * @var string Error code (or message) |
41 | 41 | */ |
42 | - public $error=''; |
|
42 | + public $error = ''; |
|
43 | 43 | |
44 | 44 | |
45 | 45 | /** |
@@ -59,17 +59,17 @@ discard block |
||
59 | 59 | * @param integer $maxfilenamelength Max length of value to show |
60 | 60 | * @return array List of drivers |
61 | 61 | */ |
62 | - static function listDrivers($db,$maxfilenamelength=0) |
|
62 | + static function listDrivers($db, $maxfilenamelength = 0) |
|
63 | 63 | { |
64 | 64 | global $conf; |
65 | 65 | |
66 | 66 | $type = 'printing'; |
67 | 67 | $list = array(); |
68 | 68 | |
69 | - $moduledir=DOL_DOCUMENT_ROOT."/core/modules/printing/"; |
|
70 | - $tmpfiles=dol_dir_list($moduledir,'all',0,'\modules.php','','name',SORT_ASC,0); |
|
71 | - foreach($tmpfiles as $record) { |
|
72 | - $list[$record['fullname']]=str_replace('.modules.php', '',$record['name']); |
|
69 | + $moduledir = DOL_DOCUMENT_ROOT."/core/modules/printing/"; |
|
70 | + $tmpfiles = dol_dir_list($moduledir, 'all', 0, '\modules.php', '', 'name', SORT_ASC, 0); |
|
71 | + foreach ($tmpfiles as $record) { |
|
72 | + $list[$record['fullname']] = str_replace('.modules.php', '', $record['name']); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return $list; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | global $langs; |
86 | 86 | $langs->load("printing"); |
87 | - $transstring="PrintingModuleDesc".$this->name; |
|
87 | + $transstring = "PrintingModuleDesc".$this->name; |
|
88 | 88 | if ($langs->trans($transstring) != $transstring) return $langs->trans($transstring); |
89 | 89 | else return $this->desc; |
90 | 90 | } |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | global $conf, $langs, $dolibarr_main_url_root; |
76 | 76 | |
77 | 77 | // Define $urlwithroot |
78 | - $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
79 | - $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
78 | + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); |
|
79 | + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
80 | 80 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
81 | 81 | |
82 | 82 | $this->db = $db; |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | $this->google_secret, |
101 | 101 | $urlwithroot.'/core/modules/oauth/google_oauthcallback.php' |
102 | 102 | ); |
103 | - $access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?'HasAccessToken':'NoAccessToken'); |
|
103 | + $access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE) ? 'HasAccessToken' : 'NoAccessToken'); |
|
104 | 104 | $serviceFactory = new \OAuth\ServiceFactory(); |
105 | 105 | $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); |
106 | - $token_ok=true; |
|
106 | + $token_ok = true; |
|
107 | 107 | try { |
108 | 108 | $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); |
109 | 109 | } catch (Exception $e) { |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | 'info'=>$access, |
138 | 138 | 'type'=>'info', |
139 | 139 | 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), |
140 | - 'delete'=>($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'') |
|
140 | + 'delete'=>($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE) ? $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp') : '') |
|
141 | 141 | ); |
142 | 142 | if ($token_ok) { |
143 | - $expiredat=''; |
|
143 | + $expiredat = ''; |
|
144 | 144 | |
145 | 145 | $refreshtoken = $token->getRefreshToken(); |
146 | 146 | |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | } |
157 | 157 | else |
158 | 158 | { |
159 | - $expiredat=dol_print_date($endoflife, "dayhour"); |
|
159 | + $expiredat = dol_print_date($endoflife, "dayhour"); |
|
160 | 160 | } |
161 | 161 | |
162 | - $this->conf[] = array('varname'=>'TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info'); |
|
163 | - $this->conf[] = array('varname'=>'TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info'); |
|
162 | + $this->conf[] = array('varname'=>'TOKEN_REFRESH', 'info'=>((!empty($refreshtoken)) ? 'Yes' : 'No'), 'type'=>'info'); |
|
163 | + $this->conf[] = array('varname'=>'TOKEN_EXPIRED', 'info'=>($expire ? 'Yes' : 'No'), 'type'=>'info'); |
|
164 | 164 | $this->conf[] = array('varname'=>'TOKEN_EXPIRE_AT', 'info'=>($expiredat), 'type'=>'info'); |
165 | 165 | } |
166 | 166 | /* |
@@ -190,37 +190,37 @@ discard block |
||
190 | 190 | $langs->load('printing'); |
191 | 191 | |
192 | 192 | $html = '<tr class="liste_titre">'; |
193 | - $html.= '<td>'.$langs->trans('GCP_Name').'</td>'; |
|
194 | - $html.= '<td>'.$langs->trans('GCP_displayName').'</td>'; |
|
195 | - $html.= '<td>'.$langs->trans('GCP_Id').'</td>'; |
|
196 | - $html.= '<td>'.$langs->trans('GCP_OwnerName').'</td>'; |
|
197 | - $html.= '<td>'.$langs->trans('GCP_State').'</td>'; |
|
198 | - $html.= '<td>'.$langs->trans('GCP_connectionStatus').'</td>'; |
|
199 | - $html.= '<td>'.$langs->trans('GCP_Type').'</td>'; |
|
200 | - $html.= '<td align="center">'.$langs->trans("Select").'</td>'; |
|
201 | - $html.= '</tr>'."\n"; |
|
193 | + $html .= '<td>'.$langs->trans('GCP_Name').'</td>'; |
|
194 | + $html .= '<td>'.$langs->trans('GCP_displayName').'</td>'; |
|
195 | + $html .= '<td>'.$langs->trans('GCP_Id').'</td>'; |
|
196 | + $html .= '<td>'.$langs->trans('GCP_OwnerName').'</td>'; |
|
197 | + $html .= '<td>'.$langs->trans('GCP_State').'</td>'; |
|
198 | + $html .= '<td>'.$langs->trans('GCP_connectionStatus').'</td>'; |
|
199 | + $html .= '<td>'.$langs->trans('GCP_Type').'</td>'; |
|
200 | + $html .= '<td align="center">'.$langs->trans("Select").'</td>'; |
|
201 | + $html .= '</tr>'."\n"; |
|
202 | 202 | $list = $this->getlistAvailablePrinters(); |
203 | 203 | //$html.= '<td><pre>'.print_r($list,true).'</pre></td>'; |
204 | 204 | foreach ($list['available'] as $printer_det) |
205 | 205 | { |
206 | - $html.= '<tr class="oddeven">'; |
|
207 | - $html.= '<td>'.$printer_det['name'].'</td>'; |
|
208 | - $html.= '<td>'.$printer_det['displayName'].'</td>'; |
|
209 | - $html.= '<td>'.$printer_det['id'].'</td>'; // id to identify printer to use |
|
210 | - $html.= '<td>'.$printer_det['ownerName'].'</td>'; |
|
211 | - $html.= '<td>'.$printer_det['status'].'</td>'; |
|
212 | - $html.= '<td>'.$langs->trans('STATE_'.$printer_det['connectionStatus']).'</td>'; |
|
213 | - $html.= '<td>'.$langs->trans('TYPE_'.$printer_det['type']).'</td>'; |
|
206 | + $html .= '<tr class="oddeven">'; |
|
207 | + $html .= '<td>'.$printer_det['name'].'</td>'; |
|
208 | + $html .= '<td>'.$printer_det['displayName'].'</td>'; |
|
209 | + $html .= '<td>'.$printer_det['id'].'</td>'; // id to identify printer to use |
|
210 | + $html .= '<td>'.$printer_det['ownerName'].'</td>'; |
|
211 | + $html .= '<td>'.$printer_det['status'].'</td>'; |
|
212 | + $html .= '<td>'.$langs->trans('STATE_'.$printer_det['connectionStatus']).'</td>'; |
|
213 | + $html .= '<td>'.$langs->trans('TYPE_'.$printer_det['type']).'</td>'; |
|
214 | 214 | // Defaut |
215 | - $html.= '<td align="center">'; |
|
215 | + $html .= '<td align="center">'; |
|
216 | 216 | if ($conf->global->PRINTING_GCP_DEFAULT == $printer_det['id']) |
217 | 217 | { |
218 | - $html.= img_picto($langs->trans("Default"),'on'); |
|
218 | + $html .= img_picto($langs->trans("Default"), 'on'); |
|
219 | 219 | } |
220 | 220 | else |
221 | - $html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTING_GCP_DEFAULT&driver=printgcp&value='.urlencode($printer_det['id']).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
222 | - $html.= '</td>'; |
|
223 | - $html.= '</tr>'."\n"; |
|
221 | + $html .= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTING_GCP_DEFAULT&driver=printgcp&value='.urlencode($printer_det['id']).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; |
|
222 | + $html .= '</td>'; |
|
223 | + $html .= '</tr>'."\n"; |
|
224 | 224 | } |
225 | 225 | $this->resprint = $html; |
226 | 226 | return $error; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | $serviceFactory = new \OAuth\ServiceFactory(); |
246 | 246 | $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); |
247 | 247 | // Check if we have auth token |
248 | - $token_ok=true; |
|
248 | + $token_ok = true; |
|
249 | 249 | try { |
250 | 250 | $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); |
251 | 251 | } catch (Exception $e) { |
@@ -275,18 +275,18 @@ discard block |
||
275 | 275 | $response = $apiService->request(self::PRINTERS_SEARCH_URL); |
276 | 276 | } catch (Exception $e) { |
277 | 277 | $this->errors[] = $e->getMessage(); |
278 | - print '<pre>'.print_r($e->getMessage(),true).'</pre>'; |
|
278 | + print '<pre>'.print_r($e->getMessage(), true).'</pre>'; |
|
279 | 279 | } |
280 | 280 | //print '<tr><td><pre>'.print_r($response, true).'</pre></td></tr>'; |
281 | 281 | $responsedata = json_decode($response, true); |
282 | 282 | $printers = $responsedata['printers']; |
283 | 283 | // Check if we have printers? |
284 | - if(count($printers)==0) { |
|
284 | + if (count($printers) == 0) { |
|
285 | 285 | // We dont have printers so return blank array |
286 | - $ret['available'] = array(); |
|
286 | + $ret['available'] = array(); |
|
287 | 287 | } else { |
288 | 288 | // We have printers so returns printers as array |
289 | - $ret['available'] = $printers; |
|
289 | + $ret['available'] = $printers; |
|
290 | 290 | } |
291 | 291 | return $ret; |
292 | 292 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @param string $subdir subdir for file |
300 | 300 | * @return int 0 if OK, >0 if KO |
301 | 301 | */ |
302 | - public function printFile($file, $module, $subdir='') |
|
302 | + public function printFile($file, $module, $subdir = '') |
|
303 | 303 | { |
304 | 304 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
305 | 305 | |
@@ -307,10 +307,10 @@ discard block |
||
307 | 307 | $error = 0; |
308 | 308 | |
309 | 309 | $fileprint = $conf->{$module}->dir_output; |
310 | - if ($subdir!='') { |
|
311 | - $fileprint.='/'.$subdir; |
|
310 | + if ($subdir != '') { |
|
311 | + $fileprint .= '/'.$subdir; |
|
312 | 312 | } |
313 | - $fileprint.='/'.$file; |
|
313 | + $fileprint .= '/'.$file; |
|
314 | 314 | $mimetype = dol_mimetype($fileprint); |
315 | 315 | // select printer uri for module order, propal,... |
316 | 316 | $sql = "SELECT rowid, printer_id, copy FROM ".MAIN_DB_PREFIX."printing WHERE module='".$module."' AND driver='printgcp' AND userid=".$user->id; |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | } |
325 | 325 | else |
326 | 326 | { |
327 | - if (! empty($conf->global->PRINTING_GCP_DEFAULT)) |
|
327 | + if (!empty($conf->global->PRINTING_GCP_DEFAULT)) |
|
328 | 328 | { |
329 | - $printer_id=$conf->global->PRINTING_GCP_DEFAULT; |
|
329 | + $printer_id = $conf->global->PRINTING_GCP_DEFAULT; |
|
330 | 330 | } |
331 | 331 | else |
332 | 332 | { |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | |
341 | 341 | $ret = $this->sendPrintToPrinter($printer_id, $file, $fileprint, $mimetype); |
342 | 342 | $this->error = 'PRINTGCP: '.$ret['errormessage']; |
343 | - if ($ret['status']!=1) { |
|
343 | + if ($ret['status'] != 1) { |
|
344 | 344 | $error++; |
345 | 345 | } |
346 | 346 | return $error; |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | public function sendPrintToPrinter($printerid, $printjobtitle, $filepath, $contenttype) |
359 | 359 | { |
360 | 360 | // Check if printer id |
361 | - if(empty($printerid)) { |
|
362 | - return array('status' =>0, 'errorcode' =>'','errormessage'=>'No provided printer ID'); |
|
361 | + if (empty($printerid)) { |
|
362 | + return array('status' =>0, 'errorcode' =>'', 'errormessage'=>'No provided printer ID'); |
|
363 | 363 | } |
364 | 364 | // Open the file which needs to be print |
365 | 365 | $handle = fopen($filepath, "rb"); |
366 | - if(!$handle) { |
|
367 | - return array('status' =>0, 'errorcode' =>'','errormessage'=>'Could not read the file.'); |
|
366 | + if (!$handle) { |
|
367 | + return array('status' =>0, 'errorcode' =>'', 'errormessage'=>'Could not read the file.'); |
|
368 | 368 | } |
369 | 369 | // Read file content |
370 | 370 | $contents = fread($handle, filesize($filepath)); |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); |
390 | 390 | |
391 | 391 | // Check if we have auth token and refresh it |
392 | - $token_ok=true; |
|
392 | + $token_ok = true; |
|
393 | 393 | try { |
394 | 394 | $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); |
395 | 395 | } catch (Exception $e) { |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | $serviceFactory = new \OAuth\ServiceFactory(); |
438 | 438 | $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); |
439 | 439 | // Check if we have auth token |
440 | - $token_ok=true; |
|
440 | + $token_ok = true; |
|
441 | 441 | try { |
442 | 442 | $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); |
443 | 443 | } catch (Exception $e) { |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | public $conf = array(); |
38 | 38 | public $host; |
39 | 39 | public $port; |
40 | - public $userid; /* user login */ |
|
40 | + public $userid; /* user login */ |
|
41 | 41 | public $user; |
42 | 42 | public $password; |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @var string Error code (or message) |
46 | 46 | */ |
47 | - public $error=''; |
|
47 | + public $error = ''; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @var string[] Error codes (or messages) |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | { |
67 | 67 | global $conf; |
68 | 68 | |
69 | - $this->db=$db; |
|
70 | - $this->host=$conf->global->PRINTIPP_HOST; |
|
71 | - $this->port=$conf->global->PRINTIPP_PORT; |
|
72 | - $this->user=$conf->global->PRINTIPP_USER; |
|
73 | - $this->password=$conf->global->PRINTIPP_PASSWORD; |
|
69 | + $this->db = $db; |
|
70 | + $this->host = $conf->global->PRINTIPP_HOST; |
|
71 | + $this->port = $conf->global->PRINTIPP_PORT; |
|
72 | + $this->user = $conf->global->PRINTIPP_USER; |
|
73 | + $this->password = $conf->global->PRINTIPP_PASSWORD; |
|
74 | 74 | $this->conf[] = array('varname'=>'PRINTIPP_HOST', 'required'=>1, 'example'=>'localhost', 'type'=>'text'); |
75 | 75 | $this->conf[] = array('varname'=>'PRINTIPP_PORT', 'required'=>1, 'example'=>'631', 'type'=>'text'); |
76 | 76 | $this->conf[] = array('varname'=>'PRINTIPP_USER', 'required'=>0, 'example'=>'', 'type'=>'text', 'moreattributes'=>'autocomplete="off"'); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return int 0 if OK, >0 if KO |
89 | 89 | */ |
90 | - public function printFile($file, $module, $subdir='') |
|
90 | + public function printFile($file, $module, $subdir = '') |
|
91 | 91 | { |
92 | 92 | global $conf, $user; |
93 | 93 | $error = 0; |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
96 | 96 | |
97 | 97 | $ipp = new CupsPrintIPP(); |
98 | - $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
98 | + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log', 'file', 3); // logging very verbose |
|
99 | 99 | $ipp->setHost($this->host); |
100 | 100 | $ipp->setPort($this->port); |
101 | - $ipp->setJobName($file,true); |
|
101 | + $ipp->setJobName($file, true); |
|
102 | 102 | $ipp->setUserName($this->userid); |
103 | - if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
103 | + if (!empty($this->user)) $ipp->setAuthentication($this->user, $this->password); |
|
104 | 104 | |
105 | 105 | // select printer uri for module order, propal,... |
106 | 106 | $sql = "SELECT rowid,printer_id,copy FROM ".MAIN_DB_PREFIX."printing WHERE module = '".$module."' AND driver = 'printipp' AND userid = ".$user->id; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | else |
116 | 116 | { |
117 | - if (! empty($conf->global->PRINTIPP_URI_DEFAULT)) |
|
117 | + if (!empty($conf->global->PRINTIPP_URI_DEFAULT)) |
|
118 | 118 | { |
119 | 119 | dol_syslog("Will use default printer conf->global->PRINTIPP_URI_DEFAULT = ".$conf->global->PRINTIPP_URI_DEFAULT); |
120 | 120 | $ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT); |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | |
133 | 133 | // Set number of copy |
134 | 134 | $ipp->setCopies($obj->copy); |
135 | - $fileprint=$conf->{$module}->dir_output; |
|
136 | - if ($subdir!='') $fileprint.='/'.$subdir; |
|
137 | - $fileprint.='/'.$file; |
|
135 | + $fileprint = $conf->{$module}->dir_output; |
|
136 | + if ($subdir != '') $fileprint .= '/'.$subdir; |
|
137 | + $fileprint .= '/'.$file; |
|
138 | 138 | $ipp->setData($fileprint); |
139 | 139 | try { |
140 | 140 | $ipp->printJob(); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $this->errors[] = $e->getMessage(); |
143 | 143 | $error++; |
144 | 144 | } |
145 | - if ($error==0) $this->errors[] = 'PRINTIPP: Job added'; |
|
145 | + if ($error == 0) $this->errors[] = 'PRINTIPP: Job added'; |
|
146 | 146 | |
147 | 147 | return $error; |
148 | 148 | } |
@@ -158,42 +158,42 @@ discard block |
||
158 | 158 | $error = 0; |
159 | 159 | |
160 | 160 | $html = '<tr class="liste_titre">'; |
161 | - $html.= '<td>'.$langs->trans('IPP_Uri').'</td>'; |
|
162 | - $html.= '<td>'.$langs->trans('IPP_Name').'</td>'; |
|
163 | - $html.= '<td>'.$langs->trans('IPP_State').'</td>'; |
|
164 | - $html.= '<td>'.$langs->trans('IPP_State_reason').'</td>'; |
|
165 | - $html.= '<td>'.$langs->trans('IPP_State_reason1').'</td>'; |
|
166 | - $html.= '<td>'.$langs->trans('IPP_BW').'</td>'; |
|
167 | - $html.= '<td>'.$langs->trans('IPP_Color').'</td>'; |
|
161 | + $html .= '<td>'.$langs->trans('IPP_Uri').'</td>'; |
|
162 | + $html .= '<td>'.$langs->trans('IPP_Name').'</td>'; |
|
163 | + $html .= '<td>'.$langs->trans('IPP_State').'</td>'; |
|
164 | + $html .= '<td>'.$langs->trans('IPP_State_reason').'</td>'; |
|
165 | + $html .= '<td>'.$langs->trans('IPP_State_reason1').'</td>'; |
|
166 | + $html .= '<td>'.$langs->trans('IPP_BW').'</td>'; |
|
167 | + $html .= '<td>'.$langs->trans('IPP_Color').'</td>'; |
|
168 | 168 | //$html.= '<td>'.$langs->trans('IPP_Device').'</td>'; |
169 | - $html.= '<td>'.$langs->trans('IPP_Media').'</td>'; |
|
170 | - $html.= '<td>'.$langs->trans('IPP_Supported').'</td>'; |
|
171 | - $html.= '<td align="center">'.$langs->trans("Select").'</td>'; |
|
172 | - $html.= "</tr>\n"; |
|
169 | + $html .= '<td>'.$langs->trans('IPP_Media').'</td>'; |
|
170 | + $html .= '<td>'.$langs->trans('IPP_Supported').'</td>'; |
|
171 | + $html .= '<td align="center">'.$langs->trans("Select").'</td>'; |
|
172 | + $html .= "</tr>\n"; |
|
173 | 173 | $list = $this->getlistAvailablePrinters(); |
174 | 174 | foreach ($list as $value) { |
175 | 175 | $printer_det = $this->getPrinterDetail($value); |
176 | - $html.= '<tr class="oddeven">'; |
|
177 | - $html.= '<td>'.$value.'</td>'; |
|
176 | + $html .= '<tr class="oddeven">'; |
|
177 | + $html .= '<td>'.$value.'</td>'; |
|
178 | 178 | //$html.= '<td><pre>'.print_r($printer_det,true).'</pre></td>'; |
179 | - $html.= '<td>'.$printer_det->printer_name->_value0.'</td>'; |
|
180 | - $html.= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state->_value0).'</td>'; |
|
181 | - $html.= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value0).'</td>'; |
|
182 | - $html.= '<td>'.(! empty($printer_det->printer_state_reasons->_value1)?$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value1):'').'</td>'; |
|
183 | - $html.= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value2).'</td>'; |
|
184 | - $html.= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value3).'</td>'; |
|
179 | + $html .= '<td>'.$printer_det->printer_name->_value0.'</td>'; |
|
180 | + $html .= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state->_value0).'</td>'; |
|
181 | + $html .= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value0).'</td>'; |
|
182 | + $html .= '<td>'.(!empty($printer_det->printer_state_reasons->_value1) ? $langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value1) : '').'</td>'; |
|
183 | + $html .= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value2).'</td>'; |
|
184 | + $html .= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value3).'</td>'; |
|
185 | 185 | //$html.= '<td>'.$printer_det->device_uri->_value0.'</td>'; |
186 | - $html.= '<td>'.$printer_det->media_default->_value0.'</td>'; |
|
187 | - $html.= '<td>'.$langs->trans('MEDIA_IPP_'.$printer_det->media_type_supported->_value1).'</td>'; |
|
186 | + $html .= '<td>'.$printer_det->media_default->_value0.'</td>'; |
|
187 | + $html .= '<td>'.$langs->trans('MEDIA_IPP_'.$printer_det->media_type_supported->_value1).'</td>'; |
|
188 | 188 | // Defaut |
189 | - $html.= '<td align="center">'; |
|
189 | + $html .= '<td align="center">'; |
|
190 | 190 | if ($conf->global->PRINTIPP_URI_DEFAULT == $value) { |
191 | - $html.= img_picto($langs->trans("Default"),'on'); |
|
191 | + $html .= img_picto($langs->trans("Default"), 'on'); |
|
192 | 192 | } else { |
193 | - $html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTIPP_URI_DEFAULT&driver=printipp&value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
193 | + $html .= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTIPP_URI_DEFAULT&driver=printipp&value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; |
|
194 | 194 | } |
195 | - $html.= '</td>'; |
|
196 | - $html.= '</tr>'."\n"; |
|
195 | + $html .= '</td>'; |
|
196 | + $html .= '</tr>'."\n"; |
|
197 | 197 | } |
198 | 198 | $this->resprint = $html; |
199 | 199 | return $error; |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | global $conf, $db; |
210 | 210 | include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
211 | 211 | $ipp = new CupsPrintIPP(); |
212 | - $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
212 | + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log', 'file', 3); // logging very verbose |
|
213 | 213 | $ipp->setHost($this->host); |
214 | 214 | $ipp->setPort($this->port); |
215 | 215 | $ipp->setUserName($this->userid); |
216 | - if (! empty($this->user)) { |
|
216 | + if (!empty($this->user)) { |
|
217 | 217 | $ipp->setAuthentication($this->user, $this->password); |
218 | 218 | } |
219 | 219 | $ipp->getPrinters(); |
@@ -228,15 +228,15 @@ discard block |
||
228 | 228 | */ |
229 | 229 | private function getPrinterDetail($uri) |
230 | 230 | { |
231 | - global $conf,$db; |
|
231 | + global $conf, $db; |
|
232 | 232 | |
233 | 233 | include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
234 | 234 | $ipp = new CupsPrintIPP(); |
235 | - $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
235 | + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log', 'file', 3); // logging very verbose |
|
236 | 236 | $ipp->setHost($this->host); |
237 | 237 | $ipp->setPort($this->port); |
238 | 238 | $ipp->setUserName($this->userid); |
239 | - if (! empty($this->user)) { |
|
239 | + if (!empty($this->user)) { |
|
240 | 240 | $ipp->setAuthentication($this->user, $this->password); |
241 | 241 | } |
242 | 242 | $ipp->setPrinterURI($uri); |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | $html = ''; |
259 | 259 | include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
260 | 260 | $ipp = new CupsPrintIPP(); |
261 | - $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
261 | + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log', 'file', 3); // logging very verbose |
|
262 | 262 | $ipp->setHost($this->host); |
263 | 263 | $ipp->setPort($this->port); |
264 | 264 | $ipp->setUserName($this->userid); |
265 | - if (! empty($this->user)) { |
|
266 | - $ipp->setAuthentication($this->user,$this->password); |
|
265 | + if (!empty($this->user)) { |
|
266 | + $ipp->setAuthentication($this->user, $this->password); |
|
267 | 267 | } |
268 | 268 | // select printer uri for module order, propal,... |
269 | 269 | $sql = 'SELECT rowid,printer_uri,printer_name FROM '.MAIN_DB_PREFIX.'printer_ipp WHERE module="'.$module.'"'; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | } |
280 | 280 | // Getting Jobs |
281 | 281 | try { |
282 | - $ipp->getJobs(false,0,'completed',false); |
|
282 | + $ipp->getJobs(false, 0, 'completed', false); |
|
283 | 283 | } catch (Exception $e) { |
284 | 284 | $this->errors[] = $e->getMessage(); |
285 | 285 | $error++; |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | $jobs = $ipp->jobs_attributes; |
297 | 297 | |
298 | 298 | //$html .= '<pre>'.print_r($jobs,true).'</pre>'; |
299 | - foreach ($jobs as $value ) { |
|
299 | + foreach ($jobs as $value) { |
|
300 | 300 | $html .= '<tr class="oddeven">'; |
301 | 301 | $html .= '<td>'.$value->job_id->_value0.'</td>'; |
302 | 302 | $html .= '<td>'.$value->job_originating_user_name->_value0.'</td>'; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * \ingroup produit |
30 | 30 | * \brief File to describe module to manage catalog of predefined products |
31 | 31 | */ |
32 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
32 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
33 | 33 | |
34 | 34 | |
35 | 35 | /** |
@@ -52,32 +52,32 @@ discard block |
||
52 | 52 | $this->family = "products"; |
53 | 53 | $this->module_position = '20'; |
54 | 54 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
55 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
56 | 56 | $this->description = "Product management"; |
57 | 57 | |
58 | 58 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
59 | 59 | $this->version = 'dolibarr'; |
60 | 60 | |
61 | 61 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
62 | - $this->picto='product'; |
|
62 | + $this->picto = 'product'; |
|
63 | 63 | |
64 | 64 | // Data directories to create when module is enabled |
65 | 65 | $this->dirs = array("/product/temp"); |
66 | 66 | |
67 | 67 | // Dependencies |
68 | - $this->hidden = false; // A condition to hide module |
|
69 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
70 | - $this->requiredby = array("modStock","modBarcode","modProductBatch"); // List of module ids to disable if this one is disabled |
|
71 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
72 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
68 | + $this->hidden = false; // A condition to hide module |
|
69 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
70 | + $this->requiredby = array("modStock", "modBarcode", "modProductBatch"); // List of module ids to disable if this one is disabled |
|
71 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
72 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
73 | 73 | |
74 | 74 | // Config pages |
75 | 75 | $this->config_page_url = array("product.php@product"); |
76 | - $this->langfiles = array("products","companies","stocks","bills"); |
|
76 | + $this->langfiles = array("products", "companies", "stocks", "bills"); |
|
77 | 77 | |
78 | 78 | // Constants |
79 | 79 | $this->const = array(); |
80 | - $r=0; |
|
80 | + $r = 0; |
|
81 | 81 | |
82 | 82 | $this->const[$r][0] = "PRODUCT_CODEPRODUCT_ADDON"; |
83 | 83 | $this->const[$r][1] = "chaine"; |
@@ -95,15 +95,15 @@ discard block |
||
95 | 95 | |
96 | 96 | // Boxes |
97 | 97 | $this->boxes = array( |
98 | - 0=>array('file'=>'box_produits.php','enabledbydefaulton'=>'Home'), |
|
99 | - 1=>array('file'=>'box_produits_alerte_stock.php','enabledbydefaulton'=>''), |
|
100 | - 2=>array('file'=>'box_graph_product_distribution.php','enabledbydefaulton'=>'Home') |
|
98 | + 0=>array('file'=>'box_produits.php', 'enabledbydefaulton'=>'Home'), |
|
99 | + 1=>array('file'=>'box_produits_alerte_stock.php', 'enabledbydefaulton'=>''), |
|
100 | + 2=>array('file'=>'box_graph_product_distribution.php', 'enabledbydefaulton'=>'Home') |
|
101 | 101 | ); |
102 | 102 | |
103 | 103 | // Permissions |
104 | 104 | $this->rights = array(); |
105 | 105 | $this->rights_class = 'produit'; |
106 | - $r=0; |
|
106 | + $r = 0; |
|
107 | 107 | |
108 | 108 | $this->rights[$r][0] = 31; // id de la permission |
109 | 109 | $this->rights[$r][1] = 'Read products'; // libelle de la permission |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $this->rights[$r][4] = 'supprimer'; |
127 | 127 | $r++; |
128 | 128 | |
129 | - $this->rights[$r][0] = 38; // Must be same permission than in service module |
|
129 | + $this->rights[$r][0] = 38; // Must be same permission than in service module |
|
130 | 130 | $this->rights[$r][1] = 'Export products'; |
131 | 131 | $this->rights[$r][2] = 'r'; |
132 | 132 | $this->rights[$r][3] = 0; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | // Menus |
144 | 144 | //------- |
145 | 145 | |
146 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
146 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
147 | 147 | /* We can't enable this here because it must be enabled in both product and service module and this create duplicate insert |
148 | 148 | $r=0; |
149 | 149 | $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
@@ -161,259 +161,259 @@ discard block |
||
161 | 161 | |
162 | 162 | // Exports |
163 | 163 | //-------- |
164 | - $r=0; |
|
164 | + $r = 0; |
|
165 | 165 | |
166 | 166 | $r++; |
167 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
168 | - $this->export_label[$r]="Products"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
169 | - $this->export_permission[$r]=array(array("produit","export")); |
|
170 | - $this->export_fields_array[$r]=array( |
|
171 | - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode", |
|
172 | - 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface", |
|
173 | - 'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC", |
|
174 | - 'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' |
|
167 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
168 | + $this->export_label[$r] = "Products"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
169 | + $this->export_permission[$r] = array(array("produit", "export")); |
|
170 | + $this->export_fields_array[$r] = array( |
|
171 | + 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.accountancy_code_sell'=>"ProductAccountancySellCode", |
|
172 | + 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.note'=>"Note", 'p.length'=>"Length", 'p.width'=>"Width", 'p.height'=>"Height", 'p.surface'=>"Surface", |
|
173 | + 'p.volume'=>"Volume", 'p.weight'=>"Weight", 'p.customcode'=>'CustomCode', 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", |
|
174 | + 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' |
|
175 | 175 | ); |
176 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; |
|
177 | - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
178 | - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
179 | - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.cost_price'=>'CostPrice')); |
|
180 | - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; |
|
176 | + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; |
|
177 | + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); |
|
178 | + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); |
|
179 | + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); |
|
180 | + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; |
|
181 | 181 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
182 | - if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin','pf.unitprice'=>'BuyingPrice','pf.delivery_time_days'=>'NbDaysToDelivery')); |
|
183 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('group_concat(cat.label)'=>'Categories')); |
|
184 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); |
|
185 | - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
186 | - $this->export_TypeFields_array[$r]=array( |
|
187 | - 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", |
|
188 | - 'p.note'=>"Text",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric", |
|
189 | - 'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean", |
|
190 | - 'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date' |
|
182 | + if (!empty($conf->fournisseur->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery')); |
|
183 | + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); |
|
184 | + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription', 'l.note'=>'TranslatedNote')); |
|
185 | + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
186 | + $this->export_TypeFields_array[$r] = array( |
|
187 | + 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_buy'=>"Text", |
|
188 | + 'p.note'=>"Text", 'p.length'=>"Numeric", 'p.width'=>"Numeric", 'p.height'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.weight'=>"Numeric", |
|
189 | + 'p.customcode'=>'Text', 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", |
|
190 | + 'p.tobuy'=>"Boolean", 'p.datec'=>'Date', 'p.tms'=>'Date' |
|
191 | 191 | ); |
192 | - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); |
|
193 | - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); |
|
194 | - if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric','pf.delivery_time_days'=>'Numeric')); |
|
195 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); |
|
196 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array("group_concat(cat.label)"=>'Text')); |
|
197 | - $this->export_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
198 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array("group_concat(cat.label)"=>'category')); |
|
199 | - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'product','p.pmp'=>'product')); |
|
200 | - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'product')); |
|
201 | - if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); |
|
202 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); |
|
203 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); |
|
204 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
205 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
206 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; |
|
207 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; |
|
208 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; |
|
209 | - if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; |
|
210 | - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
211 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] =' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" |
|
212 | - |
|
213 | - if (! empty($conf->global->PRODUIT_MULTIPRICES)) |
|
192 | + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); |
|
193 | + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); |
|
194 | + if (!empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric')); |
|
195 | + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text', 'l.description'=>'Text', 'l.note'=>'Text')); |
|
196 | + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text')); |
|
197 | + $this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
198 | + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); |
|
199 | + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product')); |
|
200 | + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); |
|
201 | + if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); |
|
202 | + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation')); |
|
203 | + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid'); |
|
204 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
205 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
206 | + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; |
|
207 | + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; |
|
208 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; |
|
209 | + if (!empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; |
|
210 | + $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
211 | + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" |
|
212 | + |
|
213 | + if (!empty($conf->global->PRODUIT_MULTIPRICES)) |
|
214 | 214 | { |
215 | 215 | // Exports product multiprice |
216 | 216 | $r++; |
217 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
218 | - $this->export_label[$r]="ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
219 | - $this->export_permission[$r]=array(array("produit","export")); |
|
220 | - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", |
|
221 | - 'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel", |
|
222 | - 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", |
|
223 | - 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", |
|
217 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
218 | + $this->export_label[$r] = "ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
219 | + $this->export_permission[$r] = array(array("produit", "export")); |
|
220 | + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", |
|
221 | + 'pr.price_base_type'=>"PriceLevelPriceBase", 'pr.price_level'=>"PriceLevel", |
|
222 | + 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", |
|
223 | + 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", |
|
224 | 224 | 'pr.tva_tx'=>'PriceLevelVATRate', |
225 | 225 | 'pr.date_price'=>'DateCreation'); |
226 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; |
|
226 | + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; |
|
227 | 227 | //$this->export_TypeFields_array[$r]=array( |
228 | 228 | // 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", |
229 | 229 | // 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', |
230 | 230 | // 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", |
231 | 231 | // 'p.datec'=>'Date','p.tms'=>'Date' |
232 | 232 | //); |
233 | - $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", |
|
234 | - 'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product", |
|
233 | + $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", |
|
234 | + 'pr.price_base_type'=>"product", 'pr.price_level'=>"product", 'pr.price'=>"product", |
|
235 | 235 | 'pr.price_ttc'=>"product", |
236 | - 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", |
|
236 | + 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", |
|
237 | 237 | 'pr.tva_tx'=>'product', |
238 | 238 | 'pr.recuperableonly'=>'product', |
239 | 239 | 'pr.date_price'=>"product"); |
240 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
241 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
242 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity |
|
243 | - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
240 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
241 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
242 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity |
|
243 | + $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
244 | 244 | } |
245 | 245 | |
246 | - if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) |
|
246 | + if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) |
|
247 | 247 | { |
248 | 248 | // Exports virtual products |
249 | 249 | $r++; |
250 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
251 | - $this->export_label[$r]="AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
252 | - $this->export_permission[$r]=array(array("produit","export")); |
|
253 | - $this->export_fields_array[$r]=array( |
|
254 | - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", |
|
255 | - 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note", |
|
256 | - 'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode', |
|
257 | - 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell", |
|
258 | - 'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' |
|
250 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
251 | + $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
252 | + $this->export_permission[$r] = array(array("produit", "export")); |
|
253 | + $this->export_fields_array[$r] = array( |
|
254 | + 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", |
|
255 | + 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.note'=>"Note", |
|
256 | + 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.weight'=>"Weight", 'p.customcode'=>'CustomCode', |
|
257 | + 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", |
|
258 | + 'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' |
|
259 | 259 | ); |
260 | - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
261 | - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
262 | - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); |
|
263 | - $this->export_TypeFields_array[$r]=array( |
|
264 | - 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", |
|
265 | - 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', |
|
266 | - 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", |
|
267 | - 'p.datec'=>'Date','p.tms'=>'Date' |
|
260 | + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); |
|
261 | + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); |
|
262 | + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); |
|
263 | + $this->export_TypeFields_array[$r] = array( |
|
264 | + 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_buy'=>"Text", |
|
265 | + 'p.note'=>"Text", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.weight'=>"Numeric", 'p.customcode'=>'Text', |
|
266 | + 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", |
|
267 | + 'p.datec'=>'Date', 'p.tms'=>'Date' |
|
268 | 268 | ); |
269 | - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); |
|
270 | - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); |
|
271 | - $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('pa.qty'=>'Numeric')); |
|
272 | - $this->export_entities_array[$r]=array( |
|
273 | - 'p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct", |
|
274 | - 'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct", |
|
275 | - 'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct', |
|
276 | - 'p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct", |
|
277 | - 'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct" |
|
269 | + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); |
|
270 | + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); |
|
271 | + $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); |
|
272 | + $this->export_entities_array[$r] = array( |
|
273 | + 'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", |
|
274 | + 'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_buy'=>'virtualproduct', 'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct", |
|
275 | + 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', |
|
276 | + 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", |
|
277 | + 'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct" |
|
278 | 278 | ); |
279 | - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); |
|
280 | - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'virtualproduct')); |
|
281 | - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('pa.qty'=>"subproduct",'pa.incdec'=>'subproduct')); |
|
282 | - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; |
|
279 | + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct')); |
|
280 | + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); |
|
281 | + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct')); |
|
282 | + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; |
|
283 | 283 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
284 | - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p2.rowid'=>"Id",'p2.ref'=>"Ref",'p2.label'=>"Label",'p2.description'=>"Description")); |
|
285 | - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p2.rowid'=>"subproduct",'p2.ref'=>"subproduct",'p2.label'=>"subproduct",'p2.description'=>"subproduct")); |
|
286 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
287 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
288 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; |
|
289 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; |
|
290 | - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
291 | - $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; |
|
284 | + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description")); |
|
285 | + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); |
|
286 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
287 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
288 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; |
|
289 | + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; |
|
290 | + $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
291 | + $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | // Imports |
295 | 295 | //-------- |
296 | - $r=0; |
|
296 | + $r = 0; |
|
297 | 297 | |
298 | 298 | $r++; |
299 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
300 | - $this->import_label[$r]="Products"; // Translation key |
|
301 | - $this->import_icon[$r]=$this->picto; |
|
302 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
303 | - $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); |
|
304 | - $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id |
|
305 | - $this->import_fields_array[$r]=array( |
|
306 | - 'p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode", |
|
307 | - 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume", |
|
308 | - 'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC", |
|
309 | - 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation' |
|
299 | + $this->import_code[$r] = $this->rights_class.'_'.$r; |
|
300 | + $this->import_label[$r] = "Products"; // Translation key |
|
301 | + $this->import_icon[$r] = $this->picto; |
|
302 | + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
303 | + $this->import_tables_array[$r] = array('p'=>MAIN_DB_PREFIX.'product', 'extra'=>MAIN_DB_PREFIX.'product_extrafields'); |
|
304 | + $this->import_tables_creator_array[$r] = array('p'=>'fk_user_author'); // Fields to store import user id |
|
305 | + $this->import_fields_array[$r] = array( |
|
306 | + 'p.ref'=>"Ref*", 'p.label'=>"Label*", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.accountancy_code_sell'=>"ProductAccountancySellCode", |
|
307 | + 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.note'=>"Note", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", |
|
308 | + 'p.weight'=>"Weight", 'p.duration'=>"Duration", 'p.customcode'=>'CustomCode', 'p.price'=>"SellingPriceHT", 'p.price_ttc'=>"SellingPriceTTC", |
|
309 | + 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell*", 'p.tobuy'=>"OnBuy*", 'p.fk_product_type'=>"Type*", 'p.finished'=>'Nature', 'p.datec'=>'DateCreation' |
|
310 | 310 | ); |
311 | - if (! empty($conf->stock->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
312 | - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.cost_price'=>'CostPrice')); |
|
313 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.recuperableonly'=>'NPR')); |
|
314 | - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); |
|
315 | - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); |
|
316 | - if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
317 | - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
311 | + if (!empty($conf->stock->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); |
|
312 | + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); |
|
313 | + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); |
|
314 | + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); |
|
315 | + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); |
|
316 | + if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); |
|
317 | + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
318 | 318 | // Add extra fields |
319 | - $import_extrafield_sample=array(); |
|
320 | - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; |
|
321 | - $resql=$this->db->query($sql); |
|
319 | + $import_extrafield_sample = array(); |
|
320 | + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; |
|
321 | + $resql = $this->db->query($sql); |
|
322 | 322 | if ($resql) // This can fail when class is used on old database (during migration for example) |
323 | 323 | { |
324 | - while ($obj=$this->db->fetch_object($resql)) |
|
324 | + while ($obj = $this->db->fetch_object($resql)) |
|
325 | 325 | { |
326 | - $fieldname='extra.'.$obj->name; |
|
327 | - $fieldlabel=ucfirst($obj->label); |
|
328 | - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
329 | - $import_extrafield_sample[$fieldname]=$fieldlabel; |
|
326 | + $fieldname = 'extra.'.$obj->name; |
|
327 | + $fieldlabel = ucfirst($obj->label); |
|
328 | + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); |
|
329 | + $import_extrafield_sample[$fieldname] = $fieldlabel; |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | // End add extra fields |
333 | - $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
334 | - $this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.tosell'=>'^[0|1]$','p.tobuy'=>'^[0|1]$','p.fk_product_type'=>'^[0|1]$','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','p.recuperableonly'=>'^[0|1]$'); |
|
335 | - $import_sample=array('p.ref'=>"PREF123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31','p.recuperableonly'=>'0 or 1'); |
|
336 | - $this->import_examplevalues_array[$r]=array_merge($import_sample,$import_extrafield_sample); |
|
337 | - $this->import_updatekeys_array[$r]=array('p.ref'=>'Ref','p.barcode'=>'BarCode'); |
|
333 | + $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
334 | + $this->import_regex_array[$r] = array('p.ref'=>'[^ ]', 'p.tosell'=>'^[0|1]$', 'p.tobuy'=>'^[0|1]$', 'p.fk_product_type'=>'^[0|1]$', 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'p.recuperableonly'=>'^[0|1]$'); |
|
335 | + $import_sample = array('p.ref'=>"PREF123456", 'p.label'=>"My product", 'p.description'=>"This is a description example for record", 'p.note'=>"Some note", 'p.price'=>"100", 'p.price_ttc'=>"110", 'p.tva_tx'=>'10', 'p.tosell'=>"0 or 1", 'p.tobuy'=>"0 or 1", 'p.fk_product_type'=>"0 for product/1 for service", 'p.finished'=>'', 'p.duration'=>"1y", 'p.datec'=>'2008-12-31', 'p.recuperableonly'=>'0 or 1'); |
|
336 | + $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); |
|
337 | + $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref', 'p.barcode'=>'BarCode'); |
|
338 | 338 | |
339 | - if (! empty($conf->fournisseur->enabled)) |
|
339 | + if (!empty($conf->fournisseur->enabled)) |
|
340 | 340 | { |
341 | 341 | // Import suppliers prices (note: this code is duplicated into module service) |
342 | 342 | $r++; |
343 | - $this->import_code[$r]=$this->rights_class.'_supplierprices'; |
|
344 | - $this->import_label[$r]="SuppliersPricesOfProductsOrServices"; // Translation key |
|
345 | - $this->import_icon[$r]=$this->picto; |
|
346 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
347 | - $this->import_tables_array[$r]=array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); |
|
348 | - $this->import_tables_creator_array[$r]=array('sp'=>'fk_user'); |
|
349 | - $this->import_fields_array[$r]=array( |
|
343 | + $this->import_code[$r] = $this->rights_class.'_supplierprices'; |
|
344 | + $this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key |
|
345 | + $this->import_icon[$r] = $this->picto; |
|
346 | + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
347 | + $this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); |
|
348 | + $this->import_tables_creator_array[$r] = array('sp'=>'fk_user'); |
|
349 | + $this->import_fields_array[$r] = array( |
|
350 | 350 | 'sp.fk_product'=>"ProductOrService*", |
351 | 351 | 'sp.fk_soc'=>"Supplier*", 'sp.ref_fourn'=>'SupplierRef', 'sp.quantity'=>"QtyMin*", 'sp.tva_tx'=>'VATRate', 'sp.default_vat_code'=>'VATCode' |
352 | 352 | ); |
353 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'VATNPR')); |
|
354 | - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); |
|
355 | - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); |
|
356 | - $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array( |
|
353 | + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); |
|
354 | + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); |
|
355 | + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); |
|
356 | + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( |
|
357 | 357 | 'sp.price'=>"PriceQtyMinHT*", |
358 | - 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty |
|
358 | + 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty |
|
359 | 359 | 'sp.remise_percent'=>'DiscountQtyMin' |
360 | 360 | )); |
361 | - $this->import_convertvalue_array[$r]=array( |
|
362 | - 'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), |
|
363 | - 'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') |
|
361 | + $this->import_convertvalue_array[$r] = array( |
|
362 | + 'sp.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'), |
|
363 | + 'sp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') |
|
364 | 364 | ); |
365 | - $this->import_examplevalues_array[$r]=array('sp.fk_product'=>"PREF123456", |
|
366 | - 'sp.fk_soc'=>"My Supplier",'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21', |
|
365 | + $this->import_examplevalues_array[$r] = array('sp.fk_product'=>"PREF123456", |
|
366 | + 'sp.fk_soc'=>"My Supplier", 'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21', |
|
367 | 367 | 'sp.price'=>"50", |
368 | 368 | 'sp.unitprice'=>'50', |
369 | 369 | 'sp.remise_percent'=>'0' |
370 | 370 | ); |
371 | - $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier'); |
|
371 | + $this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier'); |
|
372 | 372 | } |
373 | 373 | |
374 | - if (! empty($conf->global->PRODUIT_MULTIPRICES)) |
|
374 | + if (!empty($conf->global->PRODUIT_MULTIPRICES)) |
|
375 | 375 | { |
376 | 376 | // Import product multiprice |
377 | 377 | $r++; |
378 | - $this->import_code[$r]=$this->rights_class.'_multiprice'; |
|
379 | - $this->import_label[$r]="ProductsOrServiceMultiPrice"; // Translation key |
|
380 | - $this->import_icon[$r]=$this->picto; |
|
381 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
382 | - $this->import_tables_array[$r]=array('pr'=>MAIN_DB_PREFIX.'product_price'); |
|
383 | - $this->import_tables_creator_array[$r]=array('pr'=>'fk_user_author'); // Fields to store import user id |
|
384 | - $this->import_fields_array[$r]=array('pr.fk_product'=>"ProductRowid*", |
|
385 | - 'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel", |
|
386 | - 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", |
|
387 | - 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", |
|
378 | + $this->import_code[$r] = $this->rights_class.'_multiprice'; |
|
379 | + $this->import_label[$r] = "ProductsOrServiceMultiPrice"; // Translation key |
|
380 | + $this->import_icon[$r] = $this->picto; |
|
381 | + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
382 | + $this->import_tables_array[$r] = array('pr'=>MAIN_DB_PREFIX.'product_price'); |
|
383 | + $this->import_tables_creator_array[$r] = array('pr'=>'fk_user_author'); // Fields to store import user id |
|
384 | + $this->import_fields_array[$r] = array('pr.fk_product'=>"ProductRowid*", |
|
385 | + 'pr.price_base_type'=>"PriceLevelPriceBase", 'pr.price_level'=>"PriceLevel", |
|
386 | + 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", |
|
387 | + 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", |
|
388 | 388 | 'pr.tva_tx'=>'PriceLevelVATRate', |
389 | 389 | 'pr.date_price'=>'DateCreation*'); |
390 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('pr.recuperableonly'=>'NPR')); |
|
391 | - $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','pr.recuperableonly'=>'^[0|1]$'); |
|
392 | - $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"1", |
|
393 | - 'pr.price_base_type'=>"HT",'pr.price_level'=>"1", |
|
394 | - 'pr.price'=>"100",'pr.price_ttc'=>"110", |
|
395 | - 'pr.price_min'=>"100",'pr.price_min_ttc'=>"110", |
|
390 | + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); |
|
391 | + $this->import_regex_array[$r] = array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'pr.recuperableonly'=>'^[0|1]$'); |
|
392 | + $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"1", |
|
393 | + 'pr.price_base_type'=>"HT", 'pr.price_level'=>"1", |
|
394 | + 'pr.price'=>"100", 'pr.price_ttc'=>"110", |
|
395 | + 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110", |
|
396 | 396 | 'pr.tva_tx'=>'20', |
397 | 397 | 'pr.recuperableonly'=>'0', |
398 | 398 | 'pr.date_price'=>'2013-04-10'); |
399 | 399 | } |
400 | 400 | |
401 | - if (! empty($conf->global->MAIN_MULTILANGS)) |
|
401 | + if (!empty($conf->global->MAIN_MULTILANGS)) |
|
402 | 402 | { |
403 | 403 | $r++; |
404 | - $this->import_code[$r]=$this->rights_class.'_languages'; |
|
405 | - $this->import_label[$r]="ProductsOrServicesTranslations"; |
|
406 | - $this->import_icon[$r]=$this->picto; |
|
407 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
408 | - $this->import_tables_array[$r]=array('l'=>MAIN_DB_PREFIX.'product_lang'); |
|
404 | + $this->import_code[$r] = $this->rights_class.'_languages'; |
|
405 | + $this->import_label[$r] = "ProductsOrServicesTranslations"; |
|
406 | + $this->import_icon[$r] = $this->picto; |
|
407 | + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
408 | + $this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang'); |
|
409 | 409 | // multiline translation, one line per translation |
410 | - $this->import_fields_array[$r]=array('l.fk_product'=>'Ref', 'l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); |
|
410 | + $this->import_fields_array[$r] = array('l.fk_product'=>'Ref', 'l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); |
|
411 | 411 | //$this->import_fields_array[$r]['l.note']='TranslatedNote'; |
412 | - $this->import_convertvalue_array[$r]=array( |
|
413 | - 'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') |
|
412 | + $this->import_convertvalue_array[$r] = array( |
|
413 | + 'l.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') |
|
414 | 414 | ); |
415 | - $this->import_examplevalues_array[$r]=array('l.fk_product'=>'MyProductRef','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US'); |
|
416 | - $this->import_updatekeys_array[$r]=array('l.fk_product'=>'Ref','l.lang'=>'Language'); |
|
415 | + $this->import_examplevalues_array[$r] = array('l.fk_product'=>'MyProductRef', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); |
|
416 | + $this->import_updatekeys_array[$r] = array('l.fk_product'=>'Ref', 'l.lang'=>'Language'); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
@@ -426,12 +426,12 @@ discard block |
||
426 | 426 | * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') |
427 | 427 | * @return int 1 if OK, 0 if KO |
428 | 428 | */ |
429 | - function init($options='') |
|
429 | + function init($options = '') |
|
430 | 430 | { |
431 | 431 | $this->remove($options); |
432 | 432 | |
433 | 433 | $sql = array(); |
434 | 434 | |
435 | - return $this->_init($sql,$options); |
|
435 | + return $this->_init($sql, $options); |
|
436 | 436 | } |
437 | 437 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @var string Error code (or message) |
28 | 28 | */ |
29 | - public $error=''; |
|
29 | + public $error = ''; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -37,16 +37,16 @@ discard block |
||
37 | 37 | * @param integer $maxfilenamelength Max length of value to show |
38 | 38 | * @return array List of templates |
39 | 39 | */ |
40 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
40 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
41 | 41 | { |
42 | 42 | // phpcs:enable |
43 | 43 | global $conf; |
44 | 44 | |
45 | - $type='stock'; |
|
46 | - $liste=array(); |
|
45 | + $type = 'stock'; |
|
46 | + $liste = array(); |
|
47 | 47 | |
48 | 48 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
49 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
49 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
50 | 50 | |
51 | 51 | return $liste; |
52 | 52 | } |