@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | // CHANGE THIS: Put here a description of your selector module. |
31 | 31 | // This label is used if no translation is found for key MailingModuleDescXXX where XXX=name is found |
32 | 32 | var $desc='Put here a description'; |
33 | - // CHANGE THIS: Set to 1 if selector is available for admin users only |
|
33 | + // CHANGE THIS: Set to 1 if selector is available for admin users only |
|
34 | 34 | var $require_admin=0; |
35 | 35 | // CHANGE THIS: Add a tooltip language key to add a tooltip help icon after the email target selector |
36 | 36 | var $tooltip='MyTooltipLangKey'; |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | |
46 | 46 | |
47 | 47 | // CHANGE THIS: Constructor name must be called mailing_xxx with xxx=name of your selector |
48 | - /** |
|
49 | - * Constructor |
|
50 | - * |
|
51 | - * @param DoliDB $db Database handler |
|
52 | - */ |
|
48 | + /** |
|
49 | + * Constructor |
|
50 | + * |
|
51 | + * @param DoliDB $db Database handler |
|
52 | + */ |
|
53 | 53 | function __construct($db) |
54 | 54 | { |
55 | 55 | $this->db=$db; |
@@ -68,38 +68,38 @@ discard block |
||
68 | 68 | // phpcs:enable |
69 | 69 | $target = array(); |
70 | 70 | |
71 | - // CHANGE THIS |
|
72 | - // ----- Your code start here ----- |
|
71 | + // CHANGE THIS |
|
72 | + // ----- Your code start here ----- |
|
73 | 73 | |
74 | - // You must fill the $target array with record like this |
|
75 | - // $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0', 'other'=>'other_0'); |
|
76 | - // ... |
|
77 | - // $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n', 'other'=>'other_n'); |
|
74 | + // You must fill the $target array with record like this |
|
75 | + // $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0', 'other'=>'other_0'); |
|
76 | + // ... |
|
77 | + // $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n', 'other'=>'other_n'); |
|
78 | 78 | |
79 | - // Example: $target[0]=array('email'=>'[email protected]', 'name'=>'Doe', 'firstname'=>'John', 'other'=>'Other information'); |
|
79 | + // Example: $target[0]=array('email'=>'[email protected]', 'name'=>'Doe', 'firstname'=>'John', 'other'=>'Other information'); |
|
80 | 80 | |
81 | - // ----- Your code end here ----- |
|
81 | + // ----- Your code end here ----- |
|
82 | 82 | |
83 | 83 | return parent::add_to_target($mailing_id, $target); |
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | 87 | /** |
88 | - * On the main mailing area, there is a box with statistics. |
|
89 | - * If you want to add a line in this report you must provide an |
|
90 | - * array of SQL request that returns two field: |
|
91 | - * One called "label", One called "nb". |
|
92 | - * |
|
93 | - * @return array Array with SQL requests |
|
94 | - */ |
|
95 | - function getSqlArrayForStats() |
|
96 | - { |
|
97 | - // CHANGE THIS: Optionnal |
|
98 | - |
|
99 | - //var $statssql=array(); |
|
88 | + * On the main mailing area, there is a box with statistics. |
|
89 | + * If you want to add a line in this report you must provide an |
|
90 | + * array of SQL request that returns two field: |
|
91 | + * One called "label", One called "nb". |
|
92 | + * |
|
93 | + * @return array Array with SQL requests |
|
94 | + */ |
|
95 | + function getSqlArrayForStats() |
|
96 | + { |
|
97 | + // CHANGE THIS: Optionnal |
|
98 | + |
|
99 | + //var $statssql=array(); |
|
100 | 100 | //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; |
101 | - return array(); |
|
102 | - } |
|
101 | + return array(); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | 105 | /** |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | class mailing_example extends MailingTargets |
27 | 27 | { |
28 | 28 | // CHANGE THIS: Put here a name not already used |
29 | - var $name='example'; |
|
29 | + var $name = 'example'; |
|
30 | 30 | // CHANGE THIS: Put here a description of your selector module. |
31 | 31 | // This label is used if no translation is found for key MailingModuleDescXXX where XXX=name is found |
32 | - var $desc='Put here a description'; |
|
32 | + var $desc = 'Put here a description'; |
|
33 | 33 | // CHANGE THIS: Set to 1 if selector is available for admin users only |
34 | - var $require_admin=0; |
|
34 | + var $require_admin = 0; |
|
35 | 35 | // CHANGE THIS: Add a tooltip language key to add a tooltip help icon after the email target selector |
36 | - var $tooltip='MyTooltipLangKey'; |
|
36 | + var $tooltip = 'MyTooltipLangKey'; |
|
37 | 37 | |
38 | - var $require_module=array(); |
|
39 | - var $picto=''; |
|
38 | + var $require_module = array(); |
|
39 | + var $picto = ''; |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @var DoliDB Database handler. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | function __construct($db) |
54 | 54 | { |
55 | - $this->db=$db; |
|
55 | + $this->db = $db; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param string $sql Requete sql de comptage |
111 | 111 | * @return int|string Number of recipient or '?' |
112 | 112 | */ |
113 | - function getNbOfRecipients($sql='') |
|
113 | + function getNbOfRecipients($sql = '') |
|
114 | 114 | { |
115 | 115 | // CHANGE THIS: Optionnal |
116 | 116 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | // CHANGE THIS: Optionnal |
131 | 131 | |
132 | - $s=''; |
|
132 | + $s = ''; |
|
133 | 133 | return $s; |
134 | 134 | } |
135 | 135 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | class mailing_thirdparties_services_expired extends MailingTargets |
24 | 24 | { |
25 | 25 | var $name='DolibarrContractsLinesExpired'; |
26 | - // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found |
|
26 | + // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found |
|
27 | 27 | var $desc='Third parties with expired contract\'s lines'; |
28 | 28 | var $require_admin=0; |
29 | 29 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | function __construct($db) |
47 | 47 | { |
48 | - global $conf; |
|
48 | + global $conf; |
|
49 | 49 | |
50 | 50 | $this->db=$db; |
51 | 51 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | $product=''; |
96 | 96 | if ($key == '0') |
97 | 97 | { |
98 | - $this->error = "Error: You must choose a filter"; |
|
99 | - $this->errors[] = $this->error; |
|
100 | - return $this->error; |
|
98 | + $this->error = "Error: You must choose a filter"; |
|
99 | + $this->errors[] = $this->error; |
|
100 | + return $this->error; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | $product=$this->arrayofproducts[$key]; |
@@ -131,17 +131,17 @@ discard block |
||
131 | 131 | if ($old <> $obj->email) |
132 | 132 | { |
133 | 133 | $cibles[$j] = array( |
134 | - 'email' => $obj->email, |
|
135 | - 'lastname' => $obj->name, // For thirdparties, lastname must be name |
|
134 | + 'email' => $obj->email, |
|
135 | + 'lastname' => $obj->name, // For thirdparties, lastname must be name |
|
136 | 136 | 'firstname' => '', // For thirdparties, firstname is '' |
137 | - 'other' => |
|
137 | + 'other' => |
|
138 | 138 | ('DateStart='.dol_print_date($this->db->jdate($obj->date_ouverture),'day')).';'. |
139 | 139 | ('DateEnd='.dol_print_date($this->db->jdate($obj->date_fin_validite),'day')).';'. |
140 | 140 | ('Contract='.$obj->fk_contrat).';'. |
141 | 141 | ('ContactLine='.$obj->cdid), |
142 | - 'source_url' => $this->url($obj->id), |
|
143 | - 'source_id' => $obj->id, |
|
144 | - 'source_type' => 'thirdparty' |
|
142 | + 'source_url' => $this->url($obj->id), |
|
143 | + 'source_id' => $obj->id, |
|
144 | + 'source_type' => 'thirdparty' |
|
145 | 145 | ); |
146 | 146 | $old = $obj->email; |
147 | 147 | $j++; |
@@ -22,20 +22,20 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class mailing_thirdparties_services_expired extends MailingTargets |
24 | 24 | { |
25 | - var $name='DolibarrContractsLinesExpired'; |
|
25 | + var $name = 'DolibarrContractsLinesExpired'; |
|
26 | 26 | // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found |
27 | - var $desc='Third parties with expired contract\'s lines'; |
|
28 | - var $require_admin=0; |
|
27 | + var $desc = 'Third parties with expired contract\'s lines'; |
|
28 | + var $require_admin = 0; |
|
29 | 29 | |
30 | - var $require_module=array('contrat'); |
|
31 | - var $picto='company'; |
|
30 | + var $require_module = array('contrat'); |
|
31 | + var $picto = 'company'; |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @var DoliDB Database handler. |
35 | 35 | */ |
36 | 36 | public $db; |
37 | 37 | |
38 | - var $arrayofproducts=array(); |
|
38 | + var $arrayofproducts = array(); |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | { |
48 | 48 | global $conf; |
49 | 49 | |
50 | - $this->db=$db; |
|
50 | + $this->db = $db; |
|
51 | 51 | |
52 | - $this->arrayofproducts=array(); |
|
52 | + $this->arrayofproducts = array(); |
|
53 | 53 | |
54 | 54 | // List of services |
55 | 55 | $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."product"; |
56 | - $sql.= " WHERE entity IN (".getEntity('product').")"; |
|
57 | - if (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $sql.= " AND fk_product_type = 1"; // By default, only services |
|
58 | - $sql.= " ORDER BY ref"; |
|
59 | - $result=$this->db->query($sql); |
|
56 | + $sql .= " WHERE entity IN (".getEntity('product').")"; |
|
57 | + if (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $sql .= " AND fk_product_type = 1"; // By default, only services |
|
58 | + $sql .= " ORDER BY ref"; |
|
59 | + $result = $this->db->query($sql); |
|
60 | 60 | if ($result) |
61 | 61 | { |
62 | 62 | $num = $this->db->num_rows($result); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $obj = $this->db->fetch_object($result); |
69 | 69 | $i++; |
70 | - $this->arrayofproducts[$i]=$obj->ref; |
|
70 | + $this->arrayofproducts[$i] = $obj->ref; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | else |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | function add_to_target($mailing_id) |
88 | 88 | { |
89 | 89 | // phpcs:enable |
90 | - $key=GETPOST('filter','int'); |
|
90 | + $key = GETPOST('filter', 'int'); |
|
91 | 91 | |
92 | 92 | $cibles = array(); |
93 | 93 | $j = 0; |
94 | 94 | |
95 | - $product=''; |
|
95 | + $product = ''; |
|
96 | 96 | if ($key == '0') |
97 | 97 | { |
98 | 98 | $this->error = "Error: You must choose a filter"; |
@@ -100,23 +100,23 @@ discard block |
||
100 | 100 | return $this->error; |
101 | 101 | } |
102 | 102 | |
103 | - $product=$this->arrayofproducts[$key]; |
|
103 | + $product = $this->arrayofproducts[$key]; |
|
104 | 104 | |
105 | - $now=dol_now(); |
|
105 | + $now = dol_now(); |
|
106 | 106 | |
107 | 107 | // La requete doit retourner: id, email, name |
108 | 108 | $sql = "SELECT s.rowid as id, s.email, s.nom as name, cd.rowid as cdid, cd.date_ouverture, cd.date_fin_validite, cd.fk_contrat"; |
109 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; |
|
110 | - $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."product as p"; |
|
111 | - $sql.= " WHERE s.entity IN (".getEntity('societe').")"; |
|
112 | - $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; |
|
113 | - $sql.= " AND s.rowid = c.fk_soc AND cd.fk_contrat = c.rowid AND s.email != ''"; |
|
114 | - $sql.= " AND cd.statut= 4 AND cd.fk_product=p.rowid AND p.ref = '".$product."'"; |
|
115 | - $sql.= " AND cd.date_fin_validite < '".$this->db->idate($now)."'"; |
|
116 | - $sql.= " ORDER BY s.email"; |
|
109 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; |
|
110 | + $sql .= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."product as p"; |
|
111 | + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; |
|
112 | + $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; |
|
113 | + $sql .= " AND s.rowid = c.fk_soc AND cd.fk_contrat = c.rowid AND s.email != ''"; |
|
114 | + $sql .= " AND cd.statut= 4 AND cd.fk_product=p.rowid AND p.ref = '".$product."'"; |
|
115 | + $sql .= " AND cd.date_fin_validite < '".$this->db->idate($now)."'"; |
|
116 | + $sql .= " ORDER BY s.email"; |
|
117 | 117 | |
118 | 118 | // Stocke destinataires dans cibles |
119 | - $result=$this->db->query($sql); |
|
119 | + $result = $this->db->query($sql); |
|
120 | 120 | if ($result) |
121 | 121 | { |
122 | 122 | $num = $this->db->num_rows($result); |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | { |
133 | 133 | $cibles[$j] = array( |
134 | 134 | 'email' => $obj->email, |
135 | - 'lastname' => $obj->name, // For thirdparties, lastname must be name |
|
136 | - 'firstname' => '', // For thirdparties, firstname is '' |
|
135 | + 'lastname' => $obj->name, // For thirdparties, lastname must be name |
|
136 | + 'firstname' => '', // For thirdparties, firstname is '' |
|
137 | 137 | 'other' => |
138 | - ('DateStart='.dol_print_date($this->db->jdate($obj->date_ouverture),'day')).';'. |
|
139 | - ('DateEnd='.dol_print_date($this->db->jdate($obj->date_fin_validite),'day')).';'. |
|
138 | + ('DateStart='.dol_print_date($this->db->jdate($obj->date_ouverture), 'day')).';'. |
|
139 | + ('DateEnd='.dol_print_date($this->db->jdate($obj->date_fin_validite), 'day')).';'. |
|
140 | 140 | ('Contract='.$obj->fk_contrat).';'. |
141 | 141 | ('ContactLine='.$obj->cdid), |
142 | 142 | 'source_url' => $this->url($obj->id), |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | else |
154 | 154 | { |
155 | 155 | dol_syslog($this->db->lasterror()); |
156 | - $this->error=$this->db->lasterror(); |
|
156 | + $this->error = $this->db->lasterror(); |
|
157 | 157 | return -1; |
158 | 158 | } |
159 | 159 | |
@@ -189,22 +189,22 @@ discard block |
||
189 | 189 | * @param string $sql SQL request to use to count |
190 | 190 | * @return int Number of recipients |
191 | 191 | */ |
192 | - function getNbOfRecipients($sql='') |
|
192 | + function getNbOfRecipients($sql = '') |
|
193 | 193 | { |
194 | - $now=dol_now(); |
|
194 | + $now = dol_now(); |
|
195 | 195 | |
196 | 196 | // Example: return parent::getNbOfRecipients("SELECT count(*) as nb from dolibarr_table"); |
197 | 197 | // Example: return 500; |
198 | 198 | $sql = "SELECT count(*) as nb"; |
199 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; |
|
200 | - $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."product as p"; |
|
201 | - $sql.= " WHERE s.entity IN (".getEntity('societe').")"; |
|
202 | - $sql.= " AND s.rowid = c.fk_soc AND cd.fk_contrat = c.rowid AND s.email != ''"; |
|
203 | - $sql.= " AND cd.statut= 4 AND cd.fk_product=p.rowid"; |
|
204 | - $sql.= " AND p.ref IN ('".join("','",$this->arrayofproducts)."')"; |
|
205 | - $sql.= " AND cd.date_fin_validite < '".$this->db->idate($now)."'"; |
|
199 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; |
|
200 | + $sql .= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."product as p"; |
|
201 | + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; |
|
202 | + $sql .= " AND s.rowid = c.fk_soc AND cd.fk_contrat = c.rowid AND s.email != ''"; |
|
203 | + $sql .= " AND cd.statut= 4 AND cd.fk_product=p.rowid"; |
|
204 | + $sql .= " AND p.ref IN ('".join("','", $this->arrayofproducts)."')"; |
|
205 | + $sql .= " AND cd.date_fin_validite < '".$this->db->idate($now)."'"; |
|
206 | 206 | |
207 | - $a=parent::getNbOfRecipients($sql); |
|
207 | + $a = parent::getNbOfRecipients($sql); |
|
208 | 208 | |
209 | 209 | return $a; |
210 | 210 | } |
@@ -219,15 +219,15 @@ discard block |
||
219 | 219 | { |
220 | 220 | global $langs; |
221 | 221 | |
222 | - $s=$langs->trans("ProductOrService"); |
|
223 | - $s.='<select name="filter" class="flat">'; |
|
224 | - if (count($this->arrayofproducts)) $s.='<option value="0"> </option>'; |
|
225 | - else $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>'; |
|
226 | - foreach($this->arrayofproducts as $key => $val) |
|
222 | + $s = $langs->trans("ProductOrService"); |
|
223 | + $s .= '<select name="filter" class="flat">'; |
|
224 | + if (count($this->arrayofproducts)) $s .= '<option value="0"> </option>'; |
|
225 | + else $s .= '<option value="0">'.$langs->trans("ContactsAllShort").'</option>'; |
|
226 | + foreach ($this->arrayofproducts as $key => $val) |
|
227 | 227 | { |
228 | - $s.='<option value="'.$key.'">'.$val.'</option>'; |
|
228 | + $s .= '<option value="'.$key.'">'.$val.'</option>'; |
|
229 | 229 | } |
230 | - $s.='</select>'; |
|
230 | + $s .= '</select>'; |
|
231 | 231 | return $s; |
232 | 232 | } |
233 | 233 | |
@@ -240,6 +240,6 @@ discard block |
||
240 | 240 | */ |
241 | 241 | function url($id) |
242 | 242 | { |
243 | - return '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$id.'">'.img_object('',"company").'</a>'; |
|
243 | + return '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$id.'">'.img_object('', "company").'</a>'; |
|
244 | 244 | } |
245 | 245 | } |
@@ -54,7 +54,10 @@ discard block |
||
54 | 54 | // List of services |
55 | 55 | $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."product"; |
56 | 56 | $sql.= " WHERE entity IN (".getEntity('product').")"; |
57 | - if (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $sql.= " AND fk_product_type = 1"; // By default, only services |
|
57 | + if (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) { |
|
58 | + $sql.= " AND fk_product_type = 1"; |
|
59 | + } |
|
60 | + // By default, only services |
|
58 | 61 | $sql.= " ORDER BY ref"; |
59 | 62 | $result=$this->db->query($sql); |
60 | 63 | if ($result) |
@@ -69,8 +72,7 @@ discard block |
||
69 | 72 | $i++; |
70 | 73 | $this->arrayofproducts[$i]=$obj->ref; |
71 | 74 | } |
72 | - } |
|
73 | - else |
|
75 | + } else |
|
74 | 76 | { |
75 | 77 | dol_print_error($this->db); |
76 | 78 | } |
@@ -149,8 +151,7 @@ discard block |
||
149 | 151 | |
150 | 152 | $i++; |
151 | 153 | } |
152 | - } |
|
153 | - else |
|
154 | + } else |
|
154 | 155 | { |
155 | 156 | dol_syslog($this->db->lasterror()); |
156 | 157 | $this->error=$this->db->lasterror(); |
@@ -221,8 +222,11 @@ discard block |
||
221 | 222 | |
222 | 223 | $s=$langs->trans("ProductOrService"); |
223 | 224 | $s.='<select name="filter" class="flat">'; |
224 | - if (count($this->arrayofproducts)) $s.='<option value="0"> </option>'; |
|
225 | - else $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>'; |
|
225 | + if (count($this->arrayofproducts)) { |
|
226 | + $s.='<option value="0"> </option>'; |
|
227 | + } else { |
|
228 | + $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>'; |
|
229 | + } |
|
226 | 230 | foreach($this->arrayofproducts as $key => $val) |
227 | 231 | { |
228 | 232 | $s.='<option value="'.$key.'">'.$val.'</option>'; |
@@ -30,195 +30,195 @@ |
||
30 | 30 | */ |
31 | 31 | class mailing_xinputfile extends MailingTargets |
32 | 32 | { |
33 | - var $name='EmailsFromFile'; // Identifiant du module mailing |
|
34 | - // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found |
|
35 | - var $desc='EMails from a file'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e |
|
36 | - var $require_module=array(); // Module mailing actif si modules require_module actifs |
|
37 | - var $require_admin=0; // Module mailing actif pour user admin ou non |
|
38 | - var $picto='generic'; |
|
39 | - var $tooltip='UseFormatFileEmailToTarget'; |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * Constructor |
|
44 | - * |
|
45 | - * @param DoliDB $db Database handler |
|
46 | - */ |
|
47 | - function __construct($db) |
|
48 | - { |
|
49 | - $this->db=$db; |
|
50 | - } |
|
33 | + var $name='EmailsFromFile'; // Identifiant du module mailing |
|
34 | + // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found |
|
35 | + var $desc='EMails from a file'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e |
|
36 | + var $require_module=array(); // Module mailing actif si modules require_module actifs |
|
37 | + var $require_admin=0; // Module mailing actif pour user admin ou non |
|
38 | + var $picto='generic'; |
|
39 | + var $tooltip='UseFormatFileEmailToTarget'; |
|
51 | 40 | |
52 | 41 | |
53 | 42 | /** |
54 | - * On the main mailing area, there is a box with statistics. |
|
55 | - * If you want to add a line in this report you must provide an |
|
56 | - * array of SQL request that returns two field: |
|
57 | - * One called "label", One called "nb". |
|
58 | - * |
|
59 | - * @return array Array with SQL requests |
|
60 | - */ |
|
61 | - function getSqlArrayForStats() |
|
62 | - { |
|
63 | - global $langs; |
|
64 | - $langs->load("users"); |
|
65 | - |
|
66 | - $statssql=array(); |
|
67 | - return $statssql; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * Return here number of distinct emails returned by your selector. |
|
73 | - * For example if this selector is used to extract 500 different |
|
74 | - * emails from a text file, this function must return 500. |
|
75 | - * |
|
76 | - * @param string $sql Sql request to count |
|
77 | - * @return string '' means NA |
|
78 | - */ |
|
79 | - function getNbOfRecipients($sql='') |
|
80 | - { |
|
81 | - return ''; |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * Renvoie url lien vers fiche de la source du destinataire du mailing |
|
87 | - * |
|
43 | + * Constructor |
|
44 | + * |
|
45 | + * @param DoliDB $db Database handler |
|
46 | + */ |
|
47 | + function __construct($db) |
|
48 | + { |
|
49 | + $this->db=$db; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * On the main mailing area, there is a box with statistics. |
|
55 | + * If you want to add a line in this report you must provide an |
|
56 | + * array of SQL request that returns two field: |
|
57 | + * One called "label", One called "nb". |
|
58 | + * |
|
59 | + * @return array Array with SQL requests |
|
60 | + */ |
|
61 | + function getSqlArrayForStats() |
|
62 | + { |
|
63 | + global $langs; |
|
64 | + $langs->load("users"); |
|
65 | + |
|
66 | + $statssql=array(); |
|
67 | + return $statssql; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * Return here number of distinct emails returned by your selector. |
|
73 | + * For example if this selector is used to extract 500 different |
|
74 | + * emails from a text file, this function must return 500. |
|
75 | + * |
|
76 | + * @param string $sql Sql request to count |
|
77 | + * @return string '' means NA |
|
78 | + */ |
|
79 | + function getNbOfRecipients($sql='') |
|
80 | + { |
|
81 | + return ''; |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * Renvoie url lien vers fiche de la source du destinataire du mailing |
|
87 | + * |
|
88 | 88 | * @param int $id ID |
89 | - * @return string Url lien |
|
90 | - */ |
|
91 | - function url($id) |
|
92 | - { |
|
93 | - global $langs; |
|
94 | - return $langs->trans('LineInFile',$id); |
|
95 | - //' - '.$langs->trans("File").' '.dol_trunc(,12); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings |
|
101 | - * |
|
102 | - * @return string Retourne zone select |
|
103 | - */ |
|
104 | - function formFilter() |
|
105 | - { |
|
106 | - global $langs; |
|
107 | - |
|
108 | - $s=''; |
|
109 | - $s.='<input type="file" name="username" class="flat">'; |
|
110 | - return $s; |
|
111 | - } |
|
89 | + * @return string Url lien |
|
90 | + */ |
|
91 | + function url($id) |
|
92 | + { |
|
93 | + global $langs; |
|
94 | + return $langs->trans('LineInFile',$id); |
|
95 | + //' - '.$langs->trans("File").' '.dol_trunc(,12); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings |
|
101 | + * |
|
102 | + * @return string Retourne zone select |
|
103 | + */ |
|
104 | + function formFilter() |
|
105 | + { |
|
106 | + global $langs; |
|
107 | + |
|
108 | + $s=''; |
|
109 | + $s.='<input type="file" name="username" class="flat">'; |
|
110 | + return $s; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
114 | - /** |
|
115 | - * Ajoute destinataires dans table des cibles |
|
116 | - * |
|
117 | - * @param int $mailing_id Id of emailing |
|
118 | - * @return int < 0 si erreur, nb ajout si ok |
|
119 | - */ |
|
120 | - function add_to_target($mailing_id) |
|
121 | - { |
|
114 | + /** |
|
115 | + * Ajoute destinataires dans table des cibles |
|
116 | + * |
|
117 | + * @param int $mailing_id Id of emailing |
|
118 | + * @return int < 0 si erreur, nb ajout si ok |
|
119 | + */ |
|
120 | + function add_to_target($mailing_id) |
|
121 | + { |
|
122 | 122 | // phpcs:enable |
123 | - global $conf,$langs,$_FILES; |
|
124 | - |
|
125 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
126 | - |
|
127 | - // For compatibility with Unix, MS-Dos or Macintosh |
|
128 | - ini_set('auto_detect_line_endings', true); |
|
129 | - |
|
130 | - $cibles = array(); |
|
131 | - |
|
132 | - $upload_dir=$conf->mailing->dir_temp; |
|
133 | - |
|
134 | - if (dol_mkdir($upload_dir) >= 0) |
|
135 | - { |
|
136 | - $resupload = dol_move_uploaded_file($_FILES['username']['tmp_name'], $upload_dir . "/" . $_FILES['username']['name'], 1, 0, $_FILES['username']['error']); |
|
137 | - if (is_numeric($resupload) && $resupload > 0) |
|
138 | - { |
|
139 | - $cpt=0; |
|
140 | - |
|
141 | - $file=$upload_dir . "/" . $_FILES['username']['name']; |
|
142 | - $handle = @fopen($file, "r"); |
|
143 | - if ($handle) |
|
144 | - { |
|
145 | - $i = 0; |
|
146 | - $j = 0; |
|
147 | - |
|
148 | - $old = ''; |
|
149 | - while (!feof($handle)) |
|
150 | - { |
|
151 | - $cpt++; |
|
152 | - $buffer = trim(fgets($handle)); |
|
153 | - $tab=explode(';',$buffer,4); |
|
154 | - $email=$tab[0]; |
|
155 | - $name=$tab[1]; |
|
156 | - $firstname=$tab[2]; |
|
157 | - $other=$tab[3]; |
|
158 | - if (! empty($buffer)) |
|
159 | - { |
|
160 | - //print 'xx'.dol_strlen($buffer).empty($buffer)."<br>\n"; |
|
161 | - $id=$cpt; |
|
162 | - if (isValidEMail($email)) |
|
163 | - { |
|
164 | - if ($old <> $email) |
|
165 | - { |
|
166 | - $cibles[$j] = array( |
|
167 | - 'email' => $email, |
|
168 | - 'lastname' => $name, |
|
169 | - 'firstname' => $firstname, |
|
170 | - 'other' => $other, |
|
123 | + global $conf,$langs,$_FILES; |
|
124 | + |
|
125 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
126 | + |
|
127 | + // For compatibility with Unix, MS-Dos or Macintosh |
|
128 | + ini_set('auto_detect_line_endings', true); |
|
129 | + |
|
130 | + $cibles = array(); |
|
131 | + |
|
132 | + $upload_dir=$conf->mailing->dir_temp; |
|
133 | + |
|
134 | + if (dol_mkdir($upload_dir) >= 0) |
|
135 | + { |
|
136 | + $resupload = dol_move_uploaded_file($_FILES['username']['tmp_name'], $upload_dir . "/" . $_FILES['username']['name'], 1, 0, $_FILES['username']['error']); |
|
137 | + if (is_numeric($resupload) && $resupload > 0) |
|
138 | + { |
|
139 | + $cpt=0; |
|
140 | + |
|
141 | + $file=$upload_dir . "/" . $_FILES['username']['name']; |
|
142 | + $handle = @fopen($file, "r"); |
|
143 | + if ($handle) |
|
144 | + { |
|
145 | + $i = 0; |
|
146 | + $j = 0; |
|
147 | + |
|
148 | + $old = ''; |
|
149 | + while (!feof($handle)) |
|
150 | + { |
|
151 | + $cpt++; |
|
152 | + $buffer = trim(fgets($handle)); |
|
153 | + $tab=explode(';',$buffer,4); |
|
154 | + $email=$tab[0]; |
|
155 | + $name=$tab[1]; |
|
156 | + $firstname=$tab[2]; |
|
157 | + $other=$tab[3]; |
|
158 | + if (! empty($buffer)) |
|
159 | + { |
|
160 | + //print 'xx'.dol_strlen($buffer).empty($buffer)."<br>\n"; |
|
161 | + $id=$cpt; |
|
162 | + if (isValidEMail($email)) |
|
163 | + { |
|
164 | + if ($old <> $email) |
|
165 | + { |
|
166 | + $cibles[$j] = array( |
|
167 | + 'email' => $email, |
|
168 | + 'lastname' => $name, |
|
169 | + 'firstname' => $firstname, |
|
170 | + 'other' => $other, |
|
171 | 171 | 'source_url' => '', |
172 | 172 | 'source_id' => '', |
173 | 173 | 'source_type' => 'file' |
174 | - ); |
|
175 | - $old = $email; |
|
176 | - $j++; |
|
177 | - } |
|
178 | - } |
|
179 | - else |
|
180 | - { |
|
181 | - $i++; |
|
182 | - $langs->load("errors"); |
|
183 | - $this->error = $langs->trans("ErrorFoundBadEmailInFile",$i,$cpt,$email); |
|
184 | - } |
|
185 | - } |
|
186 | - } |
|
187 | - fclose($handle); |
|
188 | - |
|
189 | - if ($i > 0) |
|
190 | - { |
|
191 | - return -$i; |
|
192 | - } |
|
193 | - } |
|
194 | - else |
|
195 | - { |
|
196 | - $this->error = $langs->trans("ErrorFaildToOpenFile"); |
|
197 | - return -1; |
|
198 | - } |
|
199 | - |
|
200 | - dol_syslog(get_class($this)."::add_to_target mailing ".$cpt." targets found"); |
|
201 | - } |
|
202 | - else |
|
203 | - { |
|
204 | - $langs->load("errors"); |
|
205 | - if ($resupload < 0) // Unknown error |
|
206 | - { |
|
207 | - $this->error = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>'; |
|
208 | - } |
|
209 | - else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus |
|
210 | - { |
|
211 | - $this->error = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>'; |
|
212 | - } |
|
213 | - else // Known error |
|
214 | - { |
|
215 | - $this->error = '<div class="error">'.$langs->trans($resupload).'</div>'; |
|
216 | - } |
|
217 | - } |
|
218 | - } |
|
219 | - |
|
220 | - ini_set('auto_detect_line_endings', false); |
|
221 | - |
|
222 | - return parent::add_to_target($mailing_id, $cibles); |
|
223 | - } |
|
174 | + ); |
|
175 | + $old = $email; |
|
176 | + $j++; |
|
177 | + } |
|
178 | + } |
|
179 | + else |
|
180 | + { |
|
181 | + $i++; |
|
182 | + $langs->load("errors"); |
|
183 | + $this->error = $langs->trans("ErrorFoundBadEmailInFile",$i,$cpt,$email); |
|
184 | + } |
|
185 | + } |
|
186 | + } |
|
187 | + fclose($handle); |
|
188 | + |
|
189 | + if ($i > 0) |
|
190 | + { |
|
191 | + return -$i; |
|
192 | + } |
|
193 | + } |
|
194 | + else |
|
195 | + { |
|
196 | + $this->error = $langs->trans("ErrorFaildToOpenFile"); |
|
197 | + return -1; |
|
198 | + } |
|
199 | + |
|
200 | + dol_syslog(get_class($this)."::add_to_target mailing ".$cpt." targets found"); |
|
201 | + } |
|
202 | + else |
|
203 | + { |
|
204 | + $langs->load("errors"); |
|
205 | + if ($resupload < 0) // Unknown error |
|
206 | + { |
|
207 | + $this->error = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>'; |
|
208 | + } |
|
209 | + else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus |
|
210 | + { |
|
211 | + $this->error = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>'; |
|
212 | + } |
|
213 | + else // Known error |
|
214 | + { |
|
215 | + $this->error = '<div class="error">'.$langs->trans($resupload).'</div>'; |
|
216 | + } |
|
217 | + } |
|
218 | + } |
|
219 | + |
|
220 | + ini_set('auto_detect_line_endings', false); |
|
221 | + |
|
222 | + return parent::add_to_target($mailing_id, $cibles); |
|
223 | + } |
|
224 | 224 | } |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class mailing_xinputfile extends MailingTargets |
32 | 32 | { |
33 | - var $name='EmailsFromFile'; // Identifiant du module mailing |
|
33 | + var $name = 'EmailsFromFile'; // Identifiant du module mailing |
|
34 | 34 | // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found |
35 | - var $desc='EMails from a file'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e |
|
36 | - var $require_module=array(); // Module mailing actif si modules require_module actifs |
|
37 | - var $require_admin=0; // Module mailing actif pour user admin ou non |
|
38 | - var $picto='generic'; |
|
39 | - var $tooltip='UseFormatFileEmailToTarget'; |
|
35 | + var $desc = 'EMails from a file'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e |
|
36 | + var $require_module = array(); // Module mailing actif si modules require_module actifs |
|
37 | + var $require_admin = 0; // Module mailing actif pour user admin ou non |
|
38 | + var $picto = 'generic'; |
|
39 | + var $tooltip = 'UseFormatFileEmailToTarget'; |
|
40 | 40 | |
41 | 41 | |
42 | 42 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function __construct($db) |
48 | 48 | { |
49 | - $this->db=$db; |
|
49 | + $this->db = $db; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | global $langs; |
64 | 64 | $langs->load("users"); |
65 | 65 | |
66 | - $statssql=array(); |
|
66 | + $statssql = array(); |
|
67 | 67 | return $statssql; |
68 | 68 | } |
69 | 69 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param string $sql Sql request to count |
77 | 77 | * @return string '' means NA |
78 | 78 | */ |
79 | - function getNbOfRecipients($sql='') |
|
79 | + function getNbOfRecipients($sql = '') |
|
80 | 80 | { |
81 | 81 | return ''; |
82 | 82 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | function url($id) |
92 | 92 | { |
93 | 93 | global $langs; |
94 | - return $langs->trans('LineInFile',$id); |
|
94 | + return $langs->trans('LineInFile', $id); |
|
95 | 95 | //' - '.$langs->trans("File").' '.dol_trunc(,12); |
96 | 96 | } |
97 | 97 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | { |
106 | 106 | global $langs; |
107 | 107 | |
108 | - $s=''; |
|
109 | - $s.='<input type="file" name="username" class="flat">'; |
|
108 | + $s = ''; |
|
109 | + $s .= '<input type="file" name="username" class="flat">'; |
|
110 | 110 | return $s; |
111 | 111 | } |
112 | 112 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | function add_to_target($mailing_id) |
121 | 121 | { |
122 | 122 | // phpcs:enable |
123 | - global $conf,$langs,$_FILES; |
|
123 | + global $conf, $langs, $_FILES; |
|
124 | 124 | |
125 | 125 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
126 | 126 | |
@@ -129,16 +129,16 @@ discard block |
||
129 | 129 | |
130 | 130 | $cibles = array(); |
131 | 131 | |
132 | - $upload_dir=$conf->mailing->dir_temp; |
|
132 | + $upload_dir = $conf->mailing->dir_temp; |
|
133 | 133 | |
134 | 134 | if (dol_mkdir($upload_dir) >= 0) |
135 | 135 | { |
136 | - $resupload = dol_move_uploaded_file($_FILES['username']['tmp_name'], $upload_dir . "/" . $_FILES['username']['name'], 1, 0, $_FILES['username']['error']); |
|
136 | + $resupload = dol_move_uploaded_file($_FILES['username']['tmp_name'], $upload_dir."/".$_FILES['username']['name'], 1, 0, $_FILES['username']['error']); |
|
137 | 137 | if (is_numeric($resupload) && $resupload > 0) |
138 | 138 | { |
139 | - $cpt=0; |
|
139 | + $cpt = 0; |
|
140 | 140 | |
141 | - $file=$upload_dir . "/" . $_FILES['username']['name']; |
|
141 | + $file = $upload_dir."/".$_FILES['username']['name']; |
|
142 | 142 | $handle = @fopen($file, "r"); |
143 | 143 | if ($handle) |
144 | 144 | { |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | { |
151 | 151 | $cpt++; |
152 | 152 | $buffer = trim(fgets($handle)); |
153 | - $tab=explode(';',$buffer,4); |
|
154 | - $email=$tab[0]; |
|
155 | - $name=$tab[1]; |
|
156 | - $firstname=$tab[2]; |
|
157 | - $other=$tab[3]; |
|
158 | - if (! empty($buffer)) |
|
153 | + $tab = explode(';', $buffer, 4); |
|
154 | + $email = $tab[0]; |
|
155 | + $name = $tab[1]; |
|
156 | + $firstname = $tab[2]; |
|
157 | + $other = $tab[3]; |
|
158 | + if (!empty($buffer)) |
|
159 | 159 | { |
160 | 160 | //print 'xx'.dol_strlen($buffer).empty($buffer)."<br>\n"; |
161 | - $id=$cpt; |
|
161 | + $id = $cpt; |
|
162 | 162 | if (isValidEMail($email)) |
163 | 163 | { |
164 | 164 | if ($old <> $email) |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | $i++; |
182 | 182 | $langs->load("errors"); |
183 | - $this->error = $langs->trans("ErrorFoundBadEmailInFile",$i,$cpt,$email); |
|
183 | + $this->error = $langs->trans("ErrorFoundBadEmailInFile", $i, $cpt, $email); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | { |
207 | 207 | $this->error = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>'; |
208 | 208 | } |
209 | - else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus |
|
209 | + else if (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) // Files infected by a virus |
|
210 | 210 | { |
211 | 211 | $this->error = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>'; |
212 | 212 | } |
@@ -175,8 +175,7 @@ discard block |
||
175 | 175 | $old = $email; |
176 | 176 | $j++; |
177 | 177 | } |
178 | - } |
|
179 | - else |
|
178 | + } else |
|
180 | 179 | { |
181 | 180 | $i++; |
182 | 181 | $langs->load("errors"); |
@@ -190,27 +189,27 @@ discard block |
||
190 | 189 | { |
191 | 190 | return -$i; |
192 | 191 | } |
193 | - } |
|
194 | - else |
|
192 | + } else |
|
195 | 193 | { |
196 | 194 | $this->error = $langs->trans("ErrorFaildToOpenFile"); |
197 | 195 | return -1; |
198 | 196 | } |
199 | 197 | |
200 | 198 | dol_syslog(get_class($this)."::add_to_target mailing ".$cpt." targets found"); |
201 | - } |
|
202 | - else |
|
199 | + } else |
|
203 | 200 | { |
204 | 201 | $langs->load("errors"); |
205 | - if ($resupload < 0) // Unknown error |
|
202 | + if ($resupload < 0) { |
|
203 | + // Unknown error |
|
206 | 204 | { |
207 | 205 | $this->error = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>'; |
208 | 206 | } |
209 | - else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus |
|
207 | + } else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) { |
|
208 | + // Files infected by a virus |
|
210 | 209 | { |
211 | 210 | $this->error = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>'; |
212 | 211 | } |
213 | - else // Known error |
|
212 | + } else // Known error |
|
214 | 213 | { |
215 | 214 | $this->error = '<div class="error">'.$langs->trans($resupload).'</div>'; |
216 | 215 | } |
@@ -36,189 +36,189 @@ |
||
36 | 36 | class modBanque extends DolibarrModules |
37 | 37 | { |
38 | 38 | |
39 | - /** |
|
40 | - * Constructor. |
|
41 | - * |
|
42 | - * @param DoliDB $db Database handler |
|
43 | - */ |
|
44 | - function __construct($db) |
|
45 | - { |
|
46 | - global $conf; |
|
47 | - |
|
48 | - $this->db = $db; |
|
49 | - $this->numero = 85; |
|
50 | - |
|
51 | - $this->family = "financial"; |
|
52 | - $this->module_position = '51'; |
|
53 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
54 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | - $this->description = "Gestion des comptes financiers de type Comptes bancaires ou postaux"; |
|
56 | - |
|
57 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
58 | - $this->version = 'dolibarr'; |
|
59 | - |
|
60 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
61 | - $this->picto='account'; |
|
62 | - |
|
63 | - // Data directories to create when module is enabled |
|
64 | - $this->dirs = array("/banque/temp"); |
|
65 | - |
|
66 | - // Config pages |
|
67 | - //------------- |
|
68 | - $this->config_page_url = array("bank.php"); |
|
69 | - |
|
70 | - // Dependancies |
|
71 | - $this->depends = array(); |
|
72 | - $this->requiredby = array("modComptabilite","modAccounting","modPrelevement"); |
|
73 | - $this->conflictwith = array(); |
|
74 | - $this->langfiles = array("banks","compta","bills","companies"); |
|
75 | - |
|
76 | - // Constants |
|
77 | - $this->const = array(); |
|
78 | - |
|
79 | - // Boxes |
|
80 | - $this->boxes = array(0=>array('file'=>'box_comptes.php','enabledbydefaulton'=>'Home')); |
|
81 | - |
|
82 | - // Permissions |
|
83 | - $this->rights = array(); |
|
84 | - $this->rights_class = 'banque'; |
|
85 | - $r=0; |
|
86 | - |
|
87 | - $r++; |
|
88 | - $this->rights[$r][0] = 111; // id de la permission |
|
89 | - $this->rights[$r][1] = 'Read bank account and transactions'; |
|
90 | - $this->rights[$r][2] = 'r'; |
|
91 | - $this->rights[$r][3] = 0; |
|
92 | - $this->rights[$r][4] = 'lire'; |
|
93 | - |
|
94 | - $r++; |
|
95 | - $this->rights[$r][0] = 112; // id de la permission |
|
96 | - $this->rights[$r][1] = 'Creer/modifier montant/supprimer ecriture bancaire'; |
|
97 | - $this->rights[$r][2] = 'w'; |
|
98 | - $this->rights[$r][3] = 0; |
|
99 | - $this->rights[$r][4] = 'modifier'; |
|
100 | - |
|
101 | - $r++; |
|
102 | - $this->rights[$r][0] = 113; // id de la permission |
|
103 | - $this->rights[$r][1] = 'Configurer les comptes bancaires (creer, gerer categories)'; |
|
104 | - $this->rights[$r][2] = 'a'; |
|
105 | - $this->rights[$r][3] = 0; |
|
106 | - $this->rights[$r][4] = 'configurer'; |
|
107 | - |
|
108 | - $r++; |
|
109 | - $this->rights[$r][0] = 114; // id de la permission |
|
110 | - $this->rights[$r][1] = 'Rapprocher les ecritures bancaires'; |
|
111 | - $this->rights[$r][2] = 'w'; |
|
112 | - $this->rights[$r][3] = 0; |
|
113 | - $this->rights[$r][4] = 'consolidate'; |
|
114 | - |
|
115 | - $r++; |
|
116 | - $this->rights[$r][0] = 115; // id de la permission |
|
117 | - $this->rights[$r][1] = 'Exporter transactions et releves'; |
|
118 | - $this->rights[$r][2] = 'r'; |
|
119 | - $this->rights[$r][3] = 0; |
|
120 | - $this->rights[$r][4] = 'export'; |
|
121 | - |
|
122 | - $r++; |
|
123 | - $this->rights[$r][0] = 116; // id de la permission |
|
124 | - $this->rights[$r][1] = 'Virements entre comptes'; |
|
125 | - $this->rights[$r][2] = 'w'; |
|
126 | - $this->rights[$r][3] = 0; |
|
127 | - $this->rights[$r][4] = 'transfer'; |
|
128 | - |
|
129 | - $r++; |
|
130 | - $this->rights[$r][0] = 117; // id de la permission |
|
131 | - $this->rights[$r][1] = 'Gerer les envois de cheques'; |
|
132 | - $this->rights[$r][2] = 'w'; |
|
133 | - $this->rights[$r][3] = 0; |
|
134 | - $this->rights[$r][4] = 'cheque'; |
|
135 | - |
|
136 | - |
|
137 | - // Menus |
|
138 | - //------- |
|
139 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
140 | - |
|
141 | - |
|
142 | - // Exports |
|
143 | - //-------- |
|
144 | - $r=0; |
|
145 | - |
|
146 | - $r++; |
|
147 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
148 | - $this->export_label[$r]='Ecritures bancaires et releves'; |
|
149 | - $this->export_permission[$r]=array(array("banque","export")); |
|
150 | - $this->export_fields_array[$r]=array( |
|
151 | - 'b.rowid'=>'IdTransaction','ba.ref'=>'AccountRef','ba.label'=>'AccountLabel','b.datev'=>'DateValue','b.dateo'=>'DateOperation','b.label'=>'Label', |
|
152 | - 'b.num_chq'=>'ChequeOrTransferNumber','b.fk_bordereau'=>'ChequeBordereau','-b.amount'=>'Debit','b.amount'=>'Credit', |
|
153 | - 'b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty", |
|
154 | - "s.code_compta"=>"CustomerAccountancyCode","s.code_compta_fournisseur"=>"SupplierAccountancyCode" |
|
155 | - ); |
|
156 | - $this->export_TypeFields_array[$r]=array('ba.ref'=>'Text','ba.label'=>'Text','b.datev'=>'Date','b.dateo'=>'Date','b.label'=>'Text','b.num_chq'=>'Text','b.fk_bordereau'=>'Text','-b.amount'=>'Numeric','b.amount'=>'Numeric','b.num_releve'=>'Text','b.datec'=>"Date","bu.url_id"=>"Text","s.nom"=>"Text","s.code_compta"=>"Text","s.code_compta_fournisseur"=>"Text"); |
|
157 | - $this->export_entities_array[$r]=array( |
|
158 | - 'b.rowid'=>'account','ba.ref'=>'account','ba.label'=>'account','b.datev'=>'account','b.dateo'=>'account','b.label'=>'account', |
|
159 | - 'b.num_chq'=>'account','b.fk_bordereau'=>'account','-b.amount'=>'account','b.amount'=>'account','b.num_releve'=>'account', |
|
160 | - 'b.datec'=>"account","bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company" |
|
161 | - ); |
|
162 | - $this->export_special_array[$r]=array('-b.amount'=>'NULLIFNEG','b.amount'=>'NULLIFNEG'); |
|
163 | - if (empty($conf->fournisseur->enabled)) |
|
164 | - { |
|
165 | - unset($this->export_fields_array[$r]['s.code_compta_fournisseur']); |
|
166 | - unset($this->export_entities_array[$r]['s.code_compta_fournisseur']); |
|
167 | - } |
|
168 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
169 | - $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)'; |
|
170 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')"; |
|
171 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON bu.url_id = s.rowid'; |
|
172 | - $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account'; |
|
173 | - $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account').')'; |
|
174 | - $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve'; |
|
175 | - |
|
176 | - $r++; |
|
177 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
178 | - $this->export_label[$r]='Bordereaux remise Chq/Fact'; |
|
179 | - $this->export_permission[$r]=array(array("banque","export")); |
|
180 | - $this->export_fields_array[$r]=array("bch.rowid"=>"DepositId","bch.ref"=>"Numero","bch.ref_ext"=>"RefExt",'ba.ref'=>'AccountRef','ba.label'=>'AccountLabel','b.datev'=>'DateValue','b.num_chq'=>'ChequeOrTransferNumber','b.amount'=>'Credit','b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation", |
|
181 | - "bch.date_bordereau"=>"Date","bch.amount"=>"Total","bch.nbcheque"=>"NbCheque","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty","s.code_compta"=>"CustomerAccountancyCode","f.ref"=>"InvoiceRef" |
|
182 | - ); |
|
183 | - $this->export_TypeFields_array[$r]=array('ba.ref'=>'Text','ba.label'=>'Text','b.datev'=>'Date','b.num_chq'=>'Text','b.amount'=>'Numeric','b.num_releve'=>'Text','b.datec'=>"Date", |
|
184 | - "bch.date_bordereau"=>"Date","bch.rowid"=>"Numeric","bch.ref"=>"Numeric","bch.ref_ext"=>"Text","bch.amount"=>"Numeric","bch.nbcheque"=>"Numeric","bu.url_id"=>"Text","s.nom"=>"Text","s.code_compta"=>"Text","f.ref"=>"Text" |
|
185 | - ); |
|
186 | - $this->export_entities_array[$r]=array('ba.ref'=>'account','ba.label'=>'account','b.datev'=>'account','b.num_chq'=>'account','b.amount'=>'account','b.num_releve'=>'account','b.datec'=>"account", |
|
187 | - "bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company","f.ref"=>"invoice"); |
|
188 | - $this->export_special_array[$r]=array('b.amount'=>'NULLIFNEG'); |
|
189 | - |
|
190 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
191 | - $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'bordereau_cheque as bch, '.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)'; |
|
192 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')"; |
|
193 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON b.rowid = p.fk_bank'; |
|
194 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON p.rowid = pf.fk_paiement'; |
|
195 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON f.rowid = pf.fk_facture'; |
|
196 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON f.fk_soc = s.rowid'; |
|
197 | - $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account AND bch.rowid = b.fk_bordereau and bch.fk_bank_account=ba.rowid'; |
|
198 | - $this->export_sql_end[$r] .=" AND b.fk_type = 'CHQ'"; |
|
199 | - $this->export_sql_end[$r] .=' AND p.fk_paiement = 7'; |
|
200 | - $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account').')'; |
|
201 | - $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve'; |
|
202 | - } |
|
203 | - |
|
204 | - |
|
205 | - /** |
|
206 | - * Function called when module is enabled. |
|
207 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
208 | - * It also creates data directories. |
|
209 | - * |
|
210 | - * @param string $options Options when enabling module ('', 'noboxes') |
|
211 | - * @return int 1 if OK, 0 if KO |
|
212 | - */ |
|
213 | - function init($options='') |
|
214 | - { |
|
215 | - global $conf; |
|
216 | - |
|
217 | - // Permissions |
|
218 | - $this->remove($options); |
|
219 | - |
|
220 | - $sql = array(); |
|
221 | - |
|
222 | - return $this->_init($sql,$options); |
|
223 | - } |
|
39 | + /** |
|
40 | + * Constructor. |
|
41 | + * |
|
42 | + * @param DoliDB $db Database handler |
|
43 | + */ |
|
44 | + function __construct($db) |
|
45 | + { |
|
46 | + global $conf; |
|
47 | + |
|
48 | + $this->db = $db; |
|
49 | + $this->numero = 85; |
|
50 | + |
|
51 | + $this->family = "financial"; |
|
52 | + $this->module_position = '51'; |
|
53 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
54 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | + $this->description = "Gestion des comptes financiers de type Comptes bancaires ou postaux"; |
|
56 | + |
|
57 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
58 | + $this->version = 'dolibarr'; |
|
59 | + |
|
60 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
61 | + $this->picto='account'; |
|
62 | + |
|
63 | + // Data directories to create when module is enabled |
|
64 | + $this->dirs = array("/banque/temp"); |
|
65 | + |
|
66 | + // Config pages |
|
67 | + //------------- |
|
68 | + $this->config_page_url = array("bank.php"); |
|
69 | + |
|
70 | + // Dependancies |
|
71 | + $this->depends = array(); |
|
72 | + $this->requiredby = array("modComptabilite","modAccounting","modPrelevement"); |
|
73 | + $this->conflictwith = array(); |
|
74 | + $this->langfiles = array("banks","compta","bills","companies"); |
|
75 | + |
|
76 | + // Constants |
|
77 | + $this->const = array(); |
|
78 | + |
|
79 | + // Boxes |
|
80 | + $this->boxes = array(0=>array('file'=>'box_comptes.php','enabledbydefaulton'=>'Home')); |
|
81 | + |
|
82 | + // Permissions |
|
83 | + $this->rights = array(); |
|
84 | + $this->rights_class = 'banque'; |
|
85 | + $r=0; |
|
86 | + |
|
87 | + $r++; |
|
88 | + $this->rights[$r][0] = 111; // id de la permission |
|
89 | + $this->rights[$r][1] = 'Read bank account and transactions'; |
|
90 | + $this->rights[$r][2] = 'r'; |
|
91 | + $this->rights[$r][3] = 0; |
|
92 | + $this->rights[$r][4] = 'lire'; |
|
93 | + |
|
94 | + $r++; |
|
95 | + $this->rights[$r][0] = 112; // id de la permission |
|
96 | + $this->rights[$r][1] = 'Creer/modifier montant/supprimer ecriture bancaire'; |
|
97 | + $this->rights[$r][2] = 'w'; |
|
98 | + $this->rights[$r][3] = 0; |
|
99 | + $this->rights[$r][4] = 'modifier'; |
|
100 | + |
|
101 | + $r++; |
|
102 | + $this->rights[$r][0] = 113; // id de la permission |
|
103 | + $this->rights[$r][1] = 'Configurer les comptes bancaires (creer, gerer categories)'; |
|
104 | + $this->rights[$r][2] = 'a'; |
|
105 | + $this->rights[$r][3] = 0; |
|
106 | + $this->rights[$r][4] = 'configurer'; |
|
107 | + |
|
108 | + $r++; |
|
109 | + $this->rights[$r][0] = 114; // id de la permission |
|
110 | + $this->rights[$r][1] = 'Rapprocher les ecritures bancaires'; |
|
111 | + $this->rights[$r][2] = 'w'; |
|
112 | + $this->rights[$r][3] = 0; |
|
113 | + $this->rights[$r][4] = 'consolidate'; |
|
114 | + |
|
115 | + $r++; |
|
116 | + $this->rights[$r][0] = 115; // id de la permission |
|
117 | + $this->rights[$r][1] = 'Exporter transactions et releves'; |
|
118 | + $this->rights[$r][2] = 'r'; |
|
119 | + $this->rights[$r][3] = 0; |
|
120 | + $this->rights[$r][4] = 'export'; |
|
121 | + |
|
122 | + $r++; |
|
123 | + $this->rights[$r][0] = 116; // id de la permission |
|
124 | + $this->rights[$r][1] = 'Virements entre comptes'; |
|
125 | + $this->rights[$r][2] = 'w'; |
|
126 | + $this->rights[$r][3] = 0; |
|
127 | + $this->rights[$r][4] = 'transfer'; |
|
128 | + |
|
129 | + $r++; |
|
130 | + $this->rights[$r][0] = 117; // id de la permission |
|
131 | + $this->rights[$r][1] = 'Gerer les envois de cheques'; |
|
132 | + $this->rights[$r][2] = 'w'; |
|
133 | + $this->rights[$r][3] = 0; |
|
134 | + $this->rights[$r][4] = 'cheque'; |
|
135 | + |
|
136 | + |
|
137 | + // Menus |
|
138 | + //------- |
|
139 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
140 | + |
|
141 | + |
|
142 | + // Exports |
|
143 | + //-------- |
|
144 | + $r=0; |
|
145 | + |
|
146 | + $r++; |
|
147 | + $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
148 | + $this->export_label[$r]='Ecritures bancaires et releves'; |
|
149 | + $this->export_permission[$r]=array(array("banque","export")); |
|
150 | + $this->export_fields_array[$r]=array( |
|
151 | + 'b.rowid'=>'IdTransaction','ba.ref'=>'AccountRef','ba.label'=>'AccountLabel','b.datev'=>'DateValue','b.dateo'=>'DateOperation','b.label'=>'Label', |
|
152 | + 'b.num_chq'=>'ChequeOrTransferNumber','b.fk_bordereau'=>'ChequeBordereau','-b.amount'=>'Debit','b.amount'=>'Credit', |
|
153 | + 'b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty", |
|
154 | + "s.code_compta"=>"CustomerAccountancyCode","s.code_compta_fournisseur"=>"SupplierAccountancyCode" |
|
155 | + ); |
|
156 | + $this->export_TypeFields_array[$r]=array('ba.ref'=>'Text','ba.label'=>'Text','b.datev'=>'Date','b.dateo'=>'Date','b.label'=>'Text','b.num_chq'=>'Text','b.fk_bordereau'=>'Text','-b.amount'=>'Numeric','b.amount'=>'Numeric','b.num_releve'=>'Text','b.datec'=>"Date","bu.url_id"=>"Text","s.nom"=>"Text","s.code_compta"=>"Text","s.code_compta_fournisseur"=>"Text"); |
|
157 | + $this->export_entities_array[$r]=array( |
|
158 | + 'b.rowid'=>'account','ba.ref'=>'account','ba.label'=>'account','b.datev'=>'account','b.dateo'=>'account','b.label'=>'account', |
|
159 | + 'b.num_chq'=>'account','b.fk_bordereau'=>'account','-b.amount'=>'account','b.amount'=>'account','b.num_releve'=>'account', |
|
160 | + 'b.datec'=>"account","bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company" |
|
161 | + ); |
|
162 | + $this->export_special_array[$r]=array('-b.amount'=>'NULLIFNEG','b.amount'=>'NULLIFNEG'); |
|
163 | + if (empty($conf->fournisseur->enabled)) |
|
164 | + { |
|
165 | + unset($this->export_fields_array[$r]['s.code_compta_fournisseur']); |
|
166 | + unset($this->export_entities_array[$r]['s.code_compta_fournisseur']); |
|
167 | + } |
|
168 | + $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
169 | + $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)'; |
|
170 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')"; |
|
171 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON bu.url_id = s.rowid'; |
|
172 | + $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account'; |
|
173 | + $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account').')'; |
|
174 | + $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve'; |
|
175 | + |
|
176 | + $r++; |
|
177 | + $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
178 | + $this->export_label[$r]='Bordereaux remise Chq/Fact'; |
|
179 | + $this->export_permission[$r]=array(array("banque","export")); |
|
180 | + $this->export_fields_array[$r]=array("bch.rowid"=>"DepositId","bch.ref"=>"Numero","bch.ref_ext"=>"RefExt",'ba.ref'=>'AccountRef','ba.label'=>'AccountLabel','b.datev'=>'DateValue','b.num_chq'=>'ChequeOrTransferNumber','b.amount'=>'Credit','b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation", |
|
181 | + "bch.date_bordereau"=>"Date","bch.amount"=>"Total","bch.nbcheque"=>"NbCheque","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty","s.code_compta"=>"CustomerAccountancyCode","f.ref"=>"InvoiceRef" |
|
182 | + ); |
|
183 | + $this->export_TypeFields_array[$r]=array('ba.ref'=>'Text','ba.label'=>'Text','b.datev'=>'Date','b.num_chq'=>'Text','b.amount'=>'Numeric','b.num_releve'=>'Text','b.datec'=>"Date", |
|
184 | + "bch.date_bordereau"=>"Date","bch.rowid"=>"Numeric","bch.ref"=>"Numeric","bch.ref_ext"=>"Text","bch.amount"=>"Numeric","bch.nbcheque"=>"Numeric","bu.url_id"=>"Text","s.nom"=>"Text","s.code_compta"=>"Text","f.ref"=>"Text" |
|
185 | + ); |
|
186 | + $this->export_entities_array[$r]=array('ba.ref'=>'account','ba.label'=>'account','b.datev'=>'account','b.num_chq'=>'account','b.amount'=>'account','b.num_releve'=>'account','b.datec'=>"account", |
|
187 | + "bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company","f.ref"=>"invoice"); |
|
188 | + $this->export_special_array[$r]=array('b.amount'=>'NULLIFNEG'); |
|
189 | + |
|
190 | + $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
191 | + $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'bordereau_cheque as bch, '.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)'; |
|
192 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')"; |
|
193 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON b.rowid = p.fk_bank'; |
|
194 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON p.rowid = pf.fk_paiement'; |
|
195 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON f.rowid = pf.fk_facture'; |
|
196 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON f.fk_soc = s.rowid'; |
|
197 | + $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account AND bch.rowid = b.fk_bordereau and bch.fk_bank_account=ba.rowid'; |
|
198 | + $this->export_sql_end[$r] .=" AND b.fk_type = 'CHQ'"; |
|
199 | + $this->export_sql_end[$r] .=' AND p.fk_paiement = 7'; |
|
200 | + $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account').')'; |
|
201 | + $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve'; |
|
202 | + } |
|
203 | + |
|
204 | + |
|
205 | + /** |
|
206 | + * Function called when module is enabled. |
|
207 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
208 | + * It also creates data directories. |
|
209 | + * |
|
210 | + * @param string $options Options when enabling module ('', 'noboxes') |
|
211 | + * @return int 1 if OK, 0 if KO |
|
212 | + */ |
|
213 | + function init($options='') |
|
214 | + { |
|
215 | + global $conf; |
|
216 | + |
|
217 | + // Permissions |
|
218 | + $this->remove($options); |
|
219 | + |
|
220 | + $sql = array(); |
|
221 | + |
|
222 | + return $this->_init($sql,$options); |
|
223 | + } |
|
224 | 224 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * \brief Fichier de description et activation du module Banque |
28 | 28 | */ |
29 | 29 | |
30 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
30 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
31 | 31 | |
32 | 32 | |
33 | 33 | /** |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | $this->family = "financial"; |
52 | 52 | $this->module_position = '51'; |
53 | 53 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
54 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
54 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
55 | 55 | $this->description = "Gestion des comptes financiers de type Comptes bancaires ou postaux"; |
56 | 56 | |
57 | 57 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
58 | 58 | $this->version = 'dolibarr'; |
59 | 59 | |
60 | 60 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
61 | - $this->picto='account'; |
|
61 | + $this->picto = 'account'; |
|
62 | 62 | |
63 | 63 | // Data directories to create when module is enabled |
64 | 64 | $this->dirs = array("/banque/temp"); |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | |
70 | 70 | // Dependancies |
71 | 71 | $this->depends = array(); |
72 | - $this->requiredby = array("modComptabilite","modAccounting","modPrelevement"); |
|
72 | + $this->requiredby = array("modComptabilite", "modAccounting", "modPrelevement"); |
|
73 | 73 | $this->conflictwith = array(); |
74 | - $this->langfiles = array("banks","compta","bills","companies"); |
|
74 | + $this->langfiles = array("banks", "compta", "bills", "companies"); |
|
75 | 75 | |
76 | 76 | // Constants |
77 | 77 | $this->const = array(); |
78 | 78 | |
79 | 79 | // Boxes |
80 | - $this->boxes = array(0=>array('file'=>'box_comptes.php','enabledbydefaulton'=>'Home')); |
|
80 | + $this->boxes = array(0=>array('file'=>'box_comptes.php', 'enabledbydefaulton'=>'Home')); |
|
81 | 81 | |
82 | 82 | // Permissions |
83 | 83 | $this->rights = array(); |
84 | 84 | $this->rights_class = 'banque'; |
85 | - $r=0; |
|
85 | + $r = 0; |
|
86 | 86 | |
87 | 87 | $r++; |
88 | 88 | $this->rights[$r][0] = 111; // id de la permission |
@@ -136,69 +136,69 @@ discard block |
||
136 | 136 | |
137 | 137 | // Menus |
138 | 138 | //------- |
139 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
139 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
140 | 140 | |
141 | 141 | |
142 | 142 | // Exports |
143 | 143 | //-------- |
144 | - $r=0; |
|
144 | + $r = 0; |
|
145 | 145 | |
146 | 146 | $r++; |
147 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
148 | - $this->export_label[$r]='Ecritures bancaires et releves'; |
|
149 | - $this->export_permission[$r]=array(array("banque","export")); |
|
150 | - $this->export_fields_array[$r]=array( |
|
151 | - 'b.rowid'=>'IdTransaction','ba.ref'=>'AccountRef','ba.label'=>'AccountLabel','b.datev'=>'DateValue','b.dateo'=>'DateOperation','b.label'=>'Label', |
|
152 | - 'b.num_chq'=>'ChequeOrTransferNumber','b.fk_bordereau'=>'ChequeBordereau','-b.amount'=>'Debit','b.amount'=>'Credit', |
|
153 | - 'b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty", |
|
154 | - "s.code_compta"=>"CustomerAccountancyCode","s.code_compta_fournisseur"=>"SupplierAccountancyCode" |
|
147 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
148 | + $this->export_label[$r] = 'Ecritures bancaires et releves'; |
|
149 | + $this->export_permission[$r] = array(array("banque", "export")); |
|
150 | + $this->export_fields_array[$r] = array( |
|
151 | + 'b.rowid'=>'IdTransaction', 'ba.ref'=>'AccountRef', 'ba.label'=>'AccountLabel', 'b.datev'=>'DateValue', 'b.dateo'=>'DateOperation', 'b.label'=>'Label', |
|
152 | + 'b.num_chq'=>'ChequeOrTransferNumber', 'b.fk_bordereau'=>'ChequeBordereau', '-b.amount'=>'Debit', 'b.amount'=>'Credit', |
|
153 | + 'b.num_releve'=>'AccountStatement', 'b.datec'=>"DateCreation", "bu.url_id"=>"IdThirdParty", "s.nom"=>"ThirdParty", |
|
154 | + "s.code_compta"=>"CustomerAccountancyCode", "s.code_compta_fournisseur"=>"SupplierAccountancyCode" |
|
155 | 155 | ); |
156 | - $this->export_TypeFields_array[$r]=array('ba.ref'=>'Text','ba.label'=>'Text','b.datev'=>'Date','b.dateo'=>'Date','b.label'=>'Text','b.num_chq'=>'Text','b.fk_bordereau'=>'Text','-b.amount'=>'Numeric','b.amount'=>'Numeric','b.num_releve'=>'Text','b.datec'=>"Date","bu.url_id"=>"Text","s.nom"=>"Text","s.code_compta"=>"Text","s.code_compta_fournisseur"=>"Text"); |
|
157 | - $this->export_entities_array[$r]=array( |
|
158 | - 'b.rowid'=>'account','ba.ref'=>'account','ba.label'=>'account','b.datev'=>'account','b.dateo'=>'account','b.label'=>'account', |
|
159 | - 'b.num_chq'=>'account','b.fk_bordereau'=>'account','-b.amount'=>'account','b.amount'=>'account','b.num_releve'=>'account', |
|
160 | - 'b.datec'=>"account","bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company" |
|
156 | + $this->export_TypeFields_array[$r] = array('ba.ref'=>'Text', 'ba.label'=>'Text', 'b.datev'=>'Date', 'b.dateo'=>'Date', 'b.label'=>'Text', 'b.num_chq'=>'Text', 'b.fk_bordereau'=>'Text', '-b.amount'=>'Numeric', 'b.amount'=>'Numeric', 'b.num_releve'=>'Text', 'b.datec'=>"Date", "bu.url_id"=>"Text", "s.nom"=>"Text", "s.code_compta"=>"Text", "s.code_compta_fournisseur"=>"Text"); |
|
157 | + $this->export_entities_array[$r] = array( |
|
158 | + 'b.rowid'=>'account', 'ba.ref'=>'account', 'ba.label'=>'account', 'b.datev'=>'account', 'b.dateo'=>'account', 'b.label'=>'account', |
|
159 | + 'b.num_chq'=>'account', 'b.fk_bordereau'=>'account', '-b.amount'=>'account', 'b.amount'=>'account', 'b.num_releve'=>'account', |
|
160 | + 'b.datec'=>"account", "bu.url_id"=>"company", "s.nom"=>"company", "s.code_compta"=>"company", "s.code_compta_fournisseur"=>"company" |
|
161 | 161 | ); |
162 | - $this->export_special_array[$r]=array('-b.amount'=>'NULLIFNEG','b.amount'=>'NULLIFNEG'); |
|
162 | + $this->export_special_array[$r] = array('-b.amount'=>'NULLIFNEG', 'b.amount'=>'NULLIFNEG'); |
|
163 | 163 | if (empty($conf->fournisseur->enabled)) |
164 | 164 | { |
165 | 165 | unset($this->export_fields_array[$r]['s.code_compta_fournisseur']); |
166 | 166 | unset($this->export_entities_array[$r]['s.code_compta_fournisseur']); |
167 | 167 | } |
168 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
169 | - $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)'; |
|
170 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')"; |
|
171 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON bu.url_id = s.rowid'; |
|
172 | - $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account'; |
|
173 | - $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account').')'; |
|
174 | - $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve'; |
|
168 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
169 | + $this->export_sql_end[$r] = ' FROM ('.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)'; |
|
170 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')"; |
|
171 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON bu.url_id = s.rowid'; |
|
172 | + $this->export_sql_end[$r] .= ' WHERE ba.rowid = b.fk_account'; |
|
173 | + $this->export_sql_end[$r] .= ' AND ba.entity IN ('.getEntity('bank_account').')'; |
|
174 | + $this->export_sql_order[$r] = ' ORDER BY b.datev, b.num_releve'; |
|
175 | 175 | |
176 | 176 | $r++; |
177 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
178 | - $this->export_label[$r]='Bordereaux remise Chq/Fact'; |
|
179 | - $this->export_permission[$r]=array(array("banque","export")); |
|
180 | - $this->export_fields_array[$r]=array("bch.rowid"=>"DepositId","bch.ref"=>"Numero","bch.ref_ext"=>"RefExt",'ba.ref'=>'AccountRef','ba.label'=>'AccountLabel','b.datev'=>'DateValue','b.num_chq'=>'ChequeOrTransferNumber','b.amount'=>'Credit','b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation", |
|
181 | - "bch.date_bordereau"=>"Date","bch.amount"=>"Total","bch.nbcheque"=>"NbCheque","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty","s.code_compta"=>"CustomerAccountancyCode","f.ref"=>"InvoiceRef" |
|
177 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
178 | + $this->export_label[$r] = 'Bordereaux remise Chq/Fact'; |
|
179 | + $this->export_permission[$r] = array(array("banque", "export")); |
|
180 | + $this->export_fields_array[$r] = array("bch.rowid"=>"DepositId", "bch.ref"=>"Numero", "bch.ref_ext"=>"RefExt", 'ba.ref'=>'AccountRef', 'ba.label'=>'AccountLabel', 'b.datev'=>'DateValue', 'b.num_chq'=>'ChequeOrTransferNumber', 'b.amount'=>'Credit', 'b.num_releve'=>'AccountStatement', 'b.datec'=>"DateCreation", |
|
181 | + "bch.date_bordereau"=>"Date", "bch.amount"=>"Total", "bch.nbcheque"=>"NbCheque", "bu.url_id"=>"IdThirdParty", "s.nom"=>"ThirdParty", "s.code_compta"=>"CustomerAccountancyCode", "f.ref"=>"InvoiceRef" |
|
182 | 182 | ); |
183 | - $this->export_TypeFields_array[$r]=array('ba.ref'=>'Text','ba.label'=>'Text','b.datev'=>'Date','b.num_chq'=>'Text','b.amount'=>'Numeric','b.num_releve'=>'Text','b.datec'=>"Date", |
|
184 | - "bch.date_bordereau"=>"Date","bch.rowid"=>"Numeric","bch.ref"=>"Numeric","bch.ref_ext"=>"Text","bch.amount"=>"Numeric","bch.nbcheque"=>"Numeric","bu.url_id"=>"Text","s.nom"=>"Text","s.code_compta"=>"Text","f.ref"=>"Text" |
|
183 | + $this->export_TypeFields_array[$r] = array('ba.ref'=>'Text', 'ba.label'=>'Text', 'b.datev'=>'Date', 'b.num_chq'=>'Text', 'b.amount'=>'Numeric', 'b.num_releve'=>'Text', 'b.datec'=>"Date", |
|
184 | + "bch.date_bordereau"=>"Date", "bch.rowid"=>"Numeric", "bch.ref"=>"Numeric", "bch.ref_ext"=>"Text", "bch.amount"=>"Numeric", "bch.nbcheque"=>"Numeric", "bu.url_id"=>"Text", "s.nom"=>"Text", "s.code_compta"=>"Text", "f.ref"=>"Text" |
|
185 | 185 | ); |
186 | - $this->export_entities_array[$r]=array('ba.ref'=>'account','ba.label'=>'account','b.datev'=>'account','b.num_chq'=>'account','b.amount'=>'account','b.num_releve'=>'account','b.datec'=>"account", |
|
187 | - "bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company","f.ref"=>"invoice"); |
|
188 | - $this->export_special_array[$r]=array('b.amount'=>'NULLIFNEG'); |
|
189 | - |
|
190 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
191 | - $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'bordereau_cheque as bch, '.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)'; |
|
192 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')"; |
|
193 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON b.rowid = p.fk_bank'; |
|
194 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON p.rowid = pf.fk_paiement'; |
|
195 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON f.rowid = pf.fk_facture'; |
|
196 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON f.fk_soc = s.rowid'; |
|
197 | - $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account AND bch.rowid = b.fk_bordereau and bch.fk_bank_account=ba.rowid'; |
|
198 | - $this->export_sql_end[$r] .=" AND b.fk_type = 'CHQ'"; |
|
199 | - $this->export_sql_end[$r] .=' AND p.fk_paiement = 7'; |
|
200 | - $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account').')'; |
|
201 | - $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve'; |
|
186 | + $this->export_entities_array[$r] = array('ba.ref'=>'account', 'ba.label'=>'account', 'b.datev'=>'account', 'b.num_chq'=>'account', 'b.amount'=>'account', 'b.num_releve'=>'account', 'b.datec'=>"account", |
|
187 | + "bu.url_id"=>"company", "s.nom"=>"company", "s.code_compta"=>"company", "s.code_compta_fournisseur"=>"company", "f.ref"=>"invoice"); |
|
188 | + $this->export_special_array[$r] = array('b.amount'=>'NULLIFNEG'); |
|
189 | + |
|
190 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
191 | + $this->export_sql_end[$r] = ' FROM ('.MAIN_DB_PREFIX.'bordereau_cheque as bch, '.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)'; |
|
192 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')"; |
|
193 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON b.rowid = p.fk_bank'; |
|
194 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON p.rowid = pf.fk_paiement'; |
|
195 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON f.rowid = pf.fk_facture'; |
|
196 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON f.fk_soc = s.rowid'; |
|
197 | + $this->export_sql_end[$r] .= ' WHERE ba.rowid = b.fk_account AND bch.rowid = b.fk_bordereau and bch.fk_bank_account=ba.rowid'; |
|
198 | + $this->export_sql_end[$r] .= " AND b.fk_type = 'CHQ'"; |
|
199 | + $this->export_sql_end[$r] .= ' AND p.fk_paiement = 7'; |
|
200 | + $this->export_sql_end[$r] .= ' AND ba.entity IN ('.getEntity('bank_account').')'; |
|
201 | + $this->export_sql_order[$r] = ' ORDER BY b.datev, b.num_releve'; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param string $options Options when enabling module ('', 'noboxes') |
211 | 211 | * @return int 1 if OK, 0 if KO |
212 | 212 | */ |
213 | - function init($options='') |
|
213 | + function init($options = '') |
|
214 | 214 | { |
215 | 215 | global $conf; |
216 | 216 | |
@@ -219,6 +219,6 @@ discard block |
||
219 | 219 | |
220 | 220 | $sql = array(); |
221 | 221 | |
222 | - return $this->_init($sql,$options); |
|
222 | + return $this->_init($sql, $options); |
|
223 | 223 | } |
224 | 224 | } |
@@ -95,10 +95,10 @@ |
||
95 | 95 | |
96 | 96 | // Dependencies |
97 | 97 | $this->hidden = false; // A condition to hide module |
98 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
99 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
100 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
101 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
98 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
99 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
100 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
101 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
102 | 102 | $this->langfiles = array("ticket"); |
103 | 103 | // Constants |
104 | 104 | // List of particular constants to add when module is enabled |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \ingroup ticket |
25 | 25 | * \brief Description and activation file for module Ticket |
26 | 26 | */ |
27 | -require_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php"; |
|
27 | +require_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php"; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $this->version = 'experimental'; |
68 | 68 | // Key used in llx_const table to save module status enabled/disabled |
69 | 69 | // (where MYMODULE is value of property name of module in uppercase) |
70 | - $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); |
|
70 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
71 | 71 | // Name of image file used for this module. |
72 | 72 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png |
73 | 73 | // use this->picto='pictovalue' |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | $this->config_page_url = array("ticket.php"); |
95 | 95 | |
96 | 96 | // Dependencies |
97 | - $this->hidden = false; // A condition to hide module |
|
98 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
99 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
100 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
101 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
97 | + $this->hidden = false; // A condition to hide module |
|
98 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
99 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
100 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
101 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
102 | 102 | $this->langfiles = array("ticket"); |
103 | 103 | // Constants |
104 | 104 | // List of particular constants to add when module is enabled |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | ); |
115 | 115 | |
116 | 116 | // Dictionaries |
117 | - if (! isset($conf->ticket->enabled)) { |
|
118 | - $conf->ticket=new stdClass(); |
|
119 | - $conf->ticket->enabled=0; |
|
117 | + if (!isset($conf->ticket->enabled)) { |
|
118 | + $conf->ticket = new stdClass(); |
|
119 | + $conf->ticket->enabled = 0; |
|
120 | 120 | } |
121 | 121 | $this->dictionaries = array( |
122 | 122 | 'langs' => 'ticket', |
123 | - 'tabname' => array(MAIN_DB_PREFIX . "c_ticket_type", MAIN_DB_PREFIX . "c_ticket_category", MAIN_DB_PREFIX . "c_ticket_severity"), |
|
123 | + 'tabname' => array(MAIN_DB_PREFIX."c_ticket_type", MAIN_DB_PREFIX."c_ticket_category", MAIN_DB_PREFIX."c_ticket_severity"), |
|
124 | 124 | 'tablib' => array("TicketDictType", "TicketDictCategory", "TicketDictSeverity"), |
125 | - 'tabsql' => array('SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM ' . MAIN_DB_PREFIX . 'c_ticket_type as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM ' . MAIN_DB_PREFIX . 'c_ticket_category as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM ' . MAIN_DB_PREFIX . 'c_ticket_severity as f'), |
|
125 | + 'tabsql' => array('SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_type as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_category as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_severity as f'), |
|
126 | 126 | 'tabsqlsort' => array("pos ASC", "pos ASC", "pos ASC"), |
127 | 127 | 'tabfield' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"), |
128 | 128 | 'tabfieldvalue' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"), |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | // Permissions |
147 | 147 | $this->rights = array(); // Permission array used by this module |
148 | 148 | |
149 | - $r=0; |
|
149 | + $r = 0; |
|
150 | 150 | $this->rights[$r][0] = 56001; // id de la permission |
151 | 151 | $this->rights[$r][1] = "Read ticket"; // libelle de la permission |
152 | 152 | $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
@@ -33,288 +33,288 @@ |
||
33 | 33 | class modResource extends DolibarrModules |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
38 | - * |
|
39 | - * @param DoliDB $db Database handler |
|
40 | - */ |
|
41 | - public function __construct($db) |
|
42 | - { |
|
43 | - global $langs, $conf; |
|
44 | - |
|
45 | - $this->db = $db; |
|
46 | - |
|
47 | - // Id for module (must be unique). |
|
48 | - // Use a free id here |
|
49 | - // (See in Home -> System information -> Dolibarr for list of used modules id). |
|
50 | - $this->numero = 63000; |
|
51 | - |
|
52 | - // Key text used to identify module (for permissions, menus, etc...) |
|
53 | - $this->rights_class = 'resource'; |
|
54 | - |
|
55 | - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
|
56 | - // It is used to group modules in module setup page |
|
57 | - $this->family = "projects"; |
|
58 | - $this->module_position = '20'; |
|
59 | - // Module label (no space allowed) |
|
60 | - // used if translation string 'ModuleXXXName' not found |
|
61 | - // (where XXX is value of numeric property 'numero' of module) |
|
62 | - $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
63 | - // Module description |
|
64 | - // used if translation string 'ModuleXXXDesc' not found |
|
65 | - // (where XXX is value of numeric property 'numero' of module) |
|
66 | - $this->description = "Manage resources (printers, cars, room, ...) you can then share into events"; |
|
67 | - // Possible values for version are: 'development', 'experimental' or version |
|
68 | - $this->version = 'dolibarr'; |
|
69 | - // Key used in llx_const table to save module status enabled/disabled |
|
70 | - // (where MYMODULE is value of property name of module in uppercase) |
|
71 | - $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); |
|
72 | - // Name of image file used for this module. |
|
73 | - // If file is in theme/yourtheme/img directory under name object_pictovalue.png |
|
74 | - // use this->picto='pictovalue' |
|
75 | - // If file is in module/img directory under name object_pictovalue.png |
|
76 | - // use this->picto='pictovalue@module' |
|
77 | - $this->picto = 'resource'; // mypicto@resource |
|
78 | - // Defined all module parts (triggers, login, substitutions, menus, css, etc...) |
|
79 | - // for default path (eg: /resource/core/xxxxx) (0=disable, 1=enable) |
|
80 | - // for specific path of parts (eg: /resource/core/modules/barcode) |
|
81 | - // for specific css file (eg: /resource/css/resource.css.php) |
|
82 | - $this->module_parts = array(); |
|
83 | - |
|
84 | - // Data directories to create when module is enabled. |
|
85 | - // Example: this->dirs = array("/resource/temp"); |
|
86 | - //$this->dirs = array("/resource"); |
|
87 | - |
|
88 | - // Config pages. Put here list of php pages |
|
89 | - // stored into resource/admin directory, used to setup module. |
|
90 | - $this->config_page_url = array("resource.php"); |
|
91 | - |
|
92 | - // Dependencies |
|
93 | - // List of modules id that must be enabled if this module is enabled |
|
94 | - $this->depends = array(); |
|
95 | - // List of modules id to disable if this one is disabled |
|
96 | - $this->requiredby = array('modPlace'); |
|
97 | - // Minimum version of PHP required by module |
|
98 | - $this->phpmin = array(5, 4); |
|
99 | - |
|
100 | - $this->langfiles = array("resource"); // langfiles@resource |
|
101 | - // Constants |
|
102 | - // List of particular constants to add when module is enabled |
|
103 | - // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) |
|
104 | - // Example: |
|
105 | - $this->const = array(); |
|
106 | - |
|
107 | - // Array to add new pages in new tabs |
|
108 | - // Example: |
|
109 | - $this->tabs = array( |
|
110 | - // // To add a new tab identified by code tabname1 |
|
111 | - // 'objecttype:+tabname1:Title1:langfile@resource:$user->rights->resource->read:/resource/mynewtab1.php?id=__ID__', |
|
112 | - // // To add another new tab identified by code tabname2 |
|
113 | - // 'objecttype:+tabname2:Title2:langfile@resource:$user->rights->othermodule->read:/resource/mynewtab2.php?id=__ID__', |
|
114 | - // // To remove an existing tab identified by code tabname |
|
115 | - // 'objecttype:-tabname' |
|
116 | - ); |
|
117 | - // where objecttype can be |
|
118 | - // 'thirdparty' to add a tab in third party view |
|
119 | - // 'intervention' to add a tab in intervention view |
|
120 | - // 'order_supplier' to add a tab in supplier order view |
|
121 | - // 'invoice_supplier' to add a tab in supplier invoice view |
|
122 | - // 'invoice' to add a tab in customer invoice view |
|
123 | - // 'order' to add a tab in customer order view |
|
124 | - // 'product' to add a tab in product view |
|
125 | - // 'stock' to add a tab in stock view |
|
126 | - // 'propal' to add a tab in propal view |
|
127 | - // 'member' to add a tab in fundation member view |
|
128 | - // 'contract' to add a tab in contract view |
|
129 | - // 'user' to add a tab in user view |
|
130 | - // 'group' to add a tab in group view |
|
131 | - // 'contact' to add a tab in contact view |
|
132 | - // 'categories_x' to add a tab in category view |
|
133 | - // (reresource 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) |
|
134 | - |
|
135 | - // Boxes |
|
136 | - // Add here list of php file(s) stored in core/boxes that contains class to show a box. |
|
137 | - $this->boxes = array(); // Boxes list |
|
138 | - $r = 0; |
|
139 | - // Example: |
|
140 | - |
|
141 | - //$this->boxes[$r][1] = "MyBox@resource"; |
|
142 | - //$r ++; |
|
143 | - /* |
|
36 | + /** |
|
37 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
38 | + * |
|
39 | + * @param DoliDB $db Database handler |
|
40 | + */ |
|
41 | + public function __construct($db) |
|
42 | + { |
|
43 | + global $langs, $conf; |
|
44 | + |
|
45 | + $this->db = $db; |
|
46 | + |
|
47 | + // Id for module (must be unique). |
|
48 | + // Use a free id here |
|
49 | + // (See in Home -> System information -> Dolibarr for list of used modules id). |
|
50 | + $this->numero = 63000; |
|
51 | + |
|
52 | + // Key text used to identify module (for permissions, menus, etc...) |
|
53 | + $this->rights_class = 'resource'; |
|
54 | + |
|
55 | + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
|
56 | + // It is used to group modules in module setup page |
|
57 | + $this->family = "projects"; |
|
58 | + $this->module_position = '20'; |
|
59 | + // Module label (no space allowed) |
|
60 | + // used if translation string 'ModuleXXXName' not found |
|
61 | + // (where XXX is value of numeric property 'numero' of module) |
|
62 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
63 | + // Module description |
|
64 | + // used if translation string 'ModuleXXXDesc' not found |
|
65 | + // (where XXX is value of numeric property 'numero' of module) |
|
66 | + $this->description = "Manage resources (printers, cars, room, ...) you can then share into events"; |
|
67 | + // Possible values for version are: 'development', 'experimental' or version |
|
68 | + $this->version = 'dolibarr'; |
|
69 | + // Key used in llx_const table to save module status enabled/disabled |
|
70 | + // (where MYMODULE is value of property name of module in uppercase) |
|
71 | + $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); |
|
72 | + // Name of image file used for this module. |
|
73 | + // If file is in theme/yourtheme/img directory under name object_pictovalue.png |
|
74 | + // use this->picto='pictovalue' |
|
75 | + // If file is in module/img directory under name object_pictovalue.png |
|
76 | + // use this->picto='pictovalue@module' |
|
77 | + $this->picto = 'resource'; // mypicto@resource |
|
78 | + // Defined all module parts (triggers, login, substitutions, menus, css, etc...) |
|
79 | + // for default path (eg: /resource/core/xxxxx) (0=disable, 1=enable) |
|
80 | + // for specific path of parts (eg: /resource/core/modules/barcode) |
|
81 | + // for specific css file (eg: /resource/css/resource.css.php) |
|
82 | + $this->module_parts = array(); |
|
83 | + |
|
84 | + // Data directories to create when module is enabled. |
|
85 | + // Example: this->dirs = array("/resource/temp"); |
|
86 | + //$this->dirs = array("/resource"); |
|
87 | + |
|
88 | + // Config pages. Put here list of php pages |
|
89 | + // stored into resource/admin directory, used to setup module. |
|
90 | + $this->config_page_url = array("resource.php"); |
|
91 | + |
|
92 | + // Dependencies |
|
93 | + // List of modules id that must be enabled if this module is enabled |
|
94 | + $this->depends = array(); |
|
95 | + // List of modules id to disable if this one is disabled |
|
96 | + $this->requiredby = array('modPlace'); |
|
97 | + // Minimum version of PHP required by module |
|
98 | + $this->phpmin = array(5, 4); |
|
99 | + |
|
100 | + $this->langfiles = array("resource"); // langfiles@resource |
|
101 | + // Constants |
|
102 | + // List of particular constants to add when module is enabled |
|
103 | + // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) |
|
104 | + // Example: |
|
105 | + $this->const = array(); |
|
106 | + |
|
107 | + // Array to add new pages in new tabs |
|
108 | + // Example: |
|
109 | + $this->tabs = array( |
|
110 | + // // To add a new tab identified by code tabname1 |
|
111 | + // 'objecttype:+tabname1:Title1:langfile@resource:$user->rights->resource->read:/resource/mynewtab1.php?id=__ID__', |
|
112 | + // // To add another new tab identified by code tabname2 |
|
113 | + // 'objecttype:+tabname2:Title2:langfile@resource:$user->rights->othermodule->read:/resource/mynewtab2.php?id=__ID__', |
|
114 | + // // To remove an existing tab identified by code tabname |
|
115 | + // 'objecttype:-tabname' |
|
116 | + ); |
|
117 | + // where objecttype can be |
|
118 | + // 'thirdparty' to add a tab in third party view |
|
119 | + // 'intervention' to add a tab in intervention view |
|
120 | + // 'order_supplier' to add a tab in supplier order view |
|
121 | + // 'invoice_supplier' to add a tab in supplier invoice view |
|
122 | + // 'invoice' to add a tab in customer invoice view |
|
123 | + // 'order' to add a tab in customer order view |
|
124 | + // 'product' to add a tab in product view |
|
125 | + // 'stock' to add a tab in stock view |
|
126 | + // 'propal' to add a tab in propal view |
|
127 | + // 'member' to add a tab in fundation member view |
|
128 | + // 'contract' to add a tab in contract view |
|
129 | + // 'user' to add a tab in user view |
|
130 | + // 'group' to add a tab in group view |
|
131 | + // 'contact' to add a tab in contact view |
|
132 | + // 'categories_x' to add a tab in category view |
|
133 | + // (reresource 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) |
|
134 | + |
|
135 | + // Boxes |
|
136 | + // Add here list of php file(s) stored in core/boxes that contains class to show a box. |
|
137 | + $this->boxes = array(); // Boxes list |
|
138 | + $r = 0; |
|
139 | + // Example: |
|
140 | + |
|
141 | + //$this->boxes[$r][1] = "MyBox@resource"; |
|
142 | + //$r ++; |
|
143 | + /* |
|
144 | 144 | $this->boxes[$r][1] = "myboxb.php"; |
145 | 145 | $r++; |
146 | 146 | */ |
147 | 147 | |
148 | - // Permissions |
|
149 | - $this->rights = array(); // Permission array used by this module |
|
150 | - $r = 0; |
|
151 | - |
|
152 | - $this->rights[$r][0] = 63001; |
|
153 | - $this->rights[$r][1] = 'Read resources'; |
|
154 | - $this->rights[$r][3] = 0; |
|
155 | - $this->rights[$r][4] = 'read'; |
|
156 | - $r++; |
|
157 | - |
|
158 | - $this->rights[$r][0] = 63002; |
|
159 | - $this->rights[$r][1] = 'Create/Modify resources'; |
|
160 | - $this->rights[$r][3] = 0; |
|
161 | - $this->rights[$r][4] = 'write'; |
|
162 | - $r++; |
|
163 | - |
|
164 | - $this->rights[$r][0] = 63003; |
|
165 | - $this->rights[$r][1] = 'Delete resources'; |
|
166 | - $this->rights[$r][3] = 0; |
|
167 | - $this->rights[$r][4] = 'delete'; |
|
168 | - $r++; |
|
169 | - |
|
170 | - $this->rights[$r][0] = 63004; |
|
171 | - $this->rights[$r][1] = 'Link resources to agenda events'; |
|
172 | - $this->rights[$r][3] = 0; |
|
173 | - $this->rights[$r][4] = 'link'; |
|
174 | - $r++; |
|
175 | - |
|
176 | - |
|
177 | - // Menus |
|
178 | - //------- |
|
179 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
180 | - |
|
181 | - |
|
182 | - // Main menu entries |
|
183 | - $this->menu = array(); // List of menus to add |
|
184 | - $r = 0; |
|
185 | - |
|
186 | - // Menus declaration |
|
187 | - $this->menu[$r]=array( |
|
188 | - 'fk_menu'=>'fk_mainmenu=tools', |
|
189 | - 'type'=>'left', |
|
190 | - 'titre'=> 'MenuResourceIndex', |
|
191 | - 'mainmenu'=>'tools', |
|
192 | - 'leftmenu'=> 'resource', |
|
193 | - 'url'=> '/resource/list.php', |
|
194 | - 'langs'=> 'resource', |
|
195 | - 'position'=> 100, |
|
196 | - 'enabled'=> '1', |
|
197 | - 'perms'=> '$user->rights->resource->read', |
|
198 | - 'user'=> 0 |
|
199 | - ); |
|
200 | - $r++; |
|
201 | - |
|
202 | - $this->menu[$r++]=array( |
|
203 | - 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus |
|
204 | - 'type'=> 'left', // Toujours un menu gauche |
|
205 | - 'titre'=> 'MenuResourceAdd', |
|
206 | - 'mainmenu'=> 'tools', |
|
207 | - 'leftmenu'=> 'resource_add', |
|
208 | - 'url'=> '/resource/card.php?action=create', |
|
209 | - 'langs'=> 'resource', |
|
210 | - 'position'=> 101, |
|
211 | - 'enabled'=> '1', |
|
212 | - 'perms'=> '$user->rights->resource->write', |
|
213 | - 'target'=> '', |
|
214 | - 'user'=> 0 |
|
215 | - ); |
|
216 | - |
|
217 | - $this->menu[$r++]=array( |
|
218 | - 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus |
|
219 | - 'type'=> 'left', // Toujours un menu gauche |
|
220 | - 'titre'=> 'List', |
|
221 | - 'mainmenu'=> 'tools', |
|
222 | - 'leftmenu'=> 'resource_list', |
|
223 | - 'url'=> '/resource/list.php', |
|
224 | - 'langs'=> 'resource', |
|
225 | - 'position'=> 102, |
|
226 | - 'enabled'=> '1', |
|
227 | - 'perms'=> '$user->rights->resource->read', |
|
228 | - 'target'=> '', |
|
229 | - 'user'=> 0 |
|
230 | - ); |
|
231 | - |
|
232 | - |
|
233 | - // Exports |
|
234 | - //-------- |
|
235 | - $r=0; |
|
236 | - |
|
237 | - $r++; |
|
238 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
239 | - $this->export_label[$r]="ResourceSingular"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
240 | - $this->export_permission[$r]=array(array("resource","read")); |
|
241 | - $this->export_fields_array[$r]=array('r.rowid'=>'IdResource','r.ref'=>'ResourceFormLabel_ref','c.code'=>'ResourceTypeCode','c.label'=>'ResourceType','r.description'=>'ResourceFormLabel_description','r.note_private'=>"NotePrivate",'r.note_public'=>"NotePublic",'r.asset_number'=>'AssetNumber','r.datec'=>"DateCreation",'r.tms'=>"DateLastModification"); |
|
242 | - $this->export_TypeFields_array[$r]=array('r.rowid'=>'List:resource:ref','r.ref'=>'Text','r.asset_number'=>'Text','r.description'=>'Text','c.code'=>'Text','c.label'=>'List:c_type_resource:label','r.datec'=>'Date','r.tms'=>'Date','r.note_private'=>'Text','r.note_public'=>'Text'); |
|
243 | - $this->export_entities_array[$r]=array('r.rowid'=>'resource','r.ref'=>'resource','c.code'=>'resource','c.label'=>'resource','r.description'=>'resource','r.note_private'=>"resource",'r.resource'=>"resource",'r.asset_number'=>'resource','r.datec'=>"resource",'r.tms'=>"resource"); |
|
244 | - $keyforselect='resource'; $keyforelement='resource'; $keyforaliasextra='extra'; |
|
245 | - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
246 | - |
|
247 | - $this->export_dependencies_array[$r]=array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. |
|
248 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
249 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'resource as r '; |
|
250 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource'; |
|
251 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = c.rowid'; |
|
252 | - $this->export_sql_end[$r] .=' AND r.entity IN ('.getEntity('resource').')'; |
|
253 | - |
|
254 | - |
|
255 | - // Imports |
|
256 | - //-------- |
|
257 | - $r=0; |
|
258 | - |
|
259 | - // Import list of third parties and attributes |
|
260 | - $r++; |
|
261 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
262 | - $this->import_label[$r]='ImportDataset_resource_1'; |
|
263 | - $this->import_icon[$r]='resource'; |
|
264 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
265 | - $this->import_tables_array[$r]=array('r'=>MAIN_DB_PREFIX.'resource','extra'=>MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order) |
|
266 | - $this->import_fields_array[$r]=array('r.ref'=>"ResourceFormLabel_ref*",'r.fk_code_type_resource'=>'ResourceTypeCode','r.description'=>'ResourceFormLabel_description','r.note_private'=>"NotePrivate",'r.note_public'=>"NotePublic",'r.asset_number'=>'AssetNumber','r.datec'=>'DateCreation'); |
|
267 | - // Add extra fields |
|
268 | - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; |
|
269 | - $resql=$this->db->query($sql); |
|
270 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
271 | - { |
|
272 | - while ($obj=$this->db->fetch_object($resql)) |
|
273 | - { |
|
274 | - $fieldname='extra.'.$obj->name; |
|
275 | - $fieldlabel=ucfirst($obj->label); |
|
276 | - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
277 | - } |
|
278 | - } |
|
279 | - // End add extra fields |
|
280 | - $this->import_fieldshidden_array[$r]=array('r.fk_user_author'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'resource'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
281 | - $this->import_convertvalue_array[$r]=array( |
|
282 | - 'r.fk_code_type_resource'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/core/class/ctyperesource.class.php','class'=>'Ctyperesource','method'=>'fetch','dict'=>'DictionaryResourceType'), |
|
283 | - ); |
|
284 | - //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
|
285 | - $this->import_regex_array[$r]=array('s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
286 | - $this->import_examplevalues_array[$r]=array('r.ref'=>"REF1",'r.fk_code_type_resource'=>"Code from dictionary resource type",'r.datec'=>"2017-01-01 or 2017-01-01 12:30:00"); |
|
287 | - $this->import_updatekeys_array[$r]=array('r.rf'=>'ResourceFormLabel_ref'); |
|
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * Function called when module is enabled. |
|
292 | - * The init function add constants, boxes, permissions and menus |
|
293 | - * (defined in constructor) into Dolibarr database. |
|
294 | - * It also creates data directories |
|
295 | - * |
|
296 | - * @param string $options Options when enabling module ('', 'noboxes') |
|
297 | - * @return int 1 if OK, 0 if KO |
|
298 | - */ |
|
299 | - public function init($options = '') |
|
300 | - { |
|
301 | - $sql = array(); |
|
302 | - |
|
303 | - $result = $this->loadTables(); |
|
304 | - |
|
305 | - return $this->_init($sql, $options); |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * Create tables, keys and data required by module |
|
310 | - * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys |
|
311 | - * and create data commands must be stored in directory /resource/sql/ |
|
312 | - * This function is called by this->init |
|
313 | - * |
|
314 | - * @return int <=0 if KO, >0 if OK |
|
315 | - */ |
|
316 | - private function loadTables() |
|
317 | - { |
|
318 | - return $this->_load_tables('/resource/sql/'); |
|
319 | - } |
|
148 | + // Permissions |
|
149 | + $this->rights = array(); // Permission array used by this module |
|
150 | + $r = 0; |
|
151 | + |
|
152 | + $this->rights[$r][0] = 63001; |
|
153 | + $this->rights[$r][1] = 'Read resources'; |
|
154 | + $this->rights[$r][3] = 0; |
|
155 | + $this->rights[$r][4] = 'read'; |
|
156 | + $r++; |
|
157 | + |
|
158 | + $this->rights[$r][0] = 63002; |
|
159 | + $this->rights[$r][1] = 'Create/Modify resources'; |
|
160 | + $this->rights[$r][3] = 0; |
|
161 | + $this->rights[$r][4] = 'write'; |
|
162 | + $r++; |
|
163 | + |
|
164 | + $this->rights[$r][0] = 63003; |
|
165 | + $this->rights[$r][1] = 'Delete resources'; |
|
166 | + $this->rights[$r][3] = 0; |
|
167 | + $this->rights[$r][4] = 'delete'; |
|
168 | + $r++; |
|
169 | + |
|
170 | + $this->rights[$r][0] = 63004; |
|
171 | + $this->rights[$r][1] = 'Link resources to agenda events'; |
|
172 | + $this->rights[$r][3] = 0; |
|
173 | + $this->rights[$r][4] = 'link'; |
|
174 | + $r++; |
|
175 | + |
|
176 | + |
|
177 | + // Menus |
|
178 | + //------- |
|
179 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
180 | + |
|
181 | + |
|
182 | + // Main menu entries |
|
183 | + $this->menu = array(); // List of menus to add |
|
184 | + $r = 0; |
|
185 | + |
|
186 | + // Menus declaration |
|
187 | + $this->menu[$r]=array( |
|
188 | + 'fk_menu'=>'fk_mainmenu=tools', |
|
189 | + 'type'=>'left', |
|
190 | + 'titre'=> 'MenuResourceIndex', |
|
191 | + 'mainmenu'=>'tools', |
|
192 | + 'leftmenu'=> 'resource', |
|
193 | + 'url'=> '/resource/list.php', |
|
194 | + 'langs'=> 'resource', |
|
195 | + 'position'=> 100, |
|
196 | + 'enabled'=> '1', |
|
197 | + 'perms'=> '$user->rights->resource->read', |
|
198 | + 'user'=> 0 |
|
199 | + ); |
|
200 | + $r++; |
|
201 | + |
|
202 | + $this->menu[$r++]=array( |
|
203 | + 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus |
|
204 | + 'type'=> 'left', // Toujours un menu gauche |
|
205 | + 'titre'=> 'MenuResourceAdd', |
|
206 | + 'mainmenu'=> 'tools', |
|
207 | + 'leftmenu'=> 'resource_add', |
|
208 | + 'url'=> '/resource/card.php?action=create', |
|
209 | + 'langs'=> 'resource', |
|
210 | + 'position'=> 101, |
|
211 | + 'enabled'=> '1', |
|
212 | + 'perms'=> '$user->rights->resource->write', |
|
213 | + 'target'=> '', |
|
214 | + 'user'=> 0 |
|
215 | + ); |
|
216 | + |
|
217 | + $this->menu[$r++]=array( |
|
218 | + 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus |
|
219 | + 'type'=> 'left', // Toujours un menu gauche |
|
220 | + 'titre'=> 'List', |
|
221 | + 'mainmenu'=> 'tools', |
|
222 | + 'leftmenu'=> 'resource_list', |
|
223 | + 'url'=> '/resource/list.php', |
|
224 | + 'langs'=> 'resource', |
|
225 | + 'position'=> 102, |
|
226 | + 'enabled'=> '1', |
|
227 | + 'perms'=> '$user->rights->resource->read', |
|
228 | + 'target'=> '', |
|
229 | + 'user'=> 0 |
|
230 | + ); |
|
231 | + |
|
232 | + |
|
233 | + // Exports |
|
234 | + //-------- |
|
235 | + $r=0; |
|
236 | + |
|
237 | + $r++; |
|
238 | + $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
239 | + $this->export_label[$r]="ResourceSingular"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
240 | + $this->export_permission[$r]=array(array("resource","read")); |
|
241 | + $this->export_fields_array[$r]=array('r.rowid'=>'IdResource','r.ref'=>'ResourceFormLabel_ref','c.code'=>'ResourceTypeCode','c.label'=>'ResourceType','r.description'=>'ResourceFormLabel_description','r.note_private'=>"NotePrivate",'r.note_public'=>"NotePublic",'r.asset_number'=>'AssetNumber','r.datec'=>"DateCreation",'r.tms'=>"DateLastModification"); |
|
242 | + $this->export_TypeFields_array[$r]=array('r.rowid'=>'List:resource:ref','r.ref'=>'Text','r.asset_number'=>'Text','r.description'=>'Text','c.code'=>'Text','c.label'=>'List:c_type_resource:label','r.datec'=>'Date','r.tms'=>'Date','r.note_private'=>'Text','r.note_public'=>'Text'); |
|
243 | + $this->export_entities_array[$r]=array('r.rowid'=>'resource','r.ref'=>'resource','c.code'=>'resource','c.label'=>'resource','r.description'=>'resource','r.note_private'=>"resource",'r.resource'=>"resource",'r.asset_number'=>'resource','r.datec'=>"resource",'r.tms'=>"resource"); |
|
244 | + $keyforselect='resource'; $keyforelement='resource'; $keyforaliasextra='extra'; |
|
245 | + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
246 | + |
|
247 | + $this->export_dependencies_array[$r]=array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. |
|
248 | + $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
249 | + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'resource as r '; |
|
250 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource'; |
|
251 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = c.rowid'; |
|
252 | + $this->export_sql_end[$r] .=' AND r.entity IN ('.getEntity('resource').')'; |
|
253 | + |
|
254 | + |
|
255 | + // Imports |
|
256 | + //-------- |
|
257 | + $r=0; |
|
258 | + |
|
259 | + // Import list of third parties and attributes |
|
260 | + $r++; |
|
261 | + $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
262 | + $this->import_label[$r]='ImportDataset_resource_1'; |
|
263 | + $this->import_icon[$r]='resource'; |
|
264 | + $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
265 | + $this->import_tables_array[$r]=array('r'=>MAIN_DB_PREFIX.'resource','extra'=>MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order) |
|
266 | + $this->import_fields_array[$r]=array('r.ref'=>"ResourceFormLabel_ref*",'r.fk_code_type_resource'=>'ResourceTypeCode','r.description'=>'ResourceFormLabel_description','r.note_private'=>"NotePrivate",'r.note_public'=>"NotePublic",'r.asset_number'=>'AssetNumber','r.datec'=>'DateCreation'); |
|
267 | + // Add extra fields |
|
268 | + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; |
|
269 | + $resql=$this->db->query($sql); |
|
270 | + if ($resql) // This can fail when class is used on old database (during migration for example) |
|
271 | + { |
|
272 | + while ($obj=$this->db->fetch_object($resql)) |
|
273 | + { |
|
274 | + $fieldname='extra.'.$obj->name; |
|
275 | + $fieldlabel=ucfirst($obj->label); |
|
276 | + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
277 | + } |
|
278 | + } |
|
279 | + // End add extra fields |
|
280 | + $this->import_fieldshidden_array[$r]=array('r.fk_user_author'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'resource'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
281 | + $this->import_convertvalue_array[$r]=array( |
|
282 | + 'r.fk_code_type_resource'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/core/class/ctyperesource.class.php','class'=>'Ctyperesource','method'=>'fetch','dict'=>'DictionaryResourceType'), |
|
283 | + ); |
|
284 | + //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
|
285 | + $this->import_regex_array[$r]=array('s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
286 | + $this->import_examplevalues_array[$r]=array('r.ref'=>"REF1",'r.fk_code_type_resource'=>"Code from dictionary resource type",'r.datec'=>"2017-01-01 or 2017-01-01 12:30:00"); |
|
287 | + $this->import_updatekeys_array[$r]=array('r.rf'=>'ResourceFormLabel_ref'); |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * Function called when module is enabled. |
|
292 | + * The init function add constants, boxes, permissions and menus |
|
293 | + * (defined in constructor) into Dolibarr database. |
|
294 | + * It also creates data directories |
|
295 | + * |
|
296 | + * @param string $options Options when enabling module ('', 'noboxes') |
|
297 | + * @return int 1 if OK, 0 if KO |
|
298 | + */ |
|
299 | + public function init($options = '') |
|
300 | + { |
|
301 | + $sql = array(); |
|
302 | + |
|
303 | + $result = $this->loadTables(); |
|
304 | + |
|
305 | + return $this->_init($sql, $options); |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * Create tables, keys and data required by module |
|
310 | + * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys |
|
311 | + * and create data commands must be stored in directory /resource/sql/ |
|
312 | + * This function is called by this->init |
|
313 | + * |
|
314 | + * @return int <=0 if KO, >0 if OK |
|
315 | + */ |
|
316 | + private function loadTables() |
|
317 | + { |
|
318 | + return $this->_load_tables('/resource/sql/'); |
|
319 | + } |
|
320 | 320 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * \ingroup resource |
26 | 26 | * \brief Description and activation file for module Resource |
27 | 27 | */ |
28 | -include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php"; |
|
28 | +include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php"; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Description and activation class for module Resource |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $this->version = 'dolibarr'; |
69 | 69 | // Key used in llx_const table to save module status enabled/disabled |
70 | 70 | // (where MYMODULE is value of property name of module in uppercase) |
71 | - $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); |
|
71 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
72 | 72 | // Name of image file used for this module. |
73 | 73 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png |
74 | 74 | // use this->picto='pictovalue' |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | // Menus |
178 | 178 | //------- |
179 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
179 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
180 | 180 | |
181 | 181 | |
182 | 182 | // Main menu entries |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $r = 0; |
185 | 185 | |
186 | 186 | // Menus declaration |
187 | - $this->menu[$r]=array( |
|
187 | + $this->menu[$r] = array( |
|
188 | 188 | 'fk_menu'=>'fk_mainmenu=tools', |
189 | 189 | 'type'=>'left', |
190 | 190 | 'titre'=> 'MenuResourceIndex', |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | ); |
200 | 200 | $r++; |
201 | 201 | |
202 | - $this->menu[$r++]=array( |
|
202 | + $this->menu[$r++] = array( |
|
203 | 203 | 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus |
204 | 204 | 'type'=> 'left', // Toujours un menu gauche |
205 | 205 | 'titre'=> 'MenuResourceAdd', |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | 'user'=> 0 |
215 | 215 | ); |
216 | 216 | |
217 | - $this->menu[$r++]=array( |
|
217 | + $this->menu[$r++] = array( |
|
218 | 218 | 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus |
219 | 219 | 'type'=> 'left', // Toujours un menu gauche |
220 | 220 | 'titre'=> 'List', |
@@ -232,59 +232,59 @@ discard block |
||
232 | 232 | |
233 | 233 | // Exports |
234 | 234 | //-------- |
235 | - $r=0; |
|
235 | + $r = 0; |
|
236 | 236 | |
237 | 237 | $r++; |
238 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
239 | - $this->export_label[$r]="ResourceSingular"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
240 | - $this->export_permission[$r]=array(array("resource","read")); |
|
241 | - $this->export_fields_array[$r]=array('r.rowid'=>'IdResource','r.ref'=>'ResourceFormLabel_ref','c.code'=>'ResourceTypeCode','c.label'=>'ResourceType','r.description'=>'ResourceFormLabel_description','r.note_private'=>"NotePrivate",'r.note_public'=>"NotePublic",'r.asset_number'=>'AssetNumber','r.datec'=>"DateCreation",'r.tms'=>"DateLastModification"); |
|
242 | - $this->export_TypeFields_array[$r]=array('r.rowid'=>'List:resource:ref','r.ref'=>'Text','r.asset_number'=>'Text','r.description'=>'Text','c.code'=>'Text','c.label'=>'List:c_type_resource:label','r.datec'=>'Date','r.tms'=>'Date','r.note_private'=>'Text','r.note_public'=>'Text'); |
|
243 | - $this->export_entities_array[$r]=array('r.rowid'=>'resource','r.ref'=>'resource','c.code'=>'resource','c.label'=>'resource','r.description'=>'resource','r.note_private'=>"resource",'r.resource'=>"resource",'r.asset_number'=>'resource','r.datec'=>"resource",'r.tms'=>"resource"); |
|
244 | - $keyforselect='resource'; $keyforelement='resource'; $keyforaliasextra='extra'; |
|
238 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
239 | + $this->export_label[$r] = "ResourceSingular"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
240 | + $this->export_permission[$r] = array(array("resource", "read")); |
|
241 | + $this->export_fields_array[$r] = array('r.rowid'=>'IdResource', 'r.ref'=>'ResourceFormLabel_ref', 'c.code'=>'ResourceTypeCode', 'c.label'=>'ResourceType', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>"DateCreation", 'r.tms'=>"DateLastModification"); |
|
242 | + $this->export_TypeFields_array[$r] = array('r.rowid'=>'List:resource:ref', 'r.ref'=>'Text', 'r.asset_number'=>'Text', 'r.description'=>'Text', 'c.code'=>'Text', 'c.label'=>'List:c_type_resource:label', 'r.datec'=>'Date', 'r.tms'=>'Date', 'r.note_private'=>'Text', 'r.note_public'=>'Text'); |
|
243 | + $this->export_entities_array[$r] = array('r.rowid'=>'resource', 'r.ref'=>'resource', 'c.code'=>'resource', 'c.label'=>'resource', 'r.description'=>'resource', 'r.note_private'=>"resource", 'r.resource'=>"resource", 'r.asset_number'=>'resource', 'r.datec'=>"resource", 'r.tms'=>"resource"); |
|
244 | + $keyforselect = 'resource'; $keyforelement = 'resource'; $keyforaliasextra = 'extra'; |
|
245 | 245 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
246 | 246 | |
247 | - $this->export_dependencies_array[$r]=array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. |
|
248 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
249 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'resource as r '; |
|
250 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource'; |
|
251 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = c.rowid'; |
|
252 | - $this->export_sql_end[$r] .=' AND r.entity IN ('.getEntity('resource').')'; |
|
247 | + $this->export_dependencies_array[$r] = array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. |
|
248 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
249 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'resource as r '; |
|
250 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource'; |
|
251 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = c.rowid'; |
|
252 | + $this->export_sql_end[$r] .= ' AND r.entity IN ('.getEntity('resource').')'; |
|
253 | 253 | |
254 | 254 | |
255 | 255 | // Imports |
256 | 256 | //-------- |
257 | - $r=0; |
|
257 | + $r = 0; |
|
258 | 258 | |
259 | 259 | // Import list of third parties and attributes |
260 | 260 | $r++; |
261 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
262 | - $this->import_label[$r]='ImportDataset_resource_1'; |
|
263 | - $this->import_icon[$r]='resource'; |
|
264 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
265 | - $this->import_tables_array[$r]=array('r'=>MAIN_DB_PREFIX.'resource','extra'=>MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order) |
|
266 | - $this->import_fields_array[$r]=array('r.ref'=>"ResourceFormLabel_ref*",'r.fk_code_type_resource'=>'ResourceTypeCode','r.description'=>'ResourceFormLabel_description','r.note_private'=>"NotePrivate",'r.note_public'=>"NotePublic",'r.asset_number'=>'AssetNumber','r.datec'=>'DateCreation'); |
|
261 | + $this->import_code[$r] = $this->rights_class.'_'.$r; |
|
262 | + $this->import_label[$r] = 'ImportDataset_resource_1'; |
|
263 | + $this->import_icon[$r] = 'resource'; |
|
264 | + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
265 | + $this->import_tables_array[$r] = array('r'=>MAIN_DB_PREFIX.'resource', 'extra'=>MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order) |
|
266 | + $this->import_fields_array[$r] = array('r.ref'=>"ResourceFormLabel_ref*", 'r.fk_code_type_resource'=>'ResourceTypeCode', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>'DateCreation'); |
|
267 | 267 | // Add extra fields |
268 | - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; |
|
269 | - $resql=$this->db->query($sql); |
|
268 | + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; |
|
269 | + $resql = $this->db->query($sql); |
|
270 | 270 | if ($resql) // This can fail when class is used on old database (during migration for example) |
271 | 271 | { |
272 | - while ($obj=$this->db->fetch_object($resql)) |
|
272 | + while ($obj = $this->db->fetch_object($resql)) |
|
273 | 273 | { |
274 | - $fieldname='extra.'.$obj->name; |
|
275 | - $fieldlabel=ucfirst($obj->label); |
|
276 | - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
274 | + $fieldname = 'extra.'.$obj->name; |
|
275 | + $fieldlabel = ucfirst($obj->label); |
|
276 | + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | // End add extra fields |
280 | - $this->import_fieldshidden_array[$r]=array('r.fk_user_author'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'resource'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
281 | - $this->import_convertvalue_array[$r]=array( |
|
282 | - 'r.fk_code_type_resource'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/core/class/ctyperesource.class.php','class'=>'Ctyperesource','method'=>'fetch','dict'=>'DictionaryResourceType'), |
|
280 | + $this->import_fieldshidden_array[$r] = array('r.fk_user_author'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'resource'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
281 | + $this->import_convertvalue_array[$r] = array( |
|
282 | + 'r.fk_code_type_resource'=>array('rule'=>'fetchidfromcodeorlabel', 'classfile'=>'/core/class/ctyperesource.class.php', 'class'=>'Ctyperesource', 'method'=>'fetch', 'dict'=>'DictionaryResourceType'), |
|
283 | 283 | ); |
284 | 284 | //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
285 | - $this->import_regex_array[$r]=array('s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
286 | - $this->import_examplevalues_array[$r]=array('r.ref'=>"REF1",'r.fk_code_type_resource'=>"Code from dictionary resource type",'r.datec'=>"2017-01-01 or 2017-01-01 12:30:00"); |
|
287 | - $this->import_updatekeys_array[$r]=array('r.rf'=>'ResourceFormLabel_ref'); |
|
285 | + $this->import_regex_array[$r] = array('s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
286 | + $this->import_examplevalues_array[$r] = array('r.ref'=>"REF1", 'r.fk_code_type_resource'=>"Code from dictionary resource type", 'r.datec'=>"2017-01-01 or 2017-01-01 12:30:00"); |
|
287 | + $this->import_updatekeys_array[$r] = array('r.rf'=>'ResourceFormLabel_ref'); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -267,11 +267,13 @@ |
||
267 | 267 | // Add extra fields |
268 | 268 | $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; |
269 | 269 | $resql=$this->db->query($sql); |
270 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
270 | + if ($resql) { |
|
271 | + // This can fail when class is used on old database (during migration for example) |
|
271 | 272 | { |
272 | 273 | while ($obj=$this->db->fetch_object($resql)) |
273 | 274 | { |
274 | 275 | $fieldname='extra.'.$obj->name; |
276 | + } |
|
275 | 277 | $fieldlabel=ucfirst($obj->label); |
276 | 278 | $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
277 | 279 | } |
@@ -33,80 +33,80 @@ |
||
33 | 33 | class modLabel extends DolibarrModules |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
38 | - * |
|
39 | - * @param DoliDB $db Database handler |
|
40 | - */ |
|
41 | - function __construct($db) |
|
42 | - { |
|
43 | - $this->db = $db; |
|
44 | - $this->numero = 60; |
|
45 | - |
|
46 | - $this->family = "technic"; |
|
47 | - $this->module_position = '75'; |
|
48 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
49 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
50 | - $this->description = "Gestion des etiquettes"; |
|
51 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
52 | - $this->version = 'development'; |
|
53 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
54 | - $this->picto='label'; |
|
55 | - |
|
56 | - // Data directories to create when module is enabled |
|
57 | - $this->dirs = array("/label/temp"); |
|
58 | - |
|
59 | - // Dependencies |
|
60 | - $this->hidden = false; // A condition to hide module |
|
61 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
62 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
63 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
64 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
65 | - |
|
66 | - // Config pages |
|
67 | - // $this->config_page_url = array("label.php"); |
|
68 | - |
|
69 | - // Constants |
|
70 | - $this->const = array(); |
|
71 | - |
|
72 | - // Boxes |
|
73 | - $this->boxes = array(); |
|
74 | - |
|
75 | - // Permissions |
|
76 | - $this->rights = array(); |
|
77 | - $this->rights_class = 'label'; |
|
78 | - |
|
79 | - $this->rights[1][0] = 601; // id de la permission |
|
80 | - $this->rights[1][1] = 'Lire les etiquettes'; // libelle de la permission |
|
81 | - $this->rights[1][3] = 1; // La permission est-elle une permission par defaut |
|
82 | - $this->rights[1][4] = 'lire'; |
|
83 | - |
|
84 | - $this->rights[2][0] = 602; // id de la permission |
|
85 | - $this->rights[2][1] = 'Creer/modifier les etiquettes'; // libelle de la permission |
|
86 | - $this->rights[2][3] = 0; // La permission est-elle une permission par defaut |
|
87 | - $this->rights[2][4] = 'creer'; |
|
88 | - |
|
89 | - $this->rights[4][0] = 609; // id de la permission |
|
90 | - $this->rights[4][1] = 'Supprimer les etiquettes'; // libelle de la permission |
|
91 | - $this->rights[4][3] = 0; // La permission est-elle une permission par defaut |
|
92 | - $this->rights[4][4] = 'supprimer'; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Function called when module is enabled. |
|
97 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
98 | - * It also creates data directories |
|
99 | - * |
|
36 | + /** |
|
37 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
38 | + * |
|
39 | + * @param DoliDB $db Database handler |
|
40 | + */ |
|
41 | + function __construct($db) |
|
42 | + { |
|
43 | + $this->db = $db; |
|
44 | + $this->numero = 60; |
|
45 | + |
|
46 | + $this->family = "technic"; |
|
47 | + $this->module_position = '75'; |
|
48 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
49 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
50 | + $this->description = "Gestion des etiquettes"; |
|
51 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
52 | + $this->version = 'development'; |
|
53 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
54 | + $this->picto='label'; |
|
55 | + |
|
56 | + // Data directories to create when module is enabled |
|
57 | + $this->dirs = array("/label/temp"); |
|
58 | + |
|
59 | + // Dependencies |
|
60 | + $this->hidden = false; // A condition to hide module |
|
61 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
62 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
63 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
64 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
65 | + |
|
66 | + // Config pages |
|
67 | + // $this->config_page_url = array("label.php"); |
|
68 | + |
|
69 | + // Constants |
|
70 | + $this->const = array(); |
|
71 | + |
|
72 | + // Boxes |
|
73 | + $this->boxes = array(); |
|
74 | + |
|
75 | + // Permissions |
|
76 | + $this->rights = array(); |
|
77 | + $this->rights_class = 'label'; |
|
78 | + |
|
79 | + $this->rights[1][0] = 601; // id de la permission |
|
80 | + $this->rights[1][1] = 'Lire les etiquettes'; // libelle de la permission |
|
81 | + $this->rights[1][3] = 1; // La permission est-elle une permission par defaut |
|
82 | + $this->rights[1][4] = 'lire'; |
|
83 | + |
|
84 | + $this->rights[2][0] = 602; // id de la permission |
|
85 | + $this->rights[2][1] = 'Creer/modifier les etiquettes'; // libelle de la permission |
|
86 | + $this->rights[2][3] = 0; // La permission est-elle une permission par defaut |
|
87 | + $this->rights[2][4] = 'creer'; |
|
88 | + |
|
89 | + $this->rights[4][0] = 609; // id de la permission |
|
90 | + $this->rights[4][1] = 'Supprimer les etiquettes'; // libelle de la permission |
|
91 | + $this->rights[4][3] = 0; // La permission est-elle une permission par defaut |
|
92 | + $this->rights[4][4] = 'supprimer'; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Function called when module is enabled. |
|
97 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
98 | + * It also creates data directories |
|
99 | + * |
|
100 | 100 | * @param string $options Options when enabling module ('', 'noboxes') |
101 | - * @return int 1 if OK, 0 if KO |
|
102 | - */ |
|
103 | - function init($options='') |
|
104 | - { |
|
105 | - // Permissions |
|
106 | - $this->remove($options); |
|
101 | + * @return int 1 if OK, 0 if KO |
|
102 | + */ |
|
103 | + function init($options='') |
|
104 | + { |
|
105 | + // Permissions |
|
106 | + $this->remove($options); |
|
107 | 107 | |
108 | - $sql = array(); |
|
108 | + $sql = array(); |
|
109 | 109 | |
110 | - return $this->_init($sql,$options); |
|
111 | - } |
|
110 | + return $this->_init($sql,$options); |
|
111 | + } |
|
112 | 112 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \brief Fichier de description et activation du module Label |
25 | 25 | */ |
26 | 26 | |
27 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
27 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | $this->family = "technic"; |
47 | 47 | $this->module_position = '75'; |
48 | 48 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
49 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
49 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
50 | 50 | $this->description = "Gestion des etiquettes"; |
51 | 51 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
52 | 52 | $this->version = 'development'; |
53 | 53 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
54 | - $this->picto='label'; |
|
54 | + $this->picto = 'label'; |
|
55 | 55 | |
56 | 56 | // Data directories to create when module is enabled |
57 | 57 | $this->dirs = array("/label/temp"); |
58 | 58 | |
59 | 59 | // Dependencies |
60 | - $this->hidden = false; // A condition to hide module |
|
61 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
62 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
63 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
64 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
60 | + $this->hidden = false; // A condition to hide module |
|
61 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
62 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
63 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
64 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
65 | 65 | |
66 | 66 | // Config pages |
67 | 67 | // $this->config_page_url = array("label.php"); |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | * @param string $options Options when enabling module ('', 'noboxes') |
101 | 101 | * @return int 1 if OK, 0 if KO |
102 | 102 | */ |
103 | - function init($options='') |
|
103 | + function init($options = '') |
|
104 | 104 | { |
105 | 105 | // Permissions |
106 | 106 | $this->remove($options); |
107 | 107 | |
108 | 108 | $sql = array(); |
109 | 109 | |
110 | - return $this->_init($sql,$options); |
|
110 | + return $this->_init($sql, $options); |
|
111 | 111 | } |
112 | 112 | } |
@@ -43,137 +43,137 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public $db; |
45 | 45 | |
46 | - /** |
|
46 | + /** |
|
47 | 47 | * @var string model name |
48 | 48 | */ |
49 | 49 | public $name; |
50 | 50 | |
51 | - /** |
|
51 | + /** |
|
52 | 52 | * @var string model description (short text) |
53 | 53 | */ |
54 | 54 | public $description; |
55 | 55 | |
56 | - /** |
|
56 | + /** |
|
57 | 57 | * @var string document type |
58 | 58 | */ |
59 | 59 | public $type; |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @var array() Minimum version of PHP required by module. |
63 | - * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
63 | + * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
64 | 64 | */ |
65 | - public $phpmin = array(5, 4); |
|
65 | + public $phpmin = array(5, 4); |
|
66 | 66 | |
67 | - /** |
|
67 | + /** |
|
68 | 68 | * Dolibarr version of the loaded document |
69 | 69 | * @public string |
70 | 70 | */ |
71 | - public $version = 'dolibarr'; |
|
71 | + public $version = 'dolibarr'; |
|
72 | 72 | |
73 | - /** |
|
73 | + /** |
|
74 | 74 | * @var int page_largeur |
75 | 75 | */ |
76 | 76 | public $page_largeur; |
77 | 77 | |
78 | - /** |
|
78 | + /** |
|
79 | 79 | * @var int page_hauteur |
80 | 80 | */ |
81 | 81 | public $page_hauteur; |
82 | 82 | |
83 | - /** |
|
83 | + /** |
|
84 | 84 | * @var array format |
85 | 85 | */ |
86 | 86 | public $format; |
87 | 87 | |
88 | - /** |
|
88 | + /** |
|
89 | 89 | * @var int marge_gauche |
90 | 90 | */ |
91 | - public $marge_gauche; |
|
91 | + public $marge_gauche; |
|
92 | 92 | |
93 | - /** |
|
93 | + /** |
|
94 | 94 | * @var int marge_droite |
95 | 95 | */ |
96 | - public $marge_droite; |
|
96 | + public $marge_droite; |
|
97 | 97 | |
98 | - /** |
|
98 | + /** |
|
99 | 99 | * @var int marge_haute |
100 | 100 | */ |
101 | - public $marge_haute; |
|
101 | + public $marge_haute; |
|
102 | 102 | |
103 | - /** |
|
103 | + /** |
|
104 | 104 | * @var int marge_basse |
105 | 105 | */ |
106 | - public $marge_basse; |
|
107 | - |
|
108 | - /** |
|
109 | - * Issuer |
|
110 | - * @var Societe |
|
111 | - */ |
|
112 | - public $emetteur; |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * Constructor |
|
117 | - * |
|
118 | - * @param DoliDB $db Database handler |
|
119 | - */ |
|
120 | - function __construct($db) |
|
121 | - { |
|
122 | - global $conf, $langs, $mysoc; |
|
123 | - |
|
124 | - // Load translation files required by the page |
|
125 | - $langs->loadLangs(array("main", "bills")); |
|
126 | - |
|
127 | - $this->db = $db; |
|
128 | - $this->name = "standard"; |
|
129 | - $this->description = $langs->trans('DocumentModelStandardPDF'); |
|
130 | - |
|
131 | - // Dimension page pour format A4 |
|
132 | - $this->type = 'pdf'; |
|
133 | - $formatarray=pdf_getFormat(); |
|
134 | - $this->page_largeur = $formatarray['width']; |
|
135 | - $this->page_hauteur = $formatarray['height']; |
|
136 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
137 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
138 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
139 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
140 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
141 | - |
|
142 | - $this->option_logo = 1; // Affiche logo |
|
143 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
144 | - |
|
145 | - $this->franchise=!$mysoc->tva_assuj; |
|
106 | + public $marge_basse; |
|
107 | + |
|
108 | + /** |
|
109 | + * Issuer |
|
110 | + * @var Societe |
|
111 | + */ |
|
112 | + public $emetteur; |
|
146 | 113 | |
147 | - // Defini position des colonnes |
|
148 | - $this->posxdate=$this->marge_gauche+1; |
|
149 | - $this->posxreffacturefourn=30; |
|
150 | - $this->posxreffacture=65; |
|
151 | - $this->posxtype=100; |
|
152 | - $this->posxtotalht=80; |
|
153 | - $this->posxtva=90; |
|
154 | - $this->posxtotalttc=180; |
|
155 | - |
|
156 | - //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; |
|
157 | - if ($this->page_largeur < 210) // To work with US executive format |
|
158 | - { |
|
159 | - $this->posxreffacturefourn-=20; |
|
160 | - $this->posxreffacture-=20; |
|
161 | - $this->posxtype-=20; |
|
162 | - $this->posxtotalht-=20; |
|
163 | - $this->posxtva-=20; |
|
164 | - $this->posxtotalttc-=20; |
|
165 | - } |
|
166 | 114 | |
167 | - $this->tva=array(); |
|
115 | + /** |
|
116 | + * Constructor |
|
117 | + * |
|
118 | + * @param DoliDB $db Database handler |
|
119 | + */ |
|
120 | + function __construct($db) |
|
121 | + { |
|
122 | + global $conf, $langs, $mysoc; |
|
123 | + |
|
124 | + // Load translation files required by the page |
|
125 | + $langs->loadLangs(array("main", "bills")); |
|
126 | + |
|
127 | + $this->db = $db; |
|
128 | + $this->name = "standard"; |
|
129 | + $this->description = $langs->trans('DocumentModelStandardPDF'); |
|
130 | + |
|
131 | + // Dimension page pour format A4 |
|
132 | + $this->type = 'pdf'; |
|
133 | + $formatarray=pdf_getFormat(); |
|
134 | + $this->page_largeur = $formatarray['width']; |
|
135 | + $this->page_hauteur = $formatarray['height']; |
|
136 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
137 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
138 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
139 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
140 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
141 | + |
|
142 | + $this->option_logo = 1; // Affiche logo |
|
143 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
144 | + |
|
145 | + $this->franchise=!$mysoc->tva_assuj; |
|
146 | + |
|
147 | + // Defini position des colonnes |
|
148 | + $this->posxdate=$this->marge_gauche+1; |
|
149 | + $this->posxreffacturefourn=30; |
|
150 | + $this->posxreffacture=65; |
|
151 | + $this->posxtype=100; |
|
152 | + $this->posxtotalht=80; |
|
153 | + $this->posxtva=90; |
|
154 | + $this->posxtotalttc=180; |
|
155 | + |
|
156 | + //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; |
|
157 | + if ($this->page_largeur < 210) // To work with US executive format |
|
158 | + { |
|
159 | + $this->posxreffacturefourn-=20; |
|
160 | + $this->posxreffacture-=20; |
|
161 | + $this->posxtype-=20; |
|
162 | + $this->posxtotalht-=20; |
|
163 | + $this->posxtva-=20; |
|
164 | + $this->posxtotalttc-=20; |
|
165 | + } |
|
166 | + |
|
167 | + $this->tva=array(); |
|
168 | 168 | $this->localtax1=array(); |
169 | 169 | $this->localtax2=array(); |
170 | - $this->atleastoneratenotnull=0; |
|
171 | - $this->atleastonediscount=0; |
|
170 | + $this->atleastoneratenotnull=0; |
|
171 | + $this->atleastonediscount=0; |
|
172 | 172 | |
173 | - // Recupere emetteur |
|
174 | - $this->emetteur=$mysoc; |
|
175 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
176 | - } |
|
173 | + // Recupere emetteur |
|
174 | + $this->emetteur=$mysoc; |
|
175 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
176 | + } |
|
177 | 177 | |
178 | 178 | |
179 | 179 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -188,90 +188,90 @@ discard block |
||
188 | 188 | * @param int $hideref Do not show ref |
189 | 189 | * @return int 1=OK, 0=KO |
190 | 190 | */ |
191 | - function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0) |
|
192 | - { |
|
191 | + function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0) |
|
192 | + { |
|
193 | 193 | // phpcs:enable |
194 | - global $user, $langs, $conf, $mysoc, $hookmanager; |
|
195 | - |
|
196 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
197 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
198 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
199 | - |
|
200 | - // Load translation files required by the page |
|
201 | - $outputlangs->loadLangs(array("main", "suppliers", "companies", "bills", "dict", "products")); |
|
202 | - |
|
203 | - $object->factures = array(); |
|
204 | - |
|
205 | - if ($conf->fournisseur->payment->dir_output) |
|
206 | - { |
|
207 | - $object->fetch_thirdparty(); |
|
208 | - /** |
|
209 | - * Supplier invoice list |
|
210 | - */ |
|
211 | - $sql = 'SELECT f.rowid, f.ref, f.datef, f.ref_supplier, f.total_ht, f.total_tva, f.total_ttc, pf.amount, f.rowid as facid, f.paye'; |
|
212 | - $sql .= ', f.fk_statut, s.nom as name, s.rowid as socid'; |
|
213 | - $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s'; |
|
214 | - $sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid'; |
|
215 | - $sql .= ' AND pf.fk_paiementfourn = '.$object->id; |
|
216 | - $resql=$this->db->query($sql); |
|
217 | - if ($resql) |
|
218 | - { |
|
219 | - if ($this->db->num_rows($resql) > 0) |
|
220 | - { |
|
221 | - while($objp = $this->db->fetch_object($resql)) { |
|
222 | - $objp->type = $outputlangs->trans('SupplierInvoice'); |
|
223 | - $object->lines[] = $objp; |
|
224 | - } |
|
225 | - } |
|
226 | - } |
|
227 | - |
|
228 | - $total = $object->montant; |
|
229 | - |
|
230 | - // Definition of $dir and $file |
|
231 | - if ($object->specimen) |
|
232 | - { |
|
233 | - $dir = $conf->fournisseur->payment->dir_output; |
|
234 | - $file = $dir . "/SPECIMEN.pdf"; |
|
235 | - } |
|
236 | - else |
|
237 | - { |
|
238 | - $objectref = dol_sanitizeFileName($object->ref); |
|
239 | - $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); |
|
194 | + global $user, $langs, $conf, $mysoc, $hookmanager; |
|
195 | + |
|
196 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
197 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
198 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
199 | + |
|
200 | + // Load translation files required by the page |
|
201 | + $outputlangs->loadLangs(array("main", "suppliers", "companies", "bills", "dict", "products")); |
|
202 | + |
|
203 | + $object->factures = array(); |
|
204 | + |
|
205 | + if ($conf->fournisseur->payment->dir_output) |
|
206 | + { |
|
207 | + $object->fetch_thirdparty(); |
|
208 | + /** |
|
209 | + * Supplier invoice list |
|
210 | + */ |
|
211 | + $sql = 'SELECT f.rowid, f.ref, f.datef, f.ref_supplier, f.total_ht, f.total_tva, f.total_ttc, pf.amount, f.rowid as facid, f.paye'; |
|
212 | + $sql .= ', f.fk_statut, s.nom as name, s.rowid as socid'; |
|
213 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s'; |
|
214 | + $sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid'; |
|
215 | + $sql .= ' AND pf.fk_paiementfourn = '.$object->id; |
|
216 | + $resql=$this->db->query($sql); |
|
217 | + if ($resql) |
|
218 | + { |
|
219 | + if ($this->db->num_rows($resql) > 0) |
|
220 | + { |
|
221 | + while($objp = $this->db->fetch_object($resql)) { |
|
222 | + $objp->type = $outputlangs->trans('SupplierInvoice'); |
|
223 | + $object->lines[] = $objp; |
|
224 | + } |
|
225 | + } |
|
226 | + } |
|
227 | + |
|
228 | + $total = $object->montant; |
|
229 | + |
|
230 | + // Definition of $dir and $file |
|
231 | + if ($object->specimen) |
|
232 | + { |
|
233 | + $dir = $conf->fournisseur->payment->dir_output; |
|
234 | + $file = $dir . "/SPECIMEN.pdf"; |
|
235 | + } |
|
236 | + else |
|
237 | + { |
|
238 | + $objectref = dol_sanitizeFileName($object->ref); |
|
239 | + $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); |
|
240 | 240 | $dir = $conf->fournisseur->payment->dir_output.'/'.$objectref; |
241 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
242 | - if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
243 | - } |
|
241 | + $file = $dir . "/" . $objectref . ".pdf"; |
|
242 | + if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
243 | + } |
|
244 | 244 | |
245 | - if (! file_exists($dir)) |
|
246 | - { |
|
247 | - if (dol_mkdir($dir) < 0) |
|
248 | - { |
|
249 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
250 | - return 0; |
|
251 | - } |
|
252 | - } |
|
245 | + if (! file_exists($dir)) |
|
246 | + { |
|
247 | + if (dol_mkdir($dir) < 0) |
|
248 | + { |
|
249 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
250 | + return 0; |
|
251 | + } |
|
252 | + } |
|
253 | 253 | |
254 | - if (file_exists($dir)) |
|
255 | - { |
|
256 | - // Add pdfgeneration hook |
|
257 | - if (! is_object($hookmanager)) |
|
258 | - { |
|
259 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
260 | - $hookmanager=new HookManager($this->db); |
|
261 | - } |
|
262 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
263 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
264 | - global $action; |
|
265 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
266 | - |
|
267 | - $nblignes = count($object->lines); |
|
254 | + if (file_exists($dir)) |
|
255 | + { |
|
256 | + // Add pdfgeneration hook |
|
257 | + if (! is_object($hookmanager)) |
|
258 | + { |
|
259 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
260 | + $hookmanager=new HookManager($this->db); |
|
261 | + } |
|
262 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
263 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
264 | + global $action; |
|
265 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
266 | + |
|
267 | + $nblignes = count($object->lines); |
|
268 | 268 | |
269 | 269 | $pdf=pdf_getInstance($this->format); |
270 | 270 | $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
271 | 271 | $heightforinfotot = 50; // Height reserved to output the info and total part |
272 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
273 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
274 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
272 | + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
273 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
274 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
275 | 275 | $pdf->SetAutoPageBreak(1,0); |
276 | 276 | |
277 | 277 | if (class_exists('TCPDF')) |
@@ -287,387 +287,387 @@ discard block |
||
287 | 287 | $tplidx = $pdf->importPage(1); |
288 | 288 | } |
289 | 289 | |
290 | - $pdf->Open(); |
|
291 | - $pagenb=0; |
|
292 | - $pdf->SetDrawColor(128,128,128); |
|
290 | + $pdf->Open(); |
|
291 | + $pagenb=0; |
|
292 | + $pdf->SetDrawColor(128,128,128); |
|
293 | 293 | |
294 | - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
295 | - $pdf->SetSubject($outputlangs->transnoentities("Invoice")); |
|
296 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
297 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
298 | - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
|
299 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
294 | + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
295 | + $pdf->SetSubject($outputlangs->transnoentities("Invoice")); |
|
296 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
297 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
298 | + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
|
299 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
300 | 300 | |
301 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
301 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
302 | 302 | |
303 | 303 | |
304 | 304 | // New page |
305 | - $pdf->AddPage(); |
|
306 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
307 | - $pagenb++; |
|
308 | - $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
309 | - $pdf->SetFont('','', $default_font_size - 1); |
|
310 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
311 | - $pdf->SetTextColor(0,0,0); |
|
312 | - |
|
313 | - $tab_top = 90; |
|
314 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
315 | - $tab_height = 130; |
|
316 | - $tab_height_newpage = 150; |
|
317 | - |
|
318 | - // Incoterm |
|
319 | - $height_incoterms = 0; |
|
320 | - |
|
321 | - $height_note=0; |
|
322 | - |
|
323 | - $iniY = $tab_top + 7; |
|
324 | - $curY = $tab_top + 7; |
|
325 | - $nexY = $tab_top + 7; |
|
326 | - |
|
327 | - // Loop on each lines |
|
328 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
329 | - { |
|
330 | - $curY = $nexY; |
|
331 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
332 | - $pdf->SetTextColor(0,0,0); |
|
333 | - |
|
334 | - $pdf->setTopMargin($tab_top_newpage); |
|
335 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
336 | - $pageposbefore=$pdf->getPage(); |
|
337 | - |
|
338 | - // Description of product line |
|
339 | - $curX = $this->posxdate-1; |
|
340 | - $showpricebeforepagebreak=1; |
|
341 | - |
|
342 | - $pdf->startTransaction(); |
|
343 | - //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1); |
|
344 | - $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true); |
|
345 | - $pageposafter=$pdf->getPage(); |
|
346 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
347 | - { |
|
348 | - $pdf->rollbackTransaction(true); |
|
349 | - $pageposafter=$pageposbefore; |
|
350 | - //print $pageposafter.'-'.$pageposbefore;exit; |
|
351 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
352 | - //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1); |
|
353 | - $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true); |
|
354 | - $posyafter=$pdf->GetY(); |
|
355 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
356 | - { |
|
357 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
358 | - { |
|
359 | - $pdf->AddPage('','',true); |
|
360 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
361 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
362 | - $pdf->setPage($pageposafter+1); |
|
363 | - } |
|
364 | - } |
|
365 | - else |
|
366 | - { |
|
367 | - // We found a page break |
|
368 | - $showpricebeforepagebreak=0; |
|
369 | - } |
|
370 | - } |
|
371 | - else // No pagebreak |
|
372 | - { |
|
373 | - $pdf->commitTransaction(); |
|
374 | - } |
|
375 | - |
|
376 | - $nexY = $pdf->GetY(); |
|
305 | + $pdf->AddPage(); |
|
306 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
307 | + $pagenb++; |
|
308 | + $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
309 | + $pdf->SetFont('','', $default_font_size - 1); |
|
310 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
311 | + $pdf->SetTextColor(0,0,0); |
|
312 | + |
|
313 | + $tab_top = 90; |
|
314 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
315 | + $tab_height = 130; |
|
316 | + $tab_height_newpage = 150; |
|
317 | + |
|
318 | + // Incoterm |
|
319 | + $height_incoterms = 0; |
|
320 | + |
|
321 | + $height_note=0; |
|
322 | + |
|
323 | + $iniY = $tab_top + 7; |
|
324 | + $curY = $tab_top + 7; |
|
325 | + $nexY = $tab_top + 7; |
|
326 | + |
|
327 | + // Loop on each lines |
|
328 | + for ($i = 0 ; $i < $nblignes ; $i++) |
|
329 | + { |
|
330 | + $curY = $nexY; |
|
331 | + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
332 | + $pdf->SetTextColor(0,0,0); |
|
333 | + |
|
334 | + $pdf->setTopMargin($tab_top_newpage); |
|
335 | + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
336 | + $pageposbefore=$pdf->getPage(); |
|
337 | + |
|
338 | + // Description of product line |
|
339 | + $curX = $this->posxdate-1; |
|
340 | + $showpricebeforepagebreak=1; |
|
341 | + |
|
342 | + $pdf->startTransaction(); |
|
343 | + //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1); |
|
344 | + $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true); |
|
345 | + $pageposafter=$pdf->getPage(); |
|
346 | + if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
347 | + { |
|
348 | + $pdf->rollbackTransaction(true); |
|
349 | + $pageposafter=$pageposbefore; |
|
350 | + //print $pageposafter.'-'.$pageposbefore;exit; |
|
351 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
352 | + //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1); |
|
353 | + $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true); |
|
354 | + $posyafter=$pdf->GetY(); |
|
355 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
356 | + { |
|
357 | + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
358 | + { |
|
359 | + $pdf->AddPage('','',true); |
|
360 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
361 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
362 | + $pdf->setPage($pageposafter+1); |
|
363 | + } |
|
364 | + } |
|
365 | + else |
|
366 | + { |
|
367 | + // We found a page break |
|
368 | + $showpricebeforepagebreak=0; |
|
369 | + } |
|
370 | + } |
|
371 | + else // No pagebreak |
|
372 | + { |
|
373 | + $pdf->commitTransaction(); |
|
374 | + } |
|
375 | + |
|
376 | + $nexY = $pdf->GetY(); |
|
377 | 377 | $pageposafter=$pdf->getPage(); |
378 | - $pdf->setPage($pageposbefore); |
|
379 | - $pdf->setTopMargin($this->marge_haute); |
|
380 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
378 | + $pdf->setPage($pageposbefore); |
|
379 | + $pdf->setTopMargin($this->marge_haute); |
|
380 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
381 | 381 | |
382 | - // We suppose that a too long description is moved completely on next page |
|
383 | - if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
384 | - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
385 | - } |
|
382 | + // We suppose that a too long description is moved completely on next page |
|
383 | + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
384 | + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
385 | + } |
|
386 | 386 | |
387 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
387 | + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
388 | 388 | |
389 | - // ref fourn |
|
390 | - $pdf->SetXY($this->posxreffacturefourn, $curY); |
|
391 | - $pdf->MultiCell($this->posxreffacturefourn-$this->posxup-0.8, 3, $object->lines[$i]->ref_supplier, 0, 'L', 0); |
|
389 | + // ref fourn |
|
390 | + $pdf->SetXY($this->posxreffacturefourn, $curY); |
|
391 | + $pdf->MultiCell($this->posxreffacturefourn-$this->posxup-0.8, 3, $object->lines[$i]->ref_supplier, 0, 'L', 0); |
|
392 | 392 | |
393 | - // ref facture fourn |
|
394 | - $pdf->SetXY($this->posxreffacture, $curY); |
|
395 | - $pdf->MultiCell($this->posxreffacture-$this->posxup-0.8, 3, $object->lines[$i]->ref, 0, 'L', 0); |
|
393 | + // ref facture fourn |
|
394 | + $pdf->SetXY($this->posxreffacture, $curY); |
|
395 | + $pdf->MultiCell($this->posxreffacture-$this->posxup-0.8, 3, $object->lines[$i]->ref, 0, 'L', 0); |
|
396 | 396 | |
397 | - // type |
|
398 | - $pdf->SetXY($this->posxtype, $curY); |
|
399 | - $pdf->MultiCell($this->posxtype-$this->posxup-0.8, 3, $object->lines[$i]->type, 0, 'L', 0); |
|
397 | + // type |
|
398 | + $pdf->SetXY($this->posxtype, $curY); |
|
399 | + $pdf->MultiCell($this->posxtype-$this->posxup-0.8, 3, $object->lines[$i]->type, 0, 'L', 0); |
|
400 | 400 | |
401 | - // Total ht |
|
402 | - $pdf->SetXY($this->posxtotalht, $curY); |
|
403 | - $pdf->MultiCell($this->posxtotalht-$this->posxup-0.8, 3, price($object->lines[$i]->total_ht), 0, 'R', 0); |
|
401 | + // Total ht |
|
402 | + $pdf->SetXY($this->posxtotalht, $curY); |
|
403 | + $pdf->MultiCell($this->posxtotalht-$this->posxup-0.8, 3, price($object->lines[$i]->total_ht), 0, 'R', 0); |
|
404 | 404 | |
405 | - // Total tva |
|
406 | - $pdf->SetXY($this->posxtva, $curY); |
|
407 | - $pdf->MultiCell($this->posxtva-$this->posxup-0.8, 3, price($object->lines[$i]->total_tva), 0, 'R', 0); |
|
405 | + // Total tva |
|
406 | + $pdf->SetXY($this->posxtva, $curY); |
|
407 | + $pdf->MultiCell($this->posxtva-$this->posxup-0.8, 3, price($object->lines[$i]->total_tva), 0, 'R', 0); |
|
408 | 408 | |
409 | - // Total TTC line |
|
409 | + // Total TTC line |
|
410 | 410 | $pdf->SetXY($this->posxtotalttc, $curY); |
411 | 411 | $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxtotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R', 0); |
412 | 412 | |
413 | 413 | |
414 | - // Add line |
|
415 | - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
416 | - { |
|
417 | - $pdf->setPage($pageposafter); |
|
418 | - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
419 | - //$pdf->SetDrawColor(190,190,200); |
|
420 | - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
421 | - $pdf->SetLineStyle(array('dash'=>0)); |
|
422 | - } |
|
423 | - |
|
424 | - $nexY+=2; // Passe espace entre les lignes |
|
425 | - |
|
426 | - // Detect if some page were added automatically and output _tableau for past pages |
|
427 | - while ($pagenb < $pageposafter) |
|
428 | - { |
|
429 | - $pdf->setPage($pagenb); |
|
430 | - if ($pagenb == 1) |
|
431 | - { |
|
432 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
433 | - } |
|
434 | - else |
|
435 | - { |
|
436 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
437 | - } |
|
438 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
439 | - $pagenb++; |
|
440 | - $pdf->setPage($pagenb); |
|
441 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
442 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
443 | - } |
|
444 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
445 | - { |
|
446 | - if ($pagenb == 1) |
|
447 | - { |
|
448 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
449 | - } |
|
450 | - else |
|
451 | - { |
|
452 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
453 | - } |
|
454 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
455 | - // New page |
|
456 | - $pdf->AddPage(); |
|
457 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
458 | - $pagenb++; |
|
459 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
460 | - } |
|
461 | - } |
|
462 | - |
|
463 | - // Show square |
|
464 | - if ($pagenb == 1) |
|
465 | - { |
|
466 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
467 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
468 | - } |
|
469 | - else |
|
470 | - { |
|
471 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
472 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
473 | - } |
|
474 | - |
|
475 | - // Affiche zone cheèque |
|
476 | - $posy=$this->_tableau_cheque($pdf, $object, $bottomlasttab, $outputlangs); |
|
477 | - |
|
478 | - // Affiche zone totaux |
|
479 | - //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
|
480 | - |
|
481 | - // Pied de page |
|
482 | - $this->_pagefoot($pdf, $object, $outputlangs); |
|
483 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
484 | - |
|
485 | - $pdf->Close(); |
|
486 | - |
|
487 | - $pdf->Output($file,'F'); |
|
488 | - |
|
489 | - // Add pdfgeneration hook |
|
490 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
491 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
492 | - global $action; |
|
493 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
494 | - |
|
495 | - if (! empty($conf->global->MAIN_UMASK)) |
|
496 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
497 | - |
|
498 | - $this->result = array('fullpath'=>$file); |
|
499 | - |
|
500 | - return 1; // Pas d'erreur |
|
501 | - } |
|
502 | - else |
|
503 | - { |
|
504 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
505 | - return 0; |
|
506 | - } |
|
507 | - } |
|
508 | - else |
|
509 | - { |
|
510 | - $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); |
|
511 | - return 0; |
|
512 | - } |
|
513 | - } |
|
414 | + // Add line |
|
415 | + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
416 | + { |
|
417 | + $pdf->setPage($pageposafter); |
|
418 | + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
419 | + //$pdf->SetDrawColor(190,190,200); |
|
420 | + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
421 | + $pdf->SetLineStyle(array('dash'=>0)); |
|
422 | + } |
|
423 | + |
|
424 | + $nexY+=2; // Passe espace entre les lignes |
|
425 | + |
|
426 | + // Detect if some page were added automatically and output _tableau for past pages |
|
427 | + while ($pagenb < $pageposafter) |
|
428 | + { |
|
429 | + $pdf->setPage($pagenb); |
|
430 | + if ($pagenb == 1) |
|
431 | + { |
|
432 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
433 | + } |
|
434 | + else |
|
435 | + { |
|
436 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
437 | + } |
|
438 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
439 | + $pagenb++; |
|
440 | + $pdf->setPage($pagenb); |
|
441 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
442 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
443 | + } |
|
444 | + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
445 | + { |
|
446 | + if ($pagenb == 1) |
|
447 | + { |
|
448 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
449 | + } |
|
450 | + else |
|
451 | + { |
|
452 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
453 | + } |
|
454 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
455 | + // New page |
|
456 | + $pdf->AddPage(); |
|
457 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
458 | + $pagenb++; |
|
459 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
460 | + } |
|
461 | + } |
|
462 | + |
|
463 | + // Show square |
|
464 | + if ($pagenb == 1) |
|
465 | + { |
|
466 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
467 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
468 | + } |
|
469 | + else |
|
470 | + { |
|
471 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
472 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
473 | + } |
|
474 | + |
|
475 | + // Affiche zone cheèque |
|
476 | + $posy=$this->_tableau_cheque($pdf, $object, $bottomlasttab, $outputlangs); |
|
477 | + |
|
478 | + // Affiche zone totaux |
|
479 | + //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
|
480 | + |
|
481 | + // Pied de page |
|
482 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
483 | + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
484 | + |
|
485 | + $pdf->Close(); |
|
486 | + |
|
487 | + $pdf->Output($file,'F'); |
|
488 | + |
|
489 | + // Add pdfgeneration hook |
|
490 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
491 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
492 | + global $action; |
|
493 | + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
494 | + |
|
495 | + if (! empty($conf->global->MAIN_UMASK)) |
|
496 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
497 | + |
|
498 | + $this->result = array('fullpath'=>$file); |
|
499 | + |
|
500 | + return 1; // Pas d'erreur |
|
501 | + } |
|
502 | + else |
|
503 | + { |
|
504 | + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
505 | + return 0; |
|
506 | + } |
|
507 | + } |
|
508 | + else |
|
509 | + { |
|
510 | + $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); |
|
511 | + return 0; |
|
512 | + } |
|
513 | + } |
|
514 | 514 | |
515 | 515 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
516 | - /** |
|
517 | - * Show total to pay |
|
518 | - * |
|
519 | - * @param PDF $pdf Object PDF |
|
520 | - * @param PaiementFourn $object Object PaiementFourn |
|
521 | - * @param int $posy Position depart |
|
522 | - * @param Translate $outputlangs Objet langs |
|
523 | - * @return int Position pour suite |
|
524 | - */ |
|
525 | - function _tableau_cheque(&$pdf, $object, $posy, $outputlangs) |
|
526 | - { |
|
516 | + /** |
|
517 | + * Show total to pay |
|
518 | + * |
|
519 | + * @param PDF $pdf Object PDF |
|
520 | + * @param PaiementFourn $object Object PaiementFourn |
|
521 | + * @param int $posy Position depart |
|
522 | + * @param Translate $outputlangs Objet langs |
|
523 | + * @return int Position pour suite |
|
524 | + */ |
|
525 | + function _tableau_cheque(&$pdf, $object, $posy, $outputlangs) |
|
526 | + { |
|
527 | 527 | // phpcs:enable |
528 | - global $conf,$mysoc; |
|
528 | + global $conf,$mysoc; |
|
529 | 529 | |
530 | 530 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
531 | 531 | |
532 | - $pdf->SetFont('','', $default_font_size - 1); |
|
533 | - $pdf->SetFillColor(255,255,255); |
|
534 | - |
|
535 | - // N° payment |
|
536 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
537 | - $pdf->MultiCell(30, 4, 'N° '.$outputlangs->transnoentities("Payment"), 0, 'L', 1); |
|
538 | - |
|
539 | - // Ref payment |
|
540 | - $pdf->SetXY($this->marge_gauche + 30, $posy); |
|
541 | - $pdf->MultiCell(50, 4, $object->ref, 0, 'L', 1); |
|
542 | - |
|
543 | - // Total payments |
|
544 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - 50, $posy); |
|
545 | - $pdf->MultiCell(50, 4, price($object->montant), 0, 'R', 1); |
|
546 | - $posy += 20; |
|
547 | - |
|
548 | - // translate amount |
|
549 | - $currency = $conf->currency; |
|
550 | - $translateinletter = strtoupper(dol_convertToWord($object->montant,$outputlangs,$currency)); |
|
551 | - $pdf->SetXY($this->marge_gauche + 50, $posy); |
|
552 | - $pdf->MultiCell(90, 8, $translateinletter, 0, 'L', 1); |
|
553 | - $posy += 8; |
|
554 | - |
|
555 | - // To |
|
556 | - $pdf->SetXY($this->marge_gauche + 50, $posy); |
|
557 | - $pdf->MultiCell(150, 4, $object->thirdparty->nom, 0, 'L', 1); |
|
558 | - |
|
559 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy); |
|
560 | - $pdf->MultiCell(35, 4, str_pad(price($object->montant). ' '.$currency,18,'*',STR_PAD_LEFT), 0, 'R', 1); |
|
561 | - $posy += 10; |
|
562 | - |
|
563 | - |
|
564 | - // City |
|
565 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy); |
|
566 | - $pdf->MultiCell(150, 4, $mysoc->town, 0, 'L', 1); |
|
567 | - $posy += 4; |
|
568 | - |
|
569 | - // Date |
|
570 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy); |
|
571 | - $pdf->MultiCell(150, 4, date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y"), 0, 'L', 1); |
|
572 | - } |
|
573 | - |
|
574 | - |
|
575 | - /** |
|
576 | - * Show table for lines |
|
577 | - * |
|
578 | - * @param PDF $pdf Object PDF |
|
579 | - * @param integer $tab_top Top position of table |
|
580 | - * @param integer $tab_height Height of table (rectangle) |
|
581 | - * @param int $nexY Y (not used) |
|
582 | - * @param Translate $outputlangs Langs object |
|
583 | - * @param int $hidetop Hide top bar of array |
|
584 | - * @param int $hidebottom Hide bottom bar of array |
|
585 | - * @param string $currency Currency code |
|
586 | - * @return void |
|
587 | - */ |
|
588 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
589 | - { |
|
590 | - global $conf,$mysoc; |
|
591 | - |
|
592 | - // Force to disable hidetop and hidebottom |
|
593 | - $hidebottom=0; |
|
594 | - if ($hidetop) $hidetop=-1; |
|
595 | - |
|
596 | - $currency = !empty($currency) ? $currency : $conf->currency; |
|
597 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
532 | + $pdf->SetFont('','', $default_font_size - 1); |
|
533 | + $pdf->SetFillColor(255,255,255); |
|
598 | 534 | |
599 | - // Amount in (at tab_top - 1) |
|
600 | - $pdf->SetTextColor(0,0,0); |
|
601 | - $pdf->SetFont('','',$default_font_size - 2); |
|
535 | + // N° payment |
|
536 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
537 | + $pdf->MultiCell(30, 4, 'N° '.$outputlangs->transnoentities("Payment"), 0, 'L', 1); |
|
602 | 538 | |
603 | - $titre = strtoupper($mysoc->town).', le '.date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y"); |
|
604 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3) - 60, $tab_top-6); |
|
605 | - $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
539 | + // Ref payment |
|
540 | + $pdf->SetXY($this->marge_gauche + 30, $posy); |
|
541 | + $pdf->MultiCell(50, 4, $object->ref, 0, 'L', 1); |
|
606 | 542 | |
607 | - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
608 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top); |
|
609 | - $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
543 | + // Total payments |
|
544 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - 50, $posy); |
|
545 | + $pdf->MultiCell(50, 4, price($object->montant), 0, 'R', 1); |
|
546 | + $posy += 20; |
|
610 | 547 | |
548 | + // translate amount |
|
549 | + $currency = $conf->currency; |
|
550 | + $translateinletter = strtoupper(dol_convertToWord($object->montant,$outputlangs,$currency)); |
|
551 | + $pdf->SetXY($this->marge_gauche + 50, $posy); |
|
552 | + $pdf->MultiCell(90, 8, $translateinletter, 0, 'L', 1); |
|
553 | + $posy += 8; |
|
611 | 554 | |
612 | - $pdf->SetDrawColor(128,128,128); |
|
613 | - $pdf->SetFont('','', $default_font_size - 1); |
|
555 | + // To |
|
556 | + $pdf->SetXY($this->marge_gauche + 50, $posy); |
|
557 | + $pdf->MultiCell(150, 4, $object->thirdparty->nom, 0, 'L', 1); |
|
614 | 558 | |
615 | - // Output Rect |
|
616 | - //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
617 | - } |
|
559 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy); |
|
560 | + $pdf->MultiCell(35, 4, str_pad(price($object->montant). ' '.$currency,18,'*',STR_PAD_LEFT), 0, 'R', 1); |
|
561 | + $posy += 10; |
|
618 | 562 | |
619 | 563 | |
620 | - /** |
|
621 | - * Show top header of page. |
|
622 | - * |
|
623 | - * @param PDF $pdf Object PDF |
|
624 | - * @param FactureFournisseur $object Object to show |
|
625 | - * @param int $showaddress 0=no, 1=yes |
|
626 | - * @param Translate $outputlangs Object lang for output |
|
627 | - * @return void |
|
628 | - */ |
|
629 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
630 | - { |
|
631 | - global $langs, $conf, $mysoc; |
|
564 | + // City |
|
565 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy); |
|
566 | + $pdf->MultiCell(150, 4, $mysoc->town, 0, 'L', 1); |
|
567 | + $posy += 4; |
|
632 | 568 | |
633 | - // Load translation files required by the page |
|
634 | - $outputlangs->loadLangs(array("main", "orders", "companies", "bills")); |
|
569 | + // Date |
|
570 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy); |
|
571 | + $pdf->MultiCell(150, 4, date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y"), 0, 'L', 1); |
|
572 | + } |
|
635 | 573 | |
636 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
637 | 574 | |
638 | - // Do not add the BACKGROUND as this is for suppliers |
|
639 | - //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
575 | + /** |
|
576 | + * Show table for lines |
|
577 | + * |
|
578 | + * @param PDF $pdf Object PDF |
|
579 | + * @param integer $tab_top Top position of table |
|
580 | + * @param integer $tab_height Height of table (rectangle) |
|
581 | + * @param int $nexY Y (not used) |
|
582 | + * @param Translate $outputlangs Langs object |
|
583 | + * @param int $hidetop Hide top bar of array |
|
584 | + * @param int $hidebottom Hide bottom bar of array |
|
585 | + * @param string $currency Currency code |
|
586 | + * @return void |
|
587 | + */ |
|
588 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
589 | + { |
|
590 | + global $conf,$mysoc; |
|
640 | 591 | |
641 | - $pdf->SetTextColor(0,0,60); |
|
642 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
592 | + // Force to disable hidetop and hidebottom |
|
593 | + $hidebottom=0; |
|
594 | + if ($hidetop) $hidetop=-1; |
|
643 | 595 | |
644 | - $posy=$this->marge_haute; |
|
645 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
596 | + $currency = !empty($currency) ? $currency : $conf->currency; |
|
597 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
646 | 598 | |
647 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
599 | + // Amount in (at tab_top - 1) |
|
600 | + $pdf->SetTextColor(0,0,0); |
|
601 | + $pdf->SetFont('','',$default_font_size - 2); |
|
648 | 602 | |
649 | - // Logo |
|
650 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
651 | - if ($mysoc->logo) |
|
652 | - { |
|
653 | - if (is_readable($logo)) |
|
654 | - { |
|
655 | - $height=pdf_getHeightForLogo($logo); |
|
656 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
657 | - } |
|
658 | - else |
|
659 | - { |
|
660 | - $pdf->SetTextColor(200,0,0); |
|
661 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
662 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
663 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
|
664 | - } |
|
665 | - } |
|
666 | - else |
|
667 | - { |
|
668 | - $text=$this->emetteur->name; |
|
669 | - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
670 | - } |
|
603 | + $titre = strtoupper($mysoc->town).', le '.date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y"); |
|
604 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3) - 60, $tab_top-6); |
|
605 | + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
606 | + |
|
607 | + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
608 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top); |
|
609 | + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
610 | + |
|
611 | + |
|
612 | + $pdf->SetDrawColor(128,128,128); |
|
613 | + $pdf->SetFont('','', $default_font_size - 1); |
|
614 | + |
|
615 | + // Output Rect |
|
616 | + //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
617 | + } |
|
618 | + |
|
619 | + |
|
620 | + /** |
|
621 | + * Show top header of page. |
|
622 | + * |
|
623 | + * @param PDF $pdf Object PDF |
|
624 | + * @param FactureFournisseur $object Object to show |
|
625 | + * @param int $showaddress 0=no, 1=yes |
|
626 | + * @param Translate $outputlangs Object lang for output |
|
627 | + * @return void |
|
628 | + */ |
|
629 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
630 | + { |
|
631 | + global $langs, $conf, $mysoc; |
|
632 | + |
|
633 | + // Load translation files required by the page |
|
634 | + $outputlangs->loadLangs(array("main", "orders", "companies", "bills")); |
|
635 | + |
|
636 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
637 | + |
|
638 | + // Do not add the BACKGROUND as this is for suppliers |
|
639 | + //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
640 | + |
|
641 | + $pdf->SetTextColor(0,0,60); |
|
642 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
643 | + |
|
644 | + $posy=$this->marge_haute; |
|
645 | + $posx=$this->page_largeur-$this->marge_droite-100; |
|
646 | + |
|
647 | + $pdf->SetXY($this->marge_gauche,$posy); |
|
648 | + |
|
649 | + // Logo |
|
650 | + $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
651 | + if ($mysoc->logo) |
|
652 | + { |
|
653 | + if (is_readable($logo)) |
|
654 | + { |
|
655 | + $height=pdf_getHeightForLogo($logo); |
|
656 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
657 | + } |
|
658 | + else |
|
659 | + { |
|
660 | + $pdf->SetTextColor(200,0,0); |
|
661 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
662 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
663 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
|
664 | + } |
|
665 | + } |
|
666 | + else |
|
667 | + { |
|
668 | + $text=$this->emetteur->name; |
|
669 | + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
670 | + } |
|
671 | 671 | /* |
672 | 672 | $pdf->SetFont('','B', $default_font_size + 3); |
673 | 673 | $pdf->SetXY($posx,$posy); |
@@ -729,86 +729,86 @@ discard block |
||
729 | 729 | // Show list of linked objects |
730 | 730 | $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); |
731 | 731 | */ |
732 | - if ($showaddress) |
|
733 | - { |
|
734 | - // Sender properties |
|
735 | - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); |
|
736 | - |
|
737 | - // Show payer |
|
738 | - $posy=42; |
|
739 | - $posx=$this->marge_gauche; |
|
740 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
741 | - $hautcadre=40; |
|
742 | - |
|
743 | - // Show sender frame |
|
744 | - $pdf->SetTextColor(0,0,0); |
|
745 | - $pdf->SetFont('','', $default_font_size - 2); |
|
746 | - $pdf->SetXY($posx,$posy-5); |
|
747 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("PayedBy").":", 0, 'L'); |
|
748 | - $pdf->SetXY($posx,$posy); |
|
749 | - $pdf->SetFillColor(230,230,230); |
|
750 | - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
751 | - $pdf->SetTextColor(0,0,60); |
|
752 | - |
|
753 | - // Show sender name |
|
754 | - $pdf->SetXY($posx+2,$posy+3); |
|
755 | - $pdf->SetFont('','B', $default_font_size); |
|
756 | - $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
757 | - $posy=$pdf->getY(); |
|
758 | - |
|
759 | - // Show sender information |
|
760 | - $pdf->SetXY($posx+2,$posy); |
|
761 | - $pdf->SetFont('','', $default_font_size - 1); |
|
762 | - $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
763 | - |
|
764 | - // Payed |
|
765 | - $thirdparty = $object->thirdparty; |
|
766 | - |
|
767 | - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
768 | - |
|
769 | - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object); |
|
770 | - |
|
771 | - // Show recipient |
|
772 | - $widthrecbox=90; |
|
773 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
774 | - $posy=42; |
|
775 | - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
776 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
732 | + if ($showaddress) |
|
733 | + { |
|
734 | + // Sender properties |
|
735 | + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); |
|
736 | + |
|
737 | + // Show payer |
|
738 | + $posy=42; |
|
739 | + $posx=$this->marge_gauche; |
|
740 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
741 | + $hautcadre=40; |
|
742 | + |
|
743 | + // Show sender frame |
|
744 | + $pdf->SetTextColor(0,0,0); |
|
745 | + $pdf->SetFont('','', $default_font_size - 2); |
|
746 | + $pdf->SetXY($posx,$posy-5); |
|
747 | + $pdf->MultiCell(66,5, $outputlangs->transnoentities("PayedBy").":", 0, 'L'); |
|
748 | + $pdf->SetXY($posx,$posy); |
|
749 | + $pdf->SetFillColor(230,230,230); |
|
750 | + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
751 | + $pdf->SetTextColor(0,0,60); |
|
752 | + |
|
753 | + // Show sender name |
|
754 | + $pdf->SetXY($posx+2,$posy+3); |
|
755 | + $pdf->SetFont('','B', $default_font_size); |
|
756 | + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
757 | + $posy=$pdf->getY(); |
|
758 | + |
|
759 | + // Show sender information |
|
760 | + $pdf->SetXY($posx+2,$posy); |
|
761 | + $pdf->SetFont('','', $default_font_size - 1); |
|
762 | + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
763 | + |
|
764 | + // Payed |
|
765 | + $thirdparty = $object->thirdparty; |
|
766 | + |
|
767 | + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
768 | + |
|
769 | + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object); |
|
770 | + |
|
771 | + // Show recipient |
|
772 | + $widthrecbox=90; |
|
773 | + if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
774 | + $posy=42; |
|
775 | + $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
776 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
777 | + |
|
778 | + // Show recipient frame |
|
779 | + $pdf->SetTextColor(0,0,0); |
|
780 | + $pdf->SetFont('','', $default_font_size - 2); |
|
781 | + $pdf->SetXY($posx+2,$posy-5); |
|
782 | + $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("PayedTo").":",0,'L'); |
|
783 | + $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
784 | + |
|
785 | + // Show recipient name |
|
786 | + $pdf->SetXY($posx+2,$posy+3); |
|
787 | + $pdf->SetFont('','B', $default_font_size); |
|
788 | + $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); |
|
789 | + |
|
790 | + $posy = $pdf->getY(); |
|
791 | + |
|
792 | + // Show recipient information |
|
793 | + $pdf->SetFont('','', $default_font_size - 1); |
|
794 | + $pdf->SetXY($posx+2,$posy); |
|
795 | + $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
|
796 | + } |
|
797 | + } |
|
777 | 798 | |
778 | - // Show recipient frame |
|
779 | - $pdf->SetTextColor(0,0,0); |
|
780 | - $pdf->SetFont('','', $default_font_size - 2); |
|
781 | - $pdf->SetXY($posx+2,$posy-5); |
|
782 | - $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("PayedTo").":",0,'L'); |
|
783 | - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
784 | - |
|
785 | - // Show recipient name |
|
786 | - $pdf->SetXY($posx+2,$posy+3); |
|
787 | - $pdf->SetFont('','B', $default_font_size); |
|
788 | - $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); |
|
789 | - |
|
790 | - $posy = $pdf->getY(); |
|
791 | - |
|
792 | - // Show recipient information |
|
793 | - $pdf->SetFont('','', $default_font_size - 1); |
|
794 | - $pdf->SetXY($posx+2,$posy); |
|
795 | - $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
|
796 | - } |
|
797 | - } |
|
798 | - |
|
799 | - /** |
|
800 | - * Show footer of page. Need this->emetteur object |
|
799 | + /** |
|
800 | + * Show footer of page. Need this->emetteur object |
|
801 | 801 | * |
802 | - * @param PDF $pdf PDF |
|
803 | - * @param FactureFournisseur $object Object to show |
|
804 | - * @param Translate $outputlangs Object lang for output |
|
805 | - * @param int $hidefreetext 1=Hide free text |
|
806 | - * @return int Return height of bottom margin including footer text |
|
807 | - */ |
|
808 | - function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0) |
|
809 | - { |
|
810 | - global $conf; |
|
811 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
812 | - return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
813 | - } |
|
802 | + * @param PDF $pdf PDF |
|
803 | + * @param FactureFournisseur $object Object to show |
|
804 | + * @param Translate $outputlangs Object lang for output |
|
805 | + * @param int $hidefreetext 1=Hide free text |
|
806 | + * @return int Return height of bottom margin including footer text |
|
807 | + */ |
|
808 | + function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0) |
|
809 | + { |
|
810 | + global $conf; |
|
811 | + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
812 | + return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
813 | + } |
|
814 | 814 | } |
@@ -130,49 +130,49 @@ discard block |
||
130 | 130 | |
131 | 131 | // Dimension page pour format A4 |
132 | 132 | $this->type = 'pdf'; |
133 | - $formatarray=pdf_getFormat(); |
|
133 | + $formatarray = pdf_getFormat(); |
|
134 | 134 | $this->page_largeur = $formatarray['width']; |
135 | 135 | $this->page_hauteur = $formatarray['height']; |
136 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
137 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
138 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
139 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
140 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
136 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
137 | + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; |
|
138 | + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; |
|
139 | + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; |
|
140 | + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; |
|
141 | 141 | |
142 | - $this->option_logo = 1; // Affiche logo |
|
143 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
142 | + $this->option_logo = 1; // Affiche logo |
|
143 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
144 | 144 | |
145 | - $this->franchise=!$mysoc->tva_assuj; |
|
145 | + $this->franchise = !$mysoc->tva_assuj; |
|
146 | 146 | |
147 | 147 | // Defini position des colonnes |
148 | - $this->posxdate=$this->marge_gauche+1; |
|
149 | - $this->posxreffacturefourn=30; |
|
150 | - $this->posxreffacture=65; |
|
151 | - $this->posxtype=100; |
|
152 | - $this->posxtotalht=80; |
|
153 | - $this->posxtva=90; |
|
154 | - $this->posxtotalttc=180; |
|
148 | + $this->posxdate = $this->marge_gauche + 1; |
|
149 | + $this->posxreffacturefourn = 30; |
|
150 | + $this->posxreffacture = 65; |
|
151 | + $this->posxtype = 100; |
|
152 | + $this->posxtotalht = 80; |
|
153 | + $this->posxtva = 90; |
|
154 | + $this->posxtotalttc = 180; |
|
155 | 155 | |
156 | 156 | //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; |
157 | 157 | if ($this->page_largeur < 210) // To work with US executive format |
158 | 158 | { |
159 | - $this->posxreffacturefourn-=20; |
|
160 | - $this->posxreffacture-=20; |
|
161 | - $this->posxtype-=20; |
|
162 | - $this->posxtotalht-=20; |
|
163 | - $this->posxtva-=20; |
|
164 | - $this->posxtotalttc-=20; |
|
159 | + $this->posxreffacturefourn -= 20; |
|
160 | + $this->posxreffacture -= 20; |
|
161 | + $this->posxtype -= 20; |
|
162 | + $this->posxtotalht -= 20; |
|
163 | + $this->posxtva -= 20; |
|
164 | + $this->posxtotalttc -= 20; |
|
165 | 165 | } |
166 | 166 | |
167 | - $this->tva=array(); |
|
168 | - $this->localtax1=array(); |
|
169 | - $this->localtax2=array(); |
|
170 | - $this->atleastoneratenotnull=0; |
|
171 | - $this->atleastonediscount=0; |
|
167 | + $this->tva = array(); |
|
168 | + $this->localtax1 = array(); |
|
169 | + $this->localtax2 = array(); |
|
170 | + $this->atleastoneratenotnull = 0; |
|
171 | + $this->atleastonediscount = 0; |
|
172 | 172 | |
173 | 173 | // Recupere emetteur |
174 | - $this->emetteur=$mysoc; |
|
175 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
174 | + $this->emetteur = $mysoc; |
|
175 | + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | * @param int $hideref Do not show ref |
189 | 189 | * @return int 1=OK, 0=KO |
190 | 190 | */ |
191 | - function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0) |
|
191 | + function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
192 | 192 | { |
193 | 193 | // phpcs:enable |
194 | 194 | global $user, $langs, $conf, $mysoc, $hookmanager; |
195 | 195 | |
196 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
196 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
197 | 197 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
198 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
198 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
199 | 199 | |
200 | 200 | // Load translation files required by the page |
201 | 201 | $outputlangs->loadLangs(array("main", "suppliers", "companies", "bills", "dict", "products")); |
@@ -213,12 +213,12 @@ discard block |
||
213 | 213 | $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s'; |
214 | 214 | $sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid'; |
215 | 215 | $sql .= ' AND pf.fk_paiementfourn = '.$object->id; |
216 | - $resql=$this->db->query($sql); |
|
216 | + $resql = $this->db->query($sql); |
|
217 | 217 | if ($resql) |
218 | 218 | { |
219 | 219 | if ($this->db->num_rows($resql) > 0) |
220 | 220 | { |
221 | - while($objp = $this->db->fetch_object($resql)) { |
|
221 | + while ($objp = $this->db->fetch_object($resql)) { |
|
222 | 222 | $objp->type = $outputlangs->trans('SupplierInvoice'); |
223 | 223 | $object->lines[] = $objp; |
224 | 224 | } |
@@ -231,22 +231,22 @@ discard block |
||
231 | 231 | if ($object->specimen) |
232 | 232 | { |
233 | 233 | $dir = $conf->fournisseur->payment->dir_output; |
234 | - $file = $dir . "/SPECIMEN.pdf"; |
|
234 | + $file = $dir."/SPECIMEN.pdf"; |
|
235 | 235 | } |
236 | 236 | else |
237 | 237 | { |
238 | 238 | $objectref = dol_sanitizeFileName($object->ref); |
239 | 239 | $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); |
240 | 240 | $dir = $conf->fournisseur->payment->dir_output.'/'.$objectref; |
241 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
242 | - if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
241 | + $file = $dir."/".$objectref.".pdf"; |
|
242 | + if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf"; |
|
243 | 243 | } |
244 | 244 | |
245 | - if (! file_exists($dir)) |
|
245 | + if (!file_exists($dir)) |
|
246 | 246 | { |
247 | 247 | if (dol_mkdir($dir) < 0) |
248 | 248 | { |
249 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
249 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
250 | 250 | return 0; |
251 | 251 | } |
252 | 252 | } |
@@ -254,25 +254,25 @@ discard block |
||
254 | 254 | if (file_exists($dir)) |
255 | 255 | { |
256 | 256 | // Add pdfgeneration hook |
257 | - if (! is_object($hookmanager)) |
|
257 | + if (!is_object($hookmanager)) |
|
258 | 258 | { |
259 | 259 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
260 | - $hookmanager=new HookManager($this->db); |
|
260 | + $hookmanager = new HookManager($this->db); |
|
261 | 261 | } |
262 | 262 | $hookmanager->initHooks(array('pdfgeneration')); |
263 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
263 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
264 | 264 | global $action; |
265 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
265 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
266 | 266 | |
267 | 267 | $nblignes = count($object->lines); |
268 | 268 | |
269 | - $pdf=pdf_getInstance($this->format); |
|
270 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
271 | - $heightforinfotot = 50; // Height reserved to output the info and total part |
|
272 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
273 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
274 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
275 | - $pdf->SetAutoPageBreak(1,0); |
|
269 | + $pdf = pdf_getInstance($this->format); |
|
270 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
271 | + $heightforinfotot = 50; // Height reserved to output the info and total part |
|
272 | + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page |
|
273 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
274 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; |
|
275 | + $pdf->SetAutoPageBreak(1, 0); |
|
276 | 276 | |
277 | 277 | if (class_exists('TCPDF')) |
278 | 278 | { |
@@ -281,91 +281,91 @@ discard block |
||
281 | 281 | } |
282 | 282 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
283 | 283 | // Set path to the background PDF File |
284 | - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
284 | + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
285 | 285 | { |
286 | 286 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
287 | 287 | $tplidx = $pdf->importPage(1); |
288 | 288 | } |
289 | 289 | |
290 | 290 | $pdf->Open(); |
291 | - $pagenb=0; |
|
292 | - $pdf->SetDrawColor(128,128,128); |
|
291 | + $pagenb = 0; |
|
292 | + $pdf->SetDrawColor(128, 128, 128); |
|
293 | 293 | |
294 | 294 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
295 | 295 | $pdf->SetSubject($outputlangs->transnoentities("Invoice")); |
296 | 296 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
297 | 297 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
298 | 298 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
299 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
299 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
300 | 300 | |
301 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
301 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
302 | 302 | |
303 | 303 | |
304 | 304 | // New page |
305 | 305 | $pdf->AddPage(); |
306 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
306 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
307 | 307 | $pagenb++; |
308 | 308 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
309 | - $pdf->SetFont('','', $default_font_size - 1); |
|
310 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
311 | - $pdf->SetTextColor(0,0,0); |
|
309 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
310 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
311 | + $pdf->SetTextColor(0, 0, 0); |
|
312 | 312 | |
313 | 313 | $tab_top = 90; |
314 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
314 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); |
|
315 | 315 | $tab_height = 130; |
316 | 316 | $tab_height_newpage = 150; |
317 | 317 | |
318 | 318 | // Incoterm |
319 | 319 | $height_incoterms = 0; |
320 | 320 | |
321 | - $height_note=0; |
|
321 | + $height_note = 0; |
|
322 | 322 | |
323 | 323 | $iniY = $tab_top + 7; |
324 | 324 | $curY = $tab_top + 7; |
325 | 325 | $nexY = $tab_top + 7; |
326 | 326 | |
327 | 327 | // Loop on each lines |
328 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
328 | + for ($i = 0; $i < $nblignes; $i++) |
|
329 | 329 | { |
330 | 330 | $curY = $nexY; |
331 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
332 | - $pdf->SetTextColor(0,0,0); |
|
331 | + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage |
|
332 | + $pdf->SetTextColor(0, 0, 0); |
|
333 | 333 | |
334 | 334 | $pdf->setTopMargin($tab_top_newpage); |
335 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
336 | - $pageposbefore=$pdf->getPage(); |
|
335 | + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
336 | + $pageposbefore = $pdf->getPage(); |
|
337 | 337 | |
338 | 338 | // Description of product line |
339 | - $curX = $this->posxdate-1; |
|
340 | - $showpricebeforepagebreak=1; |
|
339 | + $curX = $this->posxdate - 1; |
|
340 | + $showpricebeforepagebreak = 1; |
|
341 | 341 | |
342 | 342 | $pdf->startTransaction(); |
343 | 343 | //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1); |
344 | - $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true); |
|
345 | - $pageposafter=$pdf->getPage(); |
|
344 | + $pdf->writeHTMLCell($this->posxtva - $curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J', true); |
|
345 | + $pageposafter = $pdf->getPage(); |
|
346 | 346 | if ($pageposafter > $pageposbefore) // There is a pagebreak |
347 | 347 | { |
348 | 348 | $pdf->rollbackTransaction(true); |
349 | - $pageposafter=$pageposbefore; |
|
349 | + $pageposafter = $pageposbefore; |
|
350 | 350 | //print $pageposafter.'-'.$pageposbefore;exit; |
351 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
351 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
352 | 352 | //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1); |
353 | - $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true); |
|
354 | - $posyafter=$pdf->GetY(); |
|
355 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
353 | + $pdf->writeHTMLCell($this->posxtva - $curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J', true); |
|
354 | + $posyafter = $pdf->GetY(); |
|
355 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text |
|
356 | 356 | { |
357 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
357 | + if ($i == ($nblignes - 1)) // No more lines, and no space left to show total, so we create a new page |
|
358 | 358 | { |
359 | - $pdf->AddPage('','',true); |
|
360 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
359 | + $pdf->AddPage('', '', true); |
|
360 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
361 | 361 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
362 | - $pdf->setPage($pageposafter+1); |
|
362 | + $pdf->setPage($pageposafter + 1); |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | else |
366 | 366 | { |
367 | 367 | // We found a page break |
368 | - $showpricebeforepagebreak=0; |
|
368 | + $showpricebeforepagebreak = 0; |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | else // No pagebreak |
@@ -374,54 +374,54 @@ discard block |
||
374 | 374 | } |
375 | 375 | |
376 | 376 | $nexY = $pdf->GetY(); |
377 | - $pageposafter=$pdf->getPage(); |
|
377 | + $pageposafter = $pdf->getPage(); |
|
378 | 378 | $pdf->setPage($pageposbefore); |
379 | 379 | $pdf->setTopMargin($this->marge_haute); |
380 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
380 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
381 | 381 | |
382 | 382 | // We suppose that a too long description is moved completely on next page |
383 | 383 | if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
384 | 384 | $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
385 | 385 | } |
386 | 386 | |
387 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
387 | + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut |
|
388 | 388 | |
389 | 389 | // ref fourn |
390 | 390 | $pdf->SetXY($this->posxreffacturefourn, $curY); |
391 | - $pdf->MultiCell($this->posxreffacturefourn-$this->posxup-0.8, 3, $object->lines[$i]->ref_supplier, 0, 'L', 0); |
|
391 | + $pdf->MultiCell($this->posxreffacturefourn - $this->posxup - 0.8, 3, $object->lines[$i]->ref_supplier, 0, 'L', 0); |
|
392 | 392 | |
393 | 393 | // ref facture fourn |
394 | 394 | $pdf->SetXY($this->posxreffacture, $curY); |
395 | - $pdf->MultiCell($this->posxreffacture-$this->posxup-0.8, 3, $object->lines[$i]->ref, 0, 'L', 0); |
|
395 | + $pdf->MultiCell($this->posxreffacture - $this->posxup - 0.8, 3, $object->lines[$i]->ref, 0, 'L', 0); |
|
396 | 396 | |
397 | 397 | // type |
398 | 398 | $pdf->SetXY($this->posxtype, $curY); |
399 | - $pdf->MultiCell($this->posxtype-$this->posxup-0.8, 3, $object->lines[$i]->type, 0, 'L', 0); |
|
399 | + $pdf->MultiCell($this->posxtype - $this->posxup - 0.8, 3, $object->lines[$i]->type, 0, 'L', 0); |
|
400 | 400 | |
401 | 401 | // Total ht |
402 | 402 | $pdf->SetXY($this->posxtotalht, $curY); |
403 | - $pdf->MultiCell($this->posxtotalht-$this->posxup-0.8, 3, price($object->lines[$i]->total_ht), 0, 'R', 0); |
|
403 | + $pdf->MultiCell($this->posxtotalht - $this->posxup - 0.8, 3, price($object->lines[$i]->total_ht), 0, 'R', 0); |
|
404 | 404 | |
405 | 405 | // Total tva |
406 | 406 | $pdf->SetXY($this->posxtva, $curY); |
407 | - $pdf->MultiCell($this->posxtva-$this->posxup-0.8, 3, price($object->lines[$i]->total_tva), 0, 'R', 0); |
|
407 | + $pdf->MultiCell($this->posxtva - $this->posxup - 0.8, 3, price($object->lines[$i]->total_tva), 0, 'R', 0); |
|
408 | 408 | |
409 | 409 | // Total TTC line |
410 | 410 | $pdf->SetXY($this->posxtotalttc, $curY); |
411 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxtotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R', 0); |
|
411 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R', 0); |
|
412 | 412 | |
413 | 413 | |
414 | 414 | // Add line |
415 | - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
415 | + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
416 | 416 | { |
417 | 417 | $pdf->setPage($pageposafter); |
418 | - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
418 | + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); |
|
419 | 419 | //$pdf->SetDrawColor(190,190,200); |
420 | - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
420 | + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); |
|
421 | 421 | $pdf->SetLineStyle(array('dash'=>0)); |
422 | 422 | } |
423 | 423 | |
424 | - $nexY+=2; // Passe espace entre les lignes |
|
424 | + $nexY += 2; // Passe espace entre les lignes |
|
425 | 425 | |
426 | 426 | // Detect if some page were added automatically and output _tableau for past pages |
427 | 427 | while ($pagenb < $pageposafter) |
@@ -435,13 +435,13 @@ discard block |
||
435 | 435 | { |
436 | 436 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
437 | 437 | } |
438 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
438 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
439 | 439 | $pagenb++; |
440 | 440 | $pdf->setPage($pagenb); |
441 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
441 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
442 | 442 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
443 | 443 | } |
444 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
444 | + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) |
|
445 | 445 | { |
446 | 446 | if ($pagenb == 1) |
447 | 447 | { |
@@ -451,10 +451,10 @@ discard block |
||
451 | 451 | { |
452 | 452 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
453 | 453 | } |
454 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
454 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
455 | 455 | // New page |
456 | 456 | $pdf->AddPage(); |
457 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
457 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
458 | 458 | $pagenb++; |
459 | 459 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
460 | 460 | } |
@@ -464,50 +464,50 @@ discard block |
||
464 | 464 | if ($pagenb == 1) |
465 | 465 | { |
466 | 466 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
467 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
467 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
468 | 468 | } |
469 | 469 | else |
470 | 470 | { |
471 | 471 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
472 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
472 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | // Affiche zone cheèque |
476 | - $posy=$this->_tableau_cheque($pdf, $object, $bottomlasttab, $outputlangs); |
|
476 | + $posy = $this->_tableau_cheque($pdf, $object, $bottomlasttab, $outputlangs); |
|
477 | 477 | |
478 | 478 | // Affiche zone totaux |
479 | 479 | //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
480 | 480 | |
481 | 481 | // Pied de page |
482 | 482 | $this->_pagefoot($pdf, $object, $outputlangs); |
483 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
483 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
484 | 484 | |
485 | 485 | $pdf->Close(); |
486 | 486 | |
487 | - $pdf->Output($file,'F'); |
|
487 | + $pdf->Output($file, 'F'); |
|
488 | 488 | |
489 | 489 | // Add pdfgeneration hook |
490 | 490 | $hookmanager->initHooks(array('pdfgeneration')); |
491 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
491 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
492 | 492 | global $action; |
493 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
493 | + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
494 | 494 | |
495 | - if (! empty($conf->global->MAIN_UMASK)) |
|
495 | + if (!empty($conf->global->MAIN_UMASK)) |
|
496 | 496 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
497 | 497 | |
498 | 498 | $this->result = array('fullpath'=>$file); |
499 | 499 | |
500 | - return 1; // Pas d'erreur |
|
500 | + return 1; // Pas d'erreur |
|
501 | 501 | } |
502 | 502 | else |
503 | 503 | { |
504 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
504 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
505 | 505 | return 0; |
506 | 506 | } |
507 | 507 | } |
508 | 508 | else |
509 | 509 | { |
510 | - $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); |
|
510 | + $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); |
|
511 | 511 | return 0; |
512 | 512 | } |
513 | 513 | } |
@@ -525,12 +525,12 @@ discard block |
||
525 | 525 | function _tableau_cheque(&$pdf, $object, $posy, $outputlangs) |
526 | 526 | { |
527 | 527 | // phpcs:enable |
528 | - global $conf,$mysoc; |
|
528 | + global $conf, $mysoc; |
|
529 | 529 | |
530 | 530 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
531 | 531 | |
532 | - $pdf->SetFont('','', $default_font_size - 1); |
|
533 | - $pdf->SetFillColor(255,255,255); |
|
532 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
533 | + $pdf->SetFillColor(255, 255, 255); |
|
534 | 534 | |
535 | 535 | // N° payment |
536 | 536 | $pdf->SetXY($this->marge_gauche, $posy); |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | |
548 | 548 | // translate amount |
549 | 549 | $currency = $conf->currency; |
550 | - $translateinletter = strtoupper(dol_convertToWord($object->montant,$outputlangs,$currency)); |
|
550 | + $translateinletter = strtoupper(dol_convertToWord($object->montant, $outputlangs, $currency)); |
|
551 | 551 | $pdf->SetXY($this->marge_gauche + 50, $posy); |
552 | 552 | $pdf->MultiCell(90, 8, $translateinletter, 0, 'L', 1); |
553 | 553 | $posy += 8; |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | $pdf->MultiCell(150, 4, $object->thirdparty->nom, 0, 'L', 1); |
558 | 558 | |
559 | 559 | $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy); |
560 | - $pdf->MultiCell(35, 4, str_pad(price($object->montant). ' '.$currency,18,'*',STR_PAD_LEFT), 0, 'R', 1); |
|
560 | + $pdf->MultiCell(35, 4, str_pad(price($object->montant).' '.$currency, 18, '*', STR_PAD_LEFT), 0, 'R', 1); |
|
561 | 561 | $posy += 10; |
562 | 562 | |
563 | 563 | |
@@ -585,32 +585,32 @@ discard block |
||
585 | 585 | * @param string $currency Currency code |
586 | 586 | * @return void |
587 | 587 | */ |
588 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
588 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') |
|
589 | 589 | { |
590 | - global $conf,$mysoc; |
|
590 | + global $conf, $mysoc; |
|
591 | 591 | |
592 | 592 | // Force to disable hidetop and hidebottom |
593 | - $hidebottom=0; |
|
594 | - if ($hidetop) $hidetop=-1; |
|
593 | + $hidebottom = 0; |
|
594 | + if ($hidetop) $hidetop = -1; |
|
595 | 595 | |
596 | 596 | $currency = !empty($currency) ? $currency : $conf->currency; |
597 | 597 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
598 | 598 | |
599 | 599 | // Amount in (at tab_top - 1) |
600 | - $pdf->SetTextColor(0,0,0); |
|
601 | - $pdf->SetFont('','',$default_font_size - 2); |
|
600 | + $pdf->SetTextColor(0, 0, 0); |
|
601 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
602 | 602 | |
603 | 603 | $titre = strtoupper($mysoc->town).', le '.date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y"); |
604 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3) - 60, $tab_top-6); |
|
604 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3) - 60, $tab_top - 6); |
|
605 | 605 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
606 | 606 | |
607 | - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
607 | + $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
608 | 608 | $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top); |
609 | 609 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
610 | 610 | |
611 | 611 | |
612 | - $pdf->SetDrawColor(128,128,128); |
|
613 | - $pdf->SetFont('','', $default_font_size - 1); |
|
612 | + $pdf->SetDrawColor(128, 128, 128); |
|
613 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
614 | 614 | |
615 | 615 | // Output Rect |
616 | 616 | //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
@@ -638,34 +638,34 @@ discard block |
||
638 | 638 | // Do not add the BACKGROUND as this is for suppliers |
639 | 639 | //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
640 | 640 | |
641 | - $pdf->SetTextColor(0,0,60); |
|
642 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
641 | + $pdf->SetTextColor(0, 0, 60); |
|
642 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
643 | 643 | |
644 | - $posy=$this->marge_haute; |
|
645 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
644 | + $posy = $this->marge_haute; |
|
645 | + $posx = $this->page_largeur - $this->marge_droite - 100; |
|
646 | 646 | |
647 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
647 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
648 | 648 | |
649 | 649 | // Logo |
650 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
650 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
651 | 651 | if ($mysoc->logo) |
652 | 652 | { |
653 | 653 | if (is_readable($logo)) |
654 | 654 | { |
655 | - $height=pdf_getHeightForLogo($logo); |
|
656 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
655 | + $height = pdf_getHeightForLogo($logo); |
|
656 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
657 | 657 | } |
658 | 658 | else |
659 | 659 | { |
660 | - $pdf->SetTextColor(200,0,0); |
|
661 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
662 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
660 | + $pdf->SetTextColor(200, 0, 0); |
|
661 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
662 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); |
|
663 | 663 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
664 | 664 | } |
665 | 665 | } |
666 | 666 | else |
667 | 667 | { |
668 | - $text=$this->emetteur->name; |
|
668 | + $text = $this->emetteur->name; |
|
669 | 669 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
670 | 670 | } |
671 | 671 | /* |
@@ -735,63 +735,63 @@ discard block |
||
735 | 735 | $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); |
736 | 736 | |
737 | 737 | // Show payer |
738 | - $posy=42; |
|
739 | - $posx=$this->marge_gauche; |
|
740 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
741 | - $hautcadre=40; |
|
738 | + $posy = 42; |
|
739 | + $posx = $this->marge_gauche; |
|
740 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; |
|
741 | + $hautcadre = 40; |
|
742 | 742 | |
743 | 743 | // Show sender frame |
744 | - $pdf->SetTextColor(0,0,0); |
|
745 | - $pdf->SetFont('','', $default_font_size - 2); |
|
746 | - $pdf->SetXY($posx,$posy-5); |
|
747 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("PayedBy").":", 0, 'L'); |
|
748 | - $pdf->SetXY($posx,$posy); |
|
749 | - $pdf->SetFillColor(230,230,230); |
|
744 | + $pdf->SetTextColor(0, 0, 0); |
|
745 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
746 | + $pdf->SetXY($posx, $posy - 5); |
|
747 | + $pdf->MultiCell(66, 5, $outputlangs->transnoentities("PayedBy").":", 0, 'L'); |
|
748 | + $pdf->SetXY($posx, $posy); |
|
749 | + $pdf->SetFillColor(230, 230, 230); |
|
750 | 750 | $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
751 | - $pdf->SetTextColor(0,0,60); |
|
751 | + $pdf->SetTextColor(0, 0, 60); |
|
752 | 752 | |
753 | 753 | // Show sender name |
754 | - $pdf->SetXY($posx+2,$posy+3); |
|
755 | - $pdf->SetFont('','B', $default_font_size); |
|
754 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
755 | + $pdf->SetFont('', 'B', $default_font_size); |
|
756 | 756 | $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
757 | - $posy=$pdf->getY(); |
|
757 | + $posy = $pdf->getY(); |
|
758 | 758 | |
759 | 759 | // Show sender information |
760 | - $pdf->SetXY($posx+2,$posy); |
|
761 | - $pdf->SetFont('','', $default_font_size - 1); |
|
760 | + $pdf->SetXY($posx + 2, $posy); |
|
761 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
762 | 762 | $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
763 | 763 | |
764 | 764 | // Payed |
765 | 765 | $thirdparty = $object->thirdparty; |
766 | 766 | |
767 | - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
767 | + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
768 | 768 | |
769 | - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object); |
|
769 | + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $mysoc, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'target', $object); |
|
770 | 770 | |
771 | 771 | // Show recipient |
772 | - $widthrecbox=90; |
|
773 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
774 | - $posy=42; |
|
775 | - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
776 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
772 | + $widthrecbox = 90; |
|
773 | + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format |
|
774 | + $posy = 42; |
|
775 | + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; |
|
776 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; |
|
777 | 777 | |
778 | 778 | // Show recipient frame |
779 | - $pdf->SetTextColor(0,0,0); |
|
780 | - $pdf->SetFont('','', $default_font_size - 2); |
|
781 | - $pdf->SetXY($posx+2,$posy-5); |
|
782 | - $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("PayedTo").":",0,'L'); |
|
779 | + $pdf->SetTextColor(0, 0, 0); |
|
780 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
781 | + $pdf->SetXY($posx + 2, $posy - 5); |
|
782 | + $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("PayedTo").":", 0, 'L'); |
|
783 | 783 | $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
784 | 784 | |
785 | 785 | // Show recipient name |
786 | - $pdf->SetXY($posx+2,$posy+3); |
|
787 | - $pdf->SetFont('','B', $default_font_size); |
|
786 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
787 | + $pdf->SetFont('', 'B', $default_font_size); |
|
788 | 788 | $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); |
789 | 789 | |
790 | 790 | $posy = $pdf->getY(); |
791 | 791 | |
792 | 792 | // Show recipient information |
793 | - $pdf->SetFont('','', $default_font_size - 1); |
|
794 | - $pdf->SetXY($posx+2,$posy); |
|
793 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
794 | + $pdf->SetXY($posx + 2, $posy); |
|
795 | 795 | $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
796 | 796 | } |
797 | 797 | } |
@@ -805,10 +805,10 @@ discard block |
||
805 | 805 | * @param int $hidefreetext 1=Hide free text |
806 | 806 | * @return int Return height of bottom margin including footer text |
807 | 807 | */ |
808 | - function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0) |
|
808 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
809 | 809 | { |
810 | 810 | global $conf; |
811 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
812 | - return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
811 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
812 | + return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
813 | 813 | } |
814 | 814 | } |
@@ -154,9 +154,11 @@ discard block |
||
154 | 154 | $this->posxtotalttc=180; |
155 | 155 | |
156 | 156 | //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; |
157 | - if ($this->page_largeur < 210) // To work with US executive format |
|
157 | + if ($this->page_largeur < 210) { |
|
158 | + // To work with US executive format |
|
158 | 159 | { |
159 | 160 | $this->posxreffacturefourn-=20; |
161 | + } |
|
160 | 162 | $this->posxreffacture-=20; |
161 | 163 | $this->posxtype-=20; |
162 | 164 | $this->posxtotalht-=20; |
@@ -172,7 +174,10 @@ discard block |
||
172 | 174 | |
173 | 175 | // Recupere emetteur |
174 | 176 | $this->emetteur=$mysoc; |
175 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
177 | + if (! $this->emetteur->country_code) { |
|
178 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
179 | + } |
|
180 | + // By default if not defined |
|
176 | 181 | } |
177 | 182 | |
178 | 183 | |
@@ -193,9 +198,13 @@ discard block |
||
193 | 198 | // phpcs:enable |
194 | 199 | global $user, $langs, $conf, $mysoc, $hookmanager; |
195 | 200 | |
196 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
201 | + if (! is_object($outputlangs)) { |
|
202 | + $outputlangs=$langs; |
|
203 | + } |
|
197 | 204 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
198 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
205 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
206 | + $outputlangs->charset_output='ISO-8859-1'; |
|
207 | + } |
|
199 | 208 | |
200 | 209 | // Load translation files required by the page |
201 | 210 | $outputlangs->loadLangs(array("main", "suppliers", "companies", "bills", "dict", "products")); |
@@ -232,14 +241,15 @@ discard block |
||
232 | 241 | { |
233 | 242 | $dir = $conf->fournisseur->payment->dir_output; |
234 | 243 | $file = $dir . "/SPECIMEN.pdf"; |
235 | - } |
|
236 | - else |
|
244 | + } else |
|
237 | 245 | { |
238 | 246 | $objectref = dol_sanitizeFileName($object->ref); |
239 | 247 | $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); |
240 | 248 | $dir = $conf->fournisseur->payment->dir_output.'/'.$objectref; |
241 | 249 | $file = $dir . "/" . $objectref . ".pdf"; |
242 | - if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
250 | + if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) { |
|
251 | + $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
252 | + } |
|
243 | 253 | } |
244 | 254 | |
245 | 255 | if (! file_exists($dir)) |
@@ -271,7 +281,9 @@ discard block |
||
271 | 281 | $heightforinfotot = 50; // Height reserved to output the info and total part |
272 | 282 | $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
273 | 283 | $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
274 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
284 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) { |
|
285 | + $heightforfooter+= 6; |
|
286 | + } |
|
275 | 287 | $pdf->SetAutoPageBreak(1,0); |
276 | 288 | |
277 | 289 | if (class_exists('TCPDF')) |
@@ -296,14 +308,18 @@ discard block |
||
296 | 308 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
297 | 309 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
298 | 310 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
299 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
311 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
312 | + $pdf->SetCompression(false); |
|
313 | + } |
|
300 | 314 | |
301 | 315 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
302 | 316 | |
303 | 317 | |
304 | 318 | // New page |
305 | 319 | $pdf->AddPage(); |
306 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
320 | + if (! empty($tplidx)) { |
|
321 | + $pdf->useTemplate($tplidx); |
|
322 | + } |
|
307 | 323 | $pagenb++; |
308 | 324 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
309 | 325 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -343,32 +359,38 @@ discard block |
||
343 | 359 | //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1); |
344 | 360 | $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true); |
345 | 361 | $pageposafter=$pdf->getPage(); |
346 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
362 | + if ($pageposafter > $pageposbefore) { |
|
363 | + // There is a pagebreak |
|
347 | 364 | { |
348 | 365 | $pdf->rollbackTransaction(true); |
366 | + } |
|
349 | 367 | $pageposafter=$pageposbefore; |
350 | 368 | //print $pageposafter.'-'.$pageposbefore;exit; |
351 | 369 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
352 | 370 | //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1); |
353 | 371 | $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true); |
354 | 372 | $posyafter=$pdf->GetY(); |
355 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
373 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
374 | + // There is no space left for total+free text |
|
356 | 375 | { |
357 | 376 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
358 | 377 | { |
359 | 378 | $pdf->AddPage('','',true); |
360 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
361 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
379 | + } |
|
380 | + if (! empty($tplidx)) { |
|
381 | + $pdf->useTemplate($tplidx); |
|
382 | + } |
|
383 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
384 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
385 | + } |
|
362 | 386 | $pdf->setPage($pageposafter+1); |
363 | 387 | } |
364 | - } |
|
365 | - else |
|
388 | + } else |
|
366 | 389 | { |
367 | 390 | // We found a page break |
368 | 391 | $showpricebeforepagebreak=0; |
369 | 392 | } |
370 | - } |
|
371 | - else // No pagebreak |
|
393 | + } else // No pagebreak |
|
372 | 394 | { |
373 | 395 | $pdf->commitTransaction(); |
374 | 396 | } |
@@ -430,8 +452,7 @@ discard block |
||
430 | 452 | if ($pagenb == 1) |
431 | 453 | { |
432 | 454 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
433 | - } |
|
434 | - else |
|
455 | + } else |
|
435 | 456 | { |
436 | 457 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
437 | 458 | } |
@@ -439,24 +460,29 @@ discard block |
||
439 | 460 | $pagenb++; |
440 | 461 | $pdf->setPage($pagenb); |
441 | 462 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
442 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
463 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
464 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
465 | + } |
|
443 | 466 | } |
444 | 467 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
445 | 468 | { |
446 | 469 | if ($pagenb == 1) |
447 | 470 | { |
448 | 471 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
449 | - } |
|
450 | - else |
|
472 | + } else |
|
451 | 473 | { |
452 | 474 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
453 | 475 | } |
454 | 476 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
455 | 477 | // New page |
456 | 478 | $pdf->AddPage(); |
457 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
479 | + if (! empty($tplidx)) { |
|
480 | + $pdf->useTemplate($tplidx); |
|
481 | + } |
|
458 | 482 | $pagenb++; |
459 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
483 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
484 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
485 | + } |
|
460 | 486 | } |
461 | 487 | } |
462 | 488 | |
@@ -465,8 +491,7 @@ discard block |
||
465 | 491 | { |
466 | 492 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
467 | 493 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
468 | - } |
|
469 | - else |
|
494 | + } else |
|
470 | 495 | { |
471 | 496 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
472 | 497 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -480,7 +505,9 @@ discard block |
||
480 | 505 | |
481 | 506 | // Pied de page |
482 | 507 | $this->_pagefoot($pdf, $object, $outputlangs); |
483 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
508 | + if (method_exists($pdf,'AliasNbPages')) { |
|
509 | + $pdf->AliasNbPages(); |
|
510 | + } |
|
484 | 511 | |
485 | 512 | $pdf->Close(); |
486 | 513 | |
@@ -492,20 +519,19 @@ discard block |
||
492 | 519 | global $action; |
493 | 520 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
494 | 521 | |
495 | - if (! empty($conf->global->MAIN_UMASK)) |
|
496 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
522 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
523 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
524 | + } |
|
497 | 525 | |
498 | 526 | $this->result = array('fullpath'=>$file); |
499 | 527 | |
500 | 528 | return 1; // Pas d'erreur |
501 | - } |
|
502 | - else |
|
529 | + } else |
|
503 | 530 | { |
504 | 531 | $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
505 | 532 | return 0; |
506 | 533 | } |
507 | - } |
|
508 | - else |
|
534 | + } else |
|
509 | 535 | { |
510 | 536 | $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); |
511 | 537 | return 0; |
@@ -591,7 +617,9 @@ discard block |
||
591 | 617 | |
592 | 618 | // Force to disable hidetop and hidebottom |
593 | 619 | $hidebottom=0; |
594 | - if ($hidetop) $hidetop=-1; |
|
620 | + if ($hidetop) { |
|
621 | + $hidetop=-1; |
|
622 | + } |
|
595 | 623 | |
596 | 624 | $currency = !empty($currency) ? $currency : $conf->currency; |
597 | 625 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -654,16 +682,14 @@ discard block |
||
654 | 682 | { |
655 | 683 | $height=pdf_getHeightForLogo($logo); |
656 | 684 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
657 | - } |
|
658 | - else |
|
685 | + } else |
|
659 | 686 | { |
660 | 687 | $pdf->SetTextColor(200,0,0); |
661 | 688 | $pdf->SetFont('','B', $default_font_size - 2); |
662 | 689 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
663 | 690 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
664 | 691 | } |
665 | - } |
|
666 | - else |
|
692 | + } else |
|
667 | 693 | { |
668 | 694 | $text=$this->emetteur->name; |
669 | 695 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -737,7 +763,9 @@ discard block |
||
737 | 763 | // Show payer |
738 | 764 | $posy=42; |
739 | 765 | $posx=$this->marge_gauche; |
740 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
766 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
767 | + $posx=$this->page_largeur-$this->marge_droite-80; |
|
768 | + } |
|
741 | 769 | $hautcadre=40; |
742 | 770 | |
743 | 771 | // Show sender frame |
@@ -770,10 +798,15 @@ discard block |
||
770 | 798 | |
771 | 799 | // Show recipient |
772 | 800 | $widthrecbox=90; |
773 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
801 | + if ($this->page_largeur < 210) { |
|
802 | + $widthrecbox=84; |
|
803 | + } |
|
804 | + // To work with US executive format |
|
774 | 805 | $posy=42; |
775 | 806 | $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
776 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
807 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
808 | + $posx=$this->marge_gauche; |
|
809 | + } |
|
777 | 810 | |
778 | 811 | // Show recipient frame |
779 | 812 | $pdf->SetTextColor(0,0,0); |
@@ -29,30 +29,30 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments |
31 | 31 | { |
32 | - /** |
|
32 | + /** |
|
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 $prefix='SPAY'; |
|
38 | + public $prefix='SPAY'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @var string Error code (or message) |
|
42 | - */ |
|
43 | - public $error=''; |
|
40 | + /** |
|
41 | + * @var string Error code (or message) |
|
42 | + */ |
|
43 | + public $error=''; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @var string Nom du modele |
|
47 | - * @deprecated |
|
48 | - * @see name |
|
49 | - */ |
|
50 | - public $nom='Bronan'; |
|
45 | + /** |
|
46 | + * @var string Nom du modele |
|
47 | + * @deprecated |
|
48 | + * @see name |
|
49 | + */ |
|
50 | + public $nom='Bronan'; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @var string model name |
|
54 | - */ |
|
55 | - public $name='Bronan'; |
|
52 | + /** |
|
53 | + * @var string model name |
|
54 | + */ |
|
55 | + public $name='Bronan'; |
|
56 | 56 | |
57 | 57 | |
58 | 58 | /** |
@@ -62,110 +62,110 @@ discard block |
||
62 | 62 | */ |
63 | 63 | function info() |
64 | 64 | { |
65 | - global $langs; |
|
66 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
65 | + global $langs; |
|
66 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * Renvoi un exemple de numerotation |
|
72 | - * |
|
73 | - * @return string Example |
|
74 | - */ |
|
75 | - function getExample() |
|
76 | - { |
|
77 | - return $this->prefix."0501-0001"; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
83 | - * de conflits qui empechera cette numerotation de fonctionner. |
|
84 | - * |
|
85 | - * @return boolean false si conflit, true si ok |
|
86 | - */ |
|
87 | - function canBeActivated() |
|
88 | - { |
|
89 | - global $conf,$langs,$db; |
|
90 | - |
|
91 | - $payyymm=''; $max=''; |
|
92 | - |
|
93 | - $posindice=9; |
|
94 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
95 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn"; |
|
96 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | - $sql.= " AND entity = ".$conf->entity; |
|
98 | - |
|
99 | - $resql=$db->query($sql); |
|
100 | - if ($resql) |
|
101 | - { |
|
102 | - $row = $db->fetch_row($resql); |
|
103 | - if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } |
|
104 | - } |
|
105 | - if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) |
|
106 | - { |
|
107 | - $langs->load("errors"); |
|
108 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
109 | - return false; |
|
110 | - } |
|
111 | - |
|
112 | - return true; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Return next free value |
|
117 | - * |
|
118 | - * @param Societe $objsoc Object thirdparty |
|
119 | - * @param Object $object Object we need next value for |
|
120 | - * @return string Value if KO, <0 if KO |
|
121 | - */ |
|
122 | - function getNextValue($objsoc,$object) |
|
123 | - { |
|
124 | - global $db,$conf; |
|
125 | - |
|
126 | - // D'abord on recupere la valeur max |
|
127 | - $posindice=10; |
|
128 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
129 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn"; |
|
130 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | - $sql.= " AND entity = ".$conf->entity; |
|
132 | - |
|
133 | - $resql=$db->query($sql); |
|
134 | - if ($resql) |
|
135 | - { |
|
136 | - $obj = $db->fetch_object($resql); |
|
137 | - if ($obj) $max = intval($obj->max); |
|
138 | - else $max=0; |
|
139 | - } |
|
140 | - else |
|
141 | - { |
|
142 | - dol_syslog(__METHOD__, LOG_DEBUG); |
|
143 | - return -1; |
|
144 | - } |
|
145 | - |
|
146 | - //$date=time(); |
|
147 | - $date=$object->datepaye; |
|
148 | - $yymm = strftime("%y%m",$date); |
|
149 | - |
|
150 | - 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 |
|
151 | - else $num = sprintf("%04s",$max+1); |
|
152 | - |
|
153 | - dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
|
154 | - return $this->prefix.$yymm."-".$num; |
|
155 | - } |
|
70 | + /** |
|
71 | + * Renvoi un exemple de numerotation |
|
72 | + * |
|
73 | + * @return string Example |
|
74 | + */ |
|
75 | + function getExample() |
|
76 | + { |
|
77 | + return $this->prefix."0501-0001"; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
83 | + * de conflits qui empechera cette numerotation de fonctionner. |
|
84 | + * |
|
85 | + * @return boolean false si conflit, true si ok |
|
86 | + */ |
|
87 | + function canBeActivated() |
|
88 | + { |
|
89 | + global $conf,$langs,$db; |
|
90 | + |
|
91 | + $payyymm=''; $max=''; |
|
92 | + |
|
93 | + $posindice=9; |
|
94 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
95 | + $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn"; |
|
96 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | + $sql.= " AND entity = ".$conf->entity; |
|
98 | + |
|
99 | + $resql=$db->query($sql); |
|
100 | + if ($resql) |
|
101 | + { |
|
102 | + $row = $db->fetch_row($resql); |
|
103 | + if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } |
|
104 | + } |
|
105 | + if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) |
|
106 | + { |
|
107 | + $langs->load("errors"); |
|
108 | + $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
109 | + return false; |
|
110 | + } |
|
111 | + |
|
112 | + return true; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Return next free value |
|
117 | + * |
|
118 | + * @param Societe $objsoc Object thirdparty |
|
119 | + * @param Object $object Object we need next value for |
|
120 | + * @return string Value if KO, <0 if KO |
|
121 | + */ |
|
122 | + function getNextValue($objsoc,$object) |
|
123 | + { |
|
124 | + global $db,$conf; |
|
125 | + |
|
126 | + // D'abord on recupere la valeur max |
|
127 | + $posindice=10; |
|
128 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
129 | + $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn"; |
|
130 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | + $sql.= " AND entity = ".$conf->entity; |
|
132 | + |
|
133 | + $resql=$db->query($sql); |
|
134 | + if ($resql) |
|
135 | + { |
|
136 | + $obj = $db->fetch_object($resql); |
|
137 | + if ($obj) $max = intval($obj->max); |
|
138 | + else $max=0; |
|
139 | + } |
|
140 | + else |
|
141 | + { |
|
142 | + dol_syslog(__METHOD__, LOG_DEBUG); |
|
143 | + return -1; |
|
144 | + } |
|
145 | + |
|
146 | + //$date=time(); |
|
147 | + $date=$object->datepaye; |
|
148 | + $yymm = strftime("%y%m",$date); |
|
149 | + |
|
150 | + 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 |
|
151 | + else $num = sprintf("%04s",$max+1); |
|
152 | + |
|
153 | + dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
|
154 | + return $this->prefix.$yymm."-".$num; |
|
155 | + } |
|
156 | 156 | |
157 | 157 | |
158 | 158 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
159 | - /** |
|
160 | - * Return next free value |
|
161 | - * |
|
162 | - * @param Societe $objsoc Object third party |
|
163 | - * @param string $objforref Object for number to search |
|
164 | - * @return string Next free value |
|
165 | - */ |
|
166 | - function payment_get_num($objsoc,$objforref) |
|
167 | - { |
|
159 | + /** |
|
160 | + * Return next free value |
|
161 | + * |
|
162 | + * @param Societe $objsoc Object third party |
|
163 | + * @param string $objforref Object for number to search |
|
164 | + * @return string Next free value |
|
165 | + */ |
|
166 | + function payment_get_num($objsoc,$objforref) |
|
167 | + { |
|
168 | 168 | // phpcs:enable |
169 | - return $this->getNextValue($objsoc,$objforref); |
|
170 | - } |
|
169 | + return $this->getNextValue($objsoc,$objforref); |
|
170 | + } |
|
171 | 171 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief File containing class for numbering module Bronan |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_payment/modules_supplier_payment.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php'; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class to manage customer payment numbering rules Cicada |
@@ -33,26 +33,26 @@ 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 $prefix='SPAY'; |
|
38 | + public $prefix = 'SPAY'; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var string Error code (or message) |
42 | 42 | */ |
43 | - public $error=''; |
|
43 | + public $error = ''; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @var string Nom du modele |
47 | 47 | * @deprecated |
48 | 48 | * @see name |
49 | 49 | */ |
50 | - public $nom='Bronan'; |
|
50 | + public $nom = 'Bronan'; |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @var string model name |
54 | 54 | */ |
55 | - public $name='Bronan'; |
|
55 | + public $name = 'Bronan'; |
|
56 | 56 | |
57 | 57 | |
58 | 58 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | function info() |
64 | 64 | { |
65 | 65 | global $langs; |
66 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
66 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -86,26 +86,26 @@ discard block |
||
86 | 86 | */ |
87 | 87 | function canBeActivated() |
88 | 88 | { |
89 | - global $conf,$langs,$db; |
|
89 | + global $conf, $langs, $db; |
|
90 | 90 | |
91 | - $payyymm=''; $max=''; |
|
91 | + $payyymm = ''; $max = ''; |
|
92 | 92 | |
93 | - $posindice=9; |
|
93 | + $posindice = 9; |
|
94 | 94 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
95 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn"; |
|
96 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | - $sql.= " AND entity = ".$conf->entity; |
|
95 | + $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn"; |
|
96 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | + $sql .= " AND entity = ".$conf->entity; |
|
98 | 98 | |
99 | - $resql=$db->query($sql); |
|
99 | + $resql = $db->query($sql); |
|
100 | 100 | if ($resql) |
101 | 101 | { |
102 | 102 | $row = $db->fetch_row($resql); |
103 | - if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } |
|
103 | + if ($row) { $payyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
104 | 104 | } |
105 | - if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) |
|
105 | + if ($payyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $payyymm)) |
|
106 | 106 | { |
107 | 107 | $langs->load("errors"); |
108 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
108 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | |
@@ -119,23 +119,23 @@ discard block |
||
119 | 119 | * @param Object $object Object we need next value for |
120 | 120 | * @return string Value if KO, <0 if KO |
121 | 121 | */ |
122 | - function getNextValue($objsoc,$object) |
|
122 | + function getNextValue($objsoc, $object) |
|
123 | 123 | { |
124 | - global $db,$conf; |
|
124 | + global $db, $conf; |
|
125 | 125 | |
126 | 126 | // D'abord on recupere la valeur max |
127 | - $posindice=10; |
|
127 | + $posindice = 10; |
|
128 | 128 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
129 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn"; |
|
130 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | - $sql.= " AND entity = ".$conf->entity; |
|
129 | + $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn"; |
|
130 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | + $sql .= " AND entity = ".$conf->entity; |
|
132 | 132 | |
133 | - $resql=$db->query($sql); |
|
133 | + $resql = $db->query($sql); |
|
134 | 134 | if ($resql) |
135 | 135 | { |
136 | 136 | $obj = $db->fetch_object($resql); |
137 | 137 | if ($obj) $max = intval($obj->max); |
138 | - else $max=0; |
|
138 | + else $max = 0; |
|
139 | 139 | } |
140 | 140 | else |
141 | 141 | { |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | //$date=time(); |
147 | - $date=$object->datepaye; |
|
148 | - $yymm = strftime("%y%m",$date); |
|
147 | + $date = $object->datepaye; |
|
148 | + $yymm = strftime("%y%m", $date); |
|
149 | 149 | |
150 | - 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 |
|
151 | - else $num = sprintf("%04s",$max+1); |
|
150 | + 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 |
|
151 | + else $num = sprintf("%04s", $max + 1); |
|
152 | 152 | |
153 | 153 | dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
154 | 154 | return $this->prefix.$yymm."-".$num; |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | * @param string $objforref Object for number to search |
164 | 164 | * @return string Next free value |
165 | 165 | */ |
166 | - function payment_get_num($objsoc,$objforref) |
|
166 | + function payment_get_num($objsoc, $objforref) |
|
167 | 167 | { |
168 | 168 | // phpcs:enable |
169 | - return $this->getNextValue($objsoc,$objforref); |
|
169 | + return $this->getNextValue($objsoc, $objforref); |
|
170 | 170 | } |
171 | 171 | } |
@@ -134,10 +134,12 @@ discard block |
||
134 | 134 | if ($resql) |
135 | 135 | { |
136 | 136 | $obj = $db->fetch_object($resql); |
137 | - if ($obj) $max = intval($obj->max); |
|
138 | - else $max=0; |
|
139 | - } |
|
140 | - else |
|
137 | + if ($obj) { |
|
138 | + $max = intval($obj->max); |
|
139 | + } else { |
|
140 | + $max=0; |
|
141 | + } |
|
142 | + } else |
|
141 | 143 | { |
142 | 144 | dol_syslog(__METHOD__, LOG_DEBUG); |
143 | 145 | return -1; |
@@ -147,8 +149,13 @@ discard block |
||
147 | 149 | $date=$object->datepaye; |
148 | 150 | $yymm = strftime("%y%m",$date); |
149 | 151 | |
150 | - 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 |
|
151 | - else $num = sprintf("%04s",$max+1); |
|
152 | + if ($max >= (pow(10, 4) - 1)) { |
|
153 | + $num=$max+1; |
|
154 | + } |
|
155 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
156 | + else { |
|
157 | + $num = sprintf("%04s",$max+1); |
|
158 | + } |
|
152 | 159 | |
153 | 160 | dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
154 | 161 | return $this->prefix.$yymm."-".$num; |