@@ -40,156 +40,156 @@ discard block |
||
40 | 40 | */ |
41 | 41 | class pdf_standard extends ModeleExpenseReport |
42 | 42 | { |
43 | - /** |
|
44 | - * @var DoliDb Database handler |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var DoliDb Database handler |
|
45 | + */ |
|
46 | 46 | public $db; |
47 | 47 | |
48 | - /** |
|
48 | + /** |
|
49 | 49 | * @var string model name |
50 | 50 | */ |
51 | 51 | public $name; |
52 | 52 | |
53 | - /** |
|
53 | + /** |
|
54 | 54 | * @var string model description (short text) |
55 | 55 | */ |
56 | 56 | public $description; |
57 | 57 | |
58 | - /** |
|
58 | + /** |
|
59 | 59 | * @var string document type |
60 | 60 | */ |
61 | 61 | public $type; |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @var array() Minimum version of PHP required by module. |
65 | - * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
65 | + * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
66 | 66 | */ |
67 | - public $phpmin = array(5, 4); |
|
67 | + public $phpmin = array(5, 4); |
|
68 | 68 | |
69 | - /** |
|
69 | + /** |
|
70 | 70 | * Dolibarr version of the loaded document |
71 | 71 | * @public string |
72 | 72 | */ |
73 | - public $version = 'dolibarr'; |
|
73 | + public $version = 'dolibarr'; |
|
74 | 74 | |
75 | - /** |
|
75 | + /** |
|
76 | 76 | * @var int page_largeur |
77 | 77 | */ |
78 | 78 | public $page_largeur; |
79 | 79 | |
80 | - /** |
|
80 | + /** |
|
81 | 81 | * @var int page_hauteur |
82 | 82 | */ |
83 | 83 | public $page_hauteur; |
84 | 84 | |
85 | - /** |
|
85 | + /** |
|
86 | 86 | * @var array format |
87 | 87 | */ |
88 | 88 | public $format; |
89 | 89 | |
90 | - /** |
|
90 | + /** |
|
91 | 91 | * @var int marge_gauche |
92 | 92 | */ |
93 | - public $marge_gauche; |
|
93 | + public $marge_gauche; |
|
94 | 94 | |
95 | - /** |
|
95 | + /** |
|
96 | 96 | * @var int marge_droite |
97 | 97 | */ |
98 | - public $marge_droite; |
|
98 | + public $marge_droite; |
|
99 | 99 | |
100 | - /** |
|
100 | + /** |
|
101 | 101 | * @var int marge_haute |
102 | 102 | */ |
103 | - public $marge_haute; |
|
103 | + public $marge_haute; |
|
104 | 104 | |
105 | - /** |
|
105 | + /** |
|
106 | 106 | * @var int marge_basse |
107 | 107 | */ |
108 | - public $marge_basse; |
|
109 | - |
|
110 | - /** |
|
111 | - * Issuer |
|
112 | - * @var Company object that emits |
|
113 | - */ |
|
114 | - public $emetteur; |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * Constructor |
|
119 | - * |
|
120 | - * @param DoliDB $db Database handler |
|
121 | - */ |
|
122 | - function __construct($db) |
|
123 | - { |
|
124 | - global $conf, $langs, $mysoc; |
|
125 | - |
|
126 | - // Translations |
|
127 | - $langs->loadLangs(array("main", "trips", "projects")); |
|
128 | - |
|
129 | - $this->db = $db; |
|
130 | - $this->name = ""; |
|
131 | - $this->description = $langs->trans('PDFStandardExpenseReports'); |
|
132 | - |
|
133 | - // Dimension page pour format A4 |
|
134 | - $this->type = 'pdf'; |
|
135 | - $formatarray=pdf_getFormat(); |
|
136 | - $this->page_largeur = $formatarray['width']; |
|
137 | - $this->page_hauteur = $formatarray['height']; |
|
138 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
139 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
140 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
141 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
142 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
143 | - |
|
144 | - $this->option_logo = 1; // Affiche logo |
|
145 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
146 | - $this->option_modereg = 1; // Affiche mode reglement |
|
147 | - $this->option_condreg = 1; // Affiche conditions reglement |
|
148 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
149 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
150 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
151 | - $this->option_credit_note = 0; // Support credit notes |
|
152 | - $this->option_freetext = 1; // Support add of a personalised text |
|
153 | - $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
154 | - |
|
155 | - $this->franchise = !$mysoc->tva_assuj; |
|
156 | - |
|
157 | - // Get source company |
|
158 | - $this->emetteur=$mysoc; |
|
159 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
160 | - |
|
161 | - // Define position of columns |
|
162 | - $this->posxpiece=$this->marge_gauche+1; |
|
163 | - $this->posxcomment=$this->marge_gauche+10; |
|
164 | - //$this->posxdate=88; |
|
165 | - //$this->posxtype=107; |
|
166 | - //$this->posxprojet=120; |
|
167 | - $this->posxtva=130; |
|
168 | - $this->posxup=145; |
|
169 | - $this->posxqty=168; |
|
170 | - $this->postotalttc=178; |
|
108 | + public $marge_basse; |
|
109 | + |
|
110 | + /** |
|
111 | + * Issuer |
|
112 | + * @var Company object that emits |
|
113 | + */ |
|
114 | + public $emetteur; |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * Constructor |
|
119 | + * |
|
120 | + * @param DoliDB $db Database handler |
|
121 | + */ |
|
122 | + function __construct($db) |
|
123 | + { |
|
124 | + global $conf, $langs, $mysoc; |
|
125 | + |
|
126 | + // Translations |
|
127 | + $langs->loadLangs(array("main", "trips", "projects")); |
|
128 | + |
|
129 | + $this->db = $db; |
|
130 | + $this->name = ""; |
|
131 | + $this->description = $langs->trans('PDFStandardExpenseReports'); |
|
132 | + |
|
133 | + // Dimension page pour format A4 |
|
134 | + $this->type = 'pdf'; |
|
135 | + $formatarray=pdf_getFormat(); |
|
136 | + $this->page_largeur = $formatarray['width']; |
|
137 | + $this->page_hauteur = $formatarray['height']; |
|
138 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
139 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
140 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
141 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
142 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
143 | + |
|
144 | + $this->option_logo = 1; // Affiche logo |
|
145 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
146 | + $this->option_modereg = 1; // Affiche mode reglement |
|
147 | + $this->option_condreg = 1; // Affiche conditions reglement |
|
148 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
149 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
150 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
151 | + $this->option_credit_note = 0; // Support credit notes |
|
152 | + $this->option_freetext = 1; // Support add of a personalised text |
|
153 | + $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
154 | + |
|
155 | + $this->franchise = !$mysoc->tva_assuj; |
|
156 | + |
|
157 | + // Get source company |
|
158 | + $this->emetteur=$mysoc; |
|
159 | + if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
160 | + |
|
161 | + // Define position of columns |
|
162 | + $this->posxpiece=$this->marge_gauche+1; |
|
163 | + $this->posxcomment=$this->marge_gauche+10; |
|
164 | + //$this->posxdate=88; |
|
165 | + //$this->posxtype=107; |
|
166 | + //$this->posxprojet=120; |
|
167 | + $this->posxtva=130; |
|
168 | + $this->posxup=145; |
|
169 | + $this->posxqty=168; |
|
170 | + $this->postotalttc=178; |
|
171 | 171 | // if (empty($conf->projet->enabled)) { |
172 | 172 | // $this->posxtva-=20; |
173 | 173 | // $this->posxup-=20; |
174 | 174 | // $this->posxqty-=20; |
175 | 175 | // $this->postotalttc-=20; |
176 | 176 | // } |
177 | - if ($this->page_largeur < 210) // To work with US executive format |
|
178 | - { |
|
179 | - $this->posxdate-=20; |
|
180 | - $this->posxtype-=20; |
|
181 | - $this->posxprojet-=20; |
|
182 | - $this->posxtva-=20; |
|
183 | - $this->posxup-=20; |
|
184 | - $this->posxqty-=20; |
|
185 | - $this->postotalttc-=20; |
|
186 | - } |
|
187 | - |
|
188 | - $this->tva=array(); |
|
189 | - $this->localtax1=array(); |
|
190 | - $this->localtax2=array(); |
|
191 | - $this->atleastoneratenotnull=0; |
|
192 | - } |
|
177 | + if ($this->page_largeur < 210) // To work with US executive format |
|
178 | + { |
|
179 | + $this->posxdate-=20; |
|
180 | + $this->posxtype-=20; |
|
181 | + $this->posxprojet-=20; |
|
182 | + $this->posxtva-=20; |
|
183 | + $this->posxup-=20; |
|
184 | + $this->posxqty-=20; |
|
185 | + $this->postotalttc-=20; |
|
186 | + } |
|
187 | + |
|
188 | + $this->tva=array(); |
|
189 | + $this->localtax1=array(); |
|
190 | + $this->localtax2=array(); |
|
191 | + $this->atleastoneratenotnull=0; |
|
192 | + } |
|
193 | 193 | |
194 | 194 | |
195 | 195 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -203,65 +203,65 @@ discard block |
||
203 | 203 | * @param int $hidedesc Do not show desc |
204 | 204 | * @param int $hideref Do not show ref |
205 | 205 | * @return int 1=OK, 0=KO |
206 | - */ |
|
207 | - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
208 | - { |
|
206 | + */ |
|
207 | + function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
208 | + { |
|
209 | 209 | // phpcs:enable |
210 | - global $user, $langs, $conf, $mysoc, $db, $hookmanager; |
|
211 | - |
|
212 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
213 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
214 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
215 | - |
|
216 | - // Load traductions files requiredby by page |
|
217 | - $outputlangs->loadLangs(array("main", "trips", "projects", "dict", "bills", "banks")); |
|
218 | - |
|
219 | - $nblignes = count($object->lines); |
|
220 | - |
|
221 | - if ($conf->expensereport->dir_output) { |
|
222 | - // Definition of $dir and $file |
|
223 | - if ($object->specimen) { |
|
224 | - $dir = $conf->expensereport->dir_output; |
|
225 | - $file = $dir . "/SPECIMEN.pdf"; |
|
226 | - } |
|
227 | - else |
|
228 | - { |
|
229 | - $objectref = dol_sanitizeFileName($object->ref); |
|
230 | - $dir = $conf->expensereport->dir_output . "/" . $objectref; |
|
231 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
232 | - } |
|
233 | - |
|
234 | - if (! file_exists($dir)) |
|
235 | - { |
|
236 | - if (dol_mkdir($dir) < 0) |
|
237 | - { |
|
238 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
239 | - return 0; |
|
240 | - } |
|
241 | - } |
|
242 | - |
|
243 | - if (file_exists($dir)) |
|
244 | - { |
|
245 | - // Add pdfgeneration hook |
|
246 | - if (! is_object($hookmanager)) |
|
247 | - { |
|
248 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
249 | - $hookmanager=new HookManager($this->db); |
|
250 | - } |
|
251 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
252 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
253 | - global $action; |
|
254 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
255 | - |
|
256 | - // Create pdf instance |
|
257 | - $pdf=pdf_getInstance($this->format); |
|
258 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
259 | - $heightforinfotot = 40; // Height reserved to output the info and total part |
|
260 | - $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 |
|
261 | - $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin) |
|
262 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
263 | - |
|
264 | - $pdf->SetAutoPageBreak(1,0); |
|
210 | + global $user, $langs, $conf, $mysoc, $db, $hookmanager; |
|
211 | + |
|
212 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
213 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
214 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
215 | + |
|
216 | + // Load traductions files requiredby by page |
|
217 | + $outputlangs->loadLangs(array("main", "trips", "projects", "dict", "bills", "banks")); |
|
218 | + |
|
219 | + $nblignes = count($object->lines); |
|
220 | + |
|
221 | + if ($conf->expensereport->dir_output) { |
|
222 | + // Definition of $dir and $file |
|
223 | + if ($object->specimen) { |
|
224 | + $dir = $conf->expensereport->dir_output; |
|
225 | + $file = $dir . "/SPECIMEN.pdf"; |
|
226 | + } |
|
227 | + else |
|
228 | + { |
|
229 | + $objectref = dol_sanitizeFileName($object->ref); |
|
230 | + $dir = $conf->expensereport->dir_output . "/" . $objectref; |
|
231 | + $file = $dir . "/" . $objectref . ".pdf"; |
|
232 | + } |
|
233 | + |
|
234 | + if (! file_exists($dir)) |
|
235 | + { |
|
236 | + if (dol_mkdir($dir) < 0) |
|
237 | + { |
|
238 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
239 | + return 0; |
|
240 | + } |
|
241 | + } |
|
242 | + |
|
243 | + if (file_exists($dir)) |
|
244 | + { |
|
245 | + // Add pdfgeneration hook |
|
246 | + if (! is_object($hookmanager)) |
|
247 | + { |
|
248 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
249 | + $hookmanager=new HookManager($this->db); |
|
250 | + } |
|
251 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
252 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
253 | + global $action; |
|
254 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
255 | + |
|
256 | + // Create pdf instance |
|
257 | + $pdf=pdf_getInstance($this->format); |
|
258 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
259 | + $heightforinfotot = 40; // Height reserved to output the info and total part |
|
260 | + $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 |
|
261 | + $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin) |
|
262 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
263 | + |
|
264 | + $pdf->SetAutoPageBreak(1,0); |
|
265 | 265 | |
266 | 266 | if (class_exists('TCPDF')) |
267 | 267 | { |
@@ -269,124 +269,124 @@ discard block |
||
269 | 269 | $pdf->setPrintFooter(false); |
270 | 270 | } |
271 | 271 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
272 | - // Set path to the background PDF File |
|
272 | + // Set path to the background PDF File |
|
273 | 273 | if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
274 | 274 | { |
275 | 275 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
276 | 276 | $tplidx = $pdf->importPage(1); |
277 | 277 | } |
278 | 278 | |
279 | - $pdf->Open(); |
|
280 | - $pagenb=0; |
|
281 | - $pdf->SetDrawColor(128,128,128); |
|
282 | - |
|
283 | - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
284 | - $pdf->SetSubject($outputlangs->transnoentities("Trips")); |
|
285 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
286 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
287 | - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Trips")); |
|
288 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
289 | - |
|
290 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
291 | - |
|
292 | - // New page |
|
293 | - $pdf->AddPage(); |
|
294 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
295 | - $pagenb++; |
|
296 | - $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
297 | - $pdf->SetFont('','', $default_font_size - 1); |
|
298 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
299 | - $pdf->SetTextColor(0,0,0); |
|
300 | - |
|
301 | - $tab_top = 95; |
|
302 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?65:10); |
|
303 | - $tab_height = 130; |
|
304 | - $tab_height_newpage = 150; |
|
305 | - |
|
306 | - // Show notes |
|
307 | - $notetoshow=empty($object->note_public)?'':$object->note_public; |
|
308 | - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) |
|
309 | - { |
|
310 | - // Get first sale rep |
|
311 | - if (is_object($object->thirdparty)) |
|
312 | - { |
|
313 | - $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
|
314 | - $salerepobj=new User($this->db); |
|
315 | - $salerepobj->fetch($salereparray[0]['id']); |
|
316 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
317 | - } |
|
318 | - } |
|
319 | - if ($notetoshow) |
|
320 | - { |
|
321 | - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
322 | - complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
323 | - $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
|
324 | - |
|
325 | - $tab_top = 95; |
|
326 | - |
|
327 | - $pdf->SetFont('','', $default_font_size - 1); |
|
328 | - $pdf->writeHTMLCell(190, 3, $this->posxpiece-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
329 | - $nexY = $pdf->GetY(); |
|
330 | - $height_note=$nexY-$tab_top; |
|
331 | - |
|
332 | - // Rect prend une longueur en 3eme param |
|
333 | - $pdf->SetDrawColor(192,192,192); |
|
334 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
335 | - |
|
336 | - $tab_height = $tab_height - $height_note; |
|
337 | - $tab_top = $nexY+6; |
|
338 | - } |
|
339 | - else |
|
340 | - { |
|
341 | - $height_note=0; |
|
342 | - } |
|
343 | - |
|
344 | - $iniY = $tab_top + 7; |
|
345 | - $initialY = $tab_top + 7; |
|
346 | - $nexY = $tab_top + 7; |
|
347 | - |
|
348 | - // Loop on each lines |
|
349 | - for ($i = 0 ; $i < $nblignes ; $i++) { |
|
350 | - $pdf->SetFont('','', $default_font_size - 2); // Into loop to work with multipage |
|
351 | - $pdf->SetTextColor(0,0,0); |
|
352 | - |
|
353 | - $pdf->setTopMargin($tab_top_newpage); |
|
354 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
355 | - $pageposbefore = $pdf->getPage(); |
|
279 | + $pdf->Open(); |
|
280 | + $pagenb=0; |
|
281 | + $pdf->SetDrawColor(128,128,128); |
|
282 | + |
|
283 | + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
284 | + $pdf->SetSubject($outputlangs->transnoentities("Trips")); |
|
285 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
286 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
287 | + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Trips")); |
|
288 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
289 | + |
|
290 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
291 | + |
|
292 | + // New page |
|
293 | + $pdf->AddPage(); |
|
294 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
295 | + $pagenb++; |
|
296 | + $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
297 | + $pdf->SetFont('','', $default_font_size - 1); |
|
298 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
299 | + $pdf->SetTextColor(0,0,0); |
|
300 | + |
|
301 | + $tab_top = 95; |
|
302 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?65:10); |
|
303 | + $tab_height = 130; |
|
304 | + $tab_height_newpage = 150; |
|
305 | + |
|
306 | + // Show notes |
|
307 | + $notetoshow=empty($object->note_public)?'':$object->note_public; |
|
308 | + if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) |
|
309 | + { |
|
310 | + // Get first sale rep |
|
311 | + if (is_object($object->thirdparty)) |
|
312 | + { |
|
313 | + $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
|
314 | + $salerepobj=new User($this->db); |
|
315 | + $salerepobj->fetch($salereparray[0]['id']); |
|
316 | + if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
317 | + } |
|
318 | + } |
|
319 | + if ($notetoshow) |
|
320 | + { |
|
321 | + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
322 | + complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
323 | + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
|
324 | + |
|
325 | + $tab_top = 95; |
|
326 | + |
|
327 | + $pdf->SetFont('','', $default_font_size - 1); |
|
328 | + $pdf->writeHTMLCell(190, 3, $this->posxpiece-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
329 | + $nexY = $pdf->GetY(); |
|
330 | + $height_note=$nexY-$tab_top; |
|
331 | + |
|
332 | + // Rect prend une longueur en 3eme param |
|
333 | + $pdf->SetDrawColor(192,192,192); |
|
334 | + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
335 | + |
|
336 | + $tab_height = $tab_height - $height_note; |
|
337 | + $tab_top = $nexY+6; |
|
338 | + } |
|
339 | + else |
|
340 | + { |
|
341 | + $height_note=0; |
|
342 | + } |
|
343 | + |
|
344 | + $iniY = $tab_top + 7; |
|
345 | + $initialY = $tab_top + 7; |
|
346 | + $nexY = $tab_top + 7; |
|
347 | + |
|
348 | + // Loop on each lines |
|
349 | + for ($i = 0 ; $i < $nblignes ; $i++) { |
|
350 | + $pdf->SetFont('','', $default_font_size - 2); // Into loop to work with multipage |
|
351 | + $pdf->SetTextColor(0,0,0); |
|
352 | + |
|
353 | + $pdf->setTopMargin($tab_top_newpage); |
|
354 | + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
355 | + $pageposbefore = $pdf->getPage(); |
|
356 | 356 | $curY = $nexY; |
357 | 357 | $pdf->startTransaction(); |
358 | 358 | $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); |
359 | 359 | $pageposafter=$pdf->getPage(); |
360 | - if ($pageposafter > $pageposbefore) { |
|
360 | + if ($pageposafter > $pageposbefore) { |
|
361 | 361 | // There is a pagebreak |
362 | - $pdf->rollbackTransaction(true); |
|
363 | - $pageposafter = $pageposbefore; |
|
364 | - //print $pageposafter.'-'.$pageposbefore;exit; |
|
365 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
366 | - $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); |
|
367 | - $pageposafter = $pdf->getPage(); |
|
368 | - $posyafter = $pdf->GetY(); |
|
369 | - //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
|
370 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
362 | + $pdf->rollbackTransaction(true); |
|
363 | + $pageposafter = $pageposbefore; |
|
364 | + //print $pageposafter.'-'.$pageposbefore;exit; |
|
365 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
366 | + $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); |
|
367 | + $pageposafter = $pdf->getPage(); |
|
368 | + $posyafter = $pdf->GetY(); |
|
369 | + //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
|
370 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
371 | 371 | // There is no space left for total+free text |
372 | - if ($i == ($nblignes-1)) { |
|
372 | + if ($i == ($nblignes-1)) { |
|
373 | 373 | // No more lines, and no space left to show total, so we create a new page |
374 | - $pdf->AddPage('', '', true); |
|
375 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
376 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
377 | - $pdf->setPage($pageposafter+1); |
|
378 | - } |
|
379 | - } |
|
380 | - else |
|
381 | - { |
|
382 | - // We found a page break |
|
383 | - $showpricebeforepagebreak=0; |
|
384 | - } |
|
385 | - } |
|
386 | - else // No pagebreak |
|
387 | - { |
|
388 | - $pdf->commitTransaction(); |
|
389 | - } |
|
374 | + $pdf->AddPage('', '', true); |
|
375 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
376 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
377 | + $pdf->setPage($pageposafter+1); |
|
378 | + } |
|
379 | + } |
|
380 | + else |
|
381 | + { |
|
382 | + // We found a page break |
|
383 | + $showpricebeforepagebreak=0; |
|
384 | + } |
|
385 | + } |
|
386 | + else // No pagebreak |
|
387 | + { |
|
388 | + $pdf->commitTransaction(); |
|
389 | + } |
|
390 | 390 | //nexY |
391 | 391 | $nexY = $pdf->GetY(); |
392 | 392 | $pageposafter=$pdf->getPage(); |
@@ -396,140 +396,140 @@ discard block |
||
396 | 396 | |
397 | 397 | //$nblineFollowComment = 1; |
398 | 398 | // Cherche nombre de lignes a venir pour savoir si place suffisante |
399 | - // if ($i < ($nblignes - 1)) // If it's not last line |
|
400 | - // { |
|
401 | - // //Fetch current description to know on which line the next one should be placed |
|
402 | - // $follow_comment = $object->lines[$i]->comments; |
|
403 | - // $follow_type = $object->lines[$i]->type_fees_code; |
|
399 | + // if ($i < ($nblignes - 1)) // If it's not last line |
|
400 | + // { |
|
401 | + // //Fetch current description to know on which line the next one should be placed |
|
402 | + // $follow_comment = $object->lines[$i]->comments; |
|
403 | + // $follow_type = $object->lines[$i]->type_fees_code; |
|
404 | 404 | |
405 | - // //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) |
|
406 | - // $nbLineCommentNeed = dol_nboflines_bis($follow_comment,52,$outputlangs->charset_output); |
|
407 | - // $nbLineTypeNeed = dol_nboflines_bis($follow_type,4,$outputlangs->charset_output); |
|
405 | + // //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) |
|
406 | + // $nbLineCommentNeed = dol_nboflines_bis($follow_comment,52,$outputlangs->charset_output); |
|
407 | + // $nbLineTypeNeed = dol_nboflines_bis($follow_type,4,$outputlangs->charset_output); |
|
408 | 408 | |
409 | 409 | // $nblineFollowComment = max($nbLineCommentNeed, $nbLineTypeNeed); |
410 | - // } |
|
410 | + // } |
|
411 | 411 | |
412 | 412 | //$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3); // Passe espace entre les lignes |
413 | 413 | $nexY += ($pdf->getFontSize()*1.3); // Passe espace entre les lignes |
414 | 414 | |
415 | - // Detect if some page were added automatically and output _tableau for past pages |
|
416 | - while ($pagenb < $pageposafter) |
|
417 | - { |
|
418 | - $pdf->setPage($pagenb); |
|
419 | - if ($pagenb == 1) |
|
420 | - { |
|
421 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
422 | - } |
|
423 | - else |
|
424 | - { |
|
425 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
426 | - } |
|
427 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
428 | - $pagenb++; |
|
429 | - $pdf->setPage($pagenb); |
|
430 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
431 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
432 | - } |
|
433 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
434 | - { |
|
435 | - if ($pagenb == 1) |
|
436 | - { |
|
437 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
438 | - } |
|
439 | - else |
|
440 | - { |
|
441 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
442 | - } |
|
443 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
444 | - // New page |
|
445 | - $pdf->AddPage(); |
|
446 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
447 | - $pagenb++; |
|
448 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
449 | - } |
|
450 | - } |
|
451 | - |
|
452 | - // Show square |
|
453 | - if ($pagenb == 1) |
|
454 | - { |
|
455 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
456 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
457 | - } |
|
458 | - else |
|
459 | - { |
|
460 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
461 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
462 | - } |
|
463 | - |
|
464 | - $pdf->SetFont('','', 10); |
|
465 | - |
|
466 | - // Show total area box |
|
467 | - $posy=$bottomlasttab+5; |
|
468 | - $posy_start_of_totals = $posy; |
|
469 | - $pdf->SetXY(130, $posy); |
|
470 | - $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalHT"), 1, 'L'); |
|
471 | - $pdf->SetXY(180, $posy); |
|
472 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ht), 1, 'R'); |
|
473 | - $pdf->SetFillColor(248,248,248); |
|
474 | - |
|
475 | - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
|
476 | - { |
|
477 | - // TODO Show vat amout per tax level |
|
478 | - $posy+=5; |
|
479 | - $pdf->SetXY(130, $posy); |
|
480 | - $pdf->SetTextColor(0,0,60); |
|
481 | - $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalVAT"), 1,'L'); |
|
482 | - $pdf->SetXY(180, $posy); |
|
483 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_tva),1, 'R'); |
|
484 | - } |
|
485 | - |
|
486 | - $posy+=5; |
|
487 | - $pdf->SetXY(130, $posy); |
|
488 | - $pdf->SetFont('','B', 10); |
|
489 | - $pdf->SetTextColor(0,0,60); |
|
490 | - $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalTTC"), 1,'L'); |
|
491 | - $pdf->SetXY(180, $posy); |
|
492 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ttc),1, 'R'); |
|
493 | - |
|
494 | - // show payments zone |
|
495 | - $sumPayments = $object->getSumPayments(); |
|
496 | - if ($sumPayments > 0 && empty($conf->global->PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS)) { |
|
497 | - $posy=$this->tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs); |
|
498 | - } |
|
499 | - |
|
500 | - // Pied de page |
|
501 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
502 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPage(); |
|
503 | - |
|
504 | - $pdf->Close(); |
|
505 | - |
|
506 | - $pdf->Output($file,'F'); |
|
507 | - |
|
508 | - // Add pdfgeneration hook |
|
509 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
510 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
511 | - global $action; |
|
512 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
513 | - |
|
514 | - if (! empty($conf->global->MAIN_UMASK)) |
|
515 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
516 | - |
|
517 | - $this->result = array('fullpath'=>$file); |
|
518 | - |
|
519 | - return 1; // Pas d'erreur |
|
520 | - } |
|
521 | - else |
|
522 | - { |
|
523 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
524 | - return 0; |
|
525 | - } |
|
526 | - } |
|
527 | - else |
|
528 | - { |
|
529 | - $this->error=$langs->trans("ErrorConstantNotDefined","EXPENSEREPORT_OUTPUTDIR"); |
|
530 | - return 0; |
|
531 | - } |
|
532 | - } |
|
415 | + // Detect if some page were added automatically and output _tableau for past pages |
|
416 | + while ($pagenb < $pageposafter) |
|
417 | + { |
|
418 | + $pdf->setPage($pagenb); |
|
419 | + if ($pagenb == 1) |
|
420 | + { |
|
421 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
422 | + } |
|
423 | + else |
|
424 | + { |
|
425 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
426 | + } |
|
427 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
428 | + $pagenb++; |
|
429 | + $pdf->setPage($pagenb); |
|
430 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
431 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
432 | + } |
|
433 | + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
434 | + { |
|
435 | + if ($pagenb == 1) |
|
436 | + { |
|
437 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
438 | + } |
|
439 | + else |
|
440 | + { |
|
441 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
442 | + } |
|
443 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
444 | + // New page |
|
445 | + $pdf->AddPage(); |
|
446 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
447 | + $pagenb++; |
|
448 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
449 | + } |
|
450 | + } |
|
451 | + |
|
452 | + // Show square |
|
453 | + if ($pagenb == 1) |
|
454 | + { |
|
455 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
456 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
457 | + } |
|
458 | + else |
|
459 | + { |
|
460 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
461 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
462 | + } |
|
463 | + |
|
464 | + $pdf->SetFont('','', 10); |
|
465 | + |
|
466 | + // Show total area box |
|
467 | + $posy=$bottomlasttab+5; |
|
468 | + $posy_start_of_totals = $posy; |
|
469 | + $pdf->SetXY(130, $posy); |
|
470 | + $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalHT"), 1, 'L'); |
|
471 | + $pdf->SetXY(180, $posy); |
|
472 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ht), 1, 'R'); |
|
473 | + $pdf->SetFillColor(248,248,248); |
|
474 | + |
|
475 | + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
|
476 | + { |
|
477 | + // TODO Show vat amout per tax level |
|
478 | + $posy+=5; |
|
479 | + $pdf->SetXY(130, $posy); |
|
480 | + $pdf->SetTextColor(0,0,60); |
|
481 | + $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalVAT"), 1,'L'); |
|
482 | + $pdf->SetXY(180, $posy); |
|
483 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_tva),1, 'R'); |
|
484 | + } |
|
485 | + |
|
486 | + $posy+=5; |
|
487 | + $pdf->SetXY(130, $posy); |
|
488 | + $pdf->SetFont('','B', 10); |
|
489 | + $pdf->SetTextColor(0,0,60); |
|
490 | + $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalTTC"), 1,'L'); |
|
491 | + $pdf->SetXY(180, $posy); |
|
492 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ttc),1, 'R'); |
|
493 | + |
|
494 | + // show payments zone |
|
495 | + $sumPayments = $object->getSumPayments(); |
|
496 | + if ($sumPayments > 0 && empty($conf->global->PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS)) { |
|
497 | + $posy=$this->tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs); |
|
498 | + } |
|
499 | + |
|
500 | + // Pied de page |
|
501 | + $this->_pagefoot($pdf,$object,$outputlangs); |
|
502 | + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPage(); |
|
503 | + |
|
504 | + $pdf->Close(); |
|
505 | + |
|
506 | + $pdf->Output($file,'F'); |
|
507 | + |
|
508 | + // Add pdfgeneration hook |
|
509 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
510 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
511 | + global $action; |
|
512 | + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
513 | + |
|
514 | + if (! empty($conf->global->MAIN_UMASK)) |
|
515 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
516 | + |
|
517 | + $this->result = array('fullpath'=>$file); |
|
518 | + |
|
519 | + return 1; // Pas d'erreur |
|
520 | + } |
|
521 | + else |
|
522 | + { |
|
523 | + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
524 | + return 0; |
|
525 | + } |
|
526 | + } |
|
527 | + else |
|
528 | + { |
|
529 | + $this->error=$langs->trans("ErrorConstantNotDefined","EXPENSEREPORT_OUTPUTDIR"); |
|
530 | + return 0; |
|
531 | + } |
|
532 | + } |
|
533 | 533 | |
534 | 534 | /** |
535 | 535 | * @param TCPDF $pdf Object PDF |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * @return void |
543 | 543 | */ |
544 | 544 | private function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails=0) |
545 | - { |
|
545 | + { |
|
546 | 546 | global $conf; |
547 | 547 | $pdf->SetFont('','', $default_font_size - 1); |
548 | 548 | |
@@ -612,24 +612,24 @@ discard block |
||
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
615 | - * Show top header of page. |
|
616 | - * |
|
617 | - * @param PDF $pdf Object PDF |
|
618 | - * @param Object $object Object to show |
|
619 | - * @param int $showaddress 0=no, 1=yes |
|
620 | - * @param Translate $outputlangs Object lang for output |
|
621 | - * @return void |
|
622 | - */ |
|
623 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
624 | - { |
|
625 | - global $conf, $langs, $hookmanager; |
|
626 | - |
|
627 | - // Load traductions files requiredby by page |
|
628 | - $outputlangs->loadLangs(array("main", "trips", "companies")); |
|
629 | - |
|
630 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
631 | - |
|
632 | - /* |
|
615 | + * Show top header of page. |
|
616 | + * |
|
617 | + * @param PDF $pdf Object PDF |
|
618 | + * @param Object $object Object to show |
|
619 | + * @param int $showaddress 0=no, 1=yes |
|
620 | + * @param Translate $outputlangs Object lang for output |
|
621 | + * @return void |
|
622 | + */ |
|
623 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
624 | + { |
|
625 | + global $conf, $langs, $hookmanager; |
|
626 | + |
|
627 | + // Load traductions files requiredby by page |
|
628 | + $outputlangs->loadLangs(array("main", "trips", "companies")); |
|
629 | + |
|
630 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
631 | + |
|
632 | + /* |
|
633 | 633 | // ajout du fondu vert en bas de page à droite |
634 | 634 | $image_fondue = $conf->mycompany->dir_output.'/fondu_vert_.jpg'; |
635 | 635 | $pdf->Image($image_fondue,20,107,200,190); |
@@ -637,430 +637,430 @@ discard block |
||
637 | 637 | pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
638 | 638 | */ |
639 | 639 | |
640 | - // Draft watermark |
|
641 | - if ($object->fk_statut == 0 && ! empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) { |
|
642 | - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->EXPENSEREPORT_DRAFT_WATERMARK); |
|
643 | - } |
|
644 | - |
|
645 | - $pdf->SetTextColor(0, 0, 60); |
|
646 | - $pdf->SetFont('', 'B', $default_font_size + 3); |
|
647 | - |
|
648 | - $posy=$this->marge_haute; |
|
649 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
650 | - |
|
651 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
652 | - |
|
653 | - // Logo |
|
654 | - $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
655 | - if ($this->emetteur->logo) { |
|
656 | - if (is_readable($logo)) { |
|
657 | - $height=pdf_getHeightForLogo($logo); |
|
658 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
659 | - } else { |
|
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("ErrorGoToGlobalSetup"), 0, 'L'); |
|
664 | - } |
|
665 | - } |
|
666 | - else |
|
667 | - { |
|
668 | - $text=$this->emetteur->name; |
|
669 | - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
670 | - } |
|
671 | - |
|
672 | - $pdf->SetFont('','B', $default_font_size + 4); |
|
673 | - $pdf->SetXY($posx,$posy); |
|
674 | - $pdf->SetTextColor(0,0,60); |
|
675 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx,6,$langs->trans("ExpenseReport"), 0, 'R'); |
|
676 | - |
|
677 | - $pdf->SetFont('','', $default_font_size -1); |
|
678 | - |
|
679 | - // Ref complete |
|
680 | - $posy+=8; |
|
681 | - $pdf->SetXY($posx,$posy); |
|
682 | - $pdf->SetTextColor(0,0,60); |
|
683 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'R'); |
|
684 | - |
|
685 | - // Date start period |
|
686 | - $posy+=5; |
|
687 | - $pdf->SetXY($posx,$posy); |
|
688 | - $pdf->SetTextColor(0,0,60); |
|
689 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateStart")." : " . ($object->date_debut>0?dol_print_date($object->date_debut,"day",false,$outputlangs):''), '', 'R'); |
|
690 | - |
|
691 | - // Date end period |
|
692 | - $posy+=5; |
|
693 | - $pdf->SetXY($posx,$posy); |
|
694 | - $pdf->SetTextColor(0,0,60); |
|
695 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateEnd")." : " . ($object->date_fin>0?dol_print_date($object->date_fin,"day",false,$outputlangs):''), '', 'R'); |
|
696 | - |
|
697 | - // Status Expense Report |
|
698 | - $posy+=6; |
|
699 | - $pdf->SetXY($posx,$posy); |
|
700 | - $pdf->SetFont('','B', $default_font_size + 2); |
|
701 | - $pdf->SetTextColor(111,81,124); |
|
702 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $object->getLibStatut(0), '', 'R'); |
|
703 | - |
|
704 | - if ($showaddress) { |
|
705 | - // Sender properties |
|
706 | - $carac_emetteur = ''; |
|
707 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->address); |
|
708 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town); |
|
709 | - $carac_emetteur .= "\n"; |
|
710 | - // Phone |
|
711 | - if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); |
|
712 | - // Fax |
|
713 | - if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); |
|
714 | ||
715 | - if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); |
|
716 | - // Web |
|
717 | - if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); |
|
718 | - |
|
719 | - // Show sender |
|
720 | - $posy=50; |
|
721 | - $posx=$this->marge_gauche; |
|
722 | - $hautcadre=40; |
|
723 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118; |
|
724 | - |
|
725 | - // Show sender frame |
|
726 | - $pdf->SetTextColor(0, 0, 0); |
|
727 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
728 | - $pdf->SetXY($posx,$posy-5); |
|
729 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("TripSociete")." :",'','L'); |
|
730 | - $pdf->SetXY($posx,$posy); |
|
731 | - $pdf->SetFillColor(224,224,224); |
|
732 | - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
733 | - $pdf->SetTextColor(0, 0, 60); |
|
734 | - |
|
735 | - // Show sender name |
|
736 | - $pdf->SetXY($posx+2,$posy+3); |
|
737 | - $pdf->SetFont('','B', $default_font_size); |
|
738 | - $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
739 | - |
|
740 | - // Show sender information |
|
741 | - $pdf->SetXY($posx+2,$posy+8); |
|
742 | - $pdf->SetFont('', '', $default_font_size - 1); |
|
743 | - $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
744 | - |
|
745 | - // Show recipient |
|
746 | - $posy=50; |
|
747 | - $posx=100; |
|
748 | - |
|
749 | - // Show recipient frame |
|
750 | - $pdf->SetTextColor(0, 0, 0); |
|
751 | - $pdf->SetFont('', 'B', 8); |
|
752 | - $pdf->SetXY($posx,$posy-5); |
|
753 | - $pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L'); |
|
754 | - $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre); |
|
755 | - |
|
756 | - // Informations for trip (dates and users workflow) |
|
757 | - if ($object->fk_user_author > 0) { |
|
758 | - $userfee=new User($this->db); |
|
759 | - $userfee->fetch($object->fk_user_author); $posy+=3; |
|
760 | - $pdf->SetXY($posx+2,$posy); |
|
761 | - $pdf->SetFont('','',10); |
|
762 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
763 | - $posy+=5; |
|
764 | - $pdf->SetXY($posx+2,$posy); |
|
765 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create,"day",false,$outputlangs),0,'L'); |
|
766 | - } |
|
767 | - |
|
768 | - if ($object->fk_statut==99) |
|
769 | - { |
|
770 | - if ($object->fk_user_refuse > 0) { |
|
771 | - $userfee=new User($this->db); |
|
772 | - $userfee->fetch($object->fk_user_refuse); $posy+=6; |
|
773 | - $pdf->SetXY($posx+2,$posy); |
|
774 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("REFUSEUR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
775 | - $posy+=5; |
|
776 | - $pdf->SetXY($posx+2,$posy); |
|
777 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse),0,'L'); |
|
778 | - $posy+=5; |
|
779 | - $pdf->SetXY($posx+2,$posy); |
|
780 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outputlangs),0,'L'); |
|
781 | - } |
|
782 | - } |
|
783 | - else if($object->fk_statut==4) |
|
784 | - { |
|
785 | - if ($object->fk_user_cancel > 0) { |
|
786 | - $userfee=new User($this->db); |
|
787 | - $userfee->fetch($object->fk_user_cancel); $posy+=6; |
|
788 | - $pdf->SetXY($posx+2,$posy); |
|
789 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("CANCEL_USER")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
790 | - $posy+=5; |
|
791 | - $pdf->SetXY($posx+2,$posy); |
|
792 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel),0,'L'); |
|
793 | - $posy+=5; |
|
794 | - $pdf->SetXY($posx+2,$posy); |
|
795 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel,"day",false,$outputlangs),0,'L'); |
|
796 | - } |
|
797 | - } |
|
798 | - else |
|
799 | - { |
|
800 | - if ($object->fk_user_approve > 0) { |
|
801 | - $userfee=new User($this->db); |
|
802 | - $userfee->fetch($object->fk_user_approve); $posy+=6; |
|
803 | - $pdf->SetXY($posx+2,$posy); |
|
804 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("VALIDOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
805 | - $posy+=5; |
|
806 | - $pdf->SetXY($posx+2,$posy); |
|
807 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateApprove")." : ".dol_print_date($object->date_approve,"day",false,$outputlangs),0,'L'); |
|
808 | - } |
|
809 | - } |
|
810 | - |
|
811 | - if($object->fk_statut==6) { |
|
812 | - if ($object->fk_user_paid > 0) { |
|
813 | - $userfee=new User($this->db); |
|
814 | - $userfee->fetch($object->fk_user_paid); $posy+=6; |
|
815 | - $pdf->SetXY($posx+2,$posy); |
|
816 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHORPAIEMENT")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
817 | - $posy+=5; |
|
818 | - $pdf->SetXY($posx+2,$posy); |
|
819 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement,"day",false,$outputlangs),0,'L'); |
|
820 | - } |
|
821 | - } |
|
822 | - } |
|
823 | - } |
|
824 | - |
|
825 | - /** |
|
826 | - * Show table for lines |
|
827 | - * |
|
828 | - * @param PDF $pdf Object PDF |
|
829 | - * @param int $tab_top Tab top |
|
830 | - * @param int $tab_height Tab height |
|
831 | - * @param int $nexY next y |
|
832 | - * @param Translate $outputlangs Output langs |
|
833 | - * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title |
|
834 | - * @param int $hidebottom Hide bottom bar of array |
|
835 | - * @param string $currency Currency code |
|
836 | - * @return void |
|
837 | - */ |
|
838 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
839 | - { |
|
840 | - global $conf; |
|
841 | - |
|
842 | - // Force to disable hidetop and hidebottom |
|
843 | - $hidebottom=0; |
|
844 | - if ($hidetop) $hidetop=-1; |
|
845 | - |
|
846 | - $currency = !empty($currency) ? $currency : $conf->currency; |
|
847 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
848 | - |
|
849 | - // Amount in (at tab_top - 1) |
|
850 | - $pdf->SetTextColor(0,0,0); |
|
851 | - $pdf->SetFont('', '', $default_font_size - 2); |
|
852 | - $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
853 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top -4); |
|
854 | - $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
855 | - |
|
856 | - $pdf->SetDrawColor(128,128,128); |
|
857 | - |
|
858 | - // Rect prend une longueur en 3eme param |
|
859 | - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); |
|
860 | - // line prend une position y en 3eme param |
|
861 | - if (empty($hidetop)) { |
|
862 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); |
|
863 | - } |
|
864 | - |
|
865 | - $pdf->SetFont('','',8); |
|
866 | - |
|
867 | - // Accountancy piece |
|
868 | - if (empty($hidetop)) { |
|
869 | - $pdf->SetXY($this->posxpiece-1, $tab_top+1); |
|
870 | - $pdf->MultiCell($this->posxcomment-$this->posxpiece-1, 1, '', '', 'R'); |
|
871 | - } |
|
872 | - |
|
873 | - // Comments |
|
874 | - $pdf->line($this->posxcomment-1, $tab_top, $this->posxcomment-1, $tab_top + $tab_height); |
|
875 | - if (empty($hidetop)) { |
|
876 | - $pdf->SetXY($this->posxcomment-1, $tab_top+1); |
|
877 | - $pdf->MultiCell($this->posxdate-$this->posxcomment-1, 1, $outputlangs->transnoentities("Description"),'','L'); |
|
878 | - } |
|
879 | - |
|
880 | - // Date |
|
881 | - //$pdf->line($this->posxdate-1, $tab_top, $this->posxdate-1, $tab_top + $tab_height); |
|
882 | - //if (empty($hidetop)) |
|
883 | - //{ |
|
884 | - // $pdf->SetXY($this->posxdate-1, $tab_top+1); |
|
885 | - // $pdf->MultiCell($this->posxtype-$this->posxdate-1,2, $outputlangs->transnoentities("Date"),'','C'); |
|
886 | - //} |
|
887 | - |
|
888 | - // Type |
|
889 | - //$pdf->line($this->posxtype-1, $tab_top, $this->posxtype-1, $tab_top + $tab_height); |
|
890 | - //if (empty($hidetop)) |
|
891 | - //{ |
|
892 | - // $pdf->SetXY($this->posxtype-1, $tab_top+1); |
|
893 | - // $pdf->MultiCell($this->posxprojet-$this->posxtype - 1, 2, $outputlangs->transnoentities("Type"), '', 'C'); |
|
894 | - //} |
|
640 | + // Draft watermark |
|
641 | + if ($object->fk_statut == 0 && ! empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) { |
|
642 | + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->EXPENSEREPORT_DRAFT_WATERMARK); |
|
643 | + } |
|
644 | + |
|
645 | + $pdf->SetTextColor(0, 0, 60); |
|
646 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
647 | + |
|
648 | + $posy=$this->marge_haute; |
|
649 | + $posx=$this->page_largeur-$this->marge_droite-100; |
|
650 | + |
|
651 | + $pdf->SetXY($this->marge_gauche,$posy); |
|
652 | + |
|
653 | + // Logo |
|
654 | + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
655 | + if ($this->emetteur->logo) { |
|
656 | + if (is_readable($logo)) { |
|
657 | + $height=pdf_getHeightForLogo($logo); |
|
658 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
659 | + } else { |
|
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("ErrorGoToGlobalSetup"), 0, 'L'); |
|
664 | + } |
|
665 | + } |
|
666 | + else |
|
667 | + { |
|
668 | + $text=$this->emetteur->name; |
|
669 | + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
670 | + } |
|
671 | + |
|
672 | + $pdf->SetFont('','B', $default_font_size + 4); |
|
673 | + $pdf->SetXY($posx,$posy); |
|
674 | + $pdf->SetTextColor(0,0,60); |
|
675 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx,6,$langs->trans("ExpenseReport"), 0, 'R'); |
|
676 | + |
|
677 | + $pdf->SetFont('','', $default_font_size -1); |
|
678 | + |
|
679 | + // Ref complete |
|
680 | + $posy+=8; |
|
681 | + $pdf->SetXY($posx,$posy); |
|
682 | + $pdf->SetTextColor(0,0,60); |
|
683 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'R'); |
|
684 | + |
|
685 | + // Date start period |
|
686 | + $posy+=5; |
|
687 | + $pdf->SetXY($posx,$posy); |
|
688 | + $pdf->SetTextColor(0,0,60); |
|
689 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateStart")." : " . ($object->date_debut>0?dol_print_date($object->date_debut,"day",false,$outputlangs):''), '', 'R'); |
|
690 | + |
|
691 | + // Date end period |
|
692 | + $posy+=5; |
|
693 | + $pdf->SetXY($posx,$posy); |
|
694 | + $pdf->SetTextColor(0,0,60); |
|
695 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateEnd")." : " . ($object->date_fin>0?dol_print_date($object->date_fin,"day",false,$outputlangs):''), '', 'R'); |
|
696 | + |
|
697 | + // Status Expense Report |
|
698 | + $posy+=6; |
|
699 | + $pdf->SetXY($posx,$posy); |
|
700 | + $pdf->SetFont('','B', $default_font_size + 2); |
|
701 | + $pdf->SetTextColor(111,81,124); |
|
702 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $object->getLibStatut(0), '', 'R'); |
|
703 | + |
|
704 | + if ($showaddress) { |
|
705 | + // Sender properties |
|
706 | + $carac_emetteur = ''; |
|
707 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->address); |
|
708 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town); |
|
709 | + $carac_emetteur .= "\n"; |
|
710 | + // Phone |
|
711 | + if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); |
|
712 | + // Fax |
|
713 | + if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); |
|
714 | ||
715 | + if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); |
|
716 | + // Web |
|
717 | + if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); |
|
718 | + |
|
719 | + // Show sender |
|
720 | + $posy=50; |
|
721 | + $posx=$this->marge_gauche; |
|
722 | + $hautcadre=40; |
|
723 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118; |
|
724 | + |
|
725 | + // Show sender frame |
|
726 | + $pdf->SetTextColor(0, 0, 0); |
|
727 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
728 | + $pdf->SetXY($posx,$posy-5); |
|
729 | + $pdf->MultiCell(66,5, $outputlangs->transnoentities("TripSociete")." :",'','L'); |
|
730 | + $pdf->SetXY($posx,$posy); |
|
731 | + $pdf->SetFillColor(224,224,224); |
|
732 | + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
733 | + $pdf->SetTextColor(0, 0, 60); |
|
734 | + |
|
735 | + // Show sender name |
|
736 | + $pdf->SetXY($posx+2,$posy+3); |
|
737 | + $pdf->SetFont('','B', $default_font_size); |
|
738 | + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
739 | + |
|
740 | + // Show sender information |
|
741 | + $pdf->SetXY($posx+2,$posy+8); |
|
742 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
743 | + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
744 | + |
|
745 | + // Show recipient |
|
746 | + $posy=50; |
|
747 | + $posx=100; |
|
748 | + |
|
749 | + // Show recipient frame |
|
750 | + $pdf->SetTextColor(0, 0, 0); |
|
751 | + $pdf->SetFont('', 'B', 8); |
|
752 | + $pdf->SetXY($posx,$posy-5); |
|
753 | + $pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L'); |
|
754 | + $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre); |
|
755 | + |
|
756 | + // Informations for trip (dates and users workflow) |
|
757 | + if ($object->fk_user_author > 0) { |
|
758 | + $userfee=new User($this->db); |
|
759 | + $userfee->fetch($object->fk_user_author); $posy+=3; |
|
760 | + $pdf->SetXY($posx+2,$posy); |
|
761 | + $pdf->SetFont('','',10); |
|
762 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
763 | + $posy+=5; |
|
764 | + $pdf->SetXY($posx+2,$posy); |
|
765 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create,"day",false,$outputlangs),0,'L'); |
|
766 | + } |
|
767 | + |
|
768 | + if ($object->fk_statut==99) |
|
769 | + { |
|
770 | + if ($object->fk_user_refuse > 0) { |
|
771 | + $userfee=new User($this->db); |
|
772 | + $userfee->fetch($object->fk_user_refuse); $posy+=6; |
|
773 | + $pdf->SetXY($posx+2,$posy); |
|
774 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("REFUSEUR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
775 | + $posy+=5; |
|
776 | + $pdf->SetXY($posx+2,$posy); |
|
777 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse),0,'L'); |
|
778 | + $posy+=5; |
|
779 | + $pdf->SetXY($posx+2,$posy); |
|
780 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outputlangs),0,'L'); |
|
781 | + } |
|
782 | + } |
|
783 | + else if($object->fk_statut==4) |
|
784 | + { |
|
785 | + if ($object->fk_user_cancel > 0) { |
|
786 | + $userfee=new User($this->db); |
|
787 | + $userfee->fetch($object->fk_user_cancel); $posy+=6; |
|
788 | + $pdf->SetXY($posx+2,$posy); |
|
789 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("CANCEL_USER")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
790 | + $posy+=5; |
|
791 | + $pdf->SetXY($posx+2,$posy); |
|
792 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel),0,'L'); |
|
793 | + $posy+=5; |
|
794 | + $pdf->SetXY($posx+2,$posy); |
|
795 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel,"day",false,$outputlangs),0,'L'); |
|
796 | + } |
|
797 | + } |
|
798 | + else |
|
799 | + { |
|
800 | + if ($object->fk_user_approve > 0) { |
|
801 | + $userfee=new User($this->db); |
|
802 | + $userfee->fetch($object->fk_user_approve); $posy+=6; |
|
803 | + $pdf->SetXY($posx+2,$posy); |
|
804 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("VALIDOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
805 | + $posy+=5; |
|
806 | + $pdf->SetXY($posx+2,$posy); |
|
807 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateApprove")." : ".dol_print_date($object->date_approve,"day",false,$outputlangs),0,'L'); |
|
808 | + } |
|
809 | + } |
|
810 | + |
|
811 | + if($object->fk_statut==6) { |
|
812 | + if ($object->fk_user_paid > 0) { |
|
813 | + $userfee=new User($this->db); |
|
814 | + $userfee->fetch($object->fk_user_paid); $posy+=6; |
|
815 | + $pdf->SetXY($posx+2,$posy); |
|
816 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHORPAIEMENT")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
817 | + $posy+=5; |
|
818 | + $pdf->SetXY($posx+2,$posy); |
|
819 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement,"day",false,$outputlangs),0,'L'); |
|
820 | + } |
|
821 | + } |
|
822 | + } |
|
823 | + } |
|
824 | + |
|
825 | + /** |
|
826 | + * Show table for lines |
|
827 | + * |
|
828 | + * @param PDF $pdf Object PDF |
|
829 | + * @param int $tab_top Tab top |
|
830 | + * @param int $tab_height Tab height |
|
831 | + * @param int $nexY next y |
|
832 | + * @param Translate $outputlangs Output langs |
|
833 | + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title |
|
834 | + * @param int $hidebottom Hide bottom bar of array |
|
835 | + * @param string $currency Currency code |
|
836 | + * @return void |
|
837 | + */ |
|
838 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
839 | + { |
|
840 | + global $conf; |
|
841 | + |
|
842 | + // Force to disable hidetop and hidebottom |
|
843 | + $hidebottom=0; |
|
844 | + if ($hidetop) $hidetop=-1; |
|
845 | + |
|
846 | + $currency = !empty($currency) ? $currency : $conf->currency; |
|
847 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
848 | + |
|
849 | + // Amount in (at tab_top - 1) |
|
850 | + $pdf->SetTextColor(0,0,0); |
|
851 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
852 | + $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
853 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top -4); |
|
854 | + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
855 | + |
|
856 | + $pdf->SetDrawColor(128,128,128); |
|
857 | + |
|
858 | + // Rect prend une longueur en 3eme param |
|
859 | + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); |
|
860 | + // line prend une position y en 3eme param |
|
861 | + if (empty($hidetop)) { |
|
862 | + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); |
|
863 | + } |
|
864 | + |
|
865 | + $pdf->SetFont('','',8); |
|
866 | + |
|
867 | + // Accountancy piece |
|
868 | + if (empty($hidetop)) { |
|
869 | + $pdf->SetXY($this->posxpiece-1, $tab_top+1); |
|
870 | + $pdf->MultiCell($this->posxcomment-$this->posxpiece-1, 1, '', '', 'R'); |
|
871 | + } |
|
872 | + |
|
873 | + // Comments |
|
874 | + $pdf->line($this->posxcomment-1, $tab_top, $this->posxcomment-1, $tab_top + $tab_height); |
|
875 | + if (empty($hidetop)) { |
|
876 | + $pdf->SetXY($this->posxcomment-1, $tab_top+1); |
|
877 | + $pdf->MultiCell($this->posxdate-$this->posxcomment-1, 1, $outputlangs->transnoentities("Description"),'','L'); |
|
878 | + } |
|
879 | + |
|
880 | + // Date |
|
881 | + //$pdf->line($this->posxdate-1, $tab_top, $this->posxdate-1, $tab_top + $tab_height); |
|
882 | + //if (empty($hidetop)) |
|
883 | + //{ |
|
884 | + // $pdf->SetXY($this->posxdate-1, $tab_top+1); |
|
885 | + // $pdf->MultiCell($this->posxtype-$this->posxdate-1,2, $outputlangs->transnoentities("Date"),'','C'); |
|
886 | + //} |
|
887 | + |
|
888 | + // Type |
|
889 | + //$pdf->line($this->posxtype-1, $tab_top, $this->posxtype-1, $tab_top + $tab_height); |
|
890 | + //if (empty($hidetop)) |
|
891 | + //{ |
|
892 | + // $pdf->SetXY($this->posxtype-1, $tab_top+1); |
|
893 | + // $pdf->MultiCell($this->posxprojet-$this->posxtype - 1, 2, $outputlangs->transnoentities("Type"), '', 'C'); |
|
894 | + //} |
|
895 | 895 | |
896 | 896 | //if (!empty($conf->projet->enabled)) |
897 | 897 | //{ |
898 | 898 | // // Project |
899 | 899 | // $pdf->line($this->posxprojet - 1, $tab_top, $this->posxprojet - 1, $tab_top + $tab_height); |
900 | - // if (empty($hidetop)) { |
|
900 | + // if (empty($hidetop)) { |
|
901 | 901 | // $pdf->SetXY($this->posxprojet - 1, $tab_top + 1); |
902 | 902 | // $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 2, $outputlangs->transnoentities("Project"), '', 'C'); |
903 | - // } |
|
903 | + // } |
|
904 | 904 | //} |
905 | 905 | |
906 | - // VAT |
|
907 | - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
|
908 | - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); |
|
909 | - if (empty($hidetop)) { |
|
910 | - $pdf->SetXY($this->posxtva-1, $tab_top+1); |
|
911 | - $pdf->MultiCell($this->posxup-$this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C'); |
|
912 | - } |
|
913 | - } |
|
906 | + // VAT |
|
907 | + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
|
908 | + $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); |
|
909 | + if (empty($hidetop)) { |
|
910 | + $pdf->SetXY($this->posxtva-1, $tab_top+1); |
|
911 | + $pdf->MultiCell($this->posxup-$this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C'); |
|
912 | + } |
|
913 | + } |
|
914 | 914 | |
915 | 915 | // Unit price |
916 | - $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); |
|
917 | - if (empty($hidetop)) { |
|
918 | - $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
919 | - $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceU"),'','C'); |
|
920 | - } |
|
921 | - |
|
922 | - // Quantity |
|
923 | - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
924 | - if (empty($hidetop)) { |
|
925 | - $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
926 | - $pdf->MultiCell($this->postotalttc-$this->posxqty - 1,2, $outputlangs->transnoentities("Qty"),'','R'); |
|
927 | - } |
|
928 | - |
|
929 | - // Total with all taxes |
|
930 | - $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height); |
|
931 | - if (empty($hidetop)) { |
|
932 | - $pdf->SetXY($this->postotalttc-1, $tab_top+1); |
|
933 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"),'','R'); |
|
934 | - } |
|
935 | - |
|
936 | - $pdf->SetTextColor(0,0,0); |
|
937 | - } |
|
938 | - |
|
939 | - /** |
|
940 | - * Show payments table |
|
941 | - * |
|
942 | - * @param PDF $pdf Object PDF |
|
943 | - * @param Object $object Object invoice |
|
944 | - * @param int $posy Position y in PDF |
|
945 | - * @param Translate $outputlangs Object langs for output |
|
946 | - * @return int <0 if KO, >0 if OK |
|
947 | - */ |
|
948 | - private function tablePayments(&$pdf, $object, $posy, $outputlangs) |
|
949 | - { |
|
950 | - global $conf; |
|
951 | - |
|
952 | - $sign=1; |
|
953 | - $tab3_posx = $this->marge_gauche; |
|
954 | - $tab3_top = $posy; |
|
955 | - $tab3_width = 88; |
|
956 | - $tab3_height = 5; |
|
957 | - |
|
958 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
959 | - |
|
960 | - $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); |
|
961 | - $pdf->SetFont('','', $default_font_size - 2); |
|
962 | - $pdf->SetXY($tab3_posx, $tab3_top - 4); |
|
963 | - $pdf->SetTextColor(0,0,0); |
|
964 | - $pdf->MultiCell(60, 3, $title, 0, 'L', 0); |
|
965 | - |
|
966 | - $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width+2, $tab3_top); // Top border line of table title |
|
967 | - |
|
968 | - $pdf->SetXY($tab3_posx, $tab3_top+1); |
|
969 | - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Date"), 0, 'L', 0); |
|
970 | - $pdf->SetXY($tab3_posx+19, $tab3_top+1); // Old value 17 |
|
971 | - $pdf->MultiCell(15, 3, $outputlangs->transnoentities("Amount"), 0, 'C', 0); |
|
972 | - $pdf->SetXY($tab3_posx+35, $tab3_top+1); |
|
973 | - $pdf->MultiCell(30, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); |
|
974 | - if (! empty($conf->banque->enabled)) { |
|
975 | - $pdf->SetXY($tab3_posx+65, $tab3_top+1); |
|
976 | - $pdf->MultiCell(25, 3, $outputlangs->transnoentities("BankAccount"), 0, 'L', 0); |
|
977 | - } |
|
978 | - $pdf->line($tab3_posx, $tab3_top+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$tab3_height); // Bottom border line of table title |
|
979 | - |
|
980 | - $y=0; |
|
981 | - |
|
982 | - // Loop on each payment |
|
983 | - // TODO create method on expensereport class to get payments |
|
984 | - // Payments already done (from payment on this expensereport) |
|
985 | - $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; |
|
986 | - $sql.= "c.code as p_code, c.libelle as payment_type,"; |
|
987 | - $sql.= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; |
|
988 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; |
|
989 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; |
|
990 | - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; |
|
991 | - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; |
|
992 | - $sql.= " WHERE e.rowid = '".$object->id."'"; |
|
993 | - $sql.= " AND p.fk_expensereport = e.rowid"; |
|
994 | - $sql.= ' AND e.entity IN ('.getEntity('expensereport').')'; |
|
995 | - $sql.= " ORDER BY dp"; |
|
996 | - |
|
997 | - $resql=$this->db->query($sql); |
|
998 | - if ($resql) |
|
999 | - { |
|
1000 | - $num = $this->db->num_rows($resql); |
|
1001 | - $i=0; |
|
1002 | - while ($i < $num) { |
|
1003 | - $y+=$tab3_height; |
|
1004 | - $row = $this->db->fetch_object($resql); |
|
1005 | - |
|
1006 | - $pdf->SetXY($tab3_posx, $tab3_top+$y+1); |
|
1007 | - $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->dp),'day',false,$outputlangs,true), 0, 'L', 0); |
|
1008 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y+1); |
|
1009 | - $pdf->MultiCell(15, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'R', 0); |
|
1010 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y+1); |
|
1011 | - $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->p_code); |
|
1012 | - |
|
1013 | - $pdf->MultiCell(40, 3, $oper, 0, 'L', 0); |
|
1014 | - if (! empty($conf->banque->enabled)) { |
|
1015 | - $pdf->SetXY($tab3_posx+65, $tab3_top+$y+1); |
|
1016 | - $pdf->MultiCell(30, 3, $row->baref, 0, 'L', 0); |
|
1017 | - } |
|
1018 | - |
|
1019 | - $pdf->line($tab3_posx, $tab3_top+$y+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$y+$tab3_height); // Bottom line border of table |
|
1020 | - $totalpaid += $row->amount; |
|
1021 | - $i++; |
|
1022 | - } |
|
1023 | - if ($num > 0 && $object->paid == 0) |
|
1024 | - { |
|
1025 | - $y+=$tab3_height; |
|
916 | + $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); |
|
917 | + if (empty($hidetop)) { |
|
918 | + $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
919 | + $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceU"),'','C'); |
|
920 | + } |
|
921 | + |
|
922 | + // Quantity |
|
923 | + $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
924 | + if (empty($hidetop)) { |
|
925 | + $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
926 | + $pdf->MultiCell($this->postotalttc-$this->posxqty - 1,2, $outputlangs->transnoentities("Qty"),'','R'); |
|
927 | + } |
|
928 | + |
|
929 | + // Total with all taxes |
|
930 | + $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height); |
|
931 | + if (empty($hidetop)) { |
|
932 | + $pdf->SetXY($this->postotalttc-1, $tab_top+1); |
|
933 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"),'','R'); |
|
934 | + } |
|
935 | + |
|
936 | + $pdf->SetTextColor(0,0,0); |
|
937 | + } |
|
938 | + |
|
939 | + /** |
|
940 | + * Show payments table |
|
941 | + * |
|
942 | + * @param PDF $pdf Object PDF |
|
943 | + * @param Object $object Object invoice |
|
944 | + * @param int $posy Position y in PDF |
|
945 | + * @param Translate $outputlangs Object langs for output |
|
946 | + * @return int <0 if KO, >0 if OK |
|
947 | + */ |
|
948 | + private function tablePayments(&$pdf, $object, $posy, $outputlangs) |
|
949 | + { |
|
950 | + global $conf; |
|
951 | + |
|
952 | + $sign=1; |
|
953 | + $tab3_posx = $this->marge_gauche; |
|
954 | + $tab3_top = $posy; |
|
955 | + $tab3_width = 88; |
|
956 | + $tab3_height = 5; |
|
957 | + |
|
958 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
959 | + |
|
960 | + $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); |
|
961 | + $pdf->SetFont('','', $default_font_size - 2); |
|
962 | + $pdf->SetXY($tab3_posx, $tab3_top - 4); |
|
963 | + $pdf->SetTextColor(0,0,0); |
|
964 | + $pdf->MultiCell(60, 3, $title, 0, 'L', 0); |
|
965 | + |
|
966 | + $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width+2, $tab3_top); // Top border line of table title |
|
967 | + |
|
968 | + $pdf->SetXY($tab3_posx, $tab3_top+1); |
|
969 | + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Date"), 0, 'L', 0); |
|
970 | + $pdf->SetXY($tab3_posx+19, $tab3_top+1); // Old value 17 |
|
971 | + $pdf->MultiCell(15, 3, $outputlangs->transnoentities("Amount"), 0, 'C', 0); |
|
972 | + $pdf->SetXY($tab3_posx+35, $tab3_top+1); |
|
973 | + $pdf->MultiCell(30, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); |
|
974 | + if (! empty($conf->banque->enabled)) { |
|
975 | + $pdf->SetXY($tab3_posx+65, $tab3_top+1); |
|
976 | + $pdf->MultiCell(25, 3, $outputlangs->transnoentities("BankAccount"), 0, 'L', 0); |
|
977 | + } |
|
978 | + $pdf->line($tab3_posx, $tab3_top+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$tab3_height); // Bottom border line of table title |
|
979 | + |
|
980 | + $y=0; |
|
981 | + |
|
982 | + // Loop on each payment |
|
983 | + // TODO create method on expensereport class to get payments |
|
984 | + // Payments already done (from payment on this expensereport) |
|
985 | + $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; |
|
986 | + $sql.= "c.code as p_code, c.libelle as payment_type,"; |
|
987 | + $sql.= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; |
|
988 | + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; |
|
989 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; |
|
990 | + $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; |
|
991 | + $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; |
|
992 | + $sql.= " WHERE e.rowid = '".$object->id."'"; |
|
993 | + $sql.= " AND p.fk_expensereport = e.rowid"; |
|
994 | + $sql.= ' AND e.entity IN ('.getEntity('expensereport').')'; |
|
995 | + $sql.= " ORDER BY dp"; |
|
996 | + |
|
997 | + $resql=$this->db->query($sql); |
|
998 | + if ($resql) |
|
999 | + { |
|
1000 | + $num = $this->db->num_rows($resql); |
|
1001 | + $i=0; |
|
1002 | + while ($i < $num) { |
|
1003 | + $y+=$tab3_height; |
|
1004 | + $row = $this->db->fetch_object($resql); |
|
1005 | + |
|
1006 | + $pdf->SetXY($tab3_posx, $tab3_top+$y+1); |
|
1007 | + $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->dp),'day',false,$outputlangs,true), 0, 'L', 0); |
|
1008 | + $pdf->SetXY($tab3_posx+17, $tab3_top+$y+1); |
|
1009 | + $pdf->MultiCell(15, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'R', 0); |
|
1010 | + $pdf->SetXY($tab3_posx+35, $tab3_top+$y+1); |
|
1011 | + $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->p_code); |
|
1012 | + |
|
1013 | + $pdf->MultiCell(40, 3, $oper, 0, 'L', 0); |
|
1014 | + if (! empty($conf->banque->enabled)) { |
|
1015 | + $pdf->SetXY($tab3_posx+65, $tab3_top+$y+1); |
|
1016 | + $pdf->MultiCell(30, 3, $row->baref, 0, 'L', 0); |
|
1017 | + } |
|
1018 | + |
|
1019 | + $pdf->line($tab3_posx, $tab3_top+$y+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$y+$tab3_height); // Bottom line border of table |
|
1020 | + $totalpaid += $row->amount; |
|
1021 | + $i++; |
|
1022 | + } |
|
1023 | + if ($num > 0 && $object->paid == 0) |
|
1024 | + { |
|
1025 | + $y+=$tab3_height; |
|
1026 | 1026 | |
1027 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1028 | - $pdf->MultiCell(15, 3, price($totalpaid), 0, 'R', 0); |
|
1029 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1030 | - $pdf->MultiCell(30, 4, $outputlangs->trans("AlreadyPaid"), 0, 'L', 0); |
|
1031 | - $y+=$tab3_height-2; |
|
1032 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1033 | - $pdf->MultiCell(15, 3, price($object->total_ttc), 0, 'R', 0); |
|
1034 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1035 | - $pdf->MultiCell(30, 4, $outputlangs->trans("AmountExpected"), 0, 'L', 0); |
|
1036 | - $y+=$tab3_height-2; |
|
1037 | - $remaintopay = $object->total_ttc - $totalpaid; |
|
1038 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1039 | - $pdf->MultiCell(15, 3, price($remaintopay), 0, 'R', 0); |
|
1040 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1041 | - $pdf->MultiCell(30, 4, $outputlangs->trans("RemainderToPay"), 0, 'L', 0); |
|
1042 | - } |
|
1043 | - } |
|
1044 | - else |
|
1045 | - { |
|
1046 | - $this->error=$this->db->lasterror(); |
|
1047 | - return -1; |
|
1048 | - } |
|
1049 | - } |
|
1050 | - |
|
1051 | - /** |
|
1052 | - * Show footer of page. Need this->emetteur object |
|
1027 | + $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1028 | + $pdf->MultiCell(15, 3, price($totalpaid), 0, 'R', 0); |
|
1029 | + $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1030 | + $pdf->MultiCell(30, 4, $outputlangs->trans("AlreadyPaid"), 0, 'L', 0); |
|
1031 | + $y+=$tab3_height-2; |
|
1032 | + $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1033 | + $pdf->MultiCell(15, 3, price($object->total_ttc), 0, 'R', 0); |
|
1034 | + $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1035 | + $pdf->MultiCell(30, 4, $outputlangs->trans("AmountExpected"), 0, 'L', 0); |
|
1036 | + $y+=$tab3_height-2; |
|
1037 | + $remaintopay = $object->total_ttc - $totalpaid; |
|
1038 | + $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1039 | + $pdf->MultiCell(15, 3, price($remaintopay), 0, 'R', 0); |
|
1040 | + $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1041 | + $pdf->MultiCell(30, 4, $outputlangs->trans("RemainderToPay"), 0, 'L', 0); |
|
1042 | + } |
|
1043 | + } |
|
1044 | + else |
|
1045 | + { |
|
1046 | + $this->error=$this->db->lasterror(); |
|
1047 | + return -1; |
|
1048 | + } |
|
1049 | + } |
|
1050 | + |
|
1051 | + /** |
|
1052 | + * Show footer of page. Need this->emetteur object |
|
1053 | 1053 | * |
1054 | - * @param PDF $pdf PDF |
|
1055 | - * @param Object $object Object to show |
|
1056 | - * @param Translate $outputlangs Object lang for output |
|
1057 | - * @param int $hidefreetext 1=Hide free text |
|
1058 | - * @return int Return height of bottom margin including footer text |
|
1059 | - */ |
|
1060 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1061 | - { |
|
1062 | - global $conf; |
|
1063 | - $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1064 | - return pdf_pagefoot($pdf, $outputlangs, 'EXPENSEREPORT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
1065 | - } |
|
1054 | + * @param PDF $pdf PDF |
|
1055 | + * @param Object $object Object to show |
|
1056 | + * @param Translate $outputlangs Object lang for output |
|
1057 | + * @param int $hidefreetext 1=Hide free text |
|
1058 | + * @return int Return height of bottom margin including footer text |
|
1059 | + */ |
|
1060 | + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1061 | + { |
|
1062 | + global $conf; |
|
1063 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1064 | + return pdf_pagefoot($pdf, $outputlangs, 'EXPENSEREPORT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
1065 | + } |
|
1066 | 1066 | } |
@@ -132,42 +132,42 @@ discard block |
||
132 | 132 | |
133 | 133 | // Dimension page pour format A4 |
134 | 134 | $this->type = 'pdf'; |
135 | - $formatarray=pdf_getFormat(); |
|
135 | + $formatarray = pdf_getFormat(); |
|
136 | 136 | $this->page_largeur = $formatarray['width']; |
137 | 137 | $this->page_hauteur = $formatarray['height']; |
138 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
139 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
140 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
141 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
142 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
143 | - |
|
144 | - $this->option_logo = 1; // Affiche logo |
|
145 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
146 | - $this->option_modereg = 1; // Affiche mode reglement |
|
147 | - $this->option_condreg = 1; // Affiche conditions reglement |
|
148 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
149 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
150 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
151 | - $this->option_credit_note = 0; // Support credit notes |
|
152 | - $this->option_freetext = 1; // Support add of a personalised text |
|
153 | - $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
138 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
139 | + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; |
|
140 | + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; |
|
141 | + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; |
|
142 | + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; |
|
143 | + |
|
144 | + $this->option_logo = 1; // Affiche logo |
|
145 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
146 | + $this->option_modereg = 1; // Affiche mode reglement |
|
147 | + $this->option_condreg = 1; // Affiche conditions reglement |
|
148 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
149 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
150 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
151 | + $this->option_credit_note = 0; // Support credit notes |
|
152 | + $this->option_freetext = 1; // Support add of a personalised text |
|
153 | + $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
154 | 154 | |
155 | 155 | $this->franchise = !$mysoc->tva_assuj; |
156 | 156 | |
157 | 157 | // Get source company |
158 | - $this->emetteur=$mysoc; |
|
159 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
158 | + $this->emetteur = $mysoc; |
|
159 | + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined |
|
160 | 160 | |
161 | 161 | // Define position of columns |
162 | - $this->posxpiece=$this->marge_gauche+1; |
|
163 | - $this->posxcomment=$this->marge_gauche+10; |
|
162 | + $this->posxpiece = $this->marge_gauche + 1; |
|
163 | + $this->posxcomment = $this->marge_gauche + 10; |
|
164 | 164 | //$this->posxdate=88; |
165 | 165 | //$this->posxtype=107; |
166 | 166 | //$this->posxprojet=120; |
167 | - $this->posxtva=130; |
|
168 | - $this->posxup=145; |
|
169 | - $this->posxqty=168; |
|
170 | - $this->postotalttc=178; |
|
167 | + $this->posxtva = 130; |
|
168 | + $this->posxup = 145; |
|
169 | + $this->posxqty = 168; |
|
170 | + $this->postotalttc = 178; |
|
171 | 171 | // if (empty($conf->projet->enabled)) { |
172 | 172 | // $this->posxtva-=20; |
173 | 173 | // $this->posxup-=20; |
@@ -176,19 +176,19 @@ discard block |
||
176 | 176 | // } |
177 | 177 | if ($this->page_largeur < 210) // To work with US executive format |
178 | 178 | { |
179 | - $this->posxdate-=20; |
|
180 | - $this->posxtype-=20; |
|
181 | - $this->posxprojet-=20; |
|
182 | - $this->posxtva-=20; |
|
183 | - $this->posxup-=20; |
|
184 | - $this->posxqty-=20; |
|
185 | - $this->postotalttc-=20; |
|
179 | + $this->posxdate -= 20; |
|
180 | + $this->posxtype -= 20; |
|
181 | + $this->posxprojet -= 20; |
|
182 | + $this->posxtva -= 20; |
|
183 | + $this->posxup -= 20; |
|
184 | + $this->posxqty -= 20; |
|
185 | + $this->postotalttc -= 20; |
|
186 | 186 | } |
187 | 187 | |
188 | - $this->tva=array(); |
|
189 | - $this->localtax1=array(); |
|
190 | - $this->localtax2=array(); |
|
191 | - $this->atleastoneratenotnull=0; |
|
188 | + $this->tva = array(); |
|
189 | + $this->localtax1 = array(); |
|
190 | + $this->localtax2 = array(); |
|
191 | + $this->atleastoneratenotnull = 0; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | // phpcs:enable |
210 | 210 | global $user, $langs, $conf, $mysoc, $db, $hookmanager; |
211 | 211 | |
212 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
212 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
213 | 213 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
214 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
214 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
215 | 215 | |
216 | 216 | // Load traductions files requiredby by page |
217 | 217 | $outputlangs->loadLangs(array("main", "trips", "projects", "dict", "bills", "banks")); |
@@ -222,20 +222,20 @@ discard block |
||
222 | 222 | // Definition of $dir and $file |
223 | 223 | if ($object->specimen) { |
224 | 224 | $dir = $conf->expensereport->dir_output; |
225 | - $file = $dir . "/SPECIMEN.pdf"; |
|
225 | + $file = $dir."/SPECIMEN.pdf"; |
|
226 | 226 | } |
227 | 227 | else |
228 | 228 | { |
229 | 229 | $objectref = dol_sanitizeFileName($object->ref); |
230 | - $dir = $conf->expensereport->dir_output . "/" . $objectref; |
|
231 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
230 | + $dir = $conf->expensereport->dir_output."/".$objectref; |
|
231 | + $file = $dir."/".$objectref.".pdf"; |
|
232 | 232 | } |
233 | 233 | |
234 | - if (! file_exists($dir)) |
|
234 | + if (!file_exists($dir)) |
|
235 | 235 | { |
236 | 236 | if (dol_mkdir($dir) < 0) |
237 | 237 | { |
238 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
238 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
239 | 239 | return 0; |
240 | 240 | } |
241 | 241 | } |
@@ -243,25 +243,25 @@ discard block |
||
243 | 243 | if (file_exists($dir)) |
244 | 244 | { |
245 | 245 | // Add pdfgeneration hook |
246 | - if (! is_object($hookmanager)) |
|
246 | + if (!is_object($hookmanager)) |
|
247 | 247 | { |
248 | 248 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
249 | - $hookmanager=new HookManager($this->db); |
|
249 | + $hookmanager = new HookManager($this->db); |
|
250 | 250 | } |
251 | 251 | $hookmanager->initHooks(array('pdfgeneration')); |
252 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
252 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
253 | 253 | global $action; |
254 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
254 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
255 | 255 | |
256 | 256 | // Create pdf instance |
257 | - $pdf=pdf_getInstance($this->format); |
|
258 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
259 | - $heightforinfotot = 40; // Height reserved to output the info and total part |
|
260 | - $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 |
|
261 | - $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin) |
|
262 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
257 | + $pdf = pdf_getInstance($this->format); |
|
258 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
259 | + $heightforinfotot = 40; // Height reserved to output the info and total part |
|
260 | + $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 |
|
261 | + $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin) |
|
262 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; |
|
263 | 263 | |
264 | - $pdf->SetAutoPageBreak(1,0); |
|
264 | + $pdf->SetAutoPageBreak(1, 0); |
|
265 | 265 | |
266 | 266 | if (class_exists('TCPDF')) |
267 | 267 | { |
@@ -270,75 +270,75 @@ discard block |
||
270 | 270 | } |
271 | 271 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
272 | 272 | // Set path to the background PDF File |
273 | - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
273 | + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
274 | 274 | { |
275 | 275 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
276 | 276 | $tplidx = $pdf->importPage(1); |
277 | 277 | } |
278 | 278 | |
279 | 279 | $pdf->Open(); |
280 | - $pagenb=0; |
|
281 | - $pdf->SetDrawColor(128,128,128); |
|
280 | + $pagenb = 0; |
|
281 | + $pdf->SetDrawColor(128, 128, 128); |
|
282 | 282 | |
283 | 283 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
284 | 284 | $pdf->SetSubject($outputlangs->transnoentities("Trips")); |
285 | 285 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
286 | 286 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
287 | 287 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Trips")); |
288 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
288 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
289 | 289 | |
290 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
290 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
291 | 291 | |
292 | 292 | // New page |
293 | 293 | $pdf->AddPage(); |
294 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
294 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
295 | 295 | $pagenb++; |
296 | 296 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
297 | - $pdf->SetFont('','', $default_font_size - 1); |
|
298 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
299 | - $pdf->SetTextColor(0,0,0); |
|
297 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
298 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
299 | + $pdf->SetTextColor(0, 0, 0); |
|
300 | 300 | |
301 | 301 | $tab_top = 95; |
302 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?65:10); |
|
302 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 65 : 10); |
|
303 | 303 | $tab_height = 130; |
304 | 304 | $tab_height_newpage = 150; |
305 | 305 | |
306 | 306 | // Show notes |
307 | - $notetoshow=empty($object->note_public)?'':$object->note_public; |
|
308 | - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) |
|
307 | + $notetoshow = empty($object->note_public) ? '' : $object->note_public; |
|
308 | + if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) |
|
309 | 309 | { |
310 | 310 | // Get first sale rep |
311 | 311 | if (is_object($object->thirdparty)) |
312 | 312 | { |
313 | - $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
|
314 | - $salerepobj=new User($this->db); |
|
313 | + $salereparray = $object->thirdparty->getSalesRepresentatives($user); |
|
314 | + $salerepobj = new User($this->db); |
|
315 | 315 | $salerepobj->fetch($salereparray[0]['id']); |
316 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
316 | + if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | if ($notetoshow) |
320 | 320 | { |
321 | - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
321 | + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); |
|
322 | 322 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
323 | 323 | $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
324 | 324 | |
325 | 325 | $tab_top = 95; |
326 | 326 | |
327 | - $pdf->SetFont('','', $default_font_size - 1); |
|
328 | - $pdf->writeHTMLCell(190, 3, $this->posxpiece-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
327 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
328 | + $pdf->writeHTMLCell(190, 3, $this->posxpiece - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
329 | 329 | $nexY = $pdf->GetY(); |
330 | - $height_note=$nexY-$tab_top; |
|
330 | + $height_note = $nexY - $tab_top; |
|
331 | 331 | |
332 | 332 | // Rect prend une longueur en 3eme param |
333 | - $pdf->SetDrawColor(192,192,192); |
|
334 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
333 | + $pdf->SetDrawColor(192, 192, 192); |
|
334 | + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); |
|
335 | 335 | |
336 | 336 | $tab_height = $tab_height - $height_note; |
337 | - $tab_top = $nexY+6; |
|
337 | + $tab_top = $nexY + 6; |
|
338 | 338 | } |
339 | 339 | else |
340 | 340 | { |
341 | - $height_note=0; |
|
341 | + $height_note = 0; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | $iniY = $tab_top + 7; |
@@ -346,41 +346,41 @@ discard block |
||
346 | 346 | $nexY = $tab_top + 7; |
347 | 347 | |
348 | 348 | // Loop on each lines |
349 | - for ($i = 0 ; $i < $nblignes ; $i++) { |
|
350 | - $pdf->SetFont('','', $default_font_size - 2); // Into loop to work with multipage |
|
351 | - $pdf->SetTextColor(0,0,0); |
|
349 | + for ($i = 0; $i < $nblignes; $i++) { |
|
350 | + $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage |
|
351 | + $pdf->SetTextColor(0, 0, 0); |
|
352 | 352 | |
353 | 353 | $pdf->setTopMargin($tab_top_newpage); |
354 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
354 | + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
355 | 355 | $pageposbefore = $pdf->getPage(); |
356 | 356 | $curY = $nexY; |
357 | 357 | $pdf->startTransaction(); |
358 | 358 | $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); |
359 | - $pageposafter=$pdf->getPage(); |
|
359 | + $pageposafter = $pdf->getPage(); |
|
360 | 360 | if ($pageposafter > $pageposbefore) { |
361 | 361 | // There is a pagebreak |
362 | 362 | $pdf->rollbackTransaction(true); |
363 | 363 | $pageposafter = $pageposbefore; |
364 | 364 | //print $pageposafter.'-'.$pageposbefore;exit; |
365 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
365 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
366 | 366 | $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); |
367 | 367 | $pageposafter = $pdf->getPage(); |
368 | 368 | $posyafter = $pdf->GetY(); |
369 | 369 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
370 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
370 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { |
|
371 | 371 | // There is no space left for total+free text |
372 | - if ($i == ($nblignes-1)) { |
|
372 | + if ($i == ($nblignes - 1)) { |
|
373 | 373 | // No more lines, and no space left to show total, so we create a new page |
374 | 374 | $pdf->AddPage('', '', true); |
375 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
375 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
376 | 376 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
377 | - $pdf->setPage($pageposafter+1); |
|
377 | + $pdf->setPage($pageposafter + 1); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | else |
381 | 381 | { |
382 | 382 | // We found a page break |
383 | - $showpricebeforepagebreak=0; |
|
383 | + $showpricebeforepagebreak = 0; |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | else // No pagebreak |
@@ -389,10 +389,10 @@ discard block |
||
389 | 389 | } |
390 | 390 | //nexY |
391 | 391 | $nexY = $pdf->GetY(); |
392 | - $pageposafter=$pdf->getPage(); |
|
392 | + $pageposafter = $pdf->getPage(); |
|
393 | 393 | $pdf->setPage($pageposbefore); |
394 | 394 | $pdf->setTopMargin($this->marge_haute); |
395 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
395 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
396 | 396 | |
397 | 397 | //$nblineFollowComment = 1; |
398 | 398 | // Cherche nombre de lignes a venir pour savoir si place suffisante |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | // } |
411 | 411 | |
412 | 412 | //$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3); // Passe espace entre les lignes |
413 | - $nexY += ($pdf->getFontSize()*1.3); // Passe espace entre les lignes |
|
413 | + $nexY += ($pdf->getFontSize() * 1.3); // Passe espace entre les lignes |
|
414 | 414 | |
415 | 415 | // Detect if some page were added automatically and output _tableau for past pages |
416 | 416 | while ($pagenb < $pageposafter) |
@@ -424,13 +424,13 @@ discard block |
||
424 | 424 | { |
425 | 425 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
426 | 426 | } |
427 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
427 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
428 | 428 | $pagenb++; |
429 | 429 | $pdf->setPage($pagenb); |
430 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
430 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
431 | 431 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
432 | 432 | } |
433 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
433 | + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) |
|
434 | 434 | { |
435 | 435 | if ($pagenb == 1) |
436 | 436 | { |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | { |
441 | 441 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
442 | 442 | } |
443 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
443 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
444 | 444 | // New page |
445 | 445 | $pdf->AddPage(); |
446 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
446 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
447 | 447 | $pagenb++; |
448 | 448 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
449 | 449 | } |
@@ -453,80 +453,80 @@ discard block |
||
453 | 453 | if ($pagenb == 1) |
454 | 454 | { |
455 | 455 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
456 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
456 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
457 | 457 | } |
458 | 458 | else |
459 | 459 | { |
460 | 460 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
461 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
461 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
462 | 462 | } |
463 | 463 | |
464 | - $pdf->SetFont('','', 10); |
|
464 | + $pdf->SetFont('', '', 10); |
|
465 | 465 | |
466 | 466 | // Show total area box |
467 | - $posy=$bottomlasttab+5; |
|
467 | + $posy = $bottomlasttab + 5; |
|
468 | 468 | $posy_start_of_totals = $posy; |
469 | 469 | $pdf->SetXY(130, $posy); |
470 | 470 | $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalHT"), 1, 'L'); |
471 | 471 | $pdf->SetXY(180, $posy); |
472 | 472 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ht), 1, 'R'); |
473 | - $pdf->SetFillColor(248,248,248); |
|
473 | + $pdf->SetFillColor(248, 248, 248); |
|
474 | 474 | |
475 | 475 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
476 | 476 | { |
477 | 477 | // TODO Show vat amout per tax level |
478 | - $posy+=5; |
|
478 | + $posy += 5; |
|
479 | 479 | $pdf->SetXY(130, $posy); |
480 | - $pdf->SetTextColor(0,0,60); |
|
481 | - $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalVAT"), 1,'L'); |
|
480 | + $pdf->SetTextColor(0, 0, 60); |
|
481 | + $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalVAT"), 1, 'L'); |
|
482 | 482 | $pdf->SetXY(180, $posy); |
483 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_tva),1, 'R'); |
|
483 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_tva), 1, 'R'); |
|
484 | 484 | } |
485 | 485 | |
486 | - $posy+=5; |
|
486 | + $posy += 5; |
|
487 | 487 | $pdf->SetXY(130, $posy); |
488 | - $pdf->SetFont('','B', 10); |
|
489 | - $pdf->SetTextColor(0,0,60); |
|
490 | - $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalTTC"), 1,'L'); |
|
488 | + $pdf->SetFont('', 'B', 10); |
|
489 | + $pdf->SetTextColor(0, 0, 60); |
|
490 | + $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalTTC"), 1, 'L'); |
|
491 | 491 | $pdf->SetXY(180, $posy); |
492 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ttc),1, 'R'); |
|
492 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ttc), 1, 'R'); |
|
493 | 493 | |
494 | 494 | // show payments zone |
495 | 495 | $sumPayments = $object->getSumPayments(); |
496 | 496 | if ($sumPayments > 0 && empty($conf->global->PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS)) { |
497 | - $posy=$this->tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs); |
|
497 | + $posy = $this->tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | // Pied de page |
501 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
502 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPage(); |
|
501 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
502 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPage(); |
|
503 | 503 | |
504 | 504 | $pdf->Close(); |
505 | 505 | |
506 | - $pdf->Output($file,'F'); |
|
506 | + $pdf->Output($file, 'F'); |
|
507 | 507 | |
508 | 508 | // Add pdfgeneration hook |
509 | 509 | $hookmanager->initHooks(array('pdfgeneration')); |
510 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
510 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
511 | 511 | global $action; |
512 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
512 | + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
513 | 513 | |
514 | - if (! empty($conf->global->MAIN_UMASK)) |
|
514 | + if (!empty($conf->global->MAIN_UMASK)) |
|
515 | 515 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
516 | 516 | |
517 | 517 | $this->result = array('fullpath'=>$file); |
518 | 518 | |
519 | - return 1; // Pas d'erreur |
|
519 | + return 1; // Pas d'erreur |
|
520 | 520 | } |
521 | 521 | else |
522 | 522 | { |
523 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
523 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
524 | 524 | return 0; |
525 | 525 | } |
526 | 526 | } |
527 | 527 | else |
528 | 528 | { |
529 | - $this->error=$langs->trans("ErrorConstantNotDefined","EXPENSEREPORT_OUTPUTDIR"); |
|
529 | + $this->error = $langs->trans("ErrorConstantNotDefined", "EXPENSEREPORT_OUTPUTDIR"); |
|
530 | 530 | return 0; |
531 | 531 | } |
532 | 532 | } |
@@ -541,21 +541,21 @@ discard block |
||
541 | 541 | * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) |
542 | 542 | * @return void |
543 | 543 | */ |
544 | - private function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails=0) |
|
544 | + private function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0) |
|
545 | 545 | { |
546 | 546 | global $conf; |
547 | - $pdf->SetFont('','', $default_font_size - 1); |
|
547 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
548 | 548 | |
549 | 549 | // Accountancy piece |
550 | 550 | $pdf->SetXY($this->posxpiece, $curY); |
551 | - $pdf->writeHTMLCell($this->posxcomment-$this->posxpiece-0.8, 4, $this->posxpiece-1, $curY, $linenumber + 1, 0, 1); |
|
551 | + $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1); |
|
552 | 552 | |
553 | 553 | // Date |
554 | 554 | //$pdf->SetXY($this->posxdate -1, $curY); |
555 | 555 | //$pdf->MultiCell($this->posxtype-$this->posxdate-0.8, 4, dol_print_date($object->lines[$linenumber]->date,"day",false,$outputlangs), 0, 'C'); |
556 | 556 | |
557 | 557 | // Type |
558 | - $pdf->SetXY($this->posxtype -1, $curY); |
|
558 | + $pdf->SetXY($this->posxtype - 1, $curY); |
|
559 | 559 | $nextColumnPosX = $this->posxup; |
560 | 560 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
561 | 561 | $nextColumnPosX = $this->posxtva; |
@@ -585,30 +585,30 @@ discard block |
||
585 | 585 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
586 | 586 | $vat_rate = pdf_getlinevatrate($object, $linenumber, $outputlangs, $hidedetails); |
587 | 587 | $pdf->SetXY($this->posxtva, $curY); |
588 | - $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 4,$vat_rate, 0, 'R'); |
|
588 | + $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0, 'R'); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | // Unit price |
592 | 592 | $pdf->SetXY($this->posxup, $curY); |
593 | - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 4,price($object->lines[$linenumber]->value_unit), 0, 'R'); |
|
593 | + $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4, price($object->lines[$linenumber]->value_unit), 0, 'R'); |
|
594 | 594 | |
595 | 595 | // Quantity |
596 | 596 | $pdf->SetXY($this->posxqty, $curY); |
597 | - $pdf->MultiCell($this->postotalttc-$this->posxqty-0.8, 4,$object->lines[$linenumber]->qty, 0, 'R'); |
|
597 | + $pdf->MultiCell($this->postotalttc - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0, 'R'); |
|
598 | 598 | |
599 | 599 | // Total with all taxes |
600 | - $pdf->SetXY($this->postotalttc-1, $curY); |
|
601 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R'); |
|
600 | + $pdf->SetXY($this->postotalttc - 1, $curY); |
|
601 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R'); |
|
602 | 602 | |
603 | 603 | // Comments |
604 | - $pdf->SetXY($this->posxcomment, $curY ); |
|
605 | - $comment = $outputlangs->trans("Date").':'. dol_print_date($object->lines[$linenumber]->date,"day",false,$outputlangs).' '; |
|
606 | - $comment .= $outputlangs->trans("Type").':'. $expensereporttypecodetoshow.'<br>'; |
|
607 | - if (! empty($object->lines[$linenumber]->projet_ref)) { |
|
608 | - $comment .= $outputlangs->trans("Project").':'. $object->lines[$linenumber]->projet_ref.'<br>'; |
|
604 | + $pdf->SetXY($this->posxcomment, $curY); |
|
605 | + $comment = $outputlangs->trans("Date").':'.dol_print_date($object->lines[$linenumber]->date, "day", false, $outputlangs).' '; |
|
606 | + $comment .= $outputlangs->trans("Type").':'.$expensereporttypecodetoshow.'<br>'; |
|
607 | + if (!empty($object->lines[$linenumber]->projet_ref)) { |
|
608 | + $comment .= $outputlangs->trans("Project").':'.$object->lines[$linenumber]->projet_ref.'<br>'; |
|
609 | 609 | } |
610 | 610 | $comment .= $object->lines[$linenumber]->comments; |
611 | - $pdf->writeHTMLCell($this->posxtva-$this->posxcomment-0.8, 4, $this->posxcomment-1, $curY, $comment, 0, 1); |
|
611 | + $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
@@ -638,185 +638,185 @@ discard block |
||
638 | 638 | */ |
639 | 639 | |
640 | 640 | // Draft watermark |
641 | - if ($object->fk_statut == 0 && ! empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) { |
|
642 | - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->EXPENSEREPORT_DRAFT_WATERMARK); |
|
641 | + if ($object->fk_statut == 0 && !empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) { |
|
642 | + pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->EXPENSEREPORT_DRAFT_WATERMARK); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | $pdf->SetTextColor(0, 0, 60); |
646 | 646 | $pdf->SetFont('', 'B', $default_font_size + 3); |
647 | 647 | |
648 | - $posy=$this->marge_haute; |
|
649 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
648 | + $posy = $this->marge_haute; |
|
649 | + $posx = $this->page_largeur - $this->marge_droite - 100; |
|
650 | 650 | |
651 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
651 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
652 | 652 | |
653 | 653 | // Logo |
654 | 654 | $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
655 | 655 | if ($this->emetteur->logo) { |
656 | 656 | if (is_readable($logo)) { |
657 | - $height=pdf_getHeightForLogo($logo); |
|
658 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
657 | + $height = pdf_getHeightForLogo($logo); |
|
658 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
659 | 659 | } else { |
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("ErrorGoToGlobalSetup"), 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 | |
672 | - $pdf->SetFont('','B', $default_font_size + 4); |
|
673 | - $pdf->SetXY($posx,$posy); |
|
674 | - $pdf->SetTextColor(0,0,60); |
|
675 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx,6,$langs->trans("ExpenseReport"), 0, 'R'); |
|
672 | + $pdf->SetFont('', 'B', $default_font_size + 4); |
|
673 | + $pdf->SetXY($posx, $posy); |
|
674 | + $pdf->SetTextColor(0, 0, 60); |
|
675 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $langs->trans("ExpenseReport"), 0, 'R'); |
|
676 | 676 | |
677 | - $pdf->SetFont('','', $default_font_size -1); |
|
677 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
678 | 678 | |
679 | 679 | // Ref complete |
680 | - $posy+=8; |
|
681 | - $pdf->SetXY($posx,$posy); |
|
682 | - $pdf->SetTextColor(0,0,60); |
|
683 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'R'); |
|
680 | + $posy += 8; |
|
681 | + $pdf->SetXY($posx, $posy); |
|
682 | + $pdf->SetTextColor(0, 0, 60); |
|
683 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R'); |
|
684 | 684 | |
685 | 685 | // Date start period |
686 | - $posy+=5; |
|
687 | - $pdf->SetXY($posx,$posy); |
|
688 | - $pdf->SetTextColor(0,0,60); |
|
689 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateStart")." : " . ($object->date_debut>0?dol_print_date($object->date_debut,"day",false,$outputlangs):''), '', 'R'); |
|
686 | + $posy += 5; |
|
687 | + $pdf->SetXY($posx, $posy); |
|
688 | + $pdf->SetTextColor(0, 0, 60); |
|
689 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateStart")." : ".($object->date_debut > 0 ?dol_print_date($object->date_debut, "day", false, $outputlangs) : ''), '', 'R'); |
|
690 | 690 | |
691 | 691 | // Date end period |
692 | - $posy+=5; |
|
693 | - $pdf->SetXY($posx,$posy); |
|
694 | - $pdf->SetTextColor(0,0,60); |
|
695 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateEnd")." : " . ($object->date_fin>0?dol_print_date($object->date_fin,"day",false,$outputlangs):''), '', 'R'); |
|
692 | + $posy += 5; |
|
693 | + $pdf->SetXY($posx, $posy); |
|
694 | + $pdf->SetTextColor(0, 0, 60); |
|
695 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateEnd")." : ".($object->date_fin > 0 ?dol_print_date($object->date_fin, "day", false, $outputlangs) : ''), '', 'R'); |
|
696 | 696 | |
697 | 697 | // Status Expense Report |
698 | - $posy+=6; |
|
699 | - $pdf->SetXY($posx,$posy); |
|
700 | - $pdf->SetFont('','B', $default_font_size + 2); |
|
701 | - $pdf->SetTextColor(111,81,124); |
|
702 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $object->getLibStatut(0), '', 'R'); |
|
698 | + $posy += 6; |
|
699 | + $pdf->SetXY($posx, $posy); |
|
700 | + $pdf->SetFont('', 'B', $default_font_size + 2); |
|
701 | + $pdf->SetTextColor(111, 81, 124); |
|
702 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $object->getLibStatut(0), '', 'R'); |
|
703 | 703 | |
704 | 704 | if ($showaddress) { |
705 | 705 | // Sender properties |
706 | 706 | $carac_emetteur = ''; |
707 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->address); |
|
708 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town); |
|
707 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($this->emetteur->address); |
|
708 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town); |
|
709 | 709 | $carac_emetteur .= "\n"; |
710 | 710 | // Phone |
711 | - if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); |
|
711 | + if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); |
|
712 | 712 | // Fax |
713 | - if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); |
|
713 | + if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '').$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); |
|
714 | 714 | |
715 | - if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); |
|
715 | + if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); |
|
716 | 716 | // Web |
717 | - if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); |
|
717 | + if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); |
|
718 | 718 | |
719 | 719 | // Show sender |
720 | - $posy=50; |
|
721 | - $posx=$this->marge_gauche; |
|
722 | - $hautcadre=40; |
|
723 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118; |
|
720 | + $posy = 50; |
|
721 | + $posx = $this->marge_gauche; |
|
722 | + $hautcadre = 40; |
|
723 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = 118; |
|
724 | 724 | |
725 | 725 | // Show sender frame |
726 | 726 | $pdf->SetTextColor(0, 0, 0); |
727 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
728 | - $pdf->SetXY($posx,$posy-5); |
|
729 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("TripSociete")." :",'','L'); |
|
730 | - $pdf->SetXY($posx,$posy); |
|
731 | - $pdf->SetFillColor(224,224,224); |
|
727 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
728 | + $pdf->SetXY($posx, $posy - 5); |
|
729 | + $pdf->MultiCell(66, 5, $outputlangs->transnoentities("TripSociete")." :", '', 'L'); |
|
730 | + $pdf->SetXY($posx, $posy); |
|
731 | + $pdf->SetFillColor(224, 224, 224); |
|
732 | 732 | $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
733 | 733 | $pdf->SetTextColor(0, 0, 60); |
734 | 734 | |
735 | 735 | // Show sender name |
736 | - $pdf->SetXY($posx+2,$posy+3); |
|
737 | - $pdf->SetFont('','B', $default_font_size); |
|
736 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
737 | + $pdf->SetFont('', 'B', $default_font_size); |
|
738 | 738 | $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
739 | 739 | |
740 | 740 | // Show sender information |
741 | - $pdf->SetXY($posx+2,$posy+8); |
|
741 | + $pdf->SetXY($posx + 2, $posy + 8); |
|
742 | 742 | $pdf->SetFont('', '', $default_font_size - 1); |
743 | 743 | $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
744 | 744 | |
745 | 745 | // Show recipient |
746 | - $posy=50; |
|
747 | - $posx=100; |
|
746 | + $posy = 50; |
|
747 | + $posx = 100; |
|
748 | 748 | |
749 | 749 | // Show recipient frame |
750 | 750 | $pdf->SetTextColor(0, 0, 0); |
751 | 751 | $pdf->SetFont('', 'B', 8); |
752 | - $pdf->SetXY($posx,$posy-5); |
|
752 | + $pdf->SetXY($posx, $posy - 5); |
|
753 | 753 | $pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L'); |
754 | 754 | $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre); |
755 | 755 | |
756 | 756 | // Informations for trip (dates and users workflow) |
757 | 757 | if ($object->fk_user_author > 0) { |
758 | - $userfee=new User($this->db); |
|
759 | - $userfee->fetch($object->fk_user_author); $posy+=3; |
|
760 | - $pdf->SetXY($posx+2,$posy); |
|
761 | - $pdf->SetFont('','',10); |
|
762 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
763 | - $posy+=5; |
|
764 | - $pdf->SetXY($posx+2,$posy); |
|
765 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create,"day",false,$outputlangs),0,'L'); |
|
758 | + $userfee = new User($this->db); |
|
759 | + $userfee->fetch($object->fk_user_author); $posy += 3; |
|
760 | + $pdf->SetXY($posx + 2, $posy); |
|
761 | + $pdf->SetFont('', '', 10); |
|
762 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHOR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); |
|
763 | + $posy += 5; |
|
764 | + $pdf->SetXY($posx + 2, $posy); |
|
765 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create, "day", false, $outputlangs), 0, 'L'); |
|
766 | 766 | } |
767 | 767 | |
768 | - if ($object->fk_statut==99) |
|
768 | + if ($object->fk_statut == 99) |
|
769 | 769 | { |
770 | 770 | if ($object->fk_user_refuse > 0) { |
771 | - $userfee=new User($this->db); |
|
772 | - $userfee->fetch($object->fk_user_refuse); $posy+=6; |
|
773 | - $pdf->SetXY($posx+2,$posy); |
|
774 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("REFUSEUR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
775 | - $posy+=5; |
|
776 | - $pdf->SetXY($posx+2,$posy); |
|
777 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse),0,'L'); |
|
778 | - $posy+=5; |
|
779 | - $pdf->SetXY($posx+2,$posy); |
|
780 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outputlangs),0,'L'); |
|
771 | + $userfee = new User($this->db); |
|
772 | + $userfee->fetch($object->fk_user_refuse); $posy += 6; |
|
773 | + $pdf->SetXY($posx + 2, $posy); |
|
774 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("REFUSEUR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); |
|
775 | + $posy += 5; |
|
776 | + $pdf->SetXY($posx + 2, $posy); |
|
777 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse), 0, 'L'); |
|
778 | + $posy += 5; |
|
779 | + $pdf->SetXY($posx + 2, $posy); |
|
780 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse, "day", false, $outputlangs), 0, 'L'); |
|
781 | 781 | } |
782 | 782 | } |
783 | - else if($object->fk_statut==4) |
|
783 | + else if ($object->fk_statut == 4) |
|
784 | 784 | { |
785 | 785 | if ($object->fk_user_cancel > 0) { |
786 | - $userfee=new User($this->db); |
|
787 | - $userfee->fetch($object->fk_user_cancel); $posy+=6; |
|
788 | - $pdf->SetXY($posx+2,$posy); |
|
789 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("CANCEL_USER")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
790 | - $posy+=5; |
|
791 | - $pdf->SetXY($posx+2,$posy); |
|
792 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel),0,'L'); |
|
793 | - $posy+=5; |
|
794 | - $pdf->SetXY($posx+2,$posy); |
|
795 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel,"day",false,$outputlangs),0,'L'); |
|
786 | + $userfee = new User($this->db); |
|
787 | + $userfee->fetch($object->fk_user_cancel); $posy += 6; |
|
788 | + $pdf->SetXY($posx + 2, $posy); |
|
789 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("CANCEL_USER")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); |
|
790 | + $posy += 5; |
|
791 | + $pdf->SetXY($posx + 2, $posy); |
|
792 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel), 0, 'L'); |
|
793 | + $posy += 5; |
|
794 | + $pdf->SetXY($posx + 2, $posy); |
|
795 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel, "day", false, $outputlangs), 0, 'L'); |
|
796 | 796 | } |
797 | 797 | } |
798 | 798 | else |
799 | 799 | { |
800 | 800 | if ($object->fk_user_approve > 0) { |
801 | - $userfee=new User($this->db); |
|
802 | - $userfee->fetch($object->fk_user_approve); $posy+=6; |
|
803 | - $pdf->SetXY($posx+2,$posy); |
|
804 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("VALIDOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
805 | - $posy+=5; |
|
806 | - $pdf->SetXY($posx+2,$posy); |
|
807 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateApprove")." : ".dol_print_date($object->date_approve,"day",false,$outputlangs),0,'L'); |
|
801 | + $userfee = new User($this->db); |
|
802 | + $userfee->fetch($object->fk_user_approve); $posy += 6; |
|
803 | + $pdf->SetXY($posx + 2, $posy); |
|
804 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("VALIDOR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); |
|
805 | + $posy += 5; |
|
806 | + $pdf->SetXY($posx + 2, $posy); |
|
807 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateApprove")." : ".dol_print_date($object->date_approve, "day", false, $outputlangs), 0, 'L'); |
|
808 | 808 | } |
809 | 809 | } |
810 | 810 | |
811 | - if($object->fk_statut==6) { |
|
811 | + if ($object->fk_statut == 6) { |
|
812 | 812 | if ($object->fk_user_paid > 0) { |
813 | - $userfee=new User($this->db); |
|
814 | - $userfee->fetch($object->fk_user_paid); $posy+=6; |
|
815 | - $pdf->SetXY($posx+2,$posy); |
|
816 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHORPAIEMENT")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
817 | - $posy+=5; |
|
818 | - $pdf->SetXY($posx+2,$posy); |
|
819 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement,"day",false,$outputlangs),0,'L'); |
|
813 | + $userfee = new User($this->db); |
|
814 | + $userfee->fetch($object->fk_user_paid); $posy += 6; |
|
815 | + $pdf->SetXY($posx + 2, $posy); |
|
816 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHORPAIEMENT")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); |
|
817 | + $posy += 5; |
|
818 | + $pdf->SetXY($posx + 2, $posy); |
|
819 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement, "day", false, $outputlangs), 0, 'L'); |
|
820 | 820 | } |
821 | 821 | } |
822 | 822 | } |
@@ -835,46 +835,46 @@ discard block |
||
835 | 835 | * @param string $currency Currency code |
836 | 836 | * @return void |
837 | 837 | */ |
838 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
838 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') |
|
839 | 839 | { |
840 | 840 | global $conf; |
841 | 841 | |
842 | 842 | // Force to disable hidetop and hidebottom |
843 | - $hidebottom=0; |
|
844 | - if ($hidetop) $hidetop=-1; |
|
843 | + $hidebottom = 0; |
|
844 | + if ($hidetop) $hidetop = -1; |
|
845 | 845 | |
846 | 846 | $currency = !empty($currency) ? $currency : $conf->currency; |
847 | 847 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
848 | 848 | |
849 | 849 | // Amount in (at tab_top - 1) |
850 | - $pdf->SetTextColor(0,0,0); |
|
850 | + $pdf->SetTextColor(0, 0, 0); |
|
851 | 851 | $pdf->SetFont('', '', $default_font_size - 2); |
852 | 852 | $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); |
853 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top -4); |
|
853 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top - 4); |
|
854 | 854 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
855 | 855 | |
856 | - $pdf->SetDrawColor(128,128,128); |
|
856 | + $pdf->SetDrawColor(128, 128, 128); |
|
857 | 857 | |
858 | 858 | // Rect prend une longueur en 3eme param |
859 | - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); |
|
859 | + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height); |
|
860 | 860 | // line prend une position y en 3eme param |
861 | 861 | if (empty($hidetop)) { |
862 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); |
|
862 | + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); |
|
863 | 863 | } |
864 | 864 | |
865 | - $pdf->SetFont('','',8); |
|
865 | + $pdf->SetFont('', '', 8); |
|
866 | 866 | |
867 | 867 | // Accountancy piece |
868 | 868 | if (empty($hidetop)) { |
869 | - $pdf->SetXY($this->posxpiece-1, $tab_top+1); |
|
870 | - $pdf->MultiCell($this->posxcomment-$this->posxpiece-1, 1, '', '', 'R'); |
|
869 | + $pdf->SetXY($this->posxpiece - 1, $tab_top + 1); |
|
870 | + $pdf->MultiCell($this->posxcomment - $this->posxpiece - 1, 1, '', '', 'R'); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | // Comments |
874 | - $pdf->line($this->posxcomment-1, $tab_top, $this->posxcomment-1, $tab_top + $tab_height); |
|
874 | + $pdf->line($this->posxcomment - 1, $tab_top, $this->posxcomment - 1, $tab_top + $tab_height); |
|
875 | 875 | if (empty($hidetop)) { |
876 | - $pdf->SetXY($this->posxcomment-1, $tab_top+1); |
|
877 | - $pdf->MultiCell($this->posxdate-$this->posxcomment-1, 1, $outputlangs->transnoentities("Description"),'','L'); |
|
876 | + $pdf->SetXY($this->posxcomment - 1, $tab_top + 1); |
|
877 | + $pdf->MultiCell($this->posxdate - $this->posxcomment - 1, 1, $outputlangs->transnoentities("Description"), '', 'L'); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | // Date |
@@ -905,35 +905,35 @@ discard block |
||
905 | 905 | |
906 | 906 | // VAT |
907 | 907 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
908 | - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); |
|
908 | + $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height); |
|
909 | 909 | if (empty($hidetop)) { |
910 | - $pdf->SetXY($this->posxtva-1, $tab_top+1); |
|
911 | - $pdf->MultiCell($this->posxup-$this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C'); |
|
910 | + $pdf->SetXY($this->posxtva - 1, $tab_top + 1); |
|
911 | + $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C'); |
|
912 | 912 | } |
913 | 913 | } |
914 | 914 | |
915 | 915 | // Unit price |
916 | - $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); |
|
916 | + $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height); |
|
917 | 917 | if (empty($hidetop)) { |
918 | - $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
919 | - $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceU"),'','C'); |
|
918 | + $pdf->SetXY($this->posxup - 1, $tab_top + 1); |
|
919 | + $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceU"), '', 'C'); |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | // Quantity |
923 | - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
923 | + $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); |
|
924 | 924 | if (empty($hidetop)) { |
925 | - $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
926 | - $pdf->MultiCell($this->postotalttc-$this->posxqty - 1,2, $outputlangs->transnoentities("Qty"),'','R'); |
|
925 | + $pdf->SetXY($this->posxqty - 1, $tab_top + 1); |
|
926 | + $pdf->MultiCell($this->postotalttc - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'R'); |
|
927 | 927 | } |
928 | 928 | |
929 | 929 | // Total with all taxes |
930 | 930 | $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height); |
931 | 931 | if (empty($hidetop)) { |
932 | - $pdf->SetXY($this->postotalttc-1, $tab_top+1); |
|
933 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"),'','R'); |
|
932 | + $pdf->SetXY($this->postotalttc - 1, $tab_top + 1); |
|
933 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"), '', 'R'); |
|
934 | 934 | } |
935 | 935 | |
936 | - $pdf->SetTextColor(0,0,0); |
|
936 | + $pdf->SetTextColor(0, 0, 0); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | /** |
@@ -949,7 +949,7 @@ discard block |
||
949 | 949 | { |
950 | 950 | global $conf; |
951 | 951 | |
952 | - $sign=1; |
|
952 | + $sign = 1; |
|
953 | 953 | $tab3_posx = $this->marge_gauche; |
954 | 954 | $tab3_top = $posy; |
955 | 955 | $tab3_width = 88; |
@@ -957,93 +957,93 @@ discard block |
||
957 | 957 | |
958 | 958 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
959 | 959 | |
960 | - $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); |
|
961 | - $pdf->SetFont('','', $default_font_size - 2); |
|
960 | + $title = $outputlangs->transnoentities("PaymentsAlreadyDone"); |
|
961 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
962 | 962 | $pdf->SetXY($tab3_posx, $tab3_top - 4); |
963 | - $pdf->SetTextColor(0,0,0); |
|
963 | + $pdf->SetTextColor(0, 0, 0); |
|
964 | 964 | $pdf->MultiCell(60, 3, $title, 0, 'L', 0); |
965 | 965 | |
966 | - $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width+2, $tab3_top); // Top border line of table title |
|
966 | + $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width + 2, $tab3_top); // Top border line of table title |
|
967 | 967 | |
968 | - $pdf->SetXY($tab3_posx, $tab3_top+1); |
|
968 | + $pdf->SetXY($tab3_posx, $tab3_top + 1); |
|
969 | 969 | $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Date"), 0, 'L', 0); |
970 | - $pdf->SetXY($tab3_posx+19, $tab3_top+1); // Old value 17 |
|
970 | + $pdf->SetXY($tab3_posx + 19, $tab3_top + 1); // Old value 17 |
|
971 | 971 | $pdf->MultiCell(15, 3, $outputlangs->transnoentities("Amount"), 0, 'C', 0); |
972 | - $pdf->SetXY($tab3_posx+35, $tab3_top+1); |
|
972 | + $pdf->SetXY($tab3_posx + 35, $tab3_top + 1); |
|
973 | 973 | $pdf->MultiCell(30, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); |
974 | - if (! empty($conf->banque->enabled)) { |
|
975 | - $pdf->SetXY($tab3_posx+65, $tab3_top+1); |
|
974 | + if (!empty($conf->banque->enabled)) { |
|
975 | + $pdf->SetXY($tab3_posx + 65, $tab3_top + 1); |
|
976 | 976 | $pdf->MultiCell(25, 3, $outputlangs->transnoentities("BankAccount"), 0, 'L', 0); |
977 | 977 | } |
978 | - $pdf->line($tab3_posx, $tab3_top+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$tab3_height); // Bottom border line of table title |
|
978 | + $pdf->line($tab3_posx, $tab3_top + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $tab3_height); // Bottom border line of table title |
|
979 | 979 | |
980 | - $y=0; |
|
980 | + $y = 0; |
|
981 | 981 | |
982 | 982 | // Loop on each payment |
983 | 983 | // TODO create method on expensereport class to get payments |
984 | 984 | // Payments already done (from payment on this expensereport) |
985 | 985 | $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; |
986 | - $sql.= "c.code as p_code, c.libelle as payment_type,"; |
|
987 | - $sql.= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; |
|
988 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; |
|
989 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; |
|
990 | - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; |
|
991 | - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; |
|
992 | - $sql.= " WHERE e.rowid = '".$object->id."'"; |
|
993 | - $sql.= " AND p.fk_expensereport = e.rowid"; |
|
994 | - $sql.= ' AND e.entity IN ('.getEntity('expensereport').')'; |
|
995 | - $sql.= " ORDER BY dp"; |
|
996 | - |
|
997 | - $resql=$this->db->query($sql); |
|
986 | + $sql .= "c.code as p_code, c.libelle as payment_type,"; |
|
987 | + $sql .= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; |
|
988 | + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; |
|
989 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; |
|
990 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; |
|
991 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; |
|
992 | + $sql .= " WHERE e.rowid = '".$object->id."'"; |
|
993 | + $sql .= " AND p.fk_expensereport = e.rowid"; |
|
994 | + $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; |
|
995 | + $sql .= " ORDER BY dp"; |
|
996 | + |
|
997 | + $resql = $this->db->query($sql); |
|
998 | 998 | if ($resql) |
999 | 999 | { |
1000 | 1000 | $num = $this->db->num_rows($resql); |
1001 | - $i=0; |
|
1001 | + $i = 0; |
|
1002 | 1002 | while ($i < $num) { |
1003 | - $y+=$tab3_height; |
|
1003 | + $y += $tab3_height; |
|
1004 | 1004 | $row = $this->db->fetch_object($resql); |
1005 | 1005 | |
1006 | - $pdf->SetXY($tab3_posx, $tab3_top+$y+1); |
|
1007 | - $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->dp),'day',false,$outputlangs,true), 0, 'L', 0); |
|
1008 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y+1); |
|
1006 | + $pdf->SetXY($tab3_posx, $tab3_top + $y + 1); |
|
1007 | + $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->dp), 'day', false, $outputlangs, true), 0, 'L', 0); |
|
1008 | + $pdf->SetXY($tab3_posx + 17, $tab3_top + $y + 1); |
|
1009 | 1009 | $pdf->MultiCell(15, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'R', 0); |
1010 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y+1); |
|
1011 | - $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->p_code); |
|
1010 | + $pdf->SetXY($tab3_posx + 35, $tab3_top + $y + 1); |
|
1011 | + $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->p_code); |
|
1012 | 1012 | |
1013 | 1013 | $pdf->MultiCell(40, 3, $oper, 0, 'L', 0); |
1014 | - if (! empty($conf->banque->enabled)) { |
|
1015 | - $pdf->SetXY($tab3_posx+65, $tab3_top+$y+1); |
|
1014 | + if (!empty($conf->banque->enabled)) { |
|
1015 | + $pdf->SetXY($tab3_posx + 65, $tab3_top + $y + 1); |
|
1016 | 1016 | $pdf->MultiCell(30, 3, $row->baref, 0, 'L', 0); |
1017 | 1017 | } |
1018 | 1018 | |
1019 | - $pdf->line($tab3_posx, $tab3_top+$y+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$y+$tab3_height); // Bottom line border of table |
|
1019 | + $pdf->line($tab3_posx, $tab3_top + $y + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $y + $tab3_height); // Bottom line border of table |
|
1020 | 1020 | $totalpaid += $row->amount; |
1021 | 1021 | $i++; |
1022 | 1022 | } |
1023 | 1023 | if ($num > 0 && $object->paid == 0) |
1024 | 1024 | { |
1025 | - $y+=$tab3_height; |
|
1025 | + $y += $tab3_height; |
|
1026 | 1026 | |
1027 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1027 | + $pdf->SetXY($tab3_posx + 17, $tab3_top + $y); |
|
1028 | 1028 | $pdf->MultiCell(15, 3, price($totalpaid), 0, 'R', 0); |
1029 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1029 | + $pdf->SetXY($tab3_posx + 35, $tab3_top + $y); |
|
1030 | 1030 | $pdf->MultiCell(30, 4, $outputlangs->trans("AlreadyPaid"), 0, 'L', 0); |
1031 | - $y+=$tab3_height-2; |
|
1032 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1031 | + $y += $tab3_height - 2; |
|
1032 | + $pdf->SetXY($tab3_posx + 17, $tab3_top + $y); |
|
1033 | 1033 | $pdf->MultiCell(15, 3, price($object->total_ttc), 0, 'R', 0); |
1034 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1034 | + $pdf->SetXY($tab3_posx + 35, $tab3_top + $y); |
|
1035 | 1035 | $pdf->MultiCell(30, 4, $outputlangs->trans("AmountExpected"), 0, 'L', 0); |
1036 | - $y+=$tab3_height-2; |
|
1036 | + $y += $tab3_height - 2; |
|
1037 | 1037 | $remaintopay = $object->total_ttc - $totalpaid; |
1038 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1038 | + $pdf->SetXY($tab3_posx + 17, $tab3_top + $y); |
|
1039 | 1039 | $pdf->MultiCell(15, 3, price($remaintopay), 0, 'R', 0); |
1040 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1040 | + $pdf->SetXY($tab3_posx + 35, $tab3_top + $y); |
|
1041 | 1041 | $pdf->MultiCell(30, 4, $outputlangs->trans("RemainderToPay"), 0, 'L', 0); |
1042 | 1042 | } |
1043 | 1043 | } |
1044 | 1044 | else |
1045 | 1045 | { |
1046 | - $this->error=$this->db->lasterror(); |
|
1046 | + $this->error = $this->db->lasterror(); |
|
1047 | 1047 | return -1; |
1048 | 1048 | } |
1049 | 1049 | } |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | * @param int $hidefreetext 1=Hide free text |
1058 | 1058 | * @return int Return height of bottom margin including footer text |
1059 | 1059 | */ |
1060 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1060 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
1061 | 1061 | { |
1062 | 1062 | global $conf; |
1063 | 1063 | $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
@@ -156,7 +156,10 @@ discard block |
||
156 | 156 | |
157 | 157 | // Get source company |
158 | 158 | $this->emetteur=$mysoc; |
159 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
159 | + if (empty($this->emetteur->country_code)) { |
|
160 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
161 | + } |
|
162 | + // By default, if was not defined |
|
160 | 163 | |
161 | 164 | // Define position of columns |
162 | 165 | $this->posxpiece=$this->marge_gauche+1; |
@@ -174,9 +177,11 @@ discard block |
||
174 | 177 | // $this->posxqty-=20; |
175 | 178 | // $this->postotalttc-=20; |
176 | 179 | // } |
177 | - if ($this->page_largeur < 210) // To work with US executive format |
|
180 | + if ($this->page_largeur < 210) { |
|
181 | + // To work with US executive format |
|
178 | 182 | { |
179 | 183 | $this->posxdate-=20; |
184 | + } |
|
180 | 185 | $this->posxtype-=20; |
181 | 186 | $this->posxprojet-=20; |
182 | 187 | $this->posxtva-=20; |
@@ -209,9 +214,13 @@ discard block |
||
209 | 214 | // phpcs:enable |
210 | 215 | global $user, $langs, $conf, $mysoc, $db, $hookmanager; |
211 | 216 | |
212 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
217 | + if (! is_object($outputlangs)) { |
|
218 | + $outputlangs=$langs; |
|
219 | + } |
|
213 | 220 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
214 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
221 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
222 | + $outputlangs->charset_output='ISO-8859-1'; |
|
223 | + } |
|
215 | 224 | |
216 | 225 | // Load traductions files requiredby by page |
217 | 226 | $outputlangs->loadLangs(array("main", "trips", "projects", "dict", "bills", "banks")); |
@@ -223,8 +232,7 @@ discard block |
||
223 | 232 | if ($object->specimen) { |
224 | 233 | $dir = $conf->expensereport->dir_output; |
225 | 234 | $file = $dir . "/SPECIMEN.pdf"; |
226 | - } |
|
227 | - else |
|
235 | + } else |
|
228 | 236 | { |
229 | 237 | $objectref = dol_sanitizeFileName($object->ref); |
230 | 238 | $dir = $conf->expensereport->dir_output . "/" . $objectref; |
@@ -259,7 +267,9 @@ discard block |
||
259 | 267 | $heightforinfotot = 40; // Height reserved to output the info and total part |
260 | 268 | $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 |
261 | 269 | $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin) |
262 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
270 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) { |
|
271 | + $heightforfooter+= 6; |
|
272 | + } |
|
263 | 273 | |
264 | 274 | $pdf->SetAutoPageBreak(1,0); |
265 | 275 | |
@@ -285,13 +295,17 @@ discard block |
||
285 | 295 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
286 | 296 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
287 | 297 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Trips")); |
288 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
298 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
299 | + $pdf->SetCompression(false); |
|
300 | + } |
|
289 | 301 | |
290 | 302 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
291 | 303 | |
292 | 304 | // New page |
293 | 305 | $pdf->AddPage(); |
294 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
306 | + if (! empty($tplidx)) { |
|
307 | + $pdf->useTemplate($tplidx); |
|
308 | + } |
|
295 | 309 | $pagenb++; |
296 | 310 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
297 | 311 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -313,7 +327,9 @@ discard block |
||
313 | 327 | $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
314 | 328 | $salerepobj=new User($this->db); |
315 | 329 | $salerepobj->fetch($salereparray[0]['id']); |
316 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
330 | + if (! empty($salerepobj->signature)) { |
|
331 | + $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
332 | + } |
|
317 | 333 | } |
318 | 334 | } |
319 | 335 | if ($notetoshow) |
@@ -335,8 +351,7 @@ discard block |
||
335 | 351 | |
336 | 352 | $tab_height = $tab_height - $height_note; |
337 | 353 | $tab_top = $nexY+6; |
338 | - } |
|
339 | - else |
|
354 | + } else |
|
340 | 355 | { |
341 | 356 | $height_note=0; |
342 | 357 | } |
@@ -372,18 +387,20 @@ discard block |
||
372 | 387 | if ($i == ($nblignes-1)) { |
373 | 388 | // No more lines, and no space left to show total, so we create a new page |
374 | 389 | $pdf->AddPage('', '', true); |
375 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
376 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
390 | + if (! empty($tplidx)) { |
|
391 | + $pdf->useTemplate($tplidx); |
|
392 | + } |
|
393 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
394 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
395 | + } |
|
377 | 396 | $pdf->setPage($pageposafter+1); |
378 | 397 | } |
379 | - } |
|
380 | - else |
|
398 | + } else |
|
381 | 399 | { |
382 | 400 | // We found a page break |
383 | 401 | $showpricebeforepagebreak=0; |
384 | 402 | } |
385 | - } |
|
386 | - else // No pagebreak |
|
403 | + } else // No pagebreak |
|
387 | 404 | { |
388 | 405 | $pdf->commitTransaction(); |
389 | 406 | } |
@@ -419,8 +436,7 @@ discard block |
||
419 | 436 | if ($pagenb == 1) |
420 | 437 | { |
421 | 438 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
422 | - } |
|
423 | - else |
|
439 | + } else |
|
424 | 440 | { |
425 | 441 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
426 | 442 | } |
@@ -428,24 +444,29 @@ discard block |
||
428 | 444 | $pagenb++; |
429 | 445 | $pdf->setPage($pagenb); |
430 | 446 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
431 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
447 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
448 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
449 | + } |
|
432 | 450 | } |
433 | 451 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
434 | 452 | { |
435 | 453 | if ($pagenb == 1) |
436 | 454 | { |
437 | 455 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
438 | - } |
|
439 | - else |
|
456 | + } else |
|
440 | 457 | { |
441 | 458 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
442 | 459 | } |
443 | 460 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
444 | 461 | // New page |
445 | 462 | $pdf->AddPage(); |
446 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
463 | + if (! empty($tplidx)) { |
|
464 | + $pdf->useTemplate($tplidx); |
|
465 | + } |
|
447 | 466 | $pagenb++; |
448 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
467 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
468 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
469 | + } |
|
449 | 470 | } |
450 | 471 | } |
451 | 472 | |
@@ -454,8 +475,7 @@ discard block |
||
454 | 475 | { |
455 | 476 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
456 | 477 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
457 | - } |
|
458 | - else |
|
478 | + } else |
|
459 | 479 | { |
460 | 480 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
461 | 481 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -499,7 +519,9 @@ discard block |
||
499 | 519 | |
500 | 520 | // Pied de page |
501 | 521 | $this->_pagefoot($pdf,$object,$outputlangs); |
502 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPage(); |
|
522 | + if (method_exists($pdf,'AliasNbPages')) { |
|
523 | + $pdf->AliasNbPage(); |
|
524 | + } |
|
503 | 525 | |
504 | 526 | $pdf->Close(); |
505 | 527 | |
@@ -511,20 +533,19 @@ discard block |
||
511 | 533 | global $action; |
512 | 534 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
513 | 535 | |
514 | - if (! empty($conf->global->MAIN_UMASK)) |
|
515 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
536 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
537 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
538 | + } |
|
516 | 539 | |
517 | 540 | $this->result = array('fullpath'=>$file); |
518 | 541 | |
519 | 542 | return 1; // Pas d'erreur |
520 | - } |
|
521 | - else |
|
543 | + } else |
|
522 | 544 | { |
523 | 545 | $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
524 | 546 | return 0; |
525 | 547 | } |
526 | - } |
|
527 | - else |
|
548 | + } else |
|
528 | 549 | { |
529 | 550 | $this->error=$langs->trans("ErrorConstantNotDefined","EXPENSEREPORT_OUTPUTDIR"); |
530 | 551 | return 0; |
@@ -662,8 +683,7 @@ discard block |
||
662 | 683 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
663 | 684 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
664 | 685 | } |
665 | - } |
|
666 | - else |
|
686 | + } else |
|
667 | 687 | { |
668 | 688 | $text=$this->emetteur->name; |
669 | 689 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -708,19 +728,29 @@ discard block |
||
708 | 728 | $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town); |
709 | 729 | $carac_emetteur .= "\n"; |
710 | 730 | // Phone |
711 | - if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); |
|
731 | + if ($this->emetteur->phone) { |
|
732 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); |
|
733 | + } |
|
712 | 734 | // Fax |
713 | - if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); |
|
735 | + if ($this->emetteur->fax) { |
|
736 | + $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); |
|
737 | + } |
|
714 | 738 | |
715 | - if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); |
|
739 | + if ($this->emetteur->email) { |
|
740 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); |
|
741 | + } |
|
716 | 742 | // Web |
717 | - if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); |
|
743 | + if ($this->emetteur->url) { |
|
744 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); |
|
745 | + } |
|
718 | 746 | |
719 | 747 | // Show sender |
720 | 748 | $posy=50; |
721 | 749 | $posx=$this->marge_gauche; |
722 | 750 | $hautcadre=40; |
723 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118; |
|
751 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
752 | + $posx=118; |
|
753 | + } |
|
724 | 754 | |
725 | 755 | // Show sender frame |
726 | 756 | $pdf->SetTextColor(0, 0, 0); |
@@ -779,8 +809,7 @@ discard block |
||
779 | 809 | $pdf->SetXY($posx+2,$posy); |
780 | 810 | $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outputlangs),0,'L'); |
781 | 811 | } |
782 | - } |
|
783 | - else if($object->fk_statut==4) |
|
812 | + } else if($object->fk_statut==4) |
|
784 | 813 | { |
785 | 814 | if ($object->fk_user_cancel > 0) { |
786 | 815 | $userfee=new User($this->db); |
@@ -794,8 +823,7 @@ discard block |
||
794 | 823 | $pdf->SetXY($posx+2,$posy); |
795 | 824 | $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel,"day",false,$outputlangs),0,'L'); |
796 | 825 | } |
797 | - } |
|
798 | - else |
|
826 | + } else |
|
799 | 827 | { |
800 | 828 | if ($object->fk_user_approve > 0) { |
801 | 829 | $userfee=new User($this->db); |
@@ -841,7 +869,9 @@ discard block |
||
841 | 869 | |
842 | 870 | // Force to disable hidetop and hidebottom |
843 | 871 | $hidebottom=0; |
844 | - if ($hidetop) $hidetop=-1; |
|
872 | + if ($hidetop) { |
|
873 | + $hidetop=-1; |
|
874 | + } |
|
845 | 875 | |
846 | 876 | $currency = !empty($currency) ? $currency : $conf->currency; |
847 | 877 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1040,8 +1070,7 @@ discard block |
||
1040 | 1070 | $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
1041 | 1071 | $pdf->MultiCell(30, 4, $outputlangs->trans("RemainderToPay"), 0, 'L', 0); |
1042 | 1072 | } |
1043 | - } |
|
1044 | - else |
|
1073 | + } else |
|
1045 | 1074 | { |
1046 | 1075 | $this->error=$this->db->lasterror(); |
1047 | 1076 | return -1; |
@@ -28,30 +28,30 @@ discard block |
||
28 | 28 | */ |
29 | 29 | class mod_expensereport_jade extends ModeleNumRefExpenseReport |
30 | 30 | { |
31 | - /** |
|
31 | + /** |
|
32 | 32 | * Dolibarr version of the loaded document |
33 | 33 | * @public string |
34 | 34 | */ |
35 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
35 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
36 | 36 | |
37 | - public $prefix='ER'; |
|
37 | + public $prefix='ER'; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var string Error code (or message) |
|
41 | - */ |
|
42 | - public $error=''; |
|
39 | + /** |
|
40 | + * @var string Error code (or message) |
|
41 | + */ |
|
42 | + public $error=''; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var string Nom du modele |
|
46 | - * @deprecated |
|
47 | - * @see name |
|
48 | - */ |
|
49 | - public $nom='Jade'; |
|
44 | + /** |
|
45 | + * @var string Nom du modele |
|
46 | + * @deprecated |
|
47 | + * @see name |
|
48 | + */ |
|
49 | + public $nom='Jade'; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var string model name |
|
53 | - */ |
|
54 | - public $name='Jade'; |
|
51 | + /** |
|
52 | + * @var string model name |
|
53 | + */ |
|
54 | + public $name='Jade'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -61,152 +61,152 @@ discard block |
||
61 | 61 | */ |
62 | 62 | function info() |
63 | 63 | { |
64 | - global $langs; |
|
65 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
64 | + global $langs; |
|
65 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * Renvoi un exemple de numerotation |
|
71 | - * |
|
72 | - * @return string Example |
|
73 | - */ |
|
74 | - function getExample() |
|
75 | - { |
|
76 | - return $this->prefix."0501-0001"; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
82 | - * de conflits qui empechera cette numerotation de fonctionner. |
|
83 | - * |
|
84 | - * @return boolean false si conflit, true si ok |
|
85 | - */ |
|
86 | - function canBeActivated() |
|
87 | - { |
|
88 | - global $conf,$langs,$db; |
|
89 | - |
|
90 | - $coyymm=''; $max=''; |
|
91 | - |
|
92 | - $posindice=8; |
|
93 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
94 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
95 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
96 | - $sql.= " AND entity = ".$conf->entity; |
|
97 | - |
|
98 | - $resql=$db->query($sql); |
|
99 | - if ($resql) |
|
100 | - { |
|
101 | - $row = $db->fetch_row($resql); |
|
102 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
103 | - } |
|
104 | - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
105 | - { |
|
106 | - $langs->load("errors"); |
|
107 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
108 | - return false; |
|
109 | - } |
|
110 | - |
|
111 | - return true; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Return next free value |
|
116 | - * |
|
117 | - * @param Object $object Object we need next value for |
|
118 | - * @return string Value if KO, <0 if KO |
|
119 | - */ |
|
120 | - function getNextValue($object) |
|
121 | - { |
|
122 | - global $db,$conf; |
|
123 | - |
|
124 | - // For backward compatibility and restore old behavior to get ref of expense report |
|
125 | - if ($conf->global->EXPENSEREPORT_USE_OLD_NUMBERING_RULE) |
|
126 | - { |
|
127 | - $fuser = null; |
|
128 | - if ($object->fk_user_author > 0) |
|
129 | - { |
|
130 | - $fuser=new User($db); |
|
131 | - $fuser->fetch($object->fk_user_author); |
|
132 | - } |
|
133 | - |
|
134 | - $expld_car = (empty($conf->global->NDF_EXPLODE_CHAR))?"-":$conf->global->NDF_EXPLODE_CHAR; |
|
135 | - $num_car = (empty($conf->global->NDF_NUM_CAR_REF))?"5":$conf->global->NDF_NUM_CAR_REF; |
|
136 | - |
|
137 | - $sql = 'SELECT MAX(de.ref_number_int) as max'; |
|
138 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport de'; |
|
139 | - |
|
140 | - $result = $db->query($sql); |
|
141 | - |
|
142 | - if($db->num_rows($result) > 0): |
|
143 | - $objp = $db->fetch_object($result); |
|
144 | - $newref = $objp->max; |
|
145 | - $newref++; |
|
146 | - while(strlen($newref) < $num_car): |
|
147 | - $newref = "0".$newref; |
|
148 | - endwhile; |
|
149 | - else: |
|
150 | - $newref = 1; |
|
151 | - while(strlen($newref) < $num_car): |
|
152 | - $newref = "0".$newref; |
|
153 | - endwhile; |
|
154 | - endif; |
|
155 | - |
|
156 | - $ref_number_int = ($newref+1)-1; |
|
157 | - $update_number_int = true; |
|
158 | - |
|
159 | - $user_author_infos = dolGetFirstLastname($fuser->firstname, $fuser->lastname); |
|
160 | - |
|
161 | - $prefix="ER"; |
|
162 | - if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX; |
|
163 | - $newref = str_replace(' ','_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut,'%y%m%d'); |
|
164 | - |
|
165 | - $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.$ref_number_int.' WHERE rowid = '.$object->id; |
|
166 | - $resqlbis = $db->query($sqlbis); |
|
167 | - if (! $resqlbis) |
|
168 | - { |
|
169 | - dol_print_error($resqlbis); |
|
170 | - exit; |
|
171 | - } |
|
172 | - |
|
173 | - dol_syslog("mod_expensereport_jade::getNextValue return ".$newref); |
|
174 | - return $newref; |
|
175 | - } |
|
176 | - |
|
177 | - // D'abord on recupere la valeur max |
|
178 | - $posindice=8; |
|
179 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
180 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
181 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
182 | - $sql.= " AND entity = ".$conf->entity; |
|
183 | - |
|
184 | - $resql=$db->query($sql); |
|
185 | - if ($resql) |
|
186 | - { |
|
187 | - $obj = $db->fetch_object($resql); |
|
188 | - if ($obj) $max = intval($obj->max); |
|
189 | - else $max=0; |
|
190 | - } |
|
191 | - else |
|
192 | - { |
|
193 | - dol_syslog("mod_expensereport_jade::getNextValue", LOG_DEBUG); |
|
194 | - return 0; |
|
195 | - } |
|
196 | - |
|
197 | - $date=$object->date_valid; // $object->date does not exists |
|
198 | - if (empty($date)) |
|
199 | - { |
|
200 | - $this->error = 'Date valid not defined'; |
|
201 | - return 0; |
|
202 | - } |
|
203 | - |
|
204 | - $yymm = strftime("%y%m",$date); |
|
205 | - |
|
206 | - 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 |
|
207 | - else $num = sprintf("%04s",$max+1); |
|
208 | - |
|
209 | - dol_syslog("mod_expensereport_jade::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
210 | - return $this->prefix.$yymm."-".$num; |
|
211 | - } |
|
69 | + /** |
|
70 | + * Renvoi un exemple de numerotation |
|
71 | + * |
|
72 | + * @return string Example |
|
73 | + */ |
|
74 | + function getExample() |
|
75 | + { |
|
76 | + return $this->prefix."0501-0001"; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
82 | + * de conflits qui empechera cette numerotation de fonctionner. |
|
83 | + * |
|
84 | + * @return boolean false si conflit, true si ok |
|
85 | + */ |
|
86 | + function canBeActivated() |
|
87 | + { |
|
88 | + global $conf,$langs,$db; |
|
89 | + |
|
90 | + $coyymm=''; $max=''; |
|
91 | + |
|
92 | + $posindice=8; |
|
93 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
94 | + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
95 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
96 | + $sql.= " AND entity = ".$conf->entity; |
|
97 | + |
|
98 | + $resql=$db->query($sql); |
|
99 | + if ($resql) |
|
100 | + { |
|
101 | + $row = $db->fetch_row($resql); |
|
102 | + if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
103 | + } |
|
104 | + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
105 | + { |
|
106 | + $langs->load("errors"); |
|
107 | + $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
108 | + return false; |
|
109 | + } |
|
110 | + |
|
111 | + return true; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Return next free value |
|
116 | + * |
|
117 | + * @param Object $object Object we need next value for |
|
118 | + * @return string Value if KO, <0 if KO |
|
119 | + */ |
|
120 | + function getNextValue($object) |
|
121 | + { |
|
122 | + global $db,$conf; |
|
123 | + |
|
124 | + // For backward compatibility and restore old behavior to get ref of expense report |
|
125 | + if ($conf->global->EXPENSEREPORT_USE_OLD_NUMBERING_RULE) |
|
126 | + { |
|
127 | + $fuser = null; |
|
128 | + if ($object->fk_user_author > 0) |
|
129 | + { |
|
130 | + $fuser=new User($db); |
|
131 | + $fuser->fetch($object->fk_user_author); |
|
132 | + } |
|
133 | + |
|
134 | + $expld_car = (empty($conf->global->NDF_EXPLODE_CHAR))?"-":$conf->global->NDF_EXPLODE_CHAR; |
|
135 | + $num_car = (empty($conf->global->NDF_NUM_CAR_REF))?"5":$conf->global->NDF_NUM_CAR_REF; |
|
136 | + |
|
137 | + $sql = 'SELECT MAX(de.ref_number_int) as max'; |
|
138 | + $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport de'; |
|
139 | + |
|
140 | + $result = $db->query($sql); |
|
141 | + |
|
142 | + if($db->num_rows($result) > 0): |
|
143 | + $objp = $db->fetch_object($result); |
|
144 | + $newref = $objp->max; |
|
145 | + $newref++; |
|
146 | + while(strlen($newref) < $num_car): |
|
147 | + $newref = "0".$newref; |
|
148 | + endwhile; |
|
149 | + else: |
|
150 | + $newref = 1; |
|
151 | + while(strlen($newref) < $num_car): |
|
152 | + $newref = "0".$newref; |
|
153 | + endwhile; |
|
154 | + endif; |
|
155 | + |
|
156 | + $ref_number_int = ($newref+1)-1; |
|
157 | + $update_number_int = true; |
|
158 | + |
|
159 | + $user_author_infos = dolGetFirstLastname($fuser->firstname, $fuser->lastname); |
|
160 | + |
|
161 | + $prefix="ER"; |
|
162 | + if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX; |
|
163 | + $newref = str_replace(' ','_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut,'%y%m%d'); |
|
164 | + |
|
165 | + $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.$ref_number_int.' WHERE rowid = '.$object->id; |
|
166 | + $resqlbis = $db->query($sqlbis); |
|
167 | + if (! $resqlbis) |
|
168 | + { |
|
169 | + dol_print_error($resqlbis); |
|
170 | + exit; |
|
171 | + } |
|
172 | + |
|
173 | + dol_syslog("mod_expensereport_jade::getNextValue return ".$newref); |
|
174 | + return $newref; |
|
175 | + } |
|
176 | + |
|
177 | + // D'abord on recupere la valeur max |
|
178 | + $posindice=8; |
|
179 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
180 | + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
181 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
182 | + $sql.= " AND entity = ".$conf->entity; |
|
183 | + |
|
184 | + $resql=$db->query($sql); |
|
185 | + if ($resql) |
|
186 | + { |
|
187 | + $obj = $db->fetch_object($resql); |
|
188 | + if ($obj) $max = intval($obj->max); |
|
189 | + else $max=0; |
|
190 | + } |
|
191 | + else |
|
192 | + { |
|
193 | + dol_syslog("mod_expensereport_jade::getNextValue", LOG_DEBUG); |
|
194 | + return 0; |
|
195 | + } |
|
196 | + |
|
197 | + $date=$object->date_valid; // $object->date does not exists |
|
198 | + if (empty($date)) |
|
199 | + { |
|
200 | + $this->error = 'Date valid not defined'; |
|
201 | + return 0; |
|
202 | + } |
|
203 | + |
|
204 | + $yymm = strftime("%y%m",$date); |
|
205 | + |
|
206 | + 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 |
|
207 | + else $num = sprintf("%04s",$max+1); |
|
208 | + |
|
209 | + dol_syslog("mod_expensereport_jade::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
210 | + return $this->prefix.$yymm."-".$num; |
|
211 | + } |
|
212 | 212 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * \ingroup expensereport |
22 | 22 | * \brief File of class to manage customer order numbering rules Jade |
23 | 23 | */ |
24 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/expensereport/modules_expensereport.php'; |
|
24 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Class to manage customer order numbering rules Jade |
@@ -32,26 +32,26 @@ discard block |
||
32 | 32 | * Dolibarr version of the loaded document |
33 | 33 | * @public string |
34 | 34 | */ |
35 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
35 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
36 | 36 | |
37 | - public $prefix='ER'; |
|
37 | + public $prefix = 'ER'; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var string Error code (or message) |
41 | 41 | */ |
42 | - public $error=''; |
|
42 | + public $error = ''; |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @var string Nom du modele |
46 | 46 | * @deprecated |
47 | 47 | * @see name |
48 | 48 | */ |
49 | - public $nom='Jade'; |
|
49 | + public $nom = 'Jade'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var string model name |
53 | 53 | */ |
54 | - public $name='Jade'; |
|
54 | + public $name = 'Jade'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | function info() |
63 | 63 | { |
64 | 64 | global $langs; |
65 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
65 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
@@ -85,26 +85,26 @@ discard block |
||
85 | 85 | */ |
86 | 86 | function canBeActivated() |
87 | 87 | { |
88 | - global $conf,$langs,$db; |
|
88 | + global $conf, $langs, $db; |
|
89 | 89 | |
90 | - $coyymm=''; $max=''; |
|
90 | + $coyymm = ''; $max = ''; |
|
91 | 91 | |
92 | - $posindice=8; |
|
92 | + $posindice = 8; |
|
93 | 93 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
94 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
95 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
96 | - $sql.= " AND entity = ".$conf->entity; |
|
94 | + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
95 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
96 | + $sql .= " AND entity = ".$conf->entity; |
|
97 | 97 | |
98 | - $resql=$db->query($sql); |
|
98 | + $resql = $db->query($sql); |
|
99 | 99 | if ($resql) |
100 | 100 | { |
101 | 101 | $row = $db->fetch_row($resql); |
102 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
102 | + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
103 | 103 | } |
104 | - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
104 | + if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) |
|
105 | 105 | { |
106 | 106 | $langs->load("errors"); |
107 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
107 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
108 | 108 | return false; |
109 | 109 | } |
110 | 110 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function getNextValue($object) |
121 | 121 | { |
122 | - global $db,$conf; |
|
122 | + global $db, $conf; |
|
123 | 123 | |
124 | 124 | // For backward compatibility and restore old behavior to get ref of expense report |
125 | 125 | if ($conf->global->EXPENSEREPORT_USE_OLD_NUMBERING_RULE) |
@@ -127,44 +127,44 @@ discard block |
||
127 | 127 | $fuser = null; |
128 | 128 | if ($object->fk_user_author > 0) |
129 | 129 | { |
130 | - $fuser=new User($db); |
|
130 | + $fuser = new User($db); |
|
131 | 131 | $fuser->fetch($object->fk_user_author); |
132 | 132 | } |
133 | 133 | |
134 | - $expld_car = (empty($conf->global->NDF_EXPLODE_CHAR))?"-":$conf->global->NDF_EXPLODE_CHAR; |
|
135 | - $num_car = (empty($conf->global->NDF_NUM_CAR_REF))?"5":$conf->global->NDF_NUM_CAR_REF; |
|
134 | + $expld_car = (empty($conf->global->NDF_EXPLODE_CHAR)) ? "-" : $conf->global->NDF_EXPLODE_CHAR; |
|
135 | + $num_car = (empty($conf->global->NDF_NUM_CAR_REF)) ? "5" : $conf->global->NDF_NUM_CAR_REF; |
|
136 | 136 | |
137 | 137 | $sql = 'SELECT MAX(de.ref_number_int) as max'; |
138 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport de'; |
|
138 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport de'; |
|
139 | 139 | |
140 | 140 | $result = $db->query($sql); |
141 | 141 | |
142 | - if($db->num_rows($result) > 0): |
|
142 | + if ($db->num_rows($result) > 0): |
|
143 | 143 | $objp = $db->fetch_object($result); |
144 | 144 | $newref = $objp->max; |
145 | 145 | $newref++; |
146 | - while(strlen($newref) < $num_car): |
|
146 | + while (strlen($newref) < $num_car): |
|
147 | 147 | $newref = "0".$newref; |
148 | 148 | endwhile; |
149 | 149 | else: |
150 | 150 | $newref = 1; |
151 | - while(strlen($newref) < $num_car): |
|
151 | + while (strlen($newref) < $num_car): |
|
152 | 152 | $newref = "0".$newref; |
153 | 153 | endwhile; |
154 | 154 | endif; |
155 | 155 | |
156 | - $ref_number_int = ($newref+1)-1; |
|
156 | + $ref_number_int = ($newref + 1) - 1; |
|
157 | 157 | $update_number_int = true; |
158 | 158 | |
159 | 159 | $user_author_infos = dolGetFirstLastname($fuser->firstname, $fuser->lastname); |
160 | 160 | |
161 | - $prefix="ER"; |
|
162 | - if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX; |
|
163 | - $newref = str_replace(' ','_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut,'%y%m%d'); |
|
161 | + $prefix = "ER"; |
|
162 | + if (!empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix = $conf->global->EXPENSE_REPORT_PREFIX; |
|
163 | + $newref = str_replace(' ', '_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut, '%y%m%d'); |
|
164 | 164 | |
165 | 165 | $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.$ref_number_int.' WHERE rowid = '.$object->id; |
166 | 166 | $resqlbis = $db->query($sqlbis); |
167 | - if (! $resqlbis) |
|
167 | + if (!$resqlbis) |
|
168 | 168 | { |
169 | 169 | dol_print_error($resqlbis); |
170 | 170 | exit; |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | // D'abord on recupere la valeur max |
178 | - $posindice=8; |
|
178 | + $posindice = 8; |
|
179 | 179 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
180 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
181 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
182 | - $sql.= " AND entity = ".$conf->entity; |
|
180 | + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
181 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
182 | + $sql .= " AND entity = ".$conf->entity; |
|
183 | 183 | |
184 | - $resql=$db->query($sql); |
|
184 | + $resql = $db->query($sql); |
|
185 | 185 | if ($resql) |
186 | 186 | { |
187 | 187 | $obj = $db->fetch_object($resql); |
188 | 188 | if ($obj) $max = intval($obj->max); |
189 | - else $max=0; |
|
189 | + else $max = 0; |
|
190 | 190 | } |
191 | 191 | else |
192 | 192 | { |
@@ -194,17 +194,17 @@ discard block |
||
194 | 194 | return 0; |
195 | 195 | } |
196 | 196 | |
197 | - $date=$object->date_valid; // $object->date does not exists |
|
197 | + $date = $object->date_valid; // $object->date does not exists |
|
198 | 198 | if (empty($date)) |
199 | 199 | { |
200 | 200 | $this->error = 'Date valid not defined'; |
201 | 201 | return 0; |
202 | 202 | } |
203 | 203 | |
204 | - $yymm = strftime("%y%m",$date); |
|
204 | + $yymm = strftime("%y%m", $date); |
|
205 | 205 | |
206 | - 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 |
|
207 | - else $num = sprintf("%04s",$max+1); |
|
206 | + 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 |
|
207 | + else $num = sprintf("%04s", $max + 1); |
|
208 | 208 | |
209 | 209 | dol_syslog("mod_expensereport_jade::getNextValue return ".$this->prefix.$yymm."-".$num); |
210 | 210 | return $this->prefix.$yymm."-".$num; |
@@ -146,8 +146,10 @@ discard block |
||
146 | 146 | while(strlen($newref) < $num_car): |
147 | 147 | $newref = "0".$newref; |
148 | 148 | endwhile; |
149 | - else: |
|
149 | + else { |
|
150 | + : |
|
150 | 151 | $newref = 1; |
152 | + } |
|
151 | 153 | while(strlen($newref) < $num_car): |
152 | 154 | $newref = "0".$newref; |
153 | 155 | endwhile; |
@@ -159,7 +161,9 @@ discard block |
||
159 | 161 | $user_author_infos = dolGetFirstLastname($fuser->firstname, $fuser->lastname); |
160 | 162 | |
161 | 163 | $prefix="ER"; |
162 | - if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX; |
|
164 | + if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) { |
|
165 | + $prefix=$conf->global->EXPENSE_REPORT_PREFIX; |
|
166 | + } |
|
163 | 167 | $newref = str_replace(' ','_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut,'%y%m%d'); |
164 | 168 | |
165 | 169 | $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.$ref_number_int.' WHERE rowid = '.$object->id; |
@@ -185,10 +189,12 @@ discard block |
||
185 | 189 | if ($resql) |
186 | 190 | { |
187 | 191 | $obj = $db->fetch_object($resql); |
188 | - if ($obj) $max = intval($obj->max); |
|
189 | - else $max=0; |
|
190 | - } |
|
191 | - else |
|
192 | + if ($obj) { |
|
193 | + $max = intval($obj->max); |
|
194 | + } else { |
|
195 | + $max=0; |
|
196 | + } |
|
197 | + } else |
|
192 | 198 | { |
193 | 199 | dol_syslog("mod_expensereport_jade::getNextValue", LOG_DEBUG); |
194 | 200 | return 0; |
@@ -203,8 +209,13 @@ discard block |
||
203 | 209 | |
204 | 210 | $yymm = strftime("%y%m",$date); |
205 | 211 | |
206 | - 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 |
|
207 | - else $num = sprintf("%04s",$max+1); |
|
212 | + if ($max >= (pow(10, 4) - 1)) { |
|
213 | + $num=$max+1; |
|
214 | + } |
|
215 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
216 | + else { |
|
217 | + $num = sprintf("%04s",$max+1); |
|
218 | + } |
|
208 | 219 | |
209 | 220 | dol_syslog("mod_expensereport_jade::getNextValue return ".$this->prefix.$yymm."-".$num); |
210 | 221 | return $this->prefix.$yymm."-".$num; |
@@ -30,28 +30,28 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class mod_expensereport_sand extends ModeleNumRefExpenseReport |
32 | 32 | { |
33 | - /** |
|
33 | + /** |
|
34 | 34 | * Dolibarr version of the loaded document |
35 | 35 | * @public string |
36 | 36 | */ |
37 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var string Error message |
|
41 | - */ |
|
42 | - public $error = ''; |
|
39 | + /** |
|
40 | + * @var string Error message |
|
41 | + */ |
|
42 | + public $error = ''; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var string Nom du modele |
|
46 | - * @deprecated |
|
47 | - * @see name |
|
48 | - */ |
|
49 | - public $nom='Sand'; |
|
44 | + /** |
|
45 | + * @var string Nom du modele |
|
46 | + * @deprecated |
|
47 | + * @see name |
|
48 | + */ |
|
49 | + public $nom='Sand'; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var string model name |
|
53 | - */ |
|
54 | - public $name='Sand'; |
|
51 | + /** |
|
52 | + * @var string model name |
|
53 | + */ |
|
54 | + public $name='Sand'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -59,39 +59,39 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return string Texte descripif |
61 | 61 | */ |
62 | - function info() |
|
62 | + function info() |
|
63 | 63 | { |
64 | - global $conf, $langs; |
|
64 | + global $conf, $langs; |
|
65 | 65 | |
66 | - $langs->load("bills"); |
|
66 | + $langs->load("bills"); |
|
67 | 67 | |
68 | - $form = new Form($this->db); |
|
68 | + $form = new Form($this->db); |
|
69 | 69 | |
70 | - $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
71 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | - $texte.= '<input type="hidden" name="maskconst" value="EXPENSEREPORT_SAND_MASK">'; |
|
75 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
70 | + $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
71 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | + $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | + $texte.= '<input type="hidden" name="maskconst" value="EXPENSEREPORT_SAND_MASK">'; |
|
75 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
76 | 76 | |
77 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport")); |
|
78 | - //$tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
77 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport")); |
|
78 | + //$tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport")); |
|
81 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
82 | 82 | |
83 | - // Parametrage du prefix |
|
84 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskvalue" value="'.$conf->global->EXPENSEREPORT_SAND_MASK.'">',$tooltip,1,1).'</td>'; |
|
83 | + // Parametrage du prefix |
|
84 | + $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskvalue" value="'.$conf->global->EXPENSEREPORT_SAND_MASK.'">',$tooltip,1,1).'</td>'; |
|
86 | 86 | |
87 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
87 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
88 | 88 | |
89 | - $texte.= '</tr>'; |
|
89 | + $texte.= '</tr>'; |
|
90 | 90 | |
91 | - $texte.= '</table>'; |
|
92 | - $texte.= '</form>'; |
|
91 | + $texte.= '</table>'; |
|
92 | + $texte.= '</form>'; |
|
93 | 93 | |
94 | - return $texte; |
|
94 | + return $texte; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,59 +101,59 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function getExample() |
103 | 103 | { |
104 | - global $conf,$langs,$user; |
|
104 | + global $conf,$langs,$user; |
|
105 | 105 | |
106 | - $exp=new ExpenseReport($this->db); |
|
107 | - $exp->initAsSpecimen(); |
|
108 | - $exp->fk_user_author = $user->id; |
|
106 | + $exp=new ExpenseReport($this->db); |
|
107 | + $exp->initAsSpecimen(); |
|
108 | + $exp->fk_user_author = $user->id; |
|
109 | 109 | |
110 | - $numExample = $this->getNextValue($exp); |
|
110 | + $numExample = $this->getNextValue($exp); |
|
111 | 111 | |
112 | - if (! $numExample) |
|
113 | - { |
|
114 | - $numExample = $langs->trans('NotConfigured'); |
|
115 | - } |
|
116 | - return $numExample; |
|
112 | + if (! $numExample) |
|
113 | + { |
|
114 | + $numExample = $langs->trans('NotConfigured'); |
|
115 | + } |
|
116 | + return $numExample; |
|
117 | 117 | } |
118 | 118 | |
119 | - /** |
|
120 | - * Return next free value |
|
121 | - * |
|
122 | - * @param Object $object Object we need next value for |
|
123 | - * @return string Value if KO, <0 if KO |
|
124 | - */ |
|
119 | + /** |
|
120 | + * Return next free value |
|
121 | + * |
|
122 | + * @param Object $object Object we need next value for |
|
123 | + * @return string Value if KO, <0 if KO |
|
124 | + */ |
|
125 | 125 | function getNextValue($object) |
126 | 126 | { |
127 | - global $db,$conf; |
|
127 | + global $db,$conf; |
|
128 | 128 | |
129 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
129 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
130 | 130 | |
131 | - // We get cursor rule |
|
132 | - $mask=$conf->global->EXPENSEREPORT_SAND_MASK; |
|
131 | + // We get cursor rule |
|
132 | + $mask=$conf->global->EXPENSEREPORT_SAND_MASK; |
|
133 | 133 | |
134 | - if (! $mask) |
|
135 | - { |
|
136 | - $this->error='NotConfigured'; |
|
137 | - return 0; |
|
138 | - } |
|
134 | + if (! $mask) |
|
135 | + { |
|
136 | + $this->error='NotConfigured'; |
|
137 | + return 0; |
|
138 | + } |
|
139 | 139 | |
140 | - $date=$object->date_valid; // $object->date does not exists |
|
141 | - if (empty($date)) |
|
142 | - { |
|
143 | - $this->error = 'Date valid not defined'; |
|
144 | - return 0; |
|
145 | - } |
|
140 | + $date=$object->date_valid; // $object->date does not exists |
|
141 | + if (empty($date)) |
|
142 | + { |
|
143 | + $this->error = 'Date valid not defined'; |
|
144 | + return 0; |
|
145 | + } |
|
146 | 146 | |
147 | - $fuser = null; |
|
148 | - if ($object->fk_user_author > 0) |
|
149 | - { |
|
150 | - $fuser=new User($db); |
|
151 | - $fuser->fetch($object->fk_user_author); |
|
152 | - } |
|
147 | + $fuser = null; |
|
148 | + if ($object->fk_user_author > 0) |
|
149 | + { |
|
150 | + $fuser=new User($db); |
|
151 | + $fuser->fetch($object->fk_user_author); |
|
152 | + } |
|
153 | 153 | |
154 | - $numFinal=get_next_value($db,$mask,'expensereport','ref','',null, $date, 'next', true, $fuser); |
|
154 | + $numFinal=get_next_value($db,$mask,'expensereport','ref','',null, $date, 'next', true, $fuser); |
|
155 | 155 | |
156 | - return $numFinal; |
|
157 | - } |
|
156 | + return $numFinal; |
|
157 | + } |
|
158 | 158 | } |
159 | 159 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief Fichier contenant la classe du modele de numerotation de reference de note de frais Sand |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/expensereport/modules_expensereport.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * Dolibarr version of the loaded document |
35 | 35 | * @public string |
36 | 36 | */ |
37 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var string Error message |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @deprecated |
47 | 47 | * @see name |
48 | 48 | */ |
49 | - public $nom='Sand'; |
|
49 | + public $nom = 'Sand'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var string model name |
53 | 53 | */ |
54 | - public $name='Sand'; |
|
54 | + public $name = 'Sand'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -68,28 +68,28 @@ discard block |
||
68 | 68 | $form = new Form($this->db); |
69 | 69 | |
70 | 70 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
71 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | - $texte.= '<input type="hidden" name="maskconst" value="EXPENSEREPORT_SAND_MASK">'; |
|
75 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
71 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | + $texte .= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | + $texte .= '<input type="hidden" name="maskconst" value="EXPENSEREPORT_SAND_MASK">'; |
|
75 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
76 | 76 | |
77 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport")); |
|
77 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("ExpenseReport"), $langs->transnoentities("ExpenseReport")); |
|
78 | 78 | //$tooltip.=$langs->trans("GenericMaskCodes2"); |
79 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
79 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
80 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("ExpenseReport"), $langs->transnoentities("ExpenseReport")); |
|
81 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
82 | 82 | |
83 | 83 | // Parametrage du prefix |
84 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskvalue" value="'.$conf->global->EXPENSEREPORT_SAND_MASK.'">',$tooltip,1,1).'</td>'; |
|
84 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskvalue" value="'.$conf->global->EXPENSEREPORT_SAND_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
86 | 86 | |
87 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
87 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
88 | 88 | |
89 | - $texte.= '</tr>'; |
|
89 | + $texte .= '</tr>'; |
|
90 | 90 | |
91 | - $texte.= '</table>'; |
|
92 | - $texte.= '</form>'; |
|
91 | + $texte .= '</table>'; |
|
92 | + $texte .= '</form>'; |
|
93 | 93 | |
94 | 94 | return $texte; |
95 | 95 | } |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function getExample() |
103 | 103 | { |
104 | - global $conf,$langs,$user; |
|
104 | + global $conf, $langs, $user; |
|
105 | 105 | |
106 | - $exp=new ExpenseReport($this->db); |
|
106 | + $exp = new ExpenseReport($this->db); |
|
107 | 107 | $exp->initAsSpecimen(); |
108 | 108 | $exp->fk_user_author = $user->id; |
109 | 109 | |
110 | 110 | $numExample = $this->getNextValue($exp); |
111 | 111 | |
112 | - if (! $numExample) |
|
112 | + if (!$numExample) |
|
113 | 113 | { |
114 | 114 | $numExample = $langs->trans('NotConfigured'); |
115 | 115 | } |
@@ -124,20 +124,20 @@ discard block |
||
124 | 124 | */ |
125 | 125 | function getNextValue($object) |
126 | 126 | { |
127 | - global $db,$conf; |
|
127 | + global $db, $conf; |
|
128 | 128 | |
129 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
129 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
130 | 130 | |
131 | 131 | // We get cursor rule |
132 | - $mask=$conf->global->EXPENSEREPORT_SAND_MASK; |
|
132 | + $mask = $conf->global->EXPENSEREPORT_SAND_MASK; |
|
133 | 133 | |
134 | - if (! $mask) |
|
134 | + if (!$mask) |
|
135 | 135 | { |
136 | - $this->error='NotConfigured'; |
|
136 | + $this->error = 'NotConfigured'; |
|
137 | 137 | return 0; |
138 | 138 | } |
139 | 139 | |
140 | - $date=$object->date_valid; // $object->date does not exists |
|
140 | + $date = $object->date_valid; // $object->date does not exists |
|
141 | 141 | if (empty($date)) |
142 | 142 | { |
143 | 143 | $this->error = 'Date valid not defined'; |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | $fuser = null; |
148 | 148 | if ($object->fk_user_author > 0) |
149 | 149 | { |
150 | - $fuser=new User($db); |
|
150 | + $fuser = new User($db); |
|
151 | 151 | $fuser->fetch($object->fk_user_author); |
152 | 152 | } |
153 | 153 | |
154 | - $numFinal=get_next_value($db,$mask,'expensereport','ref','',null, $date, 'next', true, $fuser); |
|
154 | + $numFinal = get_next_value($db, $mask, 'expensereport', 'ref', '', null, $date, 'next', true, $fuser); |
|
155 | 155 | |
156 | 156 | return $numFinal; |
157 | 157 | } |
@@ -23,33 +23,33 @@ discard block |
||
23 | 23 | */ |
24 | 24 | abstract class ModeleExpenseReport extends CommonDocGenerator |
25 | 25 | { |
26 | - /** |
|
27 | - * @var string Error code (or message) |
|
28 | - */ |
|
29 | - public $error=''; |
|
26 | + /** |
|
27 | + * @var string Error code (or message) |
|
28 | + */ |
|
29 | + public $error=''; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
33 | - /** |
|
34 | - * Return list of active generation modules |
|
33 | + /** |
|
34 | + * Return list of active generation modules |
|
35 | 35 | * |
36 | 36 | * @param DoliDB $db Database handler |
37 | 37 | * @param integer $maxfilenamelength Max length of value to show |
38 | 38 | * @return array List of templates |
39 | 39 | */ |
40 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
41 | - { |
|
40 | + static function liste_modeles($db,$maxfilenamelength=0) |
|
41 | + { |
|
42 | 42 | // phpcs:enable |
43 | - global $conf; |
|
43 | + global $conf; |
|
44 | 44 | |
45 | - $type='expensereport'; |
|
46 | - $liste=array(); |
|
45 | + $type='expensereport'; |
|
46 | + $liste=array(); |
|
47 | 47 | |
48 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
49 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
48 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
49 | + $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
50 | 50 | |
51 | - return $liste; |
|
52 | - } |
|
51 | + return $liste; |
|
52 | + } |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | function expensereport_pdf_create(DoliDB $db, ExpenseReport $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) |
70 | 70 | { |
71 | 71 | // phpcs:enable |
72 | - return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
72 | + return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -79,81 +79,81 @@ discard block |
||
79 | 79 | |
80 | 80 | abstract class ModeleNumRefExpenseReport |
81 | 81 | { |
82 | - /** |
|
83 | - * @var string Error code (or message) |
|
84 | - */ |
|
85 | - public $error=''; |
|
86 | - |
|
87 | - /** |
|
88 | - * Return if a module can be used or not |
|
89 | - * |
|
90 | - * @return boolean true if module can be used |
|
91 | - */ |
|
92 | - function isEnabled() |
|
93 | - { |
|
94 | - return true; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Renvoie la description par defaut du modele de numerotation |
|
99 | - * |
|
100 | - * @return string Texte descripif |
|
101 | - */ |
|
102 | - function info() |
|
103 | - { |
|
104 | - global $langs; |
|
105 | - $langs->load("orders"); |
|
106 | - return $langs->trans("NoDescription"); |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Renvoie un exemple de numerotation |
|
111 | - * |
|
112 | - * @return string Example |
|
113 | - */ |
|
114 | - function getExample() |
|
115 | - { |
|
116 | - global $langs; |
|
117 | - $langs->load("trips"); |
|
118 | - return $langs->trans("NoExample"); |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Test si les numeros deja en vigueur dans la base ne provoquent pas de conflits qui empecheraient cette numerotation de fonctionner. |
|
123 | - * |
|
124 | - * @return boolean false si conflit, true si ok |
|
125 | - */ |
|
126 | - function canBeActivated() |
|
127 | - { |
|
128 | - return true; |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Renvoie prochaine valeur attribuee |
|
133 | - * |
|
134 | - * @param Object $object Object we need next value for |
|
135 | - * @return string Valeur |
|
136 | - */ |
|
137 | - function getNextValue($object) |
|
138 | - { |
|
139 | - global $langs; |
|
140 | - return $langs->trans("NotAvailable"); |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Renvoie version du module numerotation |
|
145 | - * |
|
146 | - * @return string Valeur |
|
147 | - */ |
|
148 | - function getVersion() |
|
149 | - { |
|
150 | - global $langs; |
|
151 | - $langs->load("admin"); |
|
152 | - |
|
153 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
154 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
155 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
156 | - if ($this->version) return $this->version; |
|
157 | - return $langs->trans("NotAvailable"); |
|
158 | - } |
|
82 | + /** |
|
83 | + * @var string Error code (or message) |
|
84 | + */ |
|
85 | + public $error=''; |
|
86 | + |
|
87 | + /** |
|
88 | + * Return if a module can be used or not |
|
89 | + * |
|
90 | + * @return boolean true if module can be used |
|
91 | + */ |
|
92 | + function isEnabled() |
|
93 | + { |
|
94 | + return true; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Renvoie la description par defaut du modele de numerotation |
|
99 | + * |
|
100 | + * @return string Texte descripif |
|
101 | + */ |
|
102 | + function info() |
|
103 | + { |
|
104 | + global $langs; |
|
105 | + $langs->load("orders"); |
|
106 | + return $langs->trans("NoDescription"); |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Renvoie un exemple de numerotation |
|
111 | + * |
|
112 | + * @return string Example |
|
113 | + */ |
|
114 | + function getExample() |
|
115 | + { |
|
116 | + global $langs; |
|
117 | + $langs->load("trips"); |
|
118 | + return $langs->trans("NoExample"); |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Test si les numeros deja en vigueur dans la base ne provoquent pas de conflits qui empecheraient cette numerotation de fonctionner. |
|
123 | + * |
|
124 | + * @return boolean false si conflit, true si ok |
|
125 | + */ |
|
126 | + function canBeActivated() |
|
127 | + { |
|
128 | + return true; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Renvoie prochaine valeur attribuee |
|
133 | + * |
|
134 | + * @param Object $object Object we need next value for |
|
135 | + * @return string Valeur |
|
136 | + */ |
|
137 | + function getNextValue($object) |
|
138 | + { |
|
139 | + global $langs; |
|
140 | + return $langs->trans("NotAvailable"); |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Renvoie version du module numerotation |
|
145 | + * |
|
146 | + * @return string Valeur |
|
147 | + */ |
|
148 | + function getVersion() |
|
149 | + { |
|
150 | + global $langs; |
|
151 | + $langs->load("admin"); |
|
152 | + |
|
153 | + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
154 | + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
155 | + if ($this->version == 'dolibarr') return DOL_VERSION; |
|
156 | + if ($this->version) return $this->version; |
|
157 | + return $langs->trans("NotAvailable"); |
|
158 | + } |
|
159 | 159 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @var string Error code (or message) |
28 | 28 | */ |
29 | - public $error=''; |
|
29 | + public $error = ''; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -37,16 +37,16 @@ discard block |
||
37 | 37 | * @param integer $maxfilenamelength Max length of value to show |
38 | 38 | * @return array List of templates |
39 | 39 | */ |
40 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
40 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
41 | 41 | { |
42 | 42 | // phpcs:enable |
43 | 43 | global $conf; |
44 | 44 | |
45 | - $type='expensereport'; |
|
46 | - $liste=array(); |
|
45 | + $type = 'expensereport'; |
|
46 | + $liste = array(); |
|
47 | 47 | |
48 | 48 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
49 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
49 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
50 | 50 | |
51 | 51 | return $liste; |
52 | 52 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param int $hideref Hide ref |
67 | 67 | * @return int 0 if KO, 1 if OK |
68 | 68 | */ |
69 | -function expensereport_pdf_create(DoliDB $db, ExpenseReport $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) |
|
69 | +function expensereport_pdf_create(DoliDB $db, ExpenseReport $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
70 | 70 | { |
71 | 71 | // phpcs:enable |
72 | 72 | return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * @var string Error code (or message) |
84 | 84 | */ |
85 | - public $error=''; |
|
85 | + public $error = ''; |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Return if a module can be used or not |
@@ -142,10 +142,18 @@ |
||
142 | 142 | global $langs; |
143 | 143 | $langs->load("admin"); |
144 | 144 | |
145 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
146 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
147 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
148 | - if ($this->version) return $this->version; |
|
145 | + if ($this->version == 'development') { |
|
146 | + return $langs->trans("VersionDevelopment"); |
|
147 | + } |
|
148 | + if ($this->version == 'experimental') { |
|
149 | + return $langs->trans("VersionExperimental"); |
|
150 | + } |
|
151 | + if ($this->version == 'dolibarr') { |
|
152 | + return DOL_VERSION; |
|
153 | + } |
|
154 | + if ($this->version) { |
|
155 | + return $this->version; |
|
156 | + } |
|
149 | 157 | return $langs->trans("NotAvailable"); |
150 | 158 | } |
151 | 159 | } |
@@ -33,24 +33,24 @@ discard block |
||
33 | 33 | { |
34 | 34 | |
35 | 35 | /** |
36 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | - * |
|
38 | - * @param DoliDB $db Database handler |
|
36 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | + * |
|
38 | + * @param DoliDB $db Database handler |
|
39 | 39 | */ |
40 | 40 | function __construct($db) |
41 | 41 | { |
42 | - global $langs, $conf; |
|
42 | + global $langs, $conf; |
|
43 | 43 | |
44 | 44 | $this->db = $db; |
45 | 45 | $this->numero = 2300; |
46 | 46 | |
47 | - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
|
48 | - // It is used to group modules in module setup page |
|
47 | + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
|
48 | + // It is used to group modules in module setup page |
|
49 | 49 | $this->family = "base"; |
50 | 50 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
51 | 51 | $this->name = preg_replace('/^mod/i', '', get_class($this)); |
52 | 52 | $this->description = "Enable the Dolibarr cron service"; |
53 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
53 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
54 | 54 | $this->version = 'dolibarr'; |
55 | 55 | // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) |
56 | 56 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
@@ -64,26 +64,26 @@ discard block |
||
64 | 64 | //------------- |
65 | 65 | $this->config_page_url = array("cron.php@cron"); |
66 | 66 | |
67 | - // Dependancies |
|
68 | - //------------- |
|
69 | - $this->hidden = !empty($conf->global->MODULE_CRON_DISABLED); // A condition to disable module |
|
70 | - $this->depends = array(); // List of modules id that must be enabled if this module is enabled |
|
71 | - $this->requiredby = array(); // List of modules id to disable if this one is disabled |
|
72 | - $this->conflictwith = array(); // List of modules id this module is in conflict with |
|
73 | - $this->langfiles = array("cron"); |
|
74 | - |
|
75 | - // Constants |
|
76 | - //----------- |
|
77 | - $this->const = array( |
|
78 | - 0=>array( |
|
79 | - 'CRON_KEY', |
|
80 | - 'chaine', |
|
81 | - '', |
|
82 | - 'CRON KEY', |
|
83 | - 0, |
|
84 | - 'main', |
|
85 | - 0 |
|
86 | - ),); |
|
67 | + // Dependancies |
|
68 | + //------------- |
|
69 | + $this->hidden = !empty($conf->global->MODULE_CRON_DISABLED); // A condition to disable module |
|
70 | + $this->depends = array(); // List of modules id that must be enabled if this module is enabled |
|
71 | + $this->requiredby = array(); // List of modules id to disable if this one is disabled |
|
72 | + $this->conflictwith = array(); // List of modules id this module is in conflict with |
|
73 | + $this->langfiles = array("cron"); |
|
74 | + |
|
75 | + // Constants |
|
76 | + //----------- |
|
77 | + $this->const = array( |
|
78 | + 0=>array( |
|
79 | + 'CRON_KEY', |
|
80 | + 'chaine', |
|
81 | + '', |
|
82 | + 'CRON KEY', |
|
83 | + 0, |
|
84 | + 'main', |
|
85 | + 0 |
|
86 | + ),); |
|
87 | 87 | |
88 | 88 | // New pages on tabs |
89 | 89 | // ----------------- |
@@ -93,54 +93,54 @@ discard block |
||
93 | 93 | //------ |
94 | 94 | $this->boxes = array(); |
95 | 95 | |
96 | - // Cronjobs |
|
97 | - $this->cronjobs = array( |
|
98 | - 0=>array('entity'=>0, 'label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true), |
|
99 | - 1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>in_array($db->type, array('mysql', 'mysqli'))), |
|
100 | - // 1=>array('entity'=>0, 'label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24) |
|
101 | - ); |
|
96 | + // Cronjobs |
|
97 | + $this->cronjobs = array( |
|
98 | + 0=>array('entity'=>0, 'label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true), |
|
99 | + 1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>in_array($db->type, array('mysql', 'mysqli'))), |
|
100 | + // 1=>array('entity'=>0, 'label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24) |
|
101 | + ); |
|
102 | 102 | |
103 | 103 | // Permissions |
104 | - $this->rights = array(); // Permission array used by this module |
|
105 | - $this->rights_class = 'cron'; |
|
106 | - $r = 0; |
|
107 | - |
|
108 | - $this->rights[$r][0] = 23001; |
|
109 | - $this->rights[$r][1] = 'Read cron jobs'; |
|
110 | - $this->rights[$r][3] = 0; |
|
111 | - $this->rights[$r][4] = 'read'; |
|
112 | - $r++; |
|
113 | - |
|
114 | - $this->rights[$r][0] = 23002; |
|
115 | - $this->rights[$r][1] = 'Create cron Jobs'; |
|
116 | - $this->rights[$r][3] = 0; |
|
117 | - $this->rights[$r][4] = 'create'; |
|
118 | - $r++; |
|
119 | - |
|
120 | - $this->rights[$r][0] = 23003; |
|
121 | - $this->rights[$r][1] = 'Delete cron Jobs'; |
|
122 | - $this->rights[$r][3] = 0; |
|
123 | - $this->rights[$r][4] = 'delete'; |
|
124 | - $r++; |
|
125 | - |
|
126 | - $this->rights[$r][0] = 23004; |
|
127 | - $this->rights[$r][1] = 'Execute cron Jobs'; |
|
128 | - $this->rights[$r][3] = 0; |
|
129 | - $this->rights[$r][4] = 'execute'; |
|
130 | - $r++; |
|
104 | + $this->rights = array(); // Permission array used by this module |
|
105 | + $this->rights_class = 'cron'; |
|
106 | + $r = 0; |
|
107 | + |
|
108 | + $this->rights[$r][0] = 23001; |
|
109 | + $this->rights[$r][1] = 'Read cron jobs'; |
|
110 | + $this->rights[$r][3] = 0; |
|
111 | + $this->rights[$r][4] = 'read'; |
|
112 | + $r++; |
|
113 | + |
|
114 | + $this->rights[$r][0] = 23002; |
|
115 | + $this->rights[$r][1] = 'Create cron Jobs'; |
|
116 | + $this->rights[$r][3] = 0; |
|
117 | + $this->rights[$r][4] = 'create'; |
|
118 | + $r++; |
|
119 | + |
|
120 | + $this->rights[$r][0] = 23003; |
|
121 | + $this->rights[$r][1] = 'Delete cron Jobs'; |
|
122 | + $this->rights[$r][3] = 0; |
|
123 | + $this->rights[$r][4] = 'delete'; |
|
124 | + $r++; |
|
125 | + |
|
126 | + $this->rights[$r][0] = 23004; |
|
127 | + $this->rights[$r][1] = 'Execute cron Jobs'; |
|
128 | + $this->rights[$r][3] = 0; |
|
129 | + $this->rights[$r][4] = 'execute'; |
|
130 | + $r++; |
|
131 | 131 | |
132 | 132 | // Main menu entries |
133 | 133 | $r = 0; |
134 | 134 | $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
135 | - 'type'=>'left', // This is a Left menu entry |
|
136 | - 'titre'=>'CronList', |
|
137 | - 'url'=>'/cron/list.php?status=-2&leftmenu=admintools', |
|
138 | - 'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
139 | - 'position'=>200, |
|
140 | - 'enabled'=>'$conf->cron->enabled && preg_match(\'/^(admintools|all)/\', $leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
|
141 | - 'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules |
|
142 | - 'target'=>'', |
|
143 | - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
135 | + 'type'=>'left', // This is a Left menu entry |
|
136 | + 'titre'=>'CronList', |
|
137 | + 'url'=>'/cron/list.php?status=-2&leftmenu=admintools', |
|
138 | + 'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
139 | + 'position'=>200, |
|
140 | + 'enabled'=>'$conf->cron->enabled && preg_match(\'/^(admintools|all)/\', $leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
|
141 | + 'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules |
|
142 | + 'target'=>'', |
|
143 | + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
144 | 144 | $r++; |
145 | 145 | } |
146 | 146 | } |
@@ -32,139 +32,139 @@ |
||
32 | 32 | class modLoan extends DolibarrModules |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | - * |
|
38 | - * @param DoliDB $db Database handler |
|
39 | - */ |
|
40 | - function __construct($db) |
|
41 | - { |
|
42 | - global $conf; |
|
43 | - |
|
44 | - $this->db = $db; |
|
45 | - $this->numero = 520; |
|
46 | - |
|
47 | - $this->family = "financial"; |
|
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 | - // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
|
51 | - $this->description = "Loans management"; |
|
52 | - |
|
53 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
54 | - $this->version = 'dolibarr'; |
|
55 | - |
|
56 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
57 | - $this->picto='bill'; |
|
58 | - |
|
59 | - // Data directories to create when module is enabled |
|
60 | - $this->dirs = array("/loan/temp"); |
|
61 | - |
|
62 | - // Config pages |
|
63 | - $this->config_page_url = array('loan.php'); |
|
64 | - |
|
65 | - // Dependencies |
|
66 | - $this->hidden = false; // A condition to hide module |
|
67 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
68 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
69 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
70 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
71 | - $this->langfiles = array("loan"); |
|
72 | - |
|
73 | - // Constants |
|
74 | - $this->const = array(); |
|
75 | - $this->const[0] = array( |
|
76 | - "LOAN_ACCOUNTING_ACCOUNT_CAPITAL", |
|
77 | - "chaine", |
|
78 | - "164" |
|
79 | - ); |
|
80 | - $this->const[1] = array( |
|
81 | - "LOAN_ACCOUNTING_ACCOUNT_INTEREST", |
|
82 | - "chaine", |
|
83 | - "6611" |
|
84 | - ); |
|
85 | - $this->const[1] = array( |
|
86 | - "LOAN_ACCOUNTING_ACCOUNT_INSURANCE", |
|
87 | - "chaine", |
|
88 | - "6162" |
|
89 | - ); |
|
90 | - |
|
91 | - // Boxes |
|
92 | - $this->boxes = array(); |
|
93 | - |
|
94 | - // Permissions |
|
95 | - $this->rights = array(); |
|
96 | - $this->rights_class = 'loan'; |
|
97 | - $r=0; |
|
98 | - |
|
99 | - $r++; |
|
100 | - $this->rights[$r][0] = 520; |
|
101 | - $this->rights[$r][1] = 'Read loans'; |
|
102 | - $this->rights[$r][2] = 'r'; |
|
103 | - $this->rights[$r][3] = 0; |
|
104 | - $this->rights[$r][4] = 'read'; |
|
105 | - $this->rights[$r][5] = ''; |
|
106 | - |
|
107 | - $r++; |
|
108 | - $this->rights[$r][0] = 522; |
|
109 | - $this->rights[$r][1] = 'Create/modify loans'; |
|
110 | - $this->rights[$r][2] = 'w'; |
|
111 | - $this->rights[$r][3] = 0; |
|
112 | - $this->rights[$r][4] = 'write'; |
|
113 | - $this->rights[$r][5] = ''; |
|
114 | - |
|
115 | - $r++; |
|
116 | - $this->rights[$r][0] = 524; |
|
117 | - $this->rights[$r][1] = 'Delete loans'; |
|
118 | - $this->rights[$r][2] = 'd'; |
|
119 | - $this->rights[$r][3] = 0; |
|
120 | - $this->rights[$r][4] = 'delete'; |
|
121 | - $this->rights[$r][5] = ''; |
|
122 | - |
|
123 | - $r++; |
|
124 | - $this->rights[$r][0] = 525; |
|
125 | - $this->rights[$r][1] = 'Access loan calculator'; |
|
126 | - $this->rights[$r][2] = 'r'; |
|
127 | - $this->rights[$r][3] = 0; |
|
128 | - $this->rights[$r][4] = 'calc'; |
|
129 | - $this->rights[$r][5] = ''; |
|
130 | - |
|
131 | - $r++; |
|
132 | - $this->rights[$r][0] = 527; |
|
133 | - $this->rights[$r][1] = 'Export loans'; |
|
134 | - $this->rights[$r][2] = 'r'; |
|
135 | - $this->rights[$r][3] = 0; |
|
136 | - $this->rights[$r][4] = 'export'; |
|
137 | - $this->rights[$r][5] = ''; |
|
138 | - |
|
139 | - |
|
140 | - // Menus |
|
141 | - //------- |
|
142 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
143 | - |
|
144 | - |
|
145 | - // Exports |
|
146 | - //-------- |
|
147 | - $r=0; |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * Function called when module is enabled. |
|
153 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
154 | - * It also creates data directories |
|
155 | - * |
|
35 | + /** |
|
36 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | + * |
|
38 | + * @param DoliDB $db Database handler |
|
39 | + */ |
|
40 | + function __construct($db) |
|
41 | + { |
|
42 | + global $conf; |
|
43 | + |
|
44 | + $this->db = $db; |
|
45 | + $this->numero = 520; |
|
46 | + |
|
47 | + $this->family = "financial"; |
|
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 | + // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
|
51 | + $this->description = "Loans management"; |
|
52 | + |
|
53 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
54 | + $this->version = 'dolibarr'; |
|
55 | + |
|
56 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
57 | + $this->picto='bill'; |
|
58 | + |
|
59 | + // Data directories to create when module is enabled |
|
60 | + $this->dirs = array("/loan/temp"); |
|
61 | + |
|
62 | + // Config pages |
|
63 | + $this->config_page_url = array('loan.php'); |
|
64 | + |
|
65 | + // Dependencies |
|
66 | + $this->hidden = false; // A condition to hide module |
|
67 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
68 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
69 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
70 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
71 | + $this->langfiles = array("loan"); |
|
72 | + |
|
73 | + // Constants |
|
74 | + $this->const = array(); |
|
75 | + $this->const[0] = array( |
|
76 | + "LOAN_ACCOUNTING_ACCOUNT_CAPITAL", |
|
77 | + "chaine", |
|
78 | + "164" |
|
79 | + ); |
|
80 | + $this->const[1] = array( |
|
81 | + "LOAN_ACCOUNTING_ACCOUNT_INTEREST", |
|
82 | + "chaine", |
|
83 | + "6611" |
|
84 | + ); |
|
85 | + $this->const[1] = array( |
|
86 | + "LOAN_ACCOUNTING_ACCOUNT_INSURANCE", |
|
87 | + "chaine", |
|
88 | + "6162" |
|
89 | + ); |
|
90 | + |
|
91 | + // Boxes |
|
92 | + $this->boxes = array(); |
|
93 | + |
|
94 | + // Permissions |
|
95 | + $this->rights = array(); |
|
96 | + $this->rights_class = 'loan'; |
|
97 | + $r=0; |
|
98 | + |
|
99 | + $r++; |
|
100 | + $this->rights[$r][0] = 520; |
|
101 | + $this->rights[$r][1] = 'Read loans'; |
|
102 | + $this->rights[$r][2] = 'r'; |
|
103 | + $this->rights[$r][3] = 0; |
|
104 | + $this->rights[$r][4] = 'read'; |
|
105 | + $this->rights[$r][5] = ''; |
|
106 | + |
|
107 | + $r++; |
|
108 | + $this->rights[$r][0] = 522; |
|
109 | + $this->rights[$r][1] = 'Create/modify loans'; |
|
110 | + $this->rights[$r][2] = 'w'; |
|
111 | + $this->rights[$r][3] = 0; |
|
112 | + $this->rights[$r][4] = 'write'; |
|
113 | + $this->rights[$r][5] = ''; |
|
114 | + |
|
115 | + $r++; |
|
116 | + $this->rights[$r][0] = 524; |
|
117 | + $this->rights[$r][1] = 'Delete loans'; |
|
118 | + $this->rights[$r][2] = 'd'; |
|
119 | + $this->rights[$r][3] = 0; |
|
120 | + $this->rights[$r][4] = 'delete'; |
|
121 | + $this->rights[$r][5] = ''; |
|
122 | + |
|
123 | + $r++; |
|
124 | + $this->rights[$r][0] = 525; |
|
125 | + $this->rights[$r][1] = 'Access loan calculator'; |
|
126 | + $this->rights[$r][2] = 'r'; |
|
127 | + $this->rights[$r][3] = 0; |
|
128 | + $this->rights[$r][4] = 'calc'; |
|
129 | + $this->rights[$r][5] = ''; |
|
130 | + |
|
131 | + $r++; |
|
132 | + $this->rights[$r][0] = 527; |
|
133 | + $this->rights[$r][1] = 'Export loans'; |
|
134 | + $this->rights[$r][2] = 'r'; |
|
135 | + $this->rights[$r][3] = 0; |
|
136 | + $this->rights[$r][4] = 'export'; |
|
137 | + $this->rights[$r][5] = ''; |
|
138 | + |
|
139 | + |
|
140 | + // Menus |
|
141 | + //------- |
|
142 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
143 | + |
|
144 | + |
|
145 | + // Exports |
|
146 | + //-------- |
|
147 | + $r=0; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * Function called when module is enabled. |
|
153 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
154 | + * It also creates data directories |
|
155 | + * |
|
156 | 156 | * @param string $options Options when enabling module ('', 'noboxes') |
157 | - * @return int 1 if OK, 0 if KO |
|
158 | - */ |
|
159 | - function init($options='') |
|
160 | - { |
|
161 | - global $conf; |
|
157 | + * @return int 1 if OK, 0 if KO |
|
158 | + */ |
|
159 | + function init($options='') |
|
160 | + { |
|
161 | + global $conf; |
|
162 | 162 | |
163 | - // Clean before activation |
|
164 | - $this->remove($options); |
|
163 | + // Clean before activation |
|
164 | + $this->remove($options); |
|
165 | 165 | |
166 | - $sql = array(); |
|
166 | + $sql = array(); |
|
167 | 167 | |
168 | - return $this->_init($sql,$options); |
|
169 | - } |
|
168 | + return $this->_init($sql,$options); |
|
169 | + } |
|
170 | 170 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \ingroup loan |
24 | 24 | * \brief File to activate module loan |
25 | 25 | */ |
26 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
26 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | $this->family = "financial"; |
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 | // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
51 | 51 | $this->description = "Loans management"; |
52 | 52 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $this->version = 'dolibarr'; |
55 | 55 | |
56 | 56 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
57 | - $this->picto='bill'; |
|
57 | + $this->picto = 'bill'; |
|
58 | 58 | |
59 | 59 | // Data directories to create when module is enabled |
60 | 60 | $this->dirs = array("/loan/temp"); |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | $this->config_page_url = array('loan.php'); |
64 | 64 | |
65 | 65 | // Dependencies |
66 | - $this->hidden = false; // A condition to hide module |
|
67 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
68 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
69 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
70 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
66 | + $this->hidden = false; // A condition to hide module |
|
67 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
68 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
69 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
70 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
71 | 71 | $this->langfiles = array("loan"); |
72 | 72 | |
73 | 73 | // Constants |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | // Permissions |
95 | 95 | $this->rights = array(); |
96 | 96 | $this->rights_class = 'loan'; |
97 | - $r=0; |
|
97 | + $r = 0; |
|
98 | 98 | |
99 | 99 | $r++; |
100 | 100 | $this->rights[$r][0] = 520; |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | |
140 | 140 | // Menus |
141 | 141 | //------- |
142 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
142 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
143 | 143 | |
144 | 144 | |
145 | 145 | // Exports |
146 | 146 | //-------- |
147 | - $r=0; |
|
147 | + $r = 0; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @param string $options Options when enabling module ('', 'noboxes') |
157 | 157 | * @return int 1 if OK, 0 if KO |
158 | 158 | */ |
159 | - function init($options='') |
|
159 | + function init($options = '') |
|
160 | 160 | { |
161 | 161 | global $conf; |
162 | 162 | |
@@ -165,6 +165,6 @@ discard block |
||
165 | 165 | |
166 | 166 | $sql = array(); |
167 | 167 | |
168 | - return $this->_init($sql,$options); |
|
168 | + return $this->_init($sql, $options); |
|
169 | 169 | } |
170 | 170 | } |
@@ -68,10 +68,10 @@ |
||
68 | 68 | |
69 | 69 | // Dependencies |
70 | 70 | $this->hidden = false; // A condition to hide module |
71 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
72 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
73 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
74 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module // Minimum version of PHP required by module |
|
71 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
72 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
73 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
74 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module // Minimum version of PHP required by module |
|
75 | 75 | $this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module |
76 | 76 | $this->conflictwith = array(); |
77 | 77 | $this->langfiles = array("oauth"); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * \ingroup oauth |
26 | 26 | * \brief File of class to describe and activate module Oauth |
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 | |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | */ |
43 | 43 | function __construct($db) |
44 | 44 | { |
45 | - $this->db = $db ; |
|
45 | + $this->db = $db; |
|
46 | 46 | $this->numero = 66000; |
47 | 47 | // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
48 | 48 | // It is used to group modules in module setup page |
49 | 49 | $this->family = "interface"; |
50 | 50 | $this->module_position = '31'; |
51 | 51 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
52 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
52 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
53 | 53 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
54 | 54 | $this->description = "Enable OAuth authentication"; |
55 | 55 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | $this->config_page_url = array("oauth.php"); |
68 | 68 | |
69 | 69 | // Dependencies |
70 | - $this->hidden = false; // A condition to hide module |
|
71 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
72 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
73 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
74 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module // Minimum version of PHP required by module |
|
75 | - $this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module |
|
70 | + $this->hidden = false; // A condition to hide module |
|
71 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
72 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
73 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
74 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module // Minimum version of PHP required by module |
|
75 | + $this->need_dolibarr_version = array(3, 7, -2); // Minimum version of Dolibarr required by module |
|
76 | 76 | $this->conflictwith = array(); |
77 | 77 | $this->langfiles = array("oauth"); |
78 | 78 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $this->rights = array(); |
87 | 87 | $this->rights_class = 'oauth'; |
88 | 88 | |
89 | - $r=0; |
|
89 | + $r = 0; |
|
90 | 90 | // $this->rights[$r][0] Id permission (unique tous modules confondus) |
91 | 91 | // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) |
92 | 92 | // $this->rights[$r][2] Non utilise |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | $this->rights[$r][4] = 'read';*/ |
103 | 103 | |
104 | 104 | // Main menu entries |
105 | - $this->menus = array(); // List of menus to add |
|
106 | - $r=0; |
|
105 | + $this->menus = array(); // List of menus to add |
|
106 | + $r = 0; |
|
107 | 107 | |
108 | 108 | // This is to declare the Top Menu entry: |
109 | 109 | //$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @param string $options Options when enabling module ('', 'noboxes') |
131 | 131 | * @return int 1 if OK, 0 if KO |
132 | 132 | */ |
133 | - function init($options='') |
|
133 | + function init($options = '') |
|
134 | 134 | { |
135 | 135 | global $conf; |
136 | 136 |
@@ -36,225 +36,225 @@ |
||
36 | 36 | */ |
37 | 37 | class modHoliday extends DolibarrModules |
38 | 38 | { |
39 | - /** |
|
40 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
41 | - * |
|
42 | - * @param DoliDB $db Database handler |
|
43 | - */ |
|
44 | - function __construct($db) |
|
45 | - { |
|
46 | - $this->db = $db; |
|
47 | - |
|
48 | - // Id for module (must be unique). |
|
49 | - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). |
|
50 | - $this->numero = 20000; |
|
51 | - // Key text used to identify module (for permissions, menus, etc...) |
|
52 | - $this->rights_class = 'holiday'; |
|
53 | - |
|
54 | - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
|
55 | - // It is used to group modules in module setup page |
|
56 | - $this->family = "hr"; |
|
57 | - $this->module_position = '30'; |
|
58 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
59 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
60 | - // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
|
61 | - $this->description = "Leave requests"; |
|
62 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
63 | - $this->version = 'dolibarr'; |
|
64 | - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) |
|
65 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
66 | - // Name of image file used for this module. |
|
67 | - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
|
68 | - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' |
|
69 | - $this->picto='holiday'; |
|
70 | - |
|
71 | - // Data directories to create when module is enabled. |
|
72 | - // Example: this->dirs = array("/mymodule/temp"); |
|
73 | - $this->dirs = array("/holiday/temp"); |
|
74 | - $r=0; |
|
75 | - |
|
76 | - // Config pages |
|
77 | - $this->config_page_url = array("holiday.php"); |
|
78 | - |
|
79 | - |
|
80 | - // Config pages. Put here list of php page names stored in admmin directory used to setup module. |
|
81 | - // $this->config_page_url = array("holiday.php?leftmenu=setup@holiday"); |
|
82 | - |
|
83 | - // Dependencies |
|
84 | - $this->hidden = false; // A condition to hide module |
|
85 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
86 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
87 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
88 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
89 | - $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module |
|
90 | - $this->langfiles = array("holiday"); |
|
91 | - |
|
92 | - // Constants |
|
93 | - // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), |
|
94 | - // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); |
|
95 | - // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0) |
|
96 | - $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities') |
|
97 | - $r=0; |
|
98 | - |
|
99 | - $this->const[$r][0] = "HOLIDAY_ADDON"; |
|
100 | - $this->const[$r][1] = "chaine"; |
|
101 | - $this->const[$r][2] = "mod_holiday_madonna"; |
|
102 | - $this->const[$r][3] = 'Nom du gestionnaire de numerotation des congés'; |
|
103 | - $this->const[$r][4] = 0; |
|
104 | - $r++; |
|
105 | - |
|
106 | - $this->const[$r][0] = "HOLIDAY_ADDON_PDF"; |
|
107 | - $this->const[$r][1] = "chaine"; |
|
108 | - $this->const[$r][2] = "celebrate"; |
|
109 | - $this->const[$r][3] = 'Name of PDF model of holiday'; |
|
110 | - $this->const[$r][4] = 0; |
|
111 | - $r++; |
|
112 | - |
|
113 | - $this->const[$r][0] = "HOLIDAY_ADDON_PDF_ODT_PATH"; |
|
114 | - $this->const[$r][1] = "chaine"; |
|
115 | - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/holiday"; |
|
116 | - $this->const[$r][3] = ""; |
|
117 | - $this->const[$r][4] = 0; |
|
118 | - $r++; |
|
119 | - |
|
120 | - // Array to add new pages in new tabs |
|
121 | - //$this->tabs[] = array('data'=>'user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=hrm&id=__ID__'); // We avoid to get one tab for each module. RH data are already in RH tab. |
|
122 | - $this->tabs[] = array(); // To add a new tab identified by code tabname1 |
|
123 | - |
|
124 | - // Boxes |
|
125 | - $this->boxes = array(); // List of boxes |
|
126 | - $r=0; |
|
127 | - |
|
128 | - // Add here list of php file(s) stored in includes/boxes that contains class to show a box. |
|
129 | - // Example: |
|
130 | - //$this->boxes[$r][1] = "myboxa.php"; |
|
131 | - //$r++; |
|
132 | - //$this->boxes[$r][1] = "myboxb.php"; |
|
133 | - //$r++; |
|
134 | - |
|
135 | - |
|
136 | - // Permissions |
|
137 | - $this->rights = array(); // Permission array used by this module |
|
138 | - $r=0; |
|
139 | - |
|
140 | - $this->rights[$r][0] = 20001; // Permission id (must not be already used) |
|
141 | - $this->rights[$r][1] = 'Read your own leave requests'; // Permission label |
|
142 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
143 | - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
144 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
145 | - $r++; |
|
146 | - |
|
147 | - $this->rights[$r][0] = 20002; // Permission id (must not be already used) |
|
148 | - $this->rights[$r][1] = 'Create/modify your own leave requests'; // Permission label |
|
149 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
150 | - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
151 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
152 | - $r++; |
|
153 | - |
|
154 | - $this->rights[$r][0] = 20003; // Permission id (must not be already used) |
|
155 | - $this->rights[$r][1] = 'Delete leave requests'; // Permission label |
|
156 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
157 | - $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
158 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
159 | - $r++; |
|
160 | - |
|
161 | - $this->rights[$r][0] = 20007; |
|
162 | - $this->rights[$r][1] = 'Approve leave requests'; |
|
163 | - $this->rights[$r][2] = 'w'; |
|
164 | - $this->rights[$r][3] = 0; |
|
165 | - $this->rights[$r][4] = 'approve'; |
|
166 | - $r++; |
|
167 | - |
|
168 | - $this->rights[$r][0] = 20004; // Permission id (must not be already used) |
|
169 | - $this->rights[$r][1] = 'Read leave requests for everybody'; // Permission label |
|
170 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
171 | - $this->rights[$r][4] = 'read_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
172 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
173 | - $r++; |
|
174 | - |
|
175 | - $this->rights[$r][0] = 20005; // Permission id (must not be already used) |
|
176 | - $this->rights[$r][1] = 'Create/modify leave requests for everybody'; // Permission label |
|
177 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
178 | - $this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
179 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
180 | - $r++; |
|
181 | - |
|
182 | - $this->rights[$r][0] = 20006; // Permission id (must not be already used) |
|
183 | - $this->rights[$r][1] = 'Setup leave requests of users (setup and update balance)'; // Permission label |
|
184 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
185 | - $this->rights[$r][4] = 'define_holiday'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
186 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
187 | - $r++; |
|
188 | - |
|
189 | - |
|
190 | - // Menus |
|
191 | - //------- |
|
192 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
193 | - |
|
194 | - |
|
195 | - // Exports |
|
196 | - $r=0; |
|
197 | - |
|
198 | - $r++; |
|
199 | - $this->export_code[$r]='leaverequest_'.$r; |
|
200 | - $this->export_label[$r]='ListeCP'; |
|
201 | - $this->export_icon[$r]='holiday'; |
|
202 | - $this->export_permission[$r]=array(array("holiday","read_all")); |
|
203 | - $this->export_fields_array[$r]=array( |
|
204 | - 'd.rowid'=>"LeaveId",'d.fk_type'=>'TypeOfLeaveId','t.code'=>'TypeOfLeaveCode','t.label'=>'TypeOfLeaveLabel','d.fk_user'=>'UserID', |
|
205 | - 'u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.halfday'=>'HalfDay', |
|
206 | - 'd.date_valid'=>'DateApprove','d.fk_validator'=>"UserForApprovalID",'ua.lastname'=>"UserForApprovalLastname",'ua.firstname'=>"UserForApprovalFirstname", |
|
207 | - 'ua.login'=>"UserForApprovalLogin",'d.description'=>'Description','d.statut'=>'Status' |
|
208 | - ); |
|
209 | - $this->export_entities_array[$r]=array( |
|
210 | - 'u.lastname'=>'user','u.firstname'=>'user','u.login'=>'user','ua.lastname'=>'user','ua.firstname'=>'user','ua.login'=>'user' |
|
211 | - ); |
|
212 | - $this->export_alias_array[$r]=array('d.rowid'=>"idholiday"); |
|
213 | - $this->export_dependencies_array[$r]=array(); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
214 | - |
|
215 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
216 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'holiday as d'; |
|
217 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_holiday_types as t ON t.rowid = d.fk_type'; |
|
218 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua ON ua.rowid = d.fk_validator,'; |
|
219 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'user as u'; |
|
220 | - $this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid'; |
|
221 | - $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('holiday').')'; |
|
222 | - |
|
223 | - // Example: |
|
224 | - // $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
225 | - // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
226 | - // $this->export_permission[$r]=array(array("facture","facture","export")); |
|
227 | - // $this->export_fields_array[$r]=array( |
|
228 | - // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', |
|
229 | - // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', |
|
230 | - // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", |
|
231 | - // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', |
|
232 | - // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate", |
|
233 | - // 'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart", |
|
234 | - // 'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' |
|
235 | - //); |
|
236 | - // $this->export_entities_array[$r]=array( |
|
237 | - // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', |
|
238 | - // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', |
|
239 | - // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice", |
|
240 | - // 'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line", |
|
241 | - // 'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line", |
|
242 | - // 'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' |
|
243 | - //); |
|
244 | - // $this->export_alias_array[$r]=array( |
|
245 | - // 's.rowid'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.zip'=>'soc_zip','s.town'=>'soc_town','s.fk_pays'=>'soc_pays','s.phone'=>'soc_tel', |
|
246 | - // 's.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','s.code_compta'=>'soc_customer_accountancy', |
|
247 | - // 's.code_compta_fournisseur'=>'soc_supplier_accountancy','f.rowid'=>"invoiceid",'f.ref'=>"ref",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice", |
|
248 | - // 'f.total'=>"totalht",'f.total_ttc'=>"totalttc",'f.tva'=>"totalvat",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid', |
|
249 | - // 'fd.description'=>"linedescription",'fd.price'=>"lineprice",'fd.total_ht'=>"linetotalht",'fd.total_tva'=>"linetotaltva",'fd.total_ttc'=>"linetotalttc", |
|
250 | - // 'fd.tva_tx'=>"linevatrate",'fd.qty'=>"lineqty",'fd.date_start'=>"linedatestart",'fd.date_end'=>"linedateend",'fd.fk_product'=>'productid', |
|
251 | - // 'p.ref'=>'productref' |
|
252 | - //); |
|
253 | - // $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
254 | - // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; |
|
255 | - // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; |
|
256 | - // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; |
|
257 | - // $r++; |
|
258 | - } |
|
39 | + /** |
|
40 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
41 | + * |
|
42 | + * @param DoliDB $db Database handler |
|
43 | + */ |
|
44 | + function __construct($db) |
|
45 | + { |
|
46 | + $this->db = $db; |
|
47 | + |
|
48 | + // Id for module (must be unique). |
|
49 | + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). |
|
50 | + $this->numero = 20000; |
|
51 | + // Key text used to identify module (for permissions, menus, etc...) |
|
52 | + $this->rights_class = 'holiday'; |
|
53 | + |
|
54 | + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
|
55 | + // It is used to group modules in module setup page |
|
56 | + $this->family = "hr"; |
|
57 | + $this->module_position = '30'; |
|
58 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
59 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
60 | + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
|
61 | + $this->description = "Leave requests"; |
|
62 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
63 | + $this->version = 'dolibarr'; |
|
64 | + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) |
|
65 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
66 | + // Name of image file used for this module. |
|
67 | + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
|
68 | + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' |
|
69 | + $this->picto='holiday'; |
|
70 | + |
|
71 | + // Data directories to create when module is enabled. |
|
72 | + // Example: this->dirs = array("/mymodule/temp"); |
|
73 | + $this->dirs = array("/holiday/temp"); |
|
74 | + $r=0; |
|
75 | + |
|
76 | + // Config pages |
|
77 | + $this->config_page_url = array("holiday.php"); |
|
78 | + |
|
79 | + |
|
80 | + // Config pages. Put here list of php page names stored in admmin directory used to setup module. |
|
81 | + // $this->config_page_url = array("holiday.php?leftmenu=setup@holiday"); |
|
82 | + |
|
83 | + // Dependencies |
|
84 | + $this->hidden = false; // A condition to hide module |
|
85 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
86 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
87 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
88 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
89 | + $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module |
|
90 | + $this->langfiles = array("holiday"); |
|
91 | + |
|
92 | + // Constants |
|
93 | + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), |
|
94 | + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); |
|
95 | + // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0) |
|
96 | + $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities') |
|
97 | + $r=0; |
|
98 | + |
|
99 | + $this->const[$r][0] = "HOLIDAY_ADDON"; |
|
100 | + $this->const[$r][1] = "chaine"; |
|
101 | + $this->const[$r][2] = "mod_holiday_madonna"; |
|
102 | + $this->const[$r][3] = 'Nom du gestionnaire de numerotation des congés'; |
|
103 | + $this->const[$r][4] = 0; |
|
104 | + $r++; |
|
105 | + |
|
106 | + $this->const[$r][0] = "HOLIDAY_ADDON_PDF"; |
|
107 | + $this->const[$r][1] = "chaine"; |
|
108 | + $this->const[$r][2] = "celebrate"; |
|
109 | + $this->const[$r][3] = 'Name of PDF model of holiday'; |
|
110 | + $this->const[$r][4] = 0; |
|
111 | + $r++; |
|
112 | + |
|
113 | + $this->const[$r][0] = "HOLIDAY_ADDON_PDF_ODT_PATH"; |
|
114 | + $this->const[$r][1] = "chaine"; |
|
115 | + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/holiday"; |
|
116 | + $this->const[$r][3] = ""; |
|
117 | + $this->const[$r][4] = 0; |
|
118 | + $r++; |
|
119 | + |
|
120 | + // Array to add new pages in new tabs |
|
121 | + //$this->tabs[] = array('data'=>'user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=hrm&id=__ID__'); // We avoid to get one tab for each module. RH data are already in RH tab. |
|
122 | + $this->tabs[] = array(); // To add a new tab identified by code tabname1 |
|
123 | + |
|
124 | + // Boxes |
|
125 | + $this->boxes = array(); // List of boxes |
|
126 | + $r=0; |
|
127 | + |
|
128 | + // Add here list of php file(s) stored in includes/boxes that contains class to show a box. |
|
129 | + // Example: |
|
130 | + //$this->boxes[$r][1] = "myboxa.php"; |
|
131 | + //$r++; |
|
132 | + //$this->boxes[$r][1] = "myboxb.php"; |
|
133 | + //$r++; |
|
134 | + |
|
135 | + |
|
136 | + // Permissions |
|
137 | + $this->rights = array(); // Permission array used by this module |
|
138 | + $r=0; |
|
139 | + |
|
140 | + $this->rights[$r][0] = 20001; // Permission id (must not be already used) |
|
141 | + $this->rights[$r][1] = 'Read your own leave requests'; // Permission label |
|
142 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
143 | + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
144 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
145 | + $r++; |
|
146 | + |
|
147 | + $this->rights[$r][0] = 20002; // Permission id (must not be already used) |
|
148 | + $this->rights[$r][1] = 'Create/modify your own leave requests'; // Permission label |
|
149 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
150 | + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
151 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
152 | + $r++; |
|
153 | + |
|
154 | + $this->rights[$r][0] = 20003; // Permission id (must not be already used) |
|
155 | + $this->rights[$r][1] = 'Delete leave requests'; // Permission label |
|
156 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
157 | + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
158 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
159 | + $r++; |
|
160 | + |
|
161 | + $this->rights[$r][0] = 20007; |
|
162 | + $this->rights[$r][1] = 'Approve leave requests'; |
|
163 | + $this->rights[$r][2] = 'w'; |
|
164 | + $this->rights[$r][3] = 0; |
|
165 | + $this->rights[$r][4] = 'approve'; |
|
166 | + $r++; |
|
167 | + |
|
168 | + $this->rights[$r][0] = 20004; // Permission id (must not be already used) |
|
169 | + $this->rights[$r][1] = 'Read leave requests for everybody'; // Permission label |
|
170 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
171 | + $this->rights[$r][4] = 'read_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
172 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
173 | + $r++; |
|
174 | + |
|
175 | + $this->rights[$r][0] = 20005; // Permission id (must not be already used) |
|
176 | + $this->rights[$r][1] = 'Create/modify leave requests for everybody'; // Permission label |
|
177 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
178 | + $this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
179 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
180 | + $r++; |
|
181 | + |
|
182 | + $this->rights[$r][0] = 20006; // Permission id (must not be already used) |
|
183 | + $this->rights[$r][1] = 'Setup leave requests of users (setup and update balance)'; // Permission label |
|
184 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
185 | + $this->rights[$r][4] = 'define_holiday'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
186 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
187 | + $r++; |
|
188 | + |
|
189 | + |
|
190 | + // Menus |
|
191 | + //------- |
|
192 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
193 | + |
|
194 | + |
|
195 | + // Exports |
|
196 | + $r=0; |
|
197 | + |
|
198 | + $r++; |
|
199 | + $this->export_code[$r]='leaverequest_'.$r; |
|
200 | + $this->export_label[$r]='ListeCP'; |
|
201 | + $this->export_icon[$r]='holiday'; |
|
202 | + $this->export_permission[$r]=array(array("holiday","read_all")); |
|
203 | + $this->export_fields_array[$r]=array( |
|
204 | + 'd.rowid'=>"LeaveId",'d.fk_type'=>'TypeOfLeaveId','t.code'=>'TypeOfLeaveCode','t.label'=>'TypeOfLeaveLabel','d.fk_user'=>'UserID', |
|
205 | + 'u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.halfday'=>'HalfDay', |
|
206 | + 'd.date_valid'=>'DateApprove','d.fk_validator'=>"UserForApprovalID",'ua.lastname'=>"UserForApprovalLastname",'ua.firstname'=>"UserForApprovalFirstname", |
|
207 | + 'ua.login'=>"UserForApprovalLogin",'d.description'=>'Description','d.statut'=>'Status' |
|
208 | + ); |
|
209 | + $this->export_entities_array[$r]=array( |
|
210 | + 'u.lastname'=>'user','u.firstname'=>'user','u.login'=>'user','ua.lastname'=>'user','ua.firstname'=>'user','ua.login'=>'user' |
|
211 | + ); |
|
212 | + $this->export_alias_array[$r]=array('d.rowid'=>"idholiday"); |
|
213 | + $this->export_dependencies_array[$r]=array(); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
214 | + |
|
215 | + $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
216 | + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'holiday as d'; |
|
217 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_holiday_types as t ON t.rowid = d.fk_type'; |
|
218 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua ON ua.rowid = d.fk_validator,'; |
|
219 | + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'user as u'; |
|
220 | + $this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid'; |
|
221 | + $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('holiday').')'; |
|
222 | + |
|
223 | + // Example: |
|
224 | + // $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
225 | + // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
226 | + // $this->export_permission[$r]=array(array("facture","facture","export")); |
|
227 | + // $this->export_fields_array[$r]=array( |
|
228 | + // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', |
|
229 | + // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', |
|
230 | + // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", |
|
231 | + // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', |
|
232 | + // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate", |
|
233 | + // 'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart", |
|
234 | + // 'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' |
|
235 | + //); |
|
236 | + // $this->export_entities_array[$r]=array( |
|
237 | + // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', |
|
238 | + // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', |
|
239 | + // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice", |
|
240 | + // 'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line", |
|
241 | + // 'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line", |
|
242 | + // 'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' |
|
243 | + //); |
|
244 | + // $this->export_alias_array[$r]=array( |
|
245 | + // 's.rowid'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.zip'=>'soc_zip','s.town'=>'soc_town','s.fk_pays'=>'soc_pays','s.phone'=>'soc_tel', |
|
246 | + // 's.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','s.code_compta'=>'soc_customer_accountancy', |
|
247 | + // 's.code_compta_fournisseur'=>'soc_supplier_accountancy','f.rowid'=>"invoiceid",'f.ref'=>"ref",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice", |
|
248 | + // 'f.total'=>"totalht",'f.total_ttc'=>"totalttc",'f.tva'=>"totalvat",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid', |
|
249 | + // 'fd.description'=>"linedescription",'fd.price'=>"lineprice",'fd.total_ht'=>"linetotalht",'fd.total_tva'=>"linetotaltva",'fd.total_ttc'=>"linetotalttc", |
|
250 | + // 'fd.tva_tx'=>"linevatrate",'fd.qty'=>"lineqty",'fd.date_start'=>"linedatestart",'fd.date_end'=>"linedateend",'fd.fk_product'=>'productid', |
|
251 | + // 'p.ref'=>'productref' |
|
252 | + //); |
|
253 | + // $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
254 | + // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; |
|
255 | + // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; |
|
256 | + // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; |
|
257 | + // $r++; |
|
258 | + } |
|
259 | 259 | } |
260 | 260 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * \ingroup holiday |
29 | 29 | * \brief Description and activation file for module holiday |
30 | 30 | */ |
31 | -include_once DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php"; |
|
31 | +include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php"; |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $this->family = "hr"; |
57 | 57 | $this->module_position = '30'; |
58 | 58 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
59 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
59 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
60 | 60 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
61 | 61 | $this->description = "Leave requests"; |
62 | 62 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | // Name of image file used for this module. |
67 | 67 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
68 | 68 | // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' |
69 | - $this->picto='holiday'; |
|
69 | + $this->picto = 'holiday'; |
|
70 | 70 | |
71 | 71 | // Data directories to create when module is enabled. |
72 | 72 | // Example: this->dirs = array("/mymodule/temp"); |
73 | 73 | $this->dirs = array("/holiday/temp"); |
74 | - $r=0; |
|
74 | + $r = 0; |
|
75 | 75 | |
76 | 76 | // Config pages |
77 | 77 | $this->config_page_url = array("holiday.php"); |
@@ -81,20 +81,20 @@ discard block |
||
81 | 81 | // $this->config_page_url = array("holiday.php?leftmenu=setup@holiday"); |
82 | 82 | |
83 | 83 | // Dependencies |
84 | - $this->hidden = false; // A condition to hide module |
|
85 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
86 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
87 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
88 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
89 | - $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module |
|
84 | + $this->hidden = false; // A condition to hide module |
|
85 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
86 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
87 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
88 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
89 | + $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module |
|
90 | 90 | $this->langfiles = array("holiday"); |
91 | 91 | |
92 | 92 | // Constants |
93 | 93 | // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), |
94 | 94 | // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); |
95 | 95 | // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0) |
96 | - $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities') |
|
97 | - $r=0; |
|
96 | + $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities') |
|
97 | + $r = 0; |
|
98 | 98 | |
99 | 99 | $this->const[$r][0] = "HOLIDAY_ADDON"; |
100 | 100 | $this->const[$r][1] = "chaine"; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | |
120 | 120 | // Array to add new pages in new tabs |
121 | 121 | //$this->tabs[] = array('data'=>'user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=hrm&id=__ID__'); // We avoid to get one tab for each module. RH data are already in RH tab. |
122 | - $this->tabs[] = array(); // To add a new tab identified by code tabname1 |
|
122 | + $this->tabs[] = array(); // To add a new tab identified by code tabname1 |
|
123 | 123 | |
124 | 124 | // Boxes |
125 | - $this->boxes = array(); // List of boxes |
|
126 | - $r=0; |
|
125 | + $this->boxes = array(); // List of boxes |
|
126 | + $r = 0; |
|
127 | 127 | |
128 | 128 | // Add here list of php file(s) stored in includes/boxes that contains class to show a box. |
129 | 129 | // Example: |
@@ -134,28 +134,28 @@ discard block |
||
134 | 134 | |
135 | 135 | |
136 | 136 | // Permissions |
137 | - $this->rights = array(); // Permission array used by this module |
|
138 | - $r=0; |
|
139 | - |
|
140 | - $this->rights[$r][0] = 20001; // Permission id (must not be already used) |
|
141 | - $this->rights[$r][1] = 'Read your own leave requests'; // Permission label |
|
142 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
143 | - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
144 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
137 | + $this->rights = array(); // Permission array used by this module |
|
138 | + $r = 0; |
|
139 | + |
|
140 | + $this->rights[$r][0] = 20001; // Permission id (must not be already used) |
|
141 | + $this->rights[$r][1] = 'Read your own leave requests'; // Permission label |
|
142 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
143 | + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
144 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
145 | 145 | $r++; |
146 | 146 | |
147 | - $this->rights[$r][0] = 20002; // Permission id (must not be already used) |
|
148 | - $this->rights[$r][1] = 'Create/modify your own leave requests'; // Permission label |
|
149 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
150 | - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
151 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
147 | + $this->rights[$r][0] = 20002; // Permission id (must not be already used) |
|
148 | + $this->rights[$r][1] = 'Create/modify your own leave requests'; // Permission label |
|
149 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
150 | + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
151 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
152 | 152 | $r++; |
153 | 153 | |
154 | - $this->rights[$r][0] = 20003; // Permission id (must not be already used) |
|
155 | - $this->rights[$r][1] = 'Delete leave requests'; // Permission label |
|
156 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
157 | - $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
158 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
154 | + $this->rights[$r][0] = 20003; // Permission id (must not be already used) |
|
155 | + $this->rights[$r][1] = 'Delete leave requests'; // Permission label |
|
156 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
157 | + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
158 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
159 | 159 | $r++; |
160 | 160 | |
161 | 161 | $this->rights[$r][0] = 20007; |
@@ -165,60 +165,60 @@ discard block |
||
165 | 165 | $this->rights[$r][4] = 'approve'; |
166 | 166 | $r++; |
167 | 167 | |
168 | - $this->rights[$r][0] = 20004; // Permission id (must not be already used) |
|
169 | - $this->rights[$r][1] = 'Read leave requests for everybody'; // Permission label |
|
170 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
171 | - $this->rights[$r][4] = 'read_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
172 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
168 | + $this->rights[$r][0] = 20004; // Permission id (must not be already used) |
|
169 | + $this->rights[$r][1] = 'Read leave requests for everybody'; // Permission label |
|
170 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
171 | + $this->rights[$r][4] = 'read_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
172 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
173 | 173 | $r++; |
174 | 174 | |
175 | - $this->rights[$r][0] = 20005; // Permission id (must not be already used) |
|
176 | - $this->rights[$r][1] = 'Create/modify leave requests for everybody'; // Permission label |
|
177 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
178 | - $this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
179 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
175 | + $this->rights[$r][0] = 20005; // Permission id (must not be already used) |
|
176 | + $this->rights[$r][1] = 'Create/modify leave requests for everybody'; // Permission label |
|
177 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
178 | + $this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
179 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
180 | 180 | $r++; |
181 | 181 | |
182 | - $this->rights[$r][0] = 20006; // Permission id (must not be already used) |
|
183 | - $this->rights[$r][1] = 'Setup leave requests of users (setup and update balance)'; // Permission label |
|
184 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
185 | - $this->rights[$r][4] = 'define_holiday'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
186 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
182 | + $this->rights[$r][0] = 20006; // Permission id (must not be already used) |
|
183 | + $this->rights[$r][1] = 'Setup leave requests of users (setup and update balance)'; // Permission label |
|
184 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
185 | + $this->rights[$r][4] = 'define_holiday'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
186 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
187 | 187 | $r++; |
188 | 188 | |
189 | 189 | |
190 | 190 | // Menus |
191 | 191 | //------- |
192 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
192 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
193 | 193 | |
194 | 194 | |
195 | 195 | // Exports |
196 | - $r=0; |
|
196 | + $r = 0; |
|
197 | 197 | |
198 | 198 | $r++; |
199 | - $this->export_code[$r]='leaverequest_'.$r; |
|
200 | - $this->export_label[$r]='ListeCP'; |
|
201 | - $this->export_icon[$r]='holiday'; |
|
202 | - $this->export_permission[$r]=array(array("holiday","read_all")); |
|
203 | - $this->export_fields_array[$r]=array( |
|
204 | - 'd.rowid'=>"LeaveId",'d.fk_type'=>'TypeOfLeaveId','t.code'=>'TypeOfLeaveCode','t.label'=>'TypeOfLeaveLabel','d.fk_user'=>'UserID', |
|
205 | - 'u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.halfday'=>'HalfDay', |
|
206 | - 'd.date_valid'=>'DateApprove','d.fk_validator'=>"UserForApprovalID",'ua.lastname'=>"UserForApprovalLastname",'ua.firstname'=>"UserForApprovalFirstname", |
|
207 | - 'ua.login'=>"UserForApprovalLogin",'d.description'=>'Description','d.statut'=>'Status' |
|
199 | + $this->export_code[$r] = 'leaverequest_'.$r; |
|
200 | + $this->export_label[$r] = 'ListeCP'; |
|
201 | + $this->export_icon[$r] = 'holiday'; |
|
202 | + $this->export_permission[$r] = array(array("holiday", "read_all")); |
|
203 | + $this->export_fields_array[$r] = array( |
|
204 | + 'd.rowid'=>"LeaveId", 'd.fk_type'=>'TypeOfLeaveId', 't.code'=>'TypeOfLeaveCode', 't.label'=>'TypeOfLeaveLabel', 'd.fk_user'=>'UserID', |
|
205 | + 'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'u.login'=>"Login", 'd.date_debut'=>'DateStart', 'd.date_fin'=>'DateEnd', 'd.halfday'=>'HalfDay', |
|
206 | + 'd.date_valid'=>'DateApprove', 'd.fk_validator'=>"UserForApprovalID", 'ua.lastname'=>"UserForApprovalLastname", 'ua.firstname'=>"UserForApprovalFirstname", |
|
207 | + 'ua.login'=>"UserForApprovalLogin", 'd.description'=>'Description', 'd.statut'=>'Status' |
|
208 | 208 | ); |
209 | - $this->export_entities_array[$r]=array( |
|
210 | - 'u.lastname'=>'user','u.firstname'=>'user','u.login'=>'user','ua.lastname'=>'user','ua.firstname'=>'user','ua.login'=>'user' |
|
209 | + $this->export_entities_array[$r] = array( |
|
210 | + 'u.lastname'=>'user', 'u.firstname'=>'user', 'u.login'=>'user', 'ua.lastname'=>'user', 'ua.firstname'=>'user', 'ua.login'=>'user' |
|
211 | 211 | ); |
212 | - $this->export_alias_array[$r]=array('d.rowid'=>"idholiday"); |
|
213 | - $this->export_dependencies_array[$r]=array(); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
214 | - |
|
215 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
216 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'holiday as d'; |
|
217 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_holiday_types as t ON t.rowid = d.fk_type'; |
|
218 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua ON ua.rowid = d.fk_validator,'; |
|
219 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'user as u'; |
|
220 | - $this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid'; |
|
221 | - $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('holiday').')'; |
|
212 | + $this->export_alias_array[$r] = array('d.rowid'=>"idholiday"); |
|
213 | + $this->export_dependencies_array[$r] = array(); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
214 | + |
|
215 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
216 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'holiday as d'; |
|
217 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_holiday_types as t ON t.rowid = d.fk_type'; |
|
218 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua ON ua.rowid = d.fk_validator,'; |
|
219 | + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'user as u'; |
|
220 | + $this->export_sql_end[$r] .= ' WHERE d.fk_user = u.rowid'; |
|
221 | + $this->export_sql_end[$r] .= ' AND d.entity IN ('.getEntity('holiday').')'; |
|
222 | 222 | |
223 | 223 | // Example: |
224 | 224 | // $this->export_code[$r]=$this->rights_class.'_'.$r; |
@@ -41,76 +41,76 @@ discard block |
||
41 | 41 | public $datatoimport; |
42 | 42 | |
43 | 43 | /** |
44 | - * @var string Error code (or message) |
|
45 | - */ |
|
46 | - public $error=''; |
|
44 | + * @var string Error code (or message) |
|
45 | + */ |
|
46 | + public $error=''; |
|
47 | 47 | |
48 | - /** |
|
49 | - * @var string[] Error codes (or messages) |
|
50 | - */ |
|
51 | - public $errors = array(); |
|
48 | + /** |
|
49 | + * @var string[] Error codes (or messages) |
|
50 | + */ |
|
51 | + public $errors = array(); |
|
52 | 52 | |
53 | 53 | /** |
54 | - * @var int ID |
|
55 | - */ |
|
56 | - public $id; |
|
54 | + * @var int ID |
|
55 | + */ |
|
56 | + public $id; |
|
57 | 57 | |
58 | - /** |
|
58 | + /** |
|
59 | 59 | * @var string label |
60 | 60 | */ |
61 | 61 | public $label; |
62 | 62 | |
63 | - public $extension; // Extension of files imported by driver |
|
63 | + public $extension; // Extension of files imported by driver |
|
64 | 64 | |
65 | - /** |
|
65 | + /** |
|
66 | 66 | * Dolibarr version of driver |
67 | 67 | * @public string |
68 | 68 | */ |
69 | - public $version = 'dolibarr'; |
|
69 | + public $version = 'dolibarr'; |
|
70 | 70 | |
71 | - public $label_lib; // Label of external lib used by driver |
|
71 | + public $label_lib; // Label of external lib used by driver |
|
72 | 72 | |
73 | - public $version_lib; // Version of external lib used by driver |
|
73 | + public $version_lib; // Version of external lib used by driver |
|
74 | 74 | |
75 | - public $separator; |
|
75 | + public $separator; |
|
76 | 76 | |
77 | 77 | public $file; // Path of file |
78 | 78 | |
79 | - public $handle; // Handle fichier |
|
80 | - |
|
81 | - public $cacheconvert=array(); // Array to cache list of value found after a convertion |
|
79 | + public $handle; // Handle fichier |
|
82 | 80 | |
83 | - public $cachefieldtable=array(); // Array to cache list of value found into fields@tables |
|
81 | + public $cacheconvert=array(); // Array to cache list of value found after a convertion |
|
84 | 82 | |
85 | - public $workbook; // temporary import file |
|
83 | + public $cachefieldtable=array(); // Array to cache list of value found into fields@tables |
|
86 | 84 | |
87 | - public $record; // current record |
|
85 | + public $workbook; // temporary import file |
|
88 | 86 | |
89 | - public $headers; |
|
87 | + public $record; // current record |
|
90 | 88 | |
89 | + public $headers; |
|
91 | 90 | |
92 | - /** |
|
93 | - * Constructor |
|
94 | - * |
|
95 | - * @param DoliDB $db Database handler |
|
96 | - * @param string $datatoimport String code describing import set (ex: 'societe_1') |
|
97 | - */ |
|
98 | - function __construct($db,$datatoimport) |
|
99 | - { |
|
100 | - global $conf,$langs; |
|
101 | - $this->db = $db; |
|
102 | 91 | |
103 | - // this is used as an extension from the example file code, so we have to put xlsx here !!! |
|
104 | - $this->id='xlsx'; // Same value as xxx in file name export_xxx.modules.php |
|
105 | - $this->label='Excel 2007'; // Label of driver |
|
106 | - $this->desc=$langs->trans("Excel2007FormatDesc"); |
|
107 | - $this->extension='xlsx'; // Extension for generated file by this driver |
|
108 | - $this->picto='mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) |
|
109 | - $this->version='1.0'; // Driver version |
|
110 | - |
|
111 | - // If driver use an external library, put its name here |
|
92 | + /** |
|
93 | + * Constructor |
|
94 | + * |
|
95 | + * @param DoliDB $db Database handler |
|
96 | + * @param string $datatoimport String code describing import set (ex: 'societe_1') |
|
97 | + */ |
|
98 | + function __construct($db,$datatoimport) |
|
99 | + { |
|
100 | + global $conf,$langs; |
|
101 | + $this->db = $db; |
|
102 | + |
|
103 | + // this is used as an extension from the example file code, so we have to put xlsx here !!! |
|
104 | + $this->id='xlsx'; // Same value as xxx in file name export_xxx.modules.php |
|
105 | + $this->label='Excel 2007'; // Label of driver |
|
106 | + $this->desc=$langs->trans("Excel2007FormatDesc"); |
|
107 | + $this->extension='xlsx'; // Extension for generated file by this driver |
|
108 | + $this->picto='mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) |
|
109 | + $this->version='1.0'; // Driver version |
|
110 | + |
|
111 | + // If driver use an external library, put its name here |
|
112 | 112 | require_once PHPEXCEL_PATH.'PHPExcel.php'; |
113 | - require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; |
|
113 | + require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; |
|
114 | 114 | if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive |
115 | 115 | { |
116 | 116 | $langs->load("errors"); |
@@ -120,20 +120,20 @@ discard block |
||
120 | 120 | $this->label_lib='PhpExcel'; |
121 | 121 | $this->version_lib='1.8.0'; |
122 | 122 | |
123 | - $this->datatoimport=$datatoimport; |
|
124 | - if (preg_match('/^societe_/',$datatoimport)) $this->thirpartyobject=new Societe($this->db); |
|
125 | - } |
|
123 | + $this->datatoimport=$datatoimport; |
|
124 | + if (preg_match('/^societe_/',$datatoimport)) $this->thirpartyobject=new Societe($this->db); |
|
125 | + } |
|
126 | 126 | |
127 | 127 | |
128 | 128 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
129 | - /** |
|
130 | - * Output header of an example file for this format |
|
131 | - * |
|
132 | - * @param Translate $outputlangs Output language |
|
133 | - * @return string |
|
134 | - */ |
|
135 | - function write_header_example($outputlangs) |
|
136 | - { |
|
129 | + /** |
|
130 | + * Output header of an example file for this format |
|
131 | + * |
|
132 | + * @param Translate $outputlangs Output language |
|
133 | + * @return string |
|
134 | + */ |
|
135 | + function write_header_example($outputlangs) |
|
136 | + { |
|
137 | 137 | // phpcs:enable |
138 | 138 | global $user,$conf,$langs; |
139 | 139 | // create a temporary object, the final output will be generated in footer |
@@ -159,291 +159,291 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
162 | - /** |
|
163 | - * Output title line of an example file for this format |
|
164 | - * |
|
165 | - * @param Translate $outputlangs Output language |
|
166 | - * @param array $headerlinefields Array of fields name |
|
167 | - * @return string |
|
168 | - */ |
|
169 | - function write_title_example($outputlangs,$headerlinefields) |
|
170 | - { |
|
162 | + /** |
|
163 | + * Output title line of an example file for this format |
|
164 | + * |
|
165 | + * @param Translate $outputlangs Output language |
|
166 | + * @param array $headerlinefields Array of fields name |
|
167 | + * @return string |
|
168 | + */ |
|
169 | + function write_title_example($outputlangs,$headerlinefields) |
|
170 | + { |
|
171 | 171 | // phpcs:enable |
172 | - global $conf; |
|
173 | - $this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true); |
|
174 | - $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); |
|
175 | - |
|
176 | - $col = 0; |
|
177 | - foreach($headerlinefields as $field) { |
|
178 | - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, 1, $outputlangs->transnoentities($field)); |
|
179 | - // set autowidth |
|
180 | - //$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($col + 1))->setAutoSize(true); |
|
181 | - $col++; |
|
182 | - } |
|
172 | + global $conf; |
|
173 | + $this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true); |
|
174 | + $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); |
|
175 | + |
|
176 | + $col = 0; |
|
177 | + foreach($headerlinefields as $field) { |
|
178 | + $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, 1, $outputlangs->transnoentities($field)); |
|
179 | + // set autowidth |
|
180 | + //$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($col + 1))->setAutoSize(true); |
|
181 | + $col++; |
|
182 | + } |
|
183 | 183 | |
184 | - return ''; // final output will be generated in footer |
|
185 | - } |
|
184 | + return ''; // final output will be generated in footer |
|
185 | + } |
|
186 | 186 | |
187 | 187 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
188 | - /** |
|
189 | - * Output record of an example file for this format |
|
190 | - * |
|
191 | - * @param Translate $outputlangs Output language |
|
192 | - * @param array $contentlinevalues Array of lines |
|
193 | - * @return string |
|
194 | - */ |
|
195 | - function write_record_example($outputlangs,$contentlinevalues) |
|
196 | - { |
|
188 | + /** |
|
189 | + * Output record of an example file for this format |
|
190 | + * |
|
191 | + * @param Translate $outputlangs Output language |
|
192 | + * @param array $contentlinevalues Array of lines |
|
193 | + * @return string |
|
194 | + */ |
|
195 | + function write_record_example($outputlangs,$contentlinevalues) |
|
196 | + { |
|
197 | 197 | // phpcs:enable |
198 | - $col = 0; |
|
199 | - $row = 2; |
|
200 | - foreach($contentlinevalues as $cell) { |
|
201 | - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, $row, $cell); |
|
202 | - $col++; |
|
203 | - } |
|
198 | + $col = 0; |
|
199 | + $row = 2; |
|
200 | + foreach($contentlinevalues as $cell) { |
|
201 | + $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, $row, $cell); |
|
202 | + $col++; |
|
203 | + } |
|
204 | 204 | |
205 | - return ''; // final output will be generated in footer |
|
206 | - } |
|
205 | + return ''; // final output will be generated in footer |
|
206 | + } |
|
207 | 207 | |
208 | 208 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
209 | - /** |
|
210 | - * Output footer of an example file for this format |
|
211 | - * |
|
212 | - * @param Translate $outputlangs Output language |
|
213 | - * @return string |
|
214 | - */ |
|
215 | - function write_footer_example($outputlangs) |
|
216 | - { |
|
209 | + /** |
|
210 | + * Output footer of an example file for this format |
|
211 | + * |
|
212 | + * @param Translate $outputlangs Output language |
|
213 | + * @return string |
|
214 | + */ |
|
215 | + function write_footer_example($outputlangs) |
|
216 | + { |
|
217 | 217 | // phpcs:enable |
218 | - // return the file content as a string |
|
219 | - $tempfile = tempnam(sys_get_temp_dir(), 'dol'); |
|
220 | - $objWriter = new PHPExcel_Writer_Excel2007($this->workbook); |
|
221 | - $objWriter->save($tempfile); |
|
222 | - $this->workbook->disconnectWorksheets(); |
|
223 | - unset($this->workbook); |
|
224 | - |
|
225 | - $content = file_get_contents($tempfile); |
|
226 | - unlink($tempfile); |
|
227 | - return $content; |
|
228 | - } |
|
218 | + // return the file content as a string |
|
219 | + $tempfile = tempnam(sys_get_temp_dir(), 'dol'); |
|
220 | + $objWriter = new PHPExcel_Writer_Excel2007($this->workbook); |
|
221 | + $objWriter->save($tempfile); |
|
222 | + $this->workbook->disconnectWorksheets(); |
|
223 | + unset($this->workbook); |
|
224 | + |
|
225 | + $content = file_get_contents($tempfile); |
|
226 | + unlink($tempfile); |
|
227 | + return $content; |
|
228 | + } |
|
229 | 229 | |
230 | 230 | |
231 | 231 | |
232 | 232 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
233 | - /** |
|
234 | - * Open input file |
|
235 | - * |
|
236 | - * @param string $file Path of filename |
|
237 | - * @return int <0 if KO, >=0 if OK |
|
238 | - */ |
|
239 | - function import_open_file($file) |
|
240 | - { |
|
233 | + /** |
|
234 | + * Open input file |
|
235 | + * |
|
236 | + * @param string $file Path of filename |
|
237 | + * @return int <0 if KO, >=0 if OK |
|
238 | + */ |
|
239 | + function import_open_file($file) |
|
240 | + { |
|
241 | 241 | // phpcs:enable |
242 | - global $langs; |
|
243 | - $ret=1; |
|
242 | + global $langs; |
|
243 | + $ret=1; |
|
244 | 244 | |
245 | - dol_syslog(get_class($this)."::open_file file=".$file); |
|
245 | + dol_syslog(get_class($this)."::open_file file=".$file); |
|
246 | 246 | |
247 | - $reader = new PHPExcel_Reader_Excel2007(); |
|
248 | - $this->workbook = $reader->load($file); |
|
249 | - $this->record = 1; |
|
250 | - $this->file = $file; |
|
247 | + $reader = new PHPExcel_Reader_Excel2007(); |
|
248 | + $this->workbook = $reader->load($file); |
|
249 | + $this->record = 1; |
|
250 | + $this->file = $file; |
|
251 | 251 | |
252 | - return $ret; |
|
253 | - } |
|
252 | + return $ret; |
|
253 | + } |
|
254 | 254 | |
255 | 255 | |
256 | 256 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
257 | - /** |
|
258 | - * Return nb of records. File must be closed. |
|
259 | - * |
|
260 | - * @param string $file Path of filename |
|
261 | - * @return int <0 if KO, >=0 if OK |
|
262 | - */ |
|
263 | - function import_get_nb_of_lines($file) |
|
264 | - { |
|
257 | + /** |
|
258 | + * Return nb of records. File must be closed. |
|
259 | + * |
|
260 | + * @param string $file Path of filename |
|
261 | + * @return int <0 if KO, >=0 if OK |
|
262 | + */ |
|
263 | + function import_get_nb_of_lines($file) |
|
264 | + { |
|
265 | 265 | // phpcs:enable |
266 | - $reader = new PHPExcel_Reader_Excel2007(); |
|
267 | - $this->workbook = $reader->load($file); |
|
266 | + $reader = new PHPExcel_Reader_Excel2007(); |
|
267 | + $this->workbook = $reader->load($file); |
|
268 | 268 | |
269 | - $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow(); |
|
269 | + $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow(); |
|
270 | 270 | |
271 | - $this->workbook->disconnectWorksheets(); |
|
272 | - unset($this->workbook); |
|
271 | + $this->workbook->disconnectWorksheets(); |
|
272 | + unset($this->workbook); |
|
273 | 273 | |
274 | - return $rowcount; |
|
275 | - } |
|
274 | + return $rowcount; |
|
275 | + } |
|
276 | 276 | |
277 | 277 | |
278 | 278 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
279 | - /** |
|
280 | - * Input header line from file |
|
281 | - * |
|
282 | - * @return int <0 if KO, >=0 if OK |
|
283 | - */ |
|
284 | - function import_read_header() |
|
285 | - { |
|
279 | + /** |
|
280 | + * Input header line from file |
|
281 | + * |
|
282 | + * @return int <0 if KO, >=0 if OK |
|
283 | + */ |
|
284 | + function import_read_header() |
|
285 | + { |
|
286 | 286 | // phpcs:enable |
287 | - // This is not called by the import code !!! |
|
288 | - $this->headers = array(); |
|
289 | - $colcount = PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn()); |
|
290 | - for($col=0;$col<$colcount;$col++) { |
|
291 | - $this->headers[$col] = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, 1)->getValue(); |
|
292 | - } |
|
293 | - return 0; |
|
294 | - } |
|
287 | + // This is not called by the import code !!! |
|
288 | + $this->headers = array(); |
|
289 | + $colcount = PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn()); |
|
290 | + for($col=0;$col<$colcount;$col++) { |
|
291 | + $this->headers[$col] = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, 1)->getValue(); |
|
292 | + } |
|
293 | + return 0; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | |
297 | 297 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
298 | - /** |
|
299 | - * Return array of next record in input file. |
|
300 | - * |
|
301 | - * @return Array Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string) |
|
302 | - */ |
|
303 | - function import_read_record() |
|
304 | - { |
|
298 | + /** |
|
299 | + * Return array of next record in input file. |
|
300 | + * |
|
301 | + * @return Array Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string) |
|
302 | + */ |
|
303 | + function import_read_record() |
|
304 | + { |
|
305 | 305 | // phpcs:enable |
306 | - global $conf; |
|
307 | - |
|
308 | - $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow(); |
|
309 | - if($this->record > $rowcount) |
|
310 | - return false; |
|
311 | - $array = array(); |
|
312 | - $colcount = PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn(0)); |
|
313 | - for($col=0;$col<$colcount;$col++) { |
|
314 | - $val = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, $this->record)->getValue(); |
|
315 | - $array[$col]['val'] = $val; |
|
316 | - $array[$col]['type'] = (dol_strlen($val)?1:-1); // If empty we consider it null |
|
317 | - } |
|
318 | - $this->record++; |
|
319 | - return $array; |
|
320 | - } |
|
306 | + global $conf; |
|
307 | + |
|
308 | + $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow(); |
|
309 | + if($this->record > $rowcount) |
|
310 | + return false; |
|
311 | + $array = array(); |
|
312 | + $colcount = PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn(0)); |
|
313 | + for($col=0;$col<$colcount;$col++) { |
|
314 | + $val = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, $this->record)->getValue(); |
|
315 | + $array[$col]['val'] = $val; |
|
316 | + $array[$col]['type'] = (dol_strlen($val)?1:-1); // If empty we consider it null |
|
317 | + } |
|
318 | + $this->record++; |
|
319 | + return $array; |
|
320 | + } |
|
321 | 321 | |
322 | 322 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
323 | - /** |
|
324 | - * Close file handle |
|
325 | - * |
|
326 | - * @return integer |
|
327 | - */ |
|
328 | - function import_close_file() |
|
329 | - { |
|
323 | + /** |
|
324 | + * Close file handle |
|
325 | + * |
|
326 | + * @return integer |
|
327 | + */ |
|
328 | + function import_close_file() |
|
329 | + { |
|
330 | 330 | // phpcs:enable |
331 | - $this->workbook->disconnectWorksheets(); |
|
332 | - unset($this->workbook); |
|
333 | - } |
|
331 | + $this->workbook->disconnectWorksheets(); |
|
332 | + unset($this->workbook); |
|
333 | + } |
|
334 | 334 | |
335 | 335 | |
336 | 336 | // What is this doing here ? it is common to all imports, is should be in the parent class |
337 | 337 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
338 | - /** |
|
339 | - * Insert a record into database |
|
340 | - * |
|
341 | - * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... |
|
342 | - * @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]... |
|
343 | - * @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...) |
|
344 | - * @param int $maxfields Max number of fields to use |
|
345 | - * @param string $importid Import key |
|
346 | - * @param array $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor. |
|
347 | - * @return int <0 if KO, >0 if OK |
|
348 | - */ |
|
349 | - function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$maxfields,$importid,$updatekeys) |
|
350 | - { |
|
338 | + /** |
|
339 | + * Insert a record into database |
|
340 | + * |
|
341 | + * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... |
|
342 | + * @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]... |
|
343 | + * @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...) |
|
344 | + * @param int $maxfields Max number of fields to use |
|
345 | + * @param string $importid Import key |
|
346 | + * @param array $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor. |
|
347 | + * @return int <0 if KO, >0 if OK |
|
348 | + */ |
|
349 | + function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$maxfields,$importid,$updatekeys) |
|
350 | + { |
|
351 | 351 | // phpcs:enable |
352 | - global $langs,$conf,$user; |
|
352 | + global $langs,$conf,$user; |
|
353 | 353 | global $thirdparty_static; // Specific to thirdparty import |
354 | - global $tablewithentity_cache; // Cache to avoid to call desc at each rows on tables |
|
355 | - |
|
356 | - $error=0; |
|
357 | - $warning=0; |
|
358 | - $this->errors=array(); |
|
359 | - $this->warnings=array(); |
|
360 | - |
|
361 | - //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); |
|
362 | - |
|
363 | - //var_dump($array_match_file_to_database); |
|
364 | - //var_dump($arrayrecord); |
|
365 | - $array_match_database_to_file=array_flip($array_match_file_to_database); |
|
366 | - $sort_array_match_file_to_database=$array_match_file_to_database; |
|
367 | - ksort($sort_array_match_file_to_database); |
|
368 | - |
|
369 | - //var_dump($sort_array_match_file_to_database); |
|
370 | - |
|
371 | - if (count($arrayrecord) == 0 || (count($arrayrecord) == 1 && empty($arrayrecord[0]['val']))) |
|
372 | - { |
|
373 | - //print 'W'; |
|
374 | - $this->warnings[$warning]['lib']=$langs->trans('EmptyLine'); |
|
375 | - $this->warnings[$warning]['type']='EMPTY'; |
|
376 | - $warning++; |
|
377 | - } |
|
378 | - else |
|
379 | - { |
|
380 | - $last_insert_id_array = array(); // store the last inserted auto_increment id for each table, so that dependent tables can be inserted with the appropriate id (eg: extrafields fk_object will be set with the last inserted object's id) |
|
381 | - $updatedone = false; |
|
382 | - $insertdone = false; |
|
383 | - // For each table to insert, me make a separate insert |
|
384 | - foreach($objimport->array_import_tables[0] as $alias => $tablename) |
|
385 | - { |
|
386 | - // Build sql request |
|
387 | - $sql=''; |
|
388 | - $listfields=array(); |
|
389 | - $listvalues=array(); |
|
390 | - $i=0; |
|
391 | - $errorforthistable=0; |
|
392 | - |
|
393 | - // Define $tablewithentity_cache[$tablename] if not already defined |
|
394 | - if (! isset($tablewithentity_cache[$tablename])) // keep this test with "isset" |
|
395 | - { |
|
396 | - dol_syslog("Check if table ".$tablename." has an entity field"); |
|
397 | - $resql=$this->db->DDLDescTable($tablename,'entity'); |
|
398 | - if ($resql) |
|
399 | - { |
|
400 | - $obj=$this->db->fetch_object($resql); |
|
401 | - if ($obj) $tablewithentity_cache[$tablename]=1; // table contains entity field |
|
402 | - else $tablewithentity_cache[$tablename]=0; // table does not contains entity field |
|
403 | - } |
|
404 | - else dol_print_error($this->db); |
|
405 | - } |
|
406 | - else |
|
407 | - { |
|
408 | - //dol_syslog("Table ".$tablename." check for entity into cache is ".$tablewithentity_cache[$tablename]); |
|
409 | - } |
|
410 | - |
|
411 | - |
|
412 | - // Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom) |
|
413 | - foreach($sort_array_match_file_to_database as $key => $val) |
|
414 | - { |
|
415 | - $fieldalias=preg_replace('/\..*$/i','',$val); |
|
416 | - $fieldname=preg_replace('/^.*\./i','',$val); |
|
417 | - |
|
418 | - if ($alias != $fieldalias) continue; // Not a field of current table |
|
419 | - |
|
420 | - if ($key <= $maxfields) |
|
421 | - { |
|
422 | - // Set $newval with value to insert and set $listvalues with sql request part for insert |
|
423 | - $newval=''; |
|
424 | - if ($arrayrecord[($key-1)]['type'] > 0) $newval=$arrayrecord[($key-1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value |
|
425 | - |
|
426 | - // Make some tests on $newval |
|
427 | - |
|
428 | - // Is it a required field ? |
|
429 | - if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ((string) $newval=='')) |
|
430 | - { |
|
431 | - $this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue',$key); |
|
432 | - $this->errors[$error]['type']='NOTNULL'; |
|
433 | - $errorforthistable++; |
|
434 | - $error++; |
|
435 | - } |
|
436 | - // Test format only if field is not a missing mandatory field (field may be a value or empty but not mandatory) |
|
437 | - else |
|
438 | - { |
|
439 | - // We convert field if required |
|
440 | - if (! empty($objimport->array_import_convertvalue[0][$val])) |
|
441 | - { |
|
354 | + global $tablewithentity_cache; // Cache to avoid to call desc at each rows on tables |
|
355 | + |
|
356 | + $error=0; |
|
357 | + $warning=0; |
|
358 | + $this->errors=array(); |
|
359 | + $this->warnings=array(); |
|
360 | + |
|
361 | + //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); |
|
362 | + |
|
363 | + //var_dump($array_match_file_to_database); |
|
364 | + //var_dump($arrayrecord); |
|
365 | + $array_match_database_to_file=array_flip($array_match_file_to_database); |
|
366 | + $sort_array_match_file_to_database=$array_match_file_to_database; |
|
367 | + ksort($sort_array_match_file_to_database); |
|
368 | + |
|
369 | + //var_dump($sort_array_match_file_to_database); |
|
370 | + |
|
371 | + if (count($arrayrecord) == 0 || (count($arrayrecord) == 1 && empty($arrayrecord[0]['val']))) |
|
372 | + { |
|
373 | + //print 'W'; |
|
374 | + $this->warnings[$warning]['lib']=$langs->trans('EmptyLine'); |
|
375 | + $this->warnings[$warning]['type']='EMPTY'; |
|
376 | + $warning++; |
|
377 | + } |
|
378 | + else |
|
379 | + { |
|
380 | + $last_insert_id_array = array(); // store the last inserted auto_increment id for each table, so that dependent tables can be inserted with the appropriate id (eg: extrafields fk_object will be set with the last inserted object's id) |
|
381 | + $updatedone = false; |
|
382 | + $insertdone = false; |
|
383 | + // For each table to insert, me make a separate insert |
|
384 | + foreach($objimport->array_import_tables[0] as $alias => $tablename) |
|
385 | + { |
|
386 | + // Build sql request |
|
387 | + $sql=''; |
|
388 | + $listfields=array(); |
|
389 | + $listvalues=array(); |
|
390 | + $i=0; |
|
391 | + $errorforthistable=0; |
|
392 | + |
|
393 | + // Define $tablewithentity_cache[$tablename] if not already defined |
|
394 | + if (! isset($tablewithentity_cache[$tablename])) // keep this test with "isset" |
|
395 | + { |
|
396 | + dol_syslog("Check if table ".$tablename." has an entity field"); |
|
397 | + $resql=$this->db->DDLDescTable($tablename,'entity'); |
|
398 | + if ($resql) |
|
399 | + { |
|
400 | + $obj=$this->db->fetch_object($resql); |
|
401 | + if ($obj) $tablewithentity_cache[$tablename]=1; // table contains entity field |
|
402 | + else $tablewithentity_cache[$tablename]=0; // table does not contains entity field |
|
403 | + } |
|
404 | + else dol_print_error($this->db); |
|
405 | + } |
|
406 | + else |
|
407 | + { |
|
408 | + //dol_syslog("Table ".$tablename." check for entity into cache is ".$tablewithentity_cache[$tablename]); |
|
409 | + } |
|
410 | + |
|
411 | + |
|
412 | + // Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom) |
|
413 | + foreach($sort_array_match_file_to_database as $key => $val) |
|
414 | + { |
|
415 | + $fieldalias=preg_replace('/\..*$/i','',$val); |
|
416 | + $fieldname=preg_replace('/^.*\./i','',$val); |
|
417 | + |
|
418 | + if ($alias != $fieldalias) continue; // Not a field of current table |
|
419 | + |
|
420 | + if ($key <= $maxfields) |
|
421 | + { |
|
422 | + // Set $newval with value to insert and set $listvalues with sql request part for insert |
|
423 | + $newval=''; |
|
424 | + if ($arrayrecord[($key-1)]['type'] > 0) $newval=$arrayrecord[($key-1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value |
|
425 | + |
|
426 | + // Make some tests on $newval |
|
427 | + |
|
428 | + // Is it a required field ? |
|
429 | + if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ((string) $newval=='')) |
|
430 | + { |
|
431 | + $this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue',$key); |
|
432 | + $this->errors[$error]['type']='NOTNULL'; |
|
433 | + $errorforthistable++; |
|
434 | + $error++; |
|
435 | + } |
|
436 | + // Test format only if field is not a missing mandatory field (field may be a value or empty but not mandatory) |
|
437 | + else |
|
438 | + { |
|
439 | + // We convert field if required |
|
440 | + if (! empty($objimport->array_import_convertvalue[0][$val])) |
|
441 | + { |
|
442 | 442 | //print 'Must convert '.$newval.' with rule '.join(',',$objimport->array_import_convertvalue[0][$val]).'. '; |
443 | 443 | if ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeid' |
444 | - || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromref' |
|
445 | - || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel' |
|
446 | - ) |
|
444 | + || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromref' |
|
445 | + || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel' |
|
446 | + ) |
|
447 | 447 | { |
448 | 448 | // New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess. |
449 | 449 | $isidorref='id'; |
@@ -458,10 +458,10 @@ discard block |
||
458 | 458 | $method=$objimport->array_import_convertvalue[0][$val]['method']; |
459 | 459 | if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '') |
460 | 460 | { |
461 | - $newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; |
|
461 | + $newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; |
|
462 | 462 | } |
463 | 463 | else |
464 | - { |
|
464 | + { |
|
465 | 465 | $resultload = dol_include_once($file); |
466 | 466 | if (empty($resultload)) |
467 | 467 | { |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | // If not found, try the fetch from label |
475 | 475 | if (! ($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel') |
476 | 476 | { |
477 | - call_user_func_array(array($classinstance, $method),array('', '', $newval)); |
|
477 | + call_user_func_array(array($classinstance, $method),array('', '', $newval)); |
|
478 | 478 | } |
479 | 479 | $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]=$classinstance->id; |
480 | 480 | //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; |
@@ -561,257 +561,257 @@ discard block |
||
561 | 561 | } |
562 | 562 | |
563 | 563 | //print 'Val to use as insert is '.$newval.'<br>'; |
564 | - } |
|
565 | - |
|
566 | - // Test regexp |
|
567 | - if (! empty($objimport->array_import_regex[0][$val]) && ($newval != '')) |
|
568 | - { |
|
569 | - // If test is "Must exist in a field@table" |
|
570 | - if (preg_match('/^(.*)@(.*)$/',$objimport->array_import_regex[0][$val],$reg)) |
|
571 | - { |
|
572 | - $field=$reg[1]; |
|
573 | - $table=$reg[2]; |
|
574 | - |
|
575 | - // Load content of field@table into cache array |
|
576 | - if (! is_array($this->cachefieldtable[$field.'@'.$table])) // If content of field@table not already loaded into cache |
|
577 | - { |
|
578 | - $sql="SELECT ".$field." as aliasfield FROM ".$table; |
|
579 | - $resql=$this->db->query($sql); |
|
580 | - if ($resql) |
|
581 | - { |
|
582 | - $num=$this->db->num_rows($resql); |
|
583 | - $i=0; |
|
584 | - while ($i < $num) |
|
585 | - { |
|
586 | - $obj=$this->db->fetch_object($resql); |
|
587 | - if ($obj) $this->cachefieldtable[$field.'@'.$table][]=$obj->aliasfield; |
|
588 | - $i++; |
|
589 | - } |
|
590 | - } |
|
591 | - else |
|
592 | - { |
|
593 | - dol_print_error($this->db); |
|
594 | - } |
|
595 | - } |
|
596 | - |
|
597 | - // Now we check cache is not empty (should not) and key is into cache |
|
598 | - if (! is_array($this->cachefieldtable[$field.'@'.$table]) || ! in_array($newval,$this->cachefieldtable[$field.'@'.$table])) |
|
599 | - { |
|
600 | - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn',$key,$newval,$field,$table); |
|
601 | - $this->errors[$error]['type']='FOREIGNKEY'; |
|
602 | - $errorforthistable++; |
|
603 | - $error++; |
|
604 | - } |
|
605 | - } |
|
606 | - // If test is just a static regex |
|
607 | - else if (! preg_match('/'.$objimport->array_import_regex[0][$val].'/i',$newval)) |
|
608 | - { |
|
609 | - //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."<br>"; |
|
610 | - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorWrongValueForField',$key,$newval,$objimport->array_import_regex[0][$val]); |
|
611 | - $this->errors[$error]['type']='REGEX'; |
|
612 | - $errorforthistable++; |
|
613 | - $error++; |
|
614 | - } |
|
615 | - } |
|
616 | - |
|
617 | - // Other tests |
|
618 | - // ... |
|
619 | - } |
|
620 | - |
|
621 | - // Define $listfields and $listvalues to build SQL request |
|
622 | - $listfields[] = $fieldname; |
|
623 | - |
|
624 | - // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert |
|
625 | - if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) $listvalues[] = ($newval=='0'?$newval:"null"); |
|
626 | - elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) $listvalues[] = "''"; |
|
627 | - else $listvalues[] = "'".$this->db->escape($newval)."'"; |
|
628 | - } |
|
629 | - $i++; |
|
630 | - } |
|
631 | - |
|
632 | - // We add hidden fields (but only if there is at least one field to add into table) |
|
633 | - if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) |
|
634 | - { |
|
635 | - // Loop on each hidden fields to add them into listfields/listvalues |
|
636 | - foreach($objimport->array_import_fieldshidden[0] as $key => $val) |
|
637 | - { |
|
638 | - if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table |
|
639 | - if ($val == 'user->id') |
|
640 | - { |
|
641 | - $listfields[] = preg_replace('/^'.preg_quote($alias).'\./','',$key); |
|
642 | - $listvalues[] = $user->id; |
|
643 | - } |
|
644 | - elseif (preg_match('/^lastrowid-/',$val)) |
|
645 | - { |
|
646 | - $tmp=explode('-',$val); |
|
647 | - $lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0; |
|
648 | - $keyfield = preg_replace('/^'.preg_quote($alias).'\./','',$key); |
|
649 | - $listfields[] = $keyfield; |
|
564 | + } |
|
565 | + |
|
566 | + // Test regexp |
|
567 | + if (! empty($objimport->array_import_regex[0][$val]) && ($newval != '')) |
|
568 | + { |
|
569 | + // If test is "Must exist in a field@table" |
|
570 | + if (preg_match('/^(.*)@(.*)$/',$objimport->array_import_regex[0][$val],$reg)) |
|
571 | + { |
|
572 | + $field=$reg[1]; |
|
573 | + $table=$reg[2]; |
|
574 | + |
|
575 | + // Load content of field@table into cache array |
|
576 | + if (! is_array($this->cachefieldtable[$field.'@'.$table])) // If content of field@table not already loaded into cache |
|
577 | + { |
|
578 | + $sql="SELECT ".$field." as aliasfield FROM ".$table; |
|
579 | + $resql=$this->db->query($sql); |
|
580 | + if ($resql) |
|
581 | + { |
|
582 | + $num=$this->db->num_rows($resql); |
|
583 | + $i=0; |
|
584 | + while ($i < $num) |
|
585 | + { |
|
586 | + $obj=$this->db->fetch_object($resql); |
|
587 | + if ($obj) $this->cachefieldtable[$field.'@'.$table][]=$obj->aliasfield; |
|
588 | + $i++; |
|
589 | + } |
|
590 | + } |
|
591 | + else |
|
592 | + { |
|
593 | + dol_print_error($this->db); |
|
594 | + } |
|
595 | + } |
|
596 | + |
|
597 | + // Now we check cache is not empty (should not) and key is into cache |
|
598 | + if (! is_array($this->cachefieldtable[$field.'@'.$table]) || ! in_array($newval,$this->cachefieldtable[$field.'@'.$table])) |
|
599 | + { |
|
600 | + $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn',$key,$newval,$field,$table); |
|
601 | + $this->errors[$error]['type']='FOREIGNKEY'; |
|
602 | + $errorforthistable++; |
|
603 | + $error++; |
|
604 | + } |
|
605 | + } |
|
606 | + // If test is just a static regex |
|
607 | + else if (! preg_match('/'.$objimport->array_import_regex[0][$val].'/i',$newval)) |
|
608 | + { |
|
609 | + //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."<br>"; |
|
610 | + $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorWrongValueForField',$key,$newval,$objimport->array_import_regex[0][$val]); |
|
611 | + $this->errors[$error]['type']='REGEX'; |
|
612 | + $errorforthistable++; |
|
613 | + $error++; |
|
614 | + } |
|
615 | + } |
|
616 | + |
|
617 | + // Other tests |
|
618 | + // ... |
|
619 | + } |
|
620 | + |
|
621 | + // Define $listfields and $listvalues to build SQL request |
|
622 | + $listfields[] = $fieldname; |
|
623 | + |
|
624 | + // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert |
|
625 | + if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) $listvalues[] = ($newval=='0'?$newval:"null"); |
|
626 | + elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) $listvalues[] = "''"; |
|
627 | + else $listvalues[] = "'".$this->db->escape($newval)."'"; |
|
628 | + } |
|
629 | + $i++; |
|
630 | + } |
|
631 | + |
|
632 | + // We add hidden fields (but only if there is at least one field to add into table) |
|
633 | + if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) |
|
634 | + { |
|
635 | + // Loop on each hidden fields to add them into listfields/listvalues |
|
636 | + foreach($objimport->array_import_fieldshidden[0] as $key => $val) |
|
637 | + { |
|
638 | + if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table |
|
639 | + if ($val == 'user->id') |
|
640 | + { |
|
641 | + $listfields[] = preg_replace('/^'.preg_quote($alias).'\./','',$key); |
|
642 | + $listvalues[] = $user->id; |
|
643 | + } |
|
644 | + elseif (preg_match('/^lastrowid-/',$val)) |
|
645 | + { |
|
646 | + $tmp=explode('-',$val); |
|
647 | + $lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0; |
|
648 | + $keyfield = preg_replace('/^'.preg_quote($alias).'\./','',$key); |
|
649 | + $listfields[] = $keyfield; |
|
650 | 650 | $listvalues[] = $lastinsertid; |
651 | - //print $key."-".$val."-".$listfields."-".$listvalues."<br>";exit; |
|
652 | - } |
|
653 | - } |
|
654 | - } |
|
655 | - //print 'listfields='.$listfields.'<br>listvalues='.$listvalues.'<br>'; |
|
656 | - |
|
657 | - // If no error for this $alias/$tablename, we have a complete $listfields and $listvalues that are defined |
|
658 | - // so we can try to make the insert or update now. |
|
659 | - if (! $errorforthistable) |
|
660 | - { |
|
661 | - //print "$alias/$tablename/$listfields/$listvalues<br>"; |
|
662 | - if (!empty($listfields)) |
|
663 | - { |
|
664 | - $updatedone = false; |
|
665 | - $insertdone = false; |
|
666 | - if (!empty($updatekeys)) { |
|
667 | - // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) |
|
668 | - |
|
669 | - if (empty($lastinsertid)) { // No insert done yet for a parent table |
|
670 | - $sqlSelect = 'SELECT rowid FROM '.$tablename; |
|
671 | - |
|
672 | - $data = array_combine($listfields, $listvalues); |
|
673 | - $where = array(); |
|
674 | - $filters = array(); |
|
675 | - foreach ($updatekeys as $key) { |
|
676 | - $col = $objimport->array_import_updatekeys[0][$key]; |
|
677 | - $key=preg_replace('/^.*\./i','',$key); |
|
678 | - $where[] = $key.' = '.$data[$key]; |
|
679 | - $filters[] = $col.' = '.$data[$key]; |
|
680 | - } |
|
681 | - $sqlSelect.= ' WHERE '.implode(' AND ', $where); |
|
682 | - |
|
683 | - $resql=$this->db->query($sqlSelect); |
|
684 | - if($resql) { |
|
685 | - $res = $this->db->fetch_object($resql); |
|
686 | - if($resql->num_rows == 1) { |
|
687 | - $lastinsertid = $res->rowid; |
|
688 | - $last_insert_id_array[$tablename] = $lastinsertid; |
|
689 | - } else if($resql->num_rows > 1) { |
|
690 | - $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode($filters, ', ')); |
|
691 | - $this->errors[$error]['type']='SQL'; |
|
692 | - $error++; |
|
693 | - } else { |
|
694 | - // No record found with filters, insert will be tried below |
|
695 | - } |
|
696 | - } |
|
697 | - else |
|
698 | - { |
|
699 | - //print 'E'; |
|
700 | - $this->errors[$error]['lib']=$this->db->lasterror(); |
|
701 | - $this->errors[$error]['type']='SQL'; |
|
702 | - $error++; |
|
703 | - } |
|
704 | - } else { |
|
705 | - // We have a last INSERT ID. Check if we have a row referencing this foreign key. |
|
706 | - // This is required when updating table with some extrafields. When inserting a record in parent table, we can make |
|
707 | - // a direct insert into subtable extrafields, but when me wake an update, the insertid is defined and the child record |
|
708 | - // may already exists. So we rescan the extrafield table to know if record exists or not for the rowid. |
|
709 | - // Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object' |
|
710 | - $sqlSelect = 'SELECT rowid FROM '.$tablename; |
|
711 | - |
|
712 | - if(empty($keyfield)) $keyfield = 'rowid'; |
|
713 | - $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; |
|
714 | - |
|
715 | - $resql=$this->db->query($sqlSelect); |
|
716 | - if($resql) { |
|
717 | - $res = $this->db->fetch_object($resql); |
|
718 | - if($resql->num_rows == 1) { |
|
719 | - // We have a row referencing this last foreign key, continue with UPDATE. |
|
720 | - } else { |
|
721 | - // No record found referencing this last foreign key, |
|
722 | - // force $lastinsertid to 0 so we INSERT below. |
|
723 | - $lastinsertid = 0; |
|
724 | - } |
|
725 | - } |
|
726 | - else |
|
727 | - { |
|
728 | - //print 'E'; |
|
729 | - $this->errors[$error]['lib']=$this->db->lasterror(); |
|
730 | - $this->errors[$error]['type']='SQL'; |
|
731 | - $error++; |
|
732 | - } |
|
733 | - } |
|
734 | - |
|
735 | - if (!empty($lastinsertid)) { |
|
736 | - // Build SQL UPDATE request |
|
737 | - $sqlstart = 'UPDATE '.$tablename; |
|
738 | - |
|
739 | - $data = array_combine($listfields, $listvalues); |
|
740 | - $set = array(); |
|
741 | - foreach ($data as $key => $val) { |
|
742 | - $set[] = $key.' = '.$val; |
|
743 | - } |
|
744 | - $sqlstart.= ' SET '.implode(', ', $set); |
|
745 | - |
|
746 | - if(empty($keyfield)) $keyfield = 'rowid'; |
|
747 | - $sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; |
|
748 | - |
|
749 | - $sql = $sqlstart.$sqlend; |
|
750 | - |
|
751 | - // Run update request |
|
752 | - $resql=$this->db->query($sql); |
|
753 | - if($resql) { |
|
754 | - // No error, update has been done. $this->db->db->affected_rows can be 0 if data hasn't changed |
|
755 | - $updatedone = true; |
|
756 | - } |
|
757 | - else |
|
758 | - { |
|
759 | - //print 'E'; |
|
760 | - $this->errors[$error]['lib']=$this->db->lasterror(); |
|
761 | - $this->errors[$error]['type']='SQL'; |
|
762 | - $error++; |
|
763 | - } |
|
764 | - } |
|
765 | - } |
|
766 | - |
|
767 | - // Update not done, we do insert |
|
768 | - if (!$error && !$updatedone) { |
|
769 | - // Build SQL INSERT request |
|
770 | - $sqlstart = 'INSERT INTO '.$tablename.'('.implode(', ', $listfields).', import_key'; |
|
771 | - $sqlend = ') VALUES('.implode(', ', $listvalues).", '".$importid."'"; |
|
772 | - if (! empty($tablewithentity_cache[$tablename])) { |
|
773 | - $sqlstart.= ', entity'; |
|
774 | - $sqlend.= ', '.$conf->entity; |
|
775 | - } |
|
776 | - if (! empty($objimport->array_import_tables_creator[0][$alias])) { |
|
777 | - $sqlstart.= ', '.$objimport->array_import_tables_creator[0][$alias]; |
|
778 | - $sqlend.=', '.$user->id; |
|
779 | - } |
|
780 | - $sql = $sqlstart.$sqlend.')'; |
|
781 | - dol_syslog("import_xlsx.modules", LOG_DEBUG); |
|
782 | - |
|
783 | - // Run insert request |
|
784 | - if ($sql) |
|
785 | - { |
|
786 | - $resql=$this->db->query($sql); |
|
787 | - if ($resql) |
|
788 | - { |
|
789 | - $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). |
|
790 | - $insertdone = true; |
|
791 | - } |
|
792 | - else |
|
793 | - { |
|
794 | - //print 'E'; |
|
795 | - $this->errors[$error]['lib']=$this->db->lasterror(); |
|
796 | - $this->errors[$error]['type']='SQL'; |
|
797 | - $error++; |
|
798 | - } |
|
799 | - } |
|
800 | - } |
|
801 | - } |
|
802 | - /*else |
|
651 | + //print $key."-".$val."-".$listfields."-".$listvalues."<br>";exit; |
|
652 | + } |
|
653 | + } |
|
654 | + } |
|
655 | + //print 'listfields='.$listfields.'<br>listvalues='.$listvalues.'<br>'; |
|
656 | + |
|
657 | + // If no error for this $alias/$tablename, we have a complete $listfields and $listvalues that are defined |
|
658 | + // so we can try to make the insert or update now. |
|
659 | + if (! $errorforthistable) |
|
660 | + { |
|
661 | + //print "$alias/$tablename/$listfields/$listvalues<br>"; |
|
662 | + if (!empty($listfields)) |
|
663 | + { |
|
664 | + $updatedone = false; |
|
665 | + $insertdone = false; |
|
666 | + if (!empty($updatekeys)) { |
|
667 | + // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) |
|
668 | + |
|
669 | + if (empty($lastinsertid)) { // No insert done yet for a parent table |
|
670 | + $sqlSelect = 'SELECT rowid FROM '.$tablename; |
|
671 | + |
|
672 | + $data = array_combine($listfields, $listvalues); |
|
673 | + $where = array(); |
|
674 | + $filters = array(); |
|
675 | + foreach ($updatekeys as $key) { |
|
676 | + $col = $objimport->array_import_updatekeys[0][$key]; |
|
677 | + $key=preg_replace('/^.*\./i','',$key); |
|
678 | + $where[] = $key.' = '.$data[$key]; |
|
679 | + $filters[] = $col.' = '.$data[$key]; |
|
680 | + } |
|
681 | + $sqlSelect.= ' WHERE '.implode(' AND ', $where); |
|
682 | + |
|
683 | + $resql=$this->db->query($sqlSelect); |
|
684 | + if($resql) { |
|
685 | + $res = $this->db->fetch_object($resql); |
|
686 | + if($resql->num_rows == 1) { |
|
687 | + $lastinsertid = $res->rowid; |
|
688 | + $last_insert_id_array[$tablename] = $lastinsertid; |
|
689 | + } else if($resql->num_rows > 1) { |
|
690 | + $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode($filters, ', ')); |
|
691 | + $this->errors[$error]['type']='SQL'; |
|
692 | + $error++; |
|
693 | + } else { |
|
694 | + // No record found with filters, insert will be tried below |
|
695 | + } |
|
696 | + } |
|
697 | + else |
|
698 | + { |
|
699 | + //print 'E'; |
|
700 | + $this->errors[$error]['lib']=$this->db->lasterror(); |
|
701 | + $this->errors[$error]['type']='SQL'; |
|
702 | + $error++; |
|
703 | + } |
|
704 | + } else { |
|
705 | + // We have a last INSERT ID. Check if we have a row referencing this foreign key. |
|
706 | + // This is required when updating table with some extrafields. When inserting a record in parent table, we can make |
|
707 | + // a direct insert into subtable extrafields, but when me wake an update, the insertid is defined and the child record |
|
708 | + // may already exists. So we rescan the extrafield table to know if record exists or not for the rowid. |
|
709 | + // Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object' |
|
710 | + $sqlSelect = 'SELECT rowid FROM '.$tablename; |
|
711 | + |
|
712 | + if(empty($keyfield)) $keyfield = 'rowid'; |
|
713 | + $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; |
|
714 | + |
|
715 | + $resql=$this->db->query($sqlSelect); |
|
716 | + if($resql) { |
|
717 | + $res = $this->db->fetch_object($resql); |
|
718 | + if($resql->num_rows == 1) { |
|
719 | + // We have a row referencing this last foreign key, continue with UPDATE. |
|
720 | + } else { |
|
721 | + // No record found referencing this last foreign key, |
|
722 | + // force $lastinsertid to 0 so we INSERT below. |
|
723 | + $lastinsertid = 0; |
|
724 | + } |
|
725 | + } |
|
726 | + else |
|
727 | + { |
|
728 | + //print 'E'; |
|
729 | + $this->errors[$error]['lib']=$this->db->lasterror(); |
|
730 | + $this->errors[$error]['type']='SQL'; |
|
731 | + $error++; |
|
732 | + } |
|
733 | + } |
|
734 | + |
|
735 | + if (!empty($lastinsertid)) { |
|
736 | + // Build SQL UPDATE request |
|
737 | + $sqlstart = 'UPDATE '.$tablename; |
|
738 | + |
|
739 | + $data = array_combine($listfields, $listvalues); |
|
740 | + $set = array(); |
|
741 | + foreach ($data as $key => $val) { |
|
742 | + $set[] = $key.' = '.$val; |
|
743 | + } |
|
744 | + $sqlstart.= ' SET '.implode(', ', $set); |
|
745 | + |
|
746 | + if(empty($keyfield)) $keyfield = 'rowid'; |
|
747 | + $sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; |
|
748 | + |
|
749 | + $sql = $sqlstart.$sqlend; |
|
750 | + |
|
751 | + // Run update request |
|
752 | + $resql=$this->db->query($sql); |
|
753 | + if($resql) { |
|
754 | + // No error, update has been done. $this->db->db->affected_rows can be 0 if data hasn't changed |
|
755 | + $updatedone = true; |
|
756 | + } |
|
757 | + else |
|
758 | + { |
|
759 | + //print 'E'; |
|
760 | + $this->errors[$error]['lib']=$this->db->lasterror(); |
|
761 | + $this->errors[$error]['type']='SQL'; |
|
762 | + $error++; |
|
763 | + } |
|
764 | + } |
|
765 | + } |
|
766 | + |
|
767 | + // Update not done, we do insert |
|
768 | + if (!$error && !$updatedone) { |
|
769 | + // Build SQL INSERT request |
|
770 | + $sqlstart = 'INSERT INTO '.$tablename.'('.implode(', ', $listfields).', import_key'; |
|
771 | + $sqlend = ') VALUES('.implode(', ', $listvalues).", '".$importid."'"; |
|
772 | + if (! empty($tablewithentity_cache[$tablename])) { |
|
773 | + $sqlstart.= ', entity'; |
|
774 | + $sqlend.= ', '.$conf->entity; |
|
775 | + } |
|
776 | + if (! empty($objimport->array_import_tables_creator[0][$alias])) { |
|
777 | + $sqlstart.= ', '.$objimport->array_import_tables_creator[0][$alias]; |
|
778 | + $sqlend.=', '.$user->id; |
|
779 | + } |
|
780 | + $sql = $sqlstart.$sqlend.')'; |
|
781 | + dol_syslog("import_xlsx.modules", LOG_DEBUG); |
|
782 | + |
|
783 | + // Run insert request |
|
784 | + if ($sql) |
|
785 | + { |
|
786 | + $resql=$this->db->query($sql); |
|
787 | + if ($resql) |
|
788 | + { |
|
789 | + $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). |
|
790 | + $insertdone = true; |
|
791 | + } |
|
792 | + else |
|
793 | + { |
|
794 | + //print 'E'; |
|
795 | + $this->errors[$error]['lib']=$this->db->lasterror(); |
|
796 | + $this->errors[$error]['type']='SQL'; |
|
797 | + $error++; |
|
798 | + } |
|
799 | + } |
|
800 | + } |
|
801 | + } |
|
802 | + /*else |
|
803 | 803 | { |
804 | 804 | dol_print_error('','ErrorFieldListEmptyFor '.$alias."/".$tablename); |
805 | 805 | }*/ |
806 | - } |
|
806 | + } |
|
807 | 807 | |
808 | - if ($error) break; |
|
809 | - } |
|
808 | + if ($error) break; |
|
809 | + } |
|
810 | 810 | |
811 | - if($updatedone) $this->nbupdate++; |
|
812 | - if($insertdone) $this->nbinsert++; |
|
813 | - } |
|
811 | + if($updatedone) $this->nbupdate++; |
|
812 | + if($insertdone) $this->nbinsert++; |
|
813 | + } |
|
814 | 814 | |
815 | - return 1; |
|
816 | - } |
|
815 | + return 1; |
|
816 | + } |
|
817 | 817 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * \brief File to load import files with Excel format |
26 | 26 | */ |
27 | 27 | |
28 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/import/modules_import.php'; |
|
28 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php'; |
|
29 | 29 | |
30 | 30 | |
31 | 31 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | /** |
44 | 44 | * @var string Error code (or message) |
45 | 45 | */ |
46 | - public $error=''; |
|
46 | + public $error = ''; |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @var string[] Error codes (or messages) |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public $label; |
62 | 62 | |
63 | - public $extension; // Extension of files imported by driver |
|
63 | + public $extension; // Extension of files imported by driver |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Dolibarr version of driver |
@@ -68,19 +68,19 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public $version = 'dolibarr'; |
70 | 70 | |
71 | - public $label_lib; // Label of external lib used by driver |
|
71 | + public $label_lib; // Label of external lib used by driver |
|
72 | 72 | |
73 | - public $version_lib; // Version of external lib used by driver |
|
73 | + public $version_lib; // Version of external lib used by driver |
|
74 | 74 | |
75 | 75 | public $separator; |
76 | 76 | |
77 | - public $file; // Path of file |
|
77 | + public $file; // Path of file |
|
78 | 78 | |
79 | - public $handle; // Handle fichier |
|
79 | + public $handle; // Handle fichier |
|
80 | 80 | |
81 | - public $cacheconvert=array(); // Array to cache list of value found after a convertion |
|
81 | + public $cacheconvert = array(); // Array to cache list of value found after a convertion |
|
82 | 82 | |
83 | - public $cachefieldtable=array(); // Array to cache list of value found into fields@tables |
|
83 | + public $cachefieldtable = array(); // Array to cache list of value found into fields@tables |
|
84 | 84 | |
85 | 85 | public $workbook; // temporary import file |
86 | 86 | |
@@ -95,33 +95,33 @@ discard block |
||
95 | 95 | * @param DoliDB $db Database handler |
96 | 96 | * @param string $datatoimport String code describing import set (ex: 'societe_1') |
97 | 97 | */ |
98 | - function __construct($db,$datatoimport) |
|
98 | + function __construct($db, $datatoimport) |
|
99 | 99 | { |
100 | - global $conf,$langs; |
|
100 | + global $conf, $langs; |
|
101 | 101 | $this->db = $db; |
102 | 102 | |
103 | 103 | // this is used as an extension from the example file code, so we have to put xlsx here !!! |
104 | - $this->id='xlsx'; // Same value as xxx in file name export_xxx.modules.php |
|
105 | - $this->label='Excel 2007'; // Label of driver |
|
106 | - $this->desc=$langs->trans("Excel2007FormatDesc"); |
|
107 | - $this->extension='xlsx'; // Extension for generated file by this driver |
|
108 | - $this->picto='mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) |
|
109 | - $this->version='1.0'; // Driver version |
|
104 | + $this->id = 'xlsx'; // Same value as xxx in file name export_xxx.modules.php |
|
105 | + $this->label = 'Excel 2007'; // Label of driver |
|
106 | + $this->desc = $langs->trans("Excel2007FormatDesc"); |
|
107 | + $this->extension = 'xlsx'; // Extension for generated file by this driver |
|
108 | + $this->picto = 'mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) |
|
109 | + $this->version = '1.0'; // Driver version |
|
110 | 110 | |
111 | 111 | // If driver use an external library, put its name here |
112 | 112 | require_once PHPEXCEL_PATH.'PHPExcel.php'; |
113 | 113 | require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; |
114 | - if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive |
|
114 | + if (!class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive |
|
115 | 115 | { |
116 | 116 | $langs->load("errors"); |
117 | - $this->error=$langs->trans('ErrorPHPNeedModule','zip'); |
|
117 | + $this->error = $langs->trans('ErrorPHPNeedModule', 'zip'); |
|
118 | 118 | return -1; |
119 | 119 | } |
120 | - $this->label_lib='PhpExcel'; |
|
121 | - $this->version_lib='1.8.0'; |
|
120 | + $this->label_lib = 'PhpExcel'; |
|
121 | + $this->version_lib = '1.8.0'; |
|
122 | 122 | |
123 | - $this->datatoimport=$datatoimport; |
|
124 | - if (preg_match('/^societe_/',$datatoimport)) $this->thirpartyobject=new Societe($this->db); |
|
123 | + $this->datatoimport = $datatoimport; |
|
124 | + if (preg_match('/^societe_/', $datatoimport)) $this->thirpartyobject = new Societe($this->db); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | function write_header_example($outputlangs) |
136 | 136 | { |
137 | 137 | // phpcs:enable |
138 | - global $user,$conf,$langs; |
|
138 | + global $user, $conf, $langs; |
|
139 | 139 | // create a temporary object, the final output will be generated in footer |
140 | 140 | if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) { |
141 | 141 | $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM; |
142 | - $cacheSettings = array ( |
|
142 | + $cacheSettings = array( |
|
143 | 143 | 'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR |
144 | 144 | ); |
145 | 145 | PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param array $headerlinefields Array of fields name |
167 | 167 | * @return string |
168 | 168 | */ |
169 | - function write_title_example($outputlangs,$headerlinefields) |
|
169 | + function write_title_example($outputlangs, $headerlinefields) |
|
170 | 170 | { |
171 | 171 | // phpcs:enable |
172 | 172 | global $conf; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); |
175 | 175 | |
176 | 176 | $col = 0; |
177 | - foreach($headerlinefields as $field) { |
|
177 | + foreach ($headerlinefields as $field) { |
|
178 | 178 | $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, 1, $outputlangs->transnoentities($field)); |
179 | 179 | // set autowidth |
180 | 180 | //$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($col + 1))->setAutoSize(true); |
@@ -192,12 +192,12 @@ discard block |
||
192 | 192 | * @param array $contentlinevalues Array of lines |
193 | 193 | * @return string |
194 | 194 | */ |
195 | - function write_record_example($outputlangs,$contentlinevalues) |
|
195 | + function write_record_example($outputlangs, $contentlinevalues) |
|
196 | 196 | { |
197 | 197 | // phpcs:enable |
198 | 198 | $col = 0; |
199 | 199 | $row = 2; |
200 | - foreach($contentlinevalues as $cell) { |
|
200 | + foreach ($contentlinevalues as $cell) { |
|
201 | 201 | $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, $row, $cell); |
202 | 202 | $col++; |
203 | 203 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | { |
241 | 241 | // phpcs:enable |
242 | 242 | global $langs; |
243 | - $ret=1; |
|
243 | + $ret = 1; |
|
244 | 244 | |
245 | 245 | dol_syslog(get_class($this)."::open_file file=".$file); |
246 | 246 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | // This is not called by the import code !!! |
288 | 288 | $this->headers = array(); |
289 | 289 | $colcount = PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn()); |
290 | - for($col=0;$col<$colcount;$col++) { |
|
290 | + for ($col = 0; $col < $colcount; $col++) { |
|
291 | 291 | $this->headers[$col] = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, 1)->getValue(); |
292 | 292 | } |
293 | 293 | return 0; |
@@ -306,14 +306,14 @@ discard block |
||
306 | 306 | global $conf; |
307 | 307 | |
308 | 308 | $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow(); |
309 | - if($this->record > $rowcount) |
|
309 | + if ($this->record > $rowcount) |
|
310 | 310 | return false; |
311 | 311 | $array = array(); |
312 | 312 | $colcount = PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn(0)); |
313 | - for($col=0;$col<$colcount;$col++) { |
|
313 | + for ($col = 0; $col < $colcount; $col++) { |
|
314 | 314 | $val = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, $this->record)->getValue(); |
315 | 315 | $array[$col]['val'] = $val; |
316 | - $array[$col]['type'] = (dol_strlen($val)?1:-1); // If empty we consider it null |
|
316 | + $array[$col]['type'] = (dol_strlen($val) ? 1 : -1); // If empty we consider it null |
|
317 | 317 | } |
318 | 318 | $this->record++; |
319 | 319 | return $array; |
@@ -346,24 +346,24 @@ discard block |
||
346 | 346 | * @param array $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor. |
347 | 347 | * @return int <0 if KO, >0 if OK |
348 | 348 | */ |
349 | - function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$maxfields,$importid,$updatekeys) |
|
349 | + function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) |
|
350 | 350 | { |
351 | 351 | // phpcs:enable |
352 | - global $langs,$conf,$user; |
|
353 | - global $thirdparty_static; // Specific to thirdparty import |
|
354 | - global $tablewithentity_cache; // Cache to avoid to call desc at each rows on tables |
|
352 | + global $langs, $conf, $user; |
|
353 | + global $thirdparty_static; // Specific to thirdparty import |
|
354 | + global $tablewithentity_cache; // Cache to avoid to call desc at each rows on tables |
|
355 | 355 | |
356 | - $error=0; |
|
357 | - $warning=0; |
|
358 | - $this->errors=array(); |
|
359 | - $this->warnings=array(); |
|
356 | + $error = 0; |
|
357 | + $warning = 0; |
|
358 | + $this->errors = array(); |
|
359 | + $this->warnings = array(); |
|
360 | 360 | |
361 | 361 | //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); |
362 | 362 | |
363 | 363 | //var_dump($array_match_file_to_database); |
364 | 364 | //var_dump($arrayrecord); |
365 | - $array_match_database_to_file=array_flip($array_match_file_to_database); |
|
366 | - $sort_array_match_file_to_database=$array_match_file_to_database; |
|
365 | + $array_match_database_to_file = array_flip($array_match_file_to_database); |
|
366 | + $sort_array_match_file_to_database = $array_match_file_to_database; |
|
367 | 367 | ksort($sort_array_match_file_to_database); |
368 | 368 | |
369 | 369 | //var_dump($sort_array_match_file_to_database); |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | if (count($arrayrecord) == 0 || (count($arrayrecord) == 1 && empty($arrayrecord[0]['val']))) |
372 | 372 | { |
373 | 373 | //print 'W'; |
374 | - $this->warnings[$warning]['lib']=$langs->trans('EmptyLine'); |
|
375 | - $this->warnings[$warning]['type']='EMPTY'; |
|
374 | + $this->warnings[$warning]['lib'] = $langs->trans('EmptyLine'); |
|
375 | + $this->warnings[$warning]['type'] = 'EMPTY'; |
|
376 | 376 | $warning++; |
377 | 377 | } |
378 | 378 | else |
@@ -381,25 +381,25 @@ discard block |
||
381 | 381 | $updatedone = false; |
382 | 382 | $insertdone = false; |
383 | 383 | // For each table to insert, me make a separate insert |
384 | - foreach($objimport->array_import_tables[0] as $alias => $tablename) |
|
384 | + foreach ($objimport->array_import_tables[0] as $alias => $tablename) |
|
385 | 385 | { |
386 | 386 | // Build sql request |
387 | - $sql=''; |
|
388 | - $listfields=array(); |
|
389 | - $listvalues=array(); |
|
390 | - $i=0; |
|
391 | - $errorforthistable=0; |
|
387 | + $sql = ''; |
|
388 | + $listfields = array(); |
|
389 | + $listvalues = array(); |
|
390 | + $i = 0; |
|
391 | + $errorforthistable = 0; |
|
392 | 392 | |
393 | 393 | // Define $tablewithentity_cache[$tablename] if not already defined |
394 | - if (! isset($tablewithentity_cache[$tablename])) // keep this test with "isset" |
|
394 | + if (!isset($tablewithentity_cache[$tablename])) // keep this test with "isset" |
|
395 | 395 | { |
396 | 396 | dol_syslog("Check if table ".$tablename." has an entity field"); |
397 | - $resql=$this->db->DDLDescTable($tablename,'entity'); |
|
397 | + $resql = $this->db->DDLDescTable($tablename, 'entity'); |
|
398 | 398 | if ($resql) |
399 | 399 | { |
400 | - $obj=$this->db->fetch_object($resql); |
|
401 | - if ($obj) $tablewithentity_cache[$tablename]=1; // table contains entity field |
|
402 | - else $tablewithentity_cache[$tablename]=0; // table does not contains entity field |
|
400 | + $obj = $this->db->fetch_object($resql); |
|
401 | + if ($obj) $tablewithentity_cache[$tablename] = 1; // table contains entity field |
|
402 | + else $tablewithentity_cache[$tablename] = 0; // table does not contains entity field |
|
403 | 403 | } |
404 | 404 | else dol_print_error($this->db); |
405 | 405 | } |
@@ -410,26 +410,26 @@ discard block |
||
410 | 410 | |
411 | 411 | |
412 | 412 | // Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom) |
413 | - foreach($sort_array_match_file_to_database as $key => $val) |
|
413 | + foreach ($sort_array_match_file_to_database as $key => $val) |
|
414 | 414 | { |
415 | - $fieldalias=preg_replace('/\..*$/i','',$val); |
|
416 | - $fieldname=preg_replace('/^.*\./i','',$val); |
|
415 | + $fieldalias = preg_replace('/\..*$/i', '', $val); |
|
416 | + $fieldname = preg_replace('/^.*\./i', '', $val); |
|
417 | 417 | |
418 | - if ($alias != $fieldalias) continue; // Not a field of current table |
|
418 | + if ($alias != $fieldalias) continue; // Not a field of current table |
|
419 | 419 | |
420 | 420 | if ($key <= $maxfields) |
421 | 421 | { |
422 | 422 | // Set $newval with value to insert and set $listvalues with sql request part for insert |
423 | - $newval=''; |
|
424 | - if ($arrayrecord[($key-1)]['type'] > 0) $newval=$arrayrecord[($key-1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value |
|
423 | + $newval = ''; |
|
424 | + if ($arrayrecord[($key - 1)]['type'] > 0) $newval = $arrayrecord[($key - 1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value |
|
425 | 425 | |
426 | 426 | // Make some tests on $newval |
427 | 427 | |
428 | 428 | // Is it a required field ? |
429 | - if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ((string) $newval=='')) |
|
429 | + if (preg_match('/\*/', $objimport->array_import_fields[0][$val]) && ((string) $newval == '')) |
|
430 | 430 | { |
431 | - $this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue',$key); |
|
432 | - $this->errors[$error]['type']='NOTNULL'; |
|
431 | + $this->errors[$error]['lib'] = $langs->trans('ErrorMissingMandatoryValue', $key); |
|
432 | + $this->errors[$error]['type'] = 'NOTNULL'; |
|
433 | 433 | $errorforthistable++; |
434 | 434 | $error++; |
435 | 435 | } |
@@ -437,28 +437,28 @@ discard block |
||
437 | 437 | else |
438 | 438 | { |
439 | 439 | // We convert field if required |
440 | - if (! empty($objimport->array_import_convertvalue[0][$val])) |
|
440 | + if (!empty($objimport->array_import_convertvalue[0][$val])) |
|
441 | 441 | { |
442 | 442 | //print 'Must convert '.$newval.' with rule '.join(',',$objimport->array_import_convertvalue[0][$val]).'. '; |
443 | - if ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeid' |
|
444 | - || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromref' |
|
445 | - || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel' |
|
443 | + if ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeid' |
|
444 | + || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromref' |
|
445 | + || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeorlabel' |
|
446 | 446 | ) |
447 | 447 | { |
448 | 448 | // New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess. |
449 | - $isidorref='id'; |
|
450 | - if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i',$newval)) $isidorref='ref'; |
|
451 | - $newval=preg_replace('/^(id|ref):/i','',$newval); // Remove id: or ref: that was used to force if field is id or ref |
|
449 | + $isidorref = 'id'; |
|
450 | + if (!is_numeric($newval) && $newval != '' && !preg_match('/^id:/i', $newval)) $isidorref = 'ref'; |
|
451 | + $newval = preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref |
|
452 | 452 | //print 'Val is now '.$newval.' and is type '.$isidorref."<br>\n"; |
453 | 453 | |
454 | 454 | if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor |
455 | 455 | { |
456 | - $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); |
|
457 | - $class=$objimport->array_import_convertvalue[0][$val]['class']; |
|
458 | - $method=$objimport->array_import_convertvalue[0][$val]['method']; |
|
456 | + $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); |
|
457 | + $class = $objimport->array_import_convertvalue[0][$val]['class']; |
|
458 | + $method = $objimport->array_import_convertvalue[0][$val]['method']; |
|
459 | 459 | if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '') |
460 | 460 | { |
461 | - $newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; |
|
461 | + $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; |
|
462 | 462 | } |
463 | 463 | else |
464 | 464 | { |
@@ -468,94 +468,94 @@ discard block |
||
468 | 468 | dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); |
469 | 469 | break; |
470 | 470 | } |
471 | - $classinstance=new $class($this->db); |
|
471 | + $classinstance = new $class($this->db); |
|
472 | 472 | // Try the fetch from code or ref |
473 | - call_user_func_array(array($classinstance, $method),array('', $newval)); |
|
473 | + call_user_func_array(array($classinstance, $method), array('', $newval)); |
|
474 | 474 | // If not found, try the fetch from label |
475 | - if (! ($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel') |
|
475 | + if (!($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeorlabel') |
|
476 | 476 | { |
477 | - call_user_func_array(array($classinstance, $method),array('', '', $newval)); |
|
477 | + call_user_func_array(array($classinstance, $method), array('', '', $newval)); |
|
478 | 478 | } |
479 | - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]=$classinstance->id; |
|
479 | + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] = $classinstance->id; |
|
480 | 480 | //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; |
481 | 481 | if ($classinstance->id != '') // id may be 0, it is a found value |
482 | 482 | { |
483 | - $newval=$classinstance->id; |
|
483 | + $newval = $classinstance->id; |
|
484 | 484 | } |
485 | 485 | else |
486 | 486 | { |
487 | - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn',$key,$newval,'code',$langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); |
|
488 | - else if (!empty($objimport->array_import_convertvalue[0][$val]['element'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldRefNotIn',$key,$newval,$langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['element'])); |
|
489 | - else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; |
|
490 | - $this->errors[$error]['type']='FOREIGNKEY'; |
|
487 | + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); |
|
488 | + else if (!empty($objimport->array_import_convertvalue[0][$val]['element'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldRefNotIn', $key, $newval, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['element'])); |
|
489 | + else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn'; |
|
490 | + $this->errors[$error]['type'] = 'FOREIGNKEY'; |
|
491 | 491 | $errorforthistable++; |
492 | 492 | $error++; |
493 | 493 | } |
494 | 494 | } |
495 | 495 | } |
496 | 496 | } |
497 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='zeroifnull') |
|
497 | + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'zeroifnull') |
|
498 | 498 | { |
499 | - if (empty($newval)) $newval='0'; |
|
499 | + if (empty($newval)) $newval = '0'; |
|
500 | 500 | } |
501 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto') |
|
501 | + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomercodeifauto') |
|
502 | 502 | { |
503 | 503 | if (strtolower($newval) == 'auto') |
504 | 504 | { |
505 | - $this->thirpartyobject->get_codeclient(0,0); |
|
506 | - $newval=$this->thirpartyobject->code_client; |
|
505 | + $this->thirpartyobject->get_codeclient(0, 0); |
|
506 | + $newval = $this->thirpartyobject->code_client; |
|
507 | 507 | //print 'code_client='.$newval; |
508 | 508 | } |
509 | - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" |
|
509 | + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" |
|
510 | 510 | } |
511 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsuppliercodeifauto') |
|
511 | + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') |
|
512 | 512 | { |
513 | 513 | if (strtolower($newval) == 'auto') |
514 | 514 | { |
515 | - $newval=$this->thirpartyobject->get_codefournisseur(0,1); |
|
516 | - $newval=$this->thirpartyobject->code_fournisseur; |
|
515 | + $newval = $this->thirpartyobject->get_codefournisseur(0, 1); |
|
516 | + $newval = $this->thirpartyobject->code_fournisseur; |
|
517 | 517 | //print 'code_fournisseur='.$newval; |
518 | 518 | } |
519 | - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" |
|
519 | + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" |
|
520 | 520 | } |
521 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomeraccountancycodeifauto') |
|
521 | + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomeraccountancycodeifauto') |
|
522 | 522 | { |
523 | 523 | if (strtolower($newval) == 'auto') |
524 | 524 | { |
525 | 525 | $this->thirpartyobject->get_codecompta('customer'); |
526 | - $newval=$this->thirpartyobject->code_compta; |
|
526 | + $newval = $this->thirpartyobject->code_compta; |
|
527 | 527 | //print 'code_compta='.$newval; |
528 | 528 | } |
529 | - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" |
|
529 | + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" |
|
530 | 530 | } |
531 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsupplieraccountancycodeifauto') |
|
531 | + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsupplieraccountancycodeifauto') |
|
532 | 532 | { |
533 | 533 | if (strtolower($newval) == 'auto') |
534 | 534 | { |
535 | 535 | $this->thirpartyobject->get_codecompta('supplier'); |
536 | - $newval=$this->thirpartyobject->code_compta_fournisseur; |
|
537 | - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" |
|
536 | + $newval = $this->thirpartyobject->code_compta_fournisseur; |
|
537 | + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" |
|
538 | 538 | //print 'code_compta_fournisseur='.$newval; |
539 | 539 | } |
540 | - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" |
|
540 | + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" |
|
541 | 541 | } |
542 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getrefifauto') |
|
542 | + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getrefifauto') |
|
543 | 543 | { |
544 | - $defaultref=''; |
|
544 | + $defaultref = ''; |
|
545 | 545 | // TODO provide the $modTask (module of generation of ref) as parameter of import_insert function |
546 | - $obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON; |
|
547 | - if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) |
|
546 | + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; |
|
547 | + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) |
|
548 | 548 | { |
549 | - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; |
|
549 | + require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; |
|
550 | 550 | $modTask = new $obj; |
551 | - $defaultref = $modTask->getNextValue(null,null); |
|
551 | + $defaultref = $modTask->getNextValue(null, null); |
|
552 | 552 | } |
553 | - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; |
|
554 | - $newval=$defaultref; |
|
553 | + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; |
|
554 | + $newval = $defaultref; |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | |
558 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric') |
|
558 | + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') |
|
559 | 559 | { |
560 | 560 | $newval = price2num($newval); |
561 | 561 | } |
@@ -564,27 +564,27 @@ discard block |
||
564 | 564 | } |
565 | 565 | |
566 | 566 | // Test regexp |
567 | - if (! empty($objimport->array_import_regex[0][$val]) && ($newval != '')) |
|
567 | + if (!empty($objimport->array_import_regex[0][$val]) && ($newval != '')) |
|
568 | 568 | { |
569 | 569 | // If test is "Must exist in a field@table" |
570 | - if (preg_match('/^(.*)@(.*)$/',$objimport->array_import_regex[0][$val],$reg)) |
|
570 | + if (preg_match('/^(.*)@(.*)$/', $objimport->array_import_regex[0][$val], $reg)) |
|
571 | 571 | { |
572 | - $field=$reg[1]; |
|
573 | - $table=$reg[2]; |
|
572 | + $field = $reg[1]; |
|
573 | + $table = $reg[2]; |
|
574 | 574 | |
575 | 575 | // Load content of field@table into cache array |
576 | - if (! is_array($this->cachefieldtable[$field.'@'.$table])) // If content of field@table not already loaded into cache |
|
576 | + if (!is_array($this->cachefieldtable[$field.'@'.$table])) // If content of field@table not already loaded into cache |
|
577 | 577 | { |
578 | - $sql="SELECT ".$field." as aliasfield FROM ".$table; |
|
579 | - $resql=$this->db->query($sql); |
|
578 | + $sql = "SELECT ".$field." as aliasfield FROM ".$table; |
|
579 | + $resql = $this->db->query($sql); |
|
580 | 580 | if ($resql) |
581 | 581 | { |
582 | - $num=$this->db->num_rows($resql); |
|
583 | - $i=0; |
|
582 | + $num = $this->db->num_rows($resql); |
|
583 | + $i = 0; |
|
584 | 584 | while ($i < $num) |
585 | 585 | { |
586 | - $obj=$this->db->fetch_object($resql); |
|
587 | - if ($obj) $this->cachefieldtable[$field.'@'.$table][]=$obj->aliasfield; |
|
586 | + $obj = $this->db->fetch_object($resql); |
|
587 | + if ($obj) $this->cachefieldtable[$field.'@'.$table][] = $obj->aliasfield; |
|
588 | 588 | $i++; |
589 | 589 | } |
590 | 590 | } |
@@ -595,20 +595,20 @@ discard block |
||
595 | 595 | } |
596 | 596 | |
597 | 597 | // Now we check cache is not empty (should not) and key is into cache |
598 | - if (! is_array($this->cachefieldtable[$field.'@'.$table]) || ! in_array($newval,$this->cachefieldtable[$field.'@'.$table])) |
|
598 | + if (!is_array($this->cachefieldtable[$field.'@'.$table]) || !in_array($newval, $this->cachefieldtable[$field.'@'.$table])) |
|
599 | 599 | { |
600 | - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn',$key,$newval,$field,$table); |
|
601 | - $this->errors[$error]['type']='FOREIGNKEY'; |
|
600 | + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $table); |
|
601 | + $this->errors[$error]['type'] = 'FOREIGNKEY'; |
|
602 | 602 | $errorforthistable++; |
603 | 603 | $error++; |
604 | 604 | } |
605 | 605 | } |
606 | 606 | // If test is just a static regex |
607 | - else if (! preg_match('/'.$objimport->array_import_regex[0][$val].'/i',$newval)) |
|
607 | + else if (!preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) |
|
608 | 608 | { |
609 | 609 | //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."<br>"; |
610 | - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorWrongValueForField',$key,$newval,$objimport->array_import_regex[0][$val]); |
|
611 | - $this->errors[$error]['type']='REGEX'; |
|
610 | + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); |
|
611 | + $this->errors[$error]['type'] = 'REGEX'; |
|
612 | 612 | $errorforthistable++; |
613 | 613 | $error++; |
614 | 614 | } |
@@ -622,8 +622,8 @@ discard block |
||
622 | 622 | $listfields[] = $fieldname; |
623 | 623 | |
624 | 624 | // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert |
625 | - if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) $listvalues[] = ($newval=='0'?$newval:"null"); |
|
626 | - elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) $listvalues[] = "''"; |
|
625 | + if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) $listvalues[] = ($newval == '0' ? $newval : "null"); |
|
626 | + elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) $listvalues[] = "''"; |
|
627 | 627 | else $listvalues[] = "'".$this->db->escape($newval)."'"; |
628 | 628 | } |
629 | 629 | $i++; |
@@ -633,19 +633,19 @@ discard block |
||
633 | 633 | if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) |
634 | 634 | { |
635 | 635 | // Loop on each hidden fields to add them into listfields/listvalues |
636 | - foreach($objimport->array_import_fieldshidden[0] as $key => $val) |
|
636 | + foreach ($objimport->array_import_fieldshidden[0] as $key => $val) |
|
637 | 637 | { |
638 | - if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table |
|
638 | + if (!preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table |
|
639 | 639 | if ($val == 'user->id') |
640 | 640 | { |
641 | - $listfields[] = preg_replace('/^'.preg_quote($alias).'\./','',$key); |
|
641 | + $listfields[] = preg_replace('/^'.preg_quote($alias).'\./', '', $key); |
|
642 | 642 | $listvalues[] = $user->id; |
643 | 643 | } |
644 | - elseif (preg_match('/^lastrowid-/',$val)) |
|
644 | + elseif (preg_match('/^lastrowid-/', $val)) |
|
645 | 645 | { |
646 | - $tmp=explode('-',$val); |
|
647 | - $lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0; |
|
648 | - $keyfield = preg_replace('/^'.preg_quote($alias).'\./','',$key); |
|
646 | + $tmp = explode('-', $val); |
|
647 | + $lastinsertid = (isset($last_insert_id_array[$tmp[1]])) ? $last_insert_id_array[$tmp[1]] : 0; |
|
648 | + $keyfield = preg_replace('/^'.preg_quote($alias).'\./', '', $key); |
|
649 | 649 | $listfields[] = $keyfield; |
650 | 650 | $listvalues[] = $lastinsertid; |
651 | 651 | //print $key."-".$val."-".$listfields."-".$listvalues."<br>";exit; |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | |
657 | 657 | // If no error for this $alias/$tablename, we have a complete $listfields and $listvalues that are defined |
658 | 658 | // so we can try to make the insert or update now. |
659 | - if (! $errorforthistable) |
|
659 | + if (!$errorforthistable) |
|
660 | 660 | { |
661 | 661 | //print "$alias/$tablename/$listfields/$listvalues<br>"; |
662 | 662 | if (!empty($listfields)) |
@@ -674,21 +674,21 @@ discard block |
||
674 | 674 | $filters = array(); |
675 | 675 | foreach ($updatekeys as $key) { |
676 | 676 | $col = $objimport->array_import_updatekeys[0][$key]; |
677 | - $key=preg_replace('/^.*\./i','',$key); |
|
677 | + $key = preg_replace('/^.*\./i', '', $key); |
|
678 | 678 | $where[] = $key.' = '.$data[$key]; |
679 | 679 | $filters[] = $col.' = '.$data[$key]; |
680 | 680 | } |
681 | - $sqlSelect.= ' WHERE '.implode(' AND ', $where); |
|
681 | + $sqlSelect .= ' WHERE '.implode(' AND ', $where); |
|
682 | 682 | |
683 | - $resql=$this->db->query($sqlSelect); |
|
684 | - if($resql) { |
|
683 | + $resql = $this->db->query($sqlSelect); |
|
684 | + if ($resql) { |
|
685 | 685 | $res = $this->db->fetch_object($resql); |
686 | - if($resql->num_rows == 1) { |
|
686 | + if ($resql->num_rows == 1) { |
|
687 | 687 | $lastinsertid = $res->rowid; |
688 | 688 | $last_insert_id_array[$tablename] = $lastinsertid; |
689 | - } else if($resql->num_rows > 1) { |
|
690 | - $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode($filters, ', ')); |
|
691 | - $this->errors[$error]['type']='SQL'; |
|
689 | + } else if ($resql->num_rows > 1) { |
|
690 | + $this->errors[$error]['lib'] = $langs->trans('MultipleRecordFoundWithTheseFilters', implode($filters, ', ')); |
|
691 | + $this->errors[$error]['type'] = 'SQL'; |
|
692 | 692 | $error++; |
693 | 693 | } else { |
694 | 694 | // No record found with filters, insert will be tried below |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | else |
698 | 698 | { |
699 | 699 | //print 'E'; |
700 | - $this->errors[$error]['lib']=$this->db->lasterror(); |
|
701 | - $this->errors[$error]['type']='SQL'; |
|
700 | + $this->errors[$error]['lib'] = $this->db->lasterror(); |
|
701 | + $this->errors[$error]['type'] = 'SQL'; |
|
702 | 702 | $error++; |
703 | 703 | } |
704 | 704 | } else { |
@@ -709,13 +709,13 @@ discard block |
||
709 | 709 | // Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object' |
710 | 710 | $sqlSelect = 'SELECT rowid FROM '.$tablename; |
711 | 711 | |
712 | - if(empty($keyfield)) $keyfield = 'rowid'; |
|
712 | + if (empty($keyfield)) $keyfield = 'rowid'; |
|
713 | 713 | $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; |
714 | 714 | |
715 | - $resql=$this->db->query($sqlSelect); |
|
716 | - if($resql) { |
|
715 | + $resql = $this->db->query($sqlSelect); |
|
716 | + if ($resql) { |
|
717 | 717 | $res = $this->db->fetch_object($resql); |
718 | - if($resql->num_rows == 1) { |
|
718 | + if ($resql->num_rows == 1) { |
|
719 | 719 | // We have a row referencing this last foreign key, continue with UPDATE. |
720 | 720 | } else { |
721 | 721 | // No record found referencing this last foreign key, |
@@ -726,8 +726,8 @@ discard block |
||
726 | 726 | else |
727 | 727 | { |
728 | 728 | //print 'E'; |
729 | - $this->errors[$error]['lib']=$this->db->lasterror(); |
|
730 | - $this->errors[$error]['type']='SQL'; |
|
729 | + $this->errors[$error]['lib'] = $this->db->lasterror(); |
|
730 | + $this->errors[$error]['type'] = 'SQL'; |
|
731 | 731 | $error++; |
732 | 732 | } |
733 | 733 | } |
@@ -741,24 +741,24 @@ discard block |
||
741 | 741 | foreach ($data as $key => $val) { |
742 | 742 | $set[] = $key.' = '.$val; |
743 | 743 | } |
744 | - $sqlstart.= ' SET '.implode(', ', $set); |
|
744 | + $sqlstart .= ' SET '.implode(', ', $set); |
|
745 | 745 | |
746 | - if(empty($keyfield)) $keyfield = 'rowid'; |
|
746 | + if (empty($keyfield)) $keyfield = 'rowid'; |
|
747 | 747 | $sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; |
748 | 748 | |
749 | 749 | $sql = $sqlstart.$sqlend; |
750 | 750 | |
751 | 751 | // Run update request |
752 | - $resql=$this->db->query($sql); |
|
753 | - if($resql) { |
|
752 | + $resql = $this->db->query($sql); |
|
753 | + if ($resql) { |
|
754 | 754 | // No error, update has been done. $this->db->db->affected_rows can be 0 if data hasn't changed |
755 | 755 | $updatedone = true; |
756 | 756 | } |
757 | 757 | else |
758 | 758 | { |
759 | 759 | //print 'E'; |
760 | - $this->errors[$error]['lib']=$this->db->lasterror(); |
|
761 | - $this->errors[$error]['type']='SQL'; |
|
760 | + $this->errors[$error]['lib'] = $this->db->lasterror(); |
|
761 | + $this->errors[$error]['type'] = 'SQL'; |
|
762 | 762 | $error++; |
763 | 763 | } |
764 | 764 | } |
@@ -769,13 +769,13 @@ discard block |
||
769 | 769 | // Build SQL INSERT request |
770 | 770 | $sqlstart = 'INSERT INTO '.$tablename.'('.implode(', ', $listfields).', import_key'; |
771 | 771 | $sqlend = ') VALUES('.implode(', ', $listvalues).", '".$importid."'"; |
772 | - if (! empty($tablewithentity_cache[$tablename])) { |
|
773 | - $sqlstart.= ', entity'; |
|
774 | - $sqlend.= ', '.$conf->entity; |
|
772 | + if (!empty($tablewithentity_cache[$tablename])) { |
|
773 | + $sqlstart .= ', entity'; |
|
774 | + $sqlend .= ', '.$conf->entity; |
|
775 | 775 | } |
776 | - if (! empty($objimport->array_import_tables_creator[0][$alias])) { |
|
777 | - $sqlstart.= ', '.$objimport->array_import_tables_creator[0][$alias]; |
|
778 | - $sqlend.=', '.$user->id; |
|
776 | + if (!empty($objimport->array_import_tables_creator[0][$alias])) { |
|
777 | + $sqlstart .= ', '.$objimport->array_import_tables_creator[0][$alias]; |
|
778 | + $sqlend .= ', '.$user->id; |
|
779 | 779 | } |
780 | 780 | $sql = $sqlstart.$sqlend.')'; |
781 | 781 | dol_syslog("import_xlsx.modules", LOG_DEBUG); |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | // Run insert request |
784 | 784 | if ($sql) |
785 | 785 | { |
786 | - $resql=$this->db->query($sql); |
|
786 | + $resql = $this->db->query($sql); |
|
787 | 787 | if ($resql) |
788 | 788 | { |
789 | 789 | $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). |
@@ -792,8 +792,8 @@ discard block |
||
792 | 792 | else |
793 | 793 | { |
794 | 794 | //print 'E'; |
795 | - $this->errors[$error]['lib']=$this->db->lasterror(); |
|
796 | - $this->errors[$error]['type']='SQL'; |
|
795 | + $this->errors[$error]['lib'] = $this->db->lasterror(); |
|
796 | + $this->errors[$error]['type'] = 'SQL'; |
|
797 | 797 | $error++; |
798 | 798 | } |
799 | 799 | } |
@@ -808,8 +808,8 @@ discard block |
||
808 | 808 | if ($error) break; |
809 | 809 | } |
810 | 810 | |
811 | - if($updatedone) $this->nbupdate++; |
|
812 | - if($insertdone) $this->nbinsert++; |
|
811 | + if ($updatedone) $this->nbupdate++; |
|
812 | + if ($insertdone) $this->nbinsert++; |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | return 1; |
@@ -111,9 +111,11 @@ discard block |
||
111 | 111 | // If driver use an external library, put its name here |
112 | 112 | require_once PHPEXCEL_PATH.'PHPExcel.php'; |
113 | 113 | require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; |
114 | - if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive |
|
114 | + if (! class_exists('ZipArchive')) { |
|
115 | + // For Excel2007, PHPExcel need ZipArchive |
|
115 | 116 | { |
116 | 117 | $langs->load("errors"); |
118 | + } |
|
117 | 119 | $this->error=$langs->trans('ErrorPHPNeedModule','zip'); |
118 | 120 | return -1; |
119 | 121 | } |
@@ -121,7 +123,9 @@ discard block |
||
121 | 123 | $this->version_lib='1.8.0'; |
122 | 124 | |
123 | 125 | $this->datatoimport=$datatoimport; |
124 | - if (preg_match('/^societe_/',$datatoimport)) $this->thirpartyobject=new Societe($this->db); |
|
126 | + if (preg_match('/^societe_/',$datatoimport)) { |
|
127 | + $this->thirpartyobject=new Societe($this->db); |
|
128 | + } |
|
125 | 129 | } |
126 | 130 | |
127 | 131 | |
@@ -306,8 +310,9 @@ discard block |
||
306 | 310 | global $conf; |
307 | 311 | |
308 | 312 | $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow(); |
309 | - if($this->record > $rowcount) |
|
310 | - return false; |
|
313 | + if($this->record > $rowcount) { |
|
314 | + return false; |
|
315 | + } |
|
311 | 316 | $array = array(); |
312 | 317 | $colcount = PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn(0)); |
313 | 318 | for($col=0;$col<$colcount;$col++) { |
@@ -374,8 +379,7 @@ discard block |
||
374 | 379 | $this->warnings[$warning]['lib']=$langs->trans('EmptyLine'); |
375 | 380 | $this->warnings[$warning]['type']='EMPTY'; |
376 | 381 | $warning++; |
377 | - } |
|
378 | - else |
|
382 | + } else |
|
379 | 383 | { |
380 | 384 | $last_insert_id_array = array(); // store the last inserted auto_increment id for each table, so that dependent tables can be inserted with the appropriate id (eg: extrafields fk_object will be set with the last inserted object's id) |
381 | 385 | $updatedone = false; |
@@ -391,19 +395,27 @@ discard block |
||
391 | 395 | $errorforthistable=0; |
392 | 396 | |
393 | 397 | // Define $tablewithentity_cache[$tablename] if not already defined |
394 | - if (! isset($tablewithentity_cache[$tablename])) // keep this test with "isset" |
|
398 | + if (! isset($tablewithentity_cache[$tablename])) { |
|
399 | + // keep this test with "isset" |
|
395 | 400 | { |
396 | 401 | dol_syslog("Check if table ".$tablename." has an entity field"); |
402 | + } |
|
397 | 403 | $resql=$this->db->DDLDescTable($tablename,'entity'); |
398 | 404 | if ($resql) |
399 | 405 | { |
400 | 406 | $obj=$this->db->fetch_object($resql); |
401 | - if ($obj) $tablewithentity_cache[$tablename]=1; // table contains entity field |
|
402 | - else $tablewithentity_cache[$tablename]=0; // table does not contains entity field |
|
407 | + if ($obj) { |
|
408 | + $tablewithentity_cache[$tablename]=1; |
|
409 | + } |
|
410 | + // table contains entity field |
|
411 | + else { |
|
412 | + $tablewithentity_cache[$tablename]=0; |
|
413 | + } |
|
414 | + // table does not contains entity field |
|
415 | + } else { |
|
416 | + dol_print_error($this->db); |
|
403 | 417 | } |
404 | - else dol_print_error($this->db); |
|
405 | - } |
|
406 | - else |
|
418 | + } else |
|
407 | 419 | { |
408 | 420 | //dol_syslog("Table ".$tablename." check for entity into cache is ".$tablewithentity_cache[$tablename]); |
409 | 421 | } |
@@ -415,13 +427,19 @@ discard block |
||
415 | 427 | $fieldalias=preg_replace('/\..*$/i','',$val); |
416 | 428 | $fieldname=preg_replace('/^.*\./i','',$val); |
417 | 429 | |
418 | - if ($alias != $fieldalias) continue; // Not a field of current table |
|
430 | + if ($alias != $fieldalias) { |
|
431 | + continue; |
|
432 | + } |
|
433 | + // Not a field of current table |
|
419 | 434 | |
420 | 435 | if ($key <= $maxfields) |
421 | 436 | { |
422 | 437 | // Set $newval with value to insert and set $listvalues with sql request part for insert |
423 | 438 | $newval=''; |
424 | - if ($arrayrecord[($key-1)]['type'] > 0) $newval=$arrayrecord[($key-1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value |
|
439 | + if ($arrayrecord[($key-1)]['type'] > 0) { |
|
440 | + $newval=$arrayrecord[($key-1)]['val']; |
|
441 | + } |
|
442 | + // If type of field into input file is not empty string (so defined into input file), we get value |
|
425 | 443 | |
426 | 444 | // Make some tests on $newval |
427 | 445 | |
@@ -447,20 +465,23 @@ discard block |
||
447 | 465 | { |
448 | 466 | // New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess. |
449 | 467 | $isidorref='id'; |
450 | - if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i',$newval)) $isidorref='ref'; |
|
468 | + if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i',$newval)) { |
|
469 | + $isidorref='ref'; |
|
470 | + } |
|
451 | 471 | $newval=preg_replace('/^(id|ref):/i','',$newval); // Remove id: or ref: that was used to force if field is id or ref |
452 | 472 | //print 'Val is now '.$newval.' and is type '.$isidorref."<br>\n"; |
453 | 473 | |
454 | - if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor |
|
474 | + if ($isidorref == 'ref') { |
|
475 | + // If value into input import file is a ref, we apply the function defined into descriptor |
|
455 | 476 | { |
456 | 477 | $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); |
478 | + } |
|
457 | 479 | $class=$objimport->array_import_convertvalue[0][$val]['class']; |
458 | 480 | $method=$objimport->array_import_convertvalue[0][$val]['method']; |
459 | 481 | if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '') |
460 | 482 | { |
461 | 483 | $newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; |
462 | - } |
|
463 | - else |
|
484 | + } else |
|
464 | 485 | { |
465 | 486 | $resultload = dol_include_once($file); |
466 | 487 | if (empty($resultload)) |
@@ -478,27 +499,32 @@ discard block |
||
478 | 499 | } |
479 | 500 | $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]=$classinstance->id; |
480 | 501 | //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; |
481 | - if ($classinstance->id != '') // id may be 0, it is a found value |
|
502 | + if ($classinstance->id != '') { |
|
503 | + // id may be 0, it is a found value |
|
482 | 504 | { |
483 | 505 | $newval=$classinstance->id; |
484 | 506 | } |
485 | - else |
|
507 | + } else |
|
486 | 508 | { |
487 | - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn',$key,$newval,'code',$langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); |
|
488 | - else if (!empty($objimport->array_import_convertvalue[0][$val]['element'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldRefNotIn',$key,$newval,$langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['element'])); |
|
489 | - else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; |
|
509 | + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) { |
|
510 | + $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn',$key,$newval,'code',$langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); |
|
511 | + } else if (!empty($objimport->array_import_convertvalue[0][$val]['element'])) { |
|
512 | + $this->errors[$error]['lib']=$langs->trans('ErrorFieldRefNotIn',$key,$newval,$langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['element'])); |
|
513 | + } else { |
|
514 | + $this->errors[$error]['lib']='ErrorFieldValueNotIn'; |
|
515 | + } |
|
490 | 516 | $this->errors[$error]['type']='FOREIGNKEY'; |
491 | 517 | $errorforthistable++; |
492 | 518 | $error++; |
493 | 519 | } |
494 | 520 | } |
495 | 521 | } |
496 | - } |
|
497 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='zeroifnull') |
|
522 | + } elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='zeroifnull') |
|
498 | 523 | { |
499 | - if (empty($newval)) $newval='0'; |
|
500 | - } |
|
501 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto') |
|
524 | + if (empty($newval)) { |
|
525 | + $newval='0'; |
|
526 | + } |
|
527 | + } elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto') |
|
502 | 528 | { |
503 | 529 | if (strtolower($newval) == 'auto') |
504 | 530 | { |
@@ -506,9 +532,11 @@ discard block |
||
506 | 532 | $newval=$this->thirpartyobject->code_client; |
507 | 533 | //print 'code_client='.$newval; |
508 | 534 | } |
509 | - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" |
|
510 | - } |
|
511 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsuppliercodeifauto') |
|
535 | + if (empty($newval)) { |
|
536 | + $arrayrecord[($key-1)]['type']=-1; |
|
537 | + } |
|
538 | + // If we get empty value, we will use "null" |
|
539 | + } elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsuppliercodeifauto') |
|
512 | 540 | { |
513 | 541 | if (strtolower($newval) == 'auto') |
514 | 542 | { |
@@ -516,9 +544,11 @@ discard block |
||
516 | 544 | $newval=$this->thirpartyobject->code_fournisseur; |
517 | 545 | //print 'code_fournisseur='.$newval; |
518 | 546 | } |
519 | - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" |
|
520 | - } |
|
521 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomeraccountancycodeifauto') |
|
547 | + if (empty($newval)) { |
|
548 | + $arrayrecord[($key-1)]['type']=-1; |
|
549 | + } |
|
550 | + // If we get empty value, we will use "null" |
|
551 | + } elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomeraccountancycodeifauto') |
|
522 | 552 | { |
523 | 553 | if (strtolower($newval) == 'auto') |
524 | 554 | { |
@@ -526,20 +556,27 @@ discard block |
||
526 | 556 | $newval=$this->thirpartyobject->code_compta; |
527 | 557 | //print 'code_compta='.$newval; |
528 | 558 | } |
529 | - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" |
|
530 | - } |
|
531 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsupplieraccountancycodeifauto') |
|
559 | + if (empty($newval)) { |
|
560 | + $arrayrecord[($key-1)]['type']=-1; |
|
561 | + } |
|
562 | + // If we get empty value, we will use "null" |
|
563 | + } elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsupplieraccountancycodeifauto') |
|
532 | 564 | { |
533 | 565 | if (strtolower($newval) == 'auto') |
534 | 566 | { |
535 | 567 | $this->thirpartyobject->get_codecompta('supplier'); |
536 | 568 | $newval=$this->thirpartyobject->code_compta_fournisseur; |
537 | - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" |
|
569 | + if (empty($newval)) { |
|
570 | + $arrayrecord[($key-1)]['type']=-1; |
|
571 | + } |
|
572 | + // If we get empty value, we will use "null" |
|
538 | 573 | //print 'code_compta_fournisseur='.$newval; |
539 | 574 | } |
540 | - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" |
|
541 | - } |
|
542 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getrefifauto') |
|
575 | + if (empty($newval)) { |
|
576 | + $arrayrecord[($key-1)]['type']=-1; |
|
577 | + } |
|
578 | + // If we get empty value, we will use "null" |
|
579 | + } elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getrefifauto') |
|
543 | 580 | { |
544 | 581 | $defaultref=''; |
545 | 582 | // TODO provide the $modTask (module of generation of ref) as parameter of import_insert function |
@@ -550,12 +587,11 @@ discard block |
||
550 | 587 | $modTask = new $obj; |
551 | 588 | $defaultref = $modTask->getNextValue(null,null); |
552 | 589 | } |
553 | - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; |
|
590 | + if (is_numeric($defaultref) && $defaultref <= 0) { |
|
591 | + $defaultref=''; |
|
592 | + } |
|
554 | 593 | $newval=$defaultref; |
555 | - } |
|
556 | - |
|
557 | - |
|
558 | - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric') |
|
594 | + } elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric') |
|
559 | 595 | { |
560 | 596 | $newval = price2num($newval); |
561 | 597 | } |
@@ -573,9 +609,11 @@ discard block |
||
573 | 609 | $table=$reg[2]; |
574 | 610 | |
575 | 611 | // Load content of field@table into cache array |
576 | - if (! is_array($this->cachefieldtable[$field.'@'.$table])) // If content of field@table not already loaded into cache |
|
612 | + if (! is_array($this->cachefieldtable[$field.'@'.$table])) { |
|
613 | + // If content of field@table not already loaded into cache |
|
577 | 614 | { |
578 | 615 | $sql="SELECT ".$field." as aliasfield FROM ".$table; |
616 | + } |
|
579 | 617 | $resql=$this->db->query($sql); |
580 | 618 | if ($resql) |
581 | 619 | { |
@@ -584,11 +622,12 @@ discard block |
||
584 | 622 | while ($i < $num) |
585 | 623 | { |
586 | 624 | $obj=$this->db->fetch_object($resql); |
587 | - if ($obj) $this->cachefieldtable[$field.'@'.$table][]=$obj->aliasfield; |
|
625 | + if ($obj) { |
|
626 | + $this->cachefieldtable[$field.'@'.$table][]=$obj->aliasfield; |
|
627 | + } |
|
588 | 628 | $i++; |
589 | 629 | } |
590 | - } |
|
591 | - else |
|
630 | + } else |
|
592 | 631 | { |
593 | 632 | dol_print_error($this->db); |
594 | 633 | } |
@@ -622,9 +661,13 @@ discard block |
||
622 | 661 | $listfields[] = $fieldname; |
623 | 662 | |
624 | 663 | // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert |
625 | - if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) $listvalues[] = ($newval=='0'?$newval:"null"); |
|
626 | - elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) $listvalues[] = "''"; |
|
627 | - else $listvalues[] = "'".$this->db->escape($newval)."'"; |
|
664 | + if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) { |
|
665 | + $listvalues[] = ($newval=='0'?$newval:"null"); |
|
666 | + } elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) { |
|
667 | + $listvalues[] = "''"; |
|
668 | + } else { |
|
669 | + $listvalues[] = "'".$this->db->escape($newval)."'"; |
|
670 | + } |
|
628 | 671 | } |
629 | 672 | $i++; |
630 | 673 | } |
@@ -635,13 +678,15 @@ discard block |
||
635 | 678 | // Loop on each hidden fields to add them into listfields/listvalues |
636 | 679 | foreach($objimport->array_import_fieldshidden[0] as $key => $val) |
637 | 680 | { |
638 | - if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table |
|
681 | + if (! preg_match('/^'.preg_quote($alias).'\./', $key)) { |
|
682 | + continue; |
|
683 | + } |
|
684 | + // Not a field of current table |
|
639 | 685 | if ($val == 'user->id') |
640 | 686 | { |
641 | 687 | $listfields[] = preg_replace('/^'.preg_quote($alias).'\./','',$key); |
642 | 688 | $listvalues[] = $user->id; |
643 | - } |
|
644 | - elseif (preg_match('/^lastrowid-/',$val)) |
|
689 | + } elseif (preg_match('/^lastrowid-/',$val)) |
|
645 | 690 | { |
646 | 691 | $tmp=explode('-',$val); |
647 | 692 | $lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0; |
@@ -693,8 +738,7 @@ discard block |
||
693 | 738 | } else { |
694 | 739 | // No record found with filters, insert will be tried below |
695 | 740 | } |
696 | - } |
|
697 | - else |
|
741 | + } else |
|
698 | 742 | { |
699 | 743 | //print 'E'; |
700 | 744 | $this->errors[$error]['lib']=$this->db->lasterror(); |
@@ -709,7 +753,9 @@ discard block |
||
709 | 753 | // Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object' |
710 | 754 | $sqlSelect = 'SELECT rowid FROM '.$tablename; |
711 | 755 | |
712 | - if(empty($keyfield)) $keyfield = 'rowid'; |
|
756 | + if(empty($keyfield)) { |
|
757 | + $keyfield = 'rowid'; |
|
758 | + } |
|
713 | 759 | $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; |
714 | 760 | |
715 | 761 | $resql=$this->db->query($sqlSelect); |
@@ -722,8 +768,7 @@ discard block |
||
722 | 768 | // force $lastinsertid to 0 so we INSERT below. |
723 | 769 | $lastinsertid = 0; |
724 | 770 | } |
725 | - } |
|
726 | - else |
|
771 | + } else |
|
727 | 772 | { |
728 | 773 | //print 'E'; |
729 | 774 | $this->errors[$error]['lib']=$this->db->lasterror(); |
@@ -743,7 +788,9 @@ discard block |
||
743 | 788 | } |
744 | 789 | $sqlstart.= ' SET '.implode(', ', $set); |
745 | 790 | |
746 | - if(empty($keyfield)) $keyfield = 'rowid'; |
|
791 | + if(empty($keyfield)) { |
|
792 | + $keyfield = 'rowid'; |
|
793 | + } |
|
747 | 794 | $sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; |
748 | 795 | |
749 | 796 | $sql = $sqlstart.$sqlend; |
@@ -753,8 +800,7 @@ discard block |
||
753 | 800 | if($resql) { |
754 | 801 | // No error, update has been done. $this->db->db->affected_rows can be 0 if data hasn't changed |
755 | 802 | $updatedone = true; |
756 | - } |
|
757 | - else |
|
803 | + } else |
|
758 | 804 | { |
759 | 805 | //print 'E'; |
760 | 806 | $this->errors[$error]['lib']=$this->db->lasterror(); |
@@ -788,8 +834,7 @@ discard block |
||
788 | 834 | { |
789 | 835 | $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). |
790 | 836 | $insertdone = true; |
791 | - } |
|
792 | - else |
|
837 | + } else |
|
793 | 838 | { |
794 | 839 | //print 'E'; |
795 | 840 | $this->errors[$error]['lib']=$this->db->lasterror(); |
@@ -805,11 +850,17 @@ discard block |
||
805 | 850 | }*/ |
806 | 851 | } |
807 | 852 | |
808 | - if ($error) break; |
|
853 | + if ($error) { |
|
854 | + break; |
|
855 | + } |
|
809 | 856 | } |
810 | 857 | |
811 | - if($updatedone) $this->nbupdate++; |
|
812 | - if($insertdone) $this->nbinsert++; |
|
858 | + if($updatedone) { |
|
859 | + $this->nbupdate++; |
|
860 | + } |
|
861 | + if($insertdone) { |
|
862 | + $this->nbinsert++; |
|
863 | + } |
|
813 | 864 | } |
814 | 865 | |
815 | 866 | return 1; |