@@ -562,7 +562,7 @@ |
||
| 562 | 562 | * Load object contact |
| 563 | 563 | * |
| 564 | 564 | * @param int $id id du contact |
| 565 | - * @param User $user Utilisateur (abonnes aux alertes) qui veut les alertes de ce contact |
|
| 565 | + * @param integer $user Utilisateur (abonnes aux alertes) qui veut les alertes de ce contact |
|
| 566 | 566 | * @param string $ref_ext External reference, not given by Dolibarr |
| 567 | 567 | * @return int -1 if KO, 0 if OK but not found, 1 if OK |
| 568 | 568 | */ |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | public $state_code; // Code of department |
| 89 | 89 | public $state; // Label of department |
| 90 | 90 | |
| 91 | - public $poste; // Position |
|
| 91 | + public $poste; // Position |
|
| 92 | 92 | |
| 93 | 93 | public $socid; // fk_soc |
| 94 | 94 | public $statut; // 0=inactif, 1=actif |
@@ -153,14 +153,14 @@ discard block |
||
| 153 | 153 | $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; |
| 154 | 154 | if (!$user->rights->societe->client->voir && !$user->societe_id) |
| 155 | 155 | { |
| 156 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 157 | - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 156 | + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 157 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 158 | 158 | $sql.= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
| 159 | 159 | $clause = "AND"; |
| 160 | 160 | } |
| 161 | 161 | $sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')'; |
| 162 | 162 | $sql.= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; |
| 163 | - if ($user->societe_id > 0) $sql.=" AND sp.fk_soc = ".$user->societe_id; |
|
| 163 | + if ($user->societe_id > 0) $sql.=" AND sp.fk_soc = ".$user->societe_id; |
|
| 164 | 164 | |
| 165 | 165 | $resql=$this->db->query($sql); |
| 166 | 166 | if ($resql) |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | // Clean parameters |
| 199 | 199 | $this->lastname=$this->lastname?trim($this->lastname):trim($this->name); |
| 200 | - $this->firstname=trim($this->firstname); |
|
| 201 | - if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords($this->lastname); |
|
| 202 | - if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords($this->firstname); |
|
| 203 | - if (empty($this->socid)) $this->socid = 0; |
|
| 200 | + $this->firstname=trim($this->firstname); |
|
| 201 | + if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords($this->lastname); |
|
| 202 | + if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords($this->firstname); |
|
| 203 | + if (empty($this->socid)) $this->socid = 0; |
|
| 204 | 204 | if (empty($this->priv)) $this->priv = 0; |
| 205 | 205 | if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request |
| 206 | 206 | |
@@ -209,9 +209,9 @@ discard block |
||
| 209 | 209 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople ("; |
| 210 | 210 | $sql.= " datec"; |
| 211 | 211 | $sql.= ", fk_soc"; |
| 212 | - $sql.= ", lastname"; |
|
| 213 | - $sql.= ", firstname"; |
|
| 214 | - $sql.= ", fk_user_creat"; |
|
| 212 | + $sql.= ", lastname"; |
|
| 213 | + $sql.= ", firstname"; |
|
| 214 | + $sql.= ", fk_user_creat"; |
|
| 215 | 215 | $sql.= ", priv"; |
| 216 | 216 | $sql.= ", statut"; |
| 217 | 217 | $sql.= ", canvas"; |
@@ -223,14 +223,14 @@ discard block |
||
| 223 | 223 | if ($this->socid > 0) $sql.= " ".$this->socid.","; |
| 224 | 224 | else $sql.= "null,"; |
| 225 | 225 | $sql.= "'".$this->db->escape($this->lastname)."',"; |
| 226 | - $sql.= "'".$this->db->escape($this->firstname)."',"; |
|
| 226 | + $sql.= "'".$this->db->escape($this->firstname)."',"; |
|
| 227 | 227 | $sql.= " ".($user->id > 0 ? "'".$user->id."'":"null").","; |
| 228 | 228 | $sql.= " ".$this->priv.","; |
| 229 | 229 | $sql.= " ".$this->statut.","; |
| 230 | - $sql.= " ".(! empty($this->canvas)?"'".$this->db->escape($this->canvas)."'":"null").","; |
|
| 231 | - $sql.= " ".$entity.","; |
|
| 232 | - $sql.= "'".$this->db->escape($this->ref_ext)."',"; |
|
| 233 | - $sql.= " ".(! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
| 230 | + $sql.= " ".(! empty($this->canvas)?"'".$this->db->escape($this->canvas)."'":"null").","; |
|
| 231 | + $sql.= " ".$entity.","; |
|
| 232 | + $sql.= "'".$this->db->escape($this->ref_ext)."',"; |
|
| 233 | + $sql.= " ".(! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
| 234 | 234 | $sql.= ")"; |
| 235 | 235 | |
| 236 | 236 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
@@ -241,43 +241,43 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | if (! $error) |
| 243 | 243 | { |
| 244 | - $result=$this->update($this->id, $user, 1, 'add'); |
|
| 245 | - if ($result < 0) |
|
| 246 | - { |
|
| 247 | - $error++; |
|
| 248 | - $this->error=$this->db->lasterror(); |
|
| 249 | - } |
|
| 244 | + $result=$this->update($this->id, $user, 1, 'add'); |
|
| 245 | + if ($result < 0) |
|
| 246 | + { |
|
| 247 | + $error++; |
|
| 248 | + $this->error=$this->db->lasterror(); |
|
| 249 | + } |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | if (! $error) |
| 253 | - { |
|
| 254 | - $result=$this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update |
|
| 255 | - if ($result < 0) |
|
| 256 | - { |
|
| 257 | - $error++; |
|
| 258 | - $this->error=$this->db->lasterror(); |
|
| 259 | - } |
|
| 260 | - } |
|
| 253 | + { |
|
| 254 | + $result=$this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update |
|
| 255 | + if ($result < 0) |
|
| 256 | + { |
|
| 257 | + $error++; |
|
| 258 | + $this->error=$this->db->lasterror(); |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | if (! $error) |
| 263 | - { |
|
| 264 | - // Call trigger |
|
| 265 | - $result=$this->call_trigger('CONTACT_CREATE',$user); |
|
| 266 | - if ($result < 0) { $error++; } |
|
| 267 | - // End call triggers |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - if (! $error) |
|
| 271 | - { |
|
| 272 | - $this->db->commit(); |
|
| 273 | - return $this->id; |
|
| 274 | - } |
|
| 275 | - else |
|
| 276 | - { |
|
| 277 | - $this->db->rollback(); |
|
| 278 | - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); |
|
| 279 | - return -2; |
|
| 280 | - } |
|
| 263 | + { |
|
| 264 | + // Call trigger |
|
| 265 | + $result=$this->call_trigger('CONTACT_CREATE',$user); |
|
| 266 | + if ($result < 0) { $error++; } |
|
| 267 | + // End call triggers |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + if (! $error) |
|
| 271 | + { |
|
| 272 | + $this->db->commit(); |
|
| 273 | + return $this->id; |
|
| 274 | + } |
|
| 275 | + else |
|
| 276 | + { |
|
| 277 | + $this->db->rollback(); |
|
| 278 | + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); |
|
| 279 | + return -2; |
|
| 280 | + } |
|
| 281 | 281 | } |
| 282 | 282 | else |
| 283 | 283 | { |
@@ -359,29 +359,29 @@ discard block |
||
| 359 | 359 | $result = $this->db->query($sql); |
| 360 | 360 | if ($result) |
| 361 | 361 | { |
| 362 | - unset($this->country_code); |
|
| 363 | - unset($this->country); |
|
| 364 | - unset($this->state_code); |
|
| 365 | - unset($this->state); |
|
| 366 | - |
|
| 367 | - $action='update'; |
|
| 368 | - |
|
| 369 | - // Actions on extra fields (by external module or standard code) |
|
| 370 | - $hookmanager->initHooks(array('contactdao')); |
|
| 371 | - $parameters=array('socid'=>$this->id); |
|
| 372 | - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
| 373 | - if (empty($reshook)) |
|
| 374 | - { |
|
| 375 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 376 | - { |
|
| 377 | - $result=$this->insertExtraFields(); |
|
| 378 | - if ($result < 0) |
|
| 379 | - { |
|
| 380 | - $error++; |
|
| 381 | - } |
|
| 382 | - } |
|
| 383 | - } |
|
| 384 | - else if ($reshook < 0) $error++; |
|
| 362 | + unset($this->country_code); |
|
| 363 | + unset($this->country); |
|
| 364 | + unset($this->state_code); |
|
| 365 | + unset($this->state); |
|
| 366 | + |
|
| 367 | + $action='update'; |
|
| 368 | + |
|
| 369 | + // Actions on extra fields (by external module or standard code) |
|
| 370 | + $hookmanager->initHooks(array('contactdao')); |
|
| 371 | + $parameters=array('socid'=>$this->id); |
|
| 372 | + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
| 373 | + if (empty($reshook)) |
|
| 374 | + { |
|
| 375 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 376 | + { |
|
| 377 | + $result=$this->insertExtraFields(); |
|
| 378 | + if ($result < 0) |
|
| 379 | + { |
|
| 380 | + $error++; |
|
| 381 | + } |
|
| 382 | + } |
|
| 383 | + } |
|
| 384 | + else if ($reshook < 0) $error++; |
|
| 385 | 385 | |
| 386 | 386 | if (! $error && $this->user_id > 0) |
| 387 | 387 | { |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | else |
| 464 | 464 | { |
| 465 | 465 | $this->error=$this->db->lasterror().' sql='.$sql; |
| 466 | - $this->db->rollback(); |
|
| 466 | + $this->db->rollback(); |
|
| 467 | 467 | return -1; |
| 468 | 468 | } |
| 469 | 469 | } |
@@ -498,9 +498,9 @@ discard block |
||
| 498 | 498 | { |
| 499 | 499 | global $conf,$langs; |
| 500 | 500 | |
| 501 | - $info = array(); |
|
| 501 | + $info = array(); |
|
| 502 | 502 | |
| 503 | - // Object classes |
|
| 503 | + // Object classes |
|
| 504 | 504 | $info["objectclass"]=explode(',',$conf->global->LDAP_CONTACT_OBJECT_CLASS); |
| 505 | 505 | |
| 506 | 506 | $this->fullname=$this->getFullName($langs); |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | if ($this->phone_perso && ! empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso; |
| 530 | 530 | if ($this->phone_mobile && ! empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile; |
| 531 | 531 | if ($this->fax && ! empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax; |
| 532 | - if ($this->skype && ! empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; |
|
| 532 | + if ($this->skype && ! empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; |
|
| 533 | 533 | if ($this->note_private && ! empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = $this->note_private; |
| 534 | 534 | if ($this->email && ! empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email; |
| 535 | 535 | |
@@ -568,14 +568,14 @@ discard block |
||
| 568 | 568 | * @param int $id Id of contact |
| 569 | 569 | * @param User $user User asking to change alert or birthday |
| 570 | 570 | * @param int $notrigger 0=no, 1=yes |
| 571 | - * @return int <0 if KO, >=0 if OK |
|
| 571 | + * @return int <0 if KO, >=0 if OK |
|
| 572 | 572 | */ |
| 573 | 573 | function update_perso($id, $user=null, $notrigger=0) |
| 574 | 574 | { |
| 575 | - $error=0; |
|
| 576 | - $result=false; |
|
| 575 | + $error=0; |
|
| 576 | + $result=false; |
|
| 577 | 577 | |
| 578 | - $this->db->begin(); |
|
| 578 | + $this->db->begin(); |
|
| 579 | 579 | |
| 580 | 580 | // Mis a jour contact |
| 581 | 581 | $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET"; |
@@ -588,8 +588,8 @@ discard block |
||
| 588 | 588 | $resql = $this->db->query($sql); |
| 589 | 589 | if (! $resql) |
| 590 | 590 | { |
| 591 | - $error++; |
|
| 592 | - $this->error=$this->db->lasterror(); |
|
| 591 | + $error++; |
|
| 592 | + $this->error=$this->db->lasterror(); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | // Mis a jour alerte birthday |
@@ -606,8 +606,8 @@ discard block |
||
| 606 | 606 | $result = $this->db->query($sql); |
| 607 | 607 | if (! $result) |
| 608 | 608 | { |
| 609 | - $error++; |
|
| 610 | - $this->error=$this->db->lasterror(); |
|
| 609 | + $error++; |
|
| 610 | + $this->error=$this->db->lasterror(); |
|
| 611 | 611 | } |
| 612 | 612 | } |
| 613 | 613 | else |
@@ -622,29 +622,29 @@ discard block |
||
| 622 | 622 | $result = $this->db->query($sql); |
| 623 | 623 | if (! $result) |
| 624 | 624 | { |
| 625 | - $error++; |
|
| 626 | - $this->error=$this->db->lasterror(); |
|
| 625 | + $error++; |
|
| 626 | + $this->error=$this->db->lasterror(); |
|
| 627 | 627 | } |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | if (! $error && ! $notrigger) |
| 631 | 631 | { |
| 632 | - // Call trigger |
|
| 633 | - $result=$this->call_trigger('CONTACT_MODIFY',$user); |
|
| 634 | - if ($result < 0) { $error++; } |
|
| 635 | - // End call triggers |
|
| 632 | + // Call trigger |
|
| 633 | + $result=$this->call_trigger('CONTACT_MODIFY',$user); |
|
| 634 | + if ($result < 0) { $error++; } |
|
| 635 | + // End call triggers |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | if (! $error) |
| 639 | 639 | { |
| 640 | - $this->db->commit(); |
|
| 641 | - return 1; |
|
| 640 | + $this->db->commit(); |
|
| 641 | + return 1; |
|
| 642 | 642 | } |
| 643 | 643 | else |
| 644 | 644 | { |
| 645 | - dol_syslog(get_class($this)."::update Error ".$this->error,LOG_ERR); |
|
| 646 | - $this->db->rollback(); |
|
| 647 | - return -$error; |
|
| 645 | + dol_syslog(get_class($this)."::update Error ".$this->error,LOG_ERR); |
|
| 646 | + $this->db->rollback(); |
|
| 647 | + return -$error; |
|
| 648 | 648 | } |
| 649 | 649 | } |
| 650 | 650 | |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | * |
| 655 | 655 | * @param int $id id du contact |
| 656 | 656 | * @param User $user Utilisateur (abonnes aux alertes) qui veut les alertes de ce contact |
| 657 | - * @param string $ref_ext External reference, not given by Dolibarr |
|
| 657 | + * @param string $ref_ext External reference, not given by Dolibarr |
|
| 658 | 658 | * @return int -1 if KO, 0 if OK but not found, 1 if OK |
| 659 | 659 | */ |
| 660 | 660 | function fetch($id, $user=0, $ref_ext='') |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | $sql.= " c.fk_departement,"; |
| 678 | 678 | $sql.= " c.birthday,"; |
| 679 | 679 | $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype,"; |
| 680 | - $sql.= " c.photo,"; |
|
| 680 | + $sql.= " c.photo,"; |
|
| 681 | 681 | $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.no_email, c.canvas,"; |
| 682 | 682 | $sql.= " c.import_key,"; |
| 683 | 683 | $sql.= " co.label as country, co.code as country_code,"; |
@@ -828,12 +828,12 @@ discard block |
||
| 828 | 828 | */ |
| 829 | 829 | function setGenderFromCivility() |
| 830 | 830 | { |
| 831 | - unset($this->gender); |
|
| 832 | - if (in_array($this->civility_id, array('MR'))) { |
|
| 833 | - $this->gender = 'man'; |
|
| 834 | - } else if(in_array($this->civility_id, array('MME','MLE'))) { |
|
| 835 | - $this->gender = 'woman'; |
|
| 836 | - } |
|
| 831 | + unset($this->gender); |
|
| 832 | + if (in_array($this->civility_id, array('MR'))) { |
|
| 833 | + $this->gender = 'man'; |
|
| 834 | + } else if(in_array($this->civility_id, array('MME','MLE'))) { |
|
| 835 | + $this->gender = 'woman'; |
|
| 836 | + } |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | * ref_commande (for order and/or shipments) |
| 844 | 844 | * ref_propale |
| 845 | 845 | * |
| 846 | - * @return int <0 if KO, >=0 if OK |
|
| 846 | + * @return int <0 if KO, >=0 if OK |
|
| 847 | 847 | */ |
| 848 | 848 | function load_ref_elements() |
| 849 | 849 | { |
@@ -971,10 +971,10 @@ discard block |
||
| 971 | 971 | |
| 972 | 972 | if (! $error && ! $notrigger) |
| 973 | 973 | { |
| 974 | - // Call trigger |
|
| 975 | - $result=$this->call_trigger('CONTACT_DELETE',$user); |
|
| 976 | - if ($result < 0) { $error++; } |
|
| 977 | - // End call triggers |
|
| 974 | + // Call trigger |
|
| 975 | + $result=$this->call_trigger('CONTACT_DELETE',$user); |
|
| 976 | + if ($result < 0) { $error++; } |
|
| 977 | + // End call triggers |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | if (! $error) |
@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | * @param string $option Where the link point to |
| 1078 | 1078 | * @param int $maxlen Max length of |
| 1079 | 1079 | * @param string $moreparam Add more param into URL |
| 1080 | - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
|
| 1080 | + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
|
| 1081 | 1081 | * @return string String with URL |
| 1082 | 1082 | */ |
| 1083 | 1083 | function getNomUrl($withpicto=0, $option='', $maxlen=0, $moreparam='', $save_lastsearch_value=-1) |
@@ -1086,39 +1086,39 @@ discard block |
||
| 1086 | 1086 | |
| 1087 | 1087 | $result=''; |
| 1088 | 1088 | |
| 1089 | - $label = '<u>' . $langs->trans("ShowContact") . '</u>'; |
|
| 1090 | - $label.= '<br><b>' . $langs->trans("Name") . ':</b> '.$this->getFullName($langs); |
|
| 1091 | - //if ($this->civility_id) $label.= '<br><b>' . $langs->trans("Civility") . ':</b> '.$this->civility_id; // TODO Translate cibilty_id code |
|
| 1092 | - if (! empty($this->poste)) $label.= '<br><b>' . $langs->trans("Poste") . ':</b> '.$this->poste; |
|
| 1093 | - $label.= '<br><b>' . $langs->trans("EMail") . ':</b> '.$this->email; |
|
| 1094 | - $phonelist=array(); |
|
| 1095 | - if ($this->phone_pro) $phonelist[]=$this->phone_pro; |
|
| 1096 | - if ($this->phone_mobile) $phonelist[]=$this->phone_mobile; |
|
| 1097 | - if ($this->phone_perso) $phonelist[]=$this->phone_perso; |
|
| 1098 | - $label.= '<br><b>' . $langs->trans("Phone") . ':</b> '.join(', ',$phonelist); |
|
| 1099 | - $label.= '<br><b>' . $langs->trans("Address") . ':</b> '.dol_format_address($this, 1, ' ', $langs); |
|
| 1100 | - |
|
| 1101 | - $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; |
|
| 1102 | - |
|
| 1103 | - if ($option !== 'nolink') |
|
| 1104 | - { |
|
| 1105 | - // Add param to save lastsearch_values or not |
|
| 1106 | - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
| 1107 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 1108 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 1109 | - } |
|
| 1110 | - |
|
| 1111 | - $url .= $moreparam; |
|
| 1112 | - |
|
| 1113 | - $linkstart = '<a href="'.$url.'"'; |
|
| 1114 | - $linkclose=""; |
|
| 1115 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 1116 | - { |
|
| 1117 | - $label=$langs->trans("ShowContact"); |
|
| 1118 | - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1119 | - } |
|
| 1120 | - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1121 | - $linkclose.= ' class="classfortooltip">'; |
|
| 1089 | + $label = '<u>' . $langs->trans("ShowContact") . '</u>'; |
|
| 1090 | + $label.= '<br><b>' . $langs->trans("Name") . ':</b> '.$this->getFullName($langs); |
|
| 1091 | + //if ($this->civility_id) $label.= '<br><b>' . $langs->trans("Civility") . ':</b> '.$this->civility_id; // TODO Translate cibilty_id code |
|
| 1092 | + if (! empty($this->poste)) $label.= '<br><b>' . $langs->trans("Poste") . ':</b> '.$this->poste; |
|
| 1093 | + $label.= '<br><b>' . $langs->trans("EMail") . ':</b> '.$this->email; |
|
| 1094 | + $phonelist=array(); |
|
| 1095 | + if ($this->phone_pro) $phonelist[]=$this->phone_pro; |
|
| 1096 | + if ($this->phone_mobile) $phonelist[]=$this->phone_mobile; |
|
| 1097 | + if ($this->phone_perso) $phonelist[]=$this->phone_perso; |
|
| 1098 | + $label.= '<br><b>' . $langs->trans("Phone") . ':</b> '.join(', ',$phonelist); |
|
| 1099 | + $label.= '<br><b>' . $langs->trans("Address") . ':</b> '.dol_format_address($this, 1, ' ', $langs); |
|
| 1100 | + |
|
| 1101 | + $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; |
|
| 1102 | + |
|
| 1103 | + if ($option !== 'nolink') |
|
| 1104 | + { |
|
| 1105 | + // Add param to save lastsearch_values or not |
|
| 1106 | + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
| 1107 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 1108 | + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 1109 | + } |
|
| 1110 | + |
|
| 1111 | + $url .= $moreparam; |
|
| 1112 | + |
|
| 1113 | + $linkstart = '<a href="'.$url.'"'; |
|
| 1114 | + $linkclose=""; |
|
| 1115 | + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 1116 | + { |
|
| 1117 | + $label=$langs->trans("ShowContact"); |
|
| 1118 | + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1119 | + } |
|
| 1120 | + $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1121 | + $linkclose.= ' class="classfortooltip">'; |
|
| 1122 | 1122 | |
| 1123 | 1123 | if (! is_object($hookmanager)) |
| 1124 | 1124 | { |
@@ -1160,7 +1160,7 @@ discard block |
||
| 1160 | 1160 | |
| 1161 | 1161 | $code=(! empty($this->civility_id)?$this->civility_id:(! empty($this->civilite_id)?$this->civilite_id:'')); |
| 1162 | 1162 | if (empty($code)) return ''; |
| 1163 | - return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); |
|
| 1163 | + return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); |
|
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | 1166 | /** |
@@ -1234,11 +1234,11 @@ discard block |
||
| 1234 | 1234 | |
| 1235 | 1235 | |
| 1236 | 1236 | /** |
| 1237 | - * Initialise an instance with random values. |
|
| 1238 | - * Used to build previews or test instances. |
|
| 1239 | - * id must be 0 if object instance is a specimen. |
|
| 1240 | - * |
|
| 1241 | - * @return void |
|
| 1237 | + * Initialise an instance with random values. |
|
| 1238 | + * Used to build previews or test instances. |
|
| 1239 | + * id must be 0 if object instance is a specimen. |
|
| 1240 | + * |
|
| 1241 | + * @return void |
|
| 1242 | 1242 | */ |
| 1243 | 1243 | function initAsSpecimen() |
| 1244 | 1244 | { |
@@ -1264,7 +1264,7 @@ discard block |
||
| 1264 | 1264 | $this->country_code = 'FR'; |
| 1265 | 1265 | $this->country = 'France'; |
| 1266 | 1266 | $this->email = '[email protected]'; |
| 1267 | - $this->skype = 'tom.hanson'; |
|
| 1267 | + $this->skype = 'tom.hanson'; |
|
| 1268 | 1268 | |
| 1269 | 1269 | $this->phone_pro = '0909090901'; |
| 1270 | 1270 | $this->phone_perso = '0909090902'; |
@@ -1305,10 +1305,10 @@ discard block |
||
| 1305 | 1305 | dol_syslog(get_class($this)."::setstatus", LOG_DEBUG); |
| 1306 | 1306 | if ($result) |
| 1307 | 1307 | { |
| 1308 | - // Call trigger |
|
| 1309 | - $result=$this->call_trigger('CONTACT_ENABLEDISABLE',$user); |
|
| 1310 | - if ($result < 0) { $error++; } |
|
| 1311 | - // End call triggers |
|
| 1308 | + // Call trigger |
|
| 1309 | + $result=$this->call_trigger('CONTACT_ENABLEDISABLE',$user); |
|
| 1310 | + if ($result < 0) { $error++; } |
|
| 1311 | + // End call triggers |
|
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | 1314 | if ($error) |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * \ingroup societe |
| 30 | 30 | * \brief File of contacts class |
| 31 | 31 | */ |
| 32 | -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; |
|
| 32 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | class Contact extends CommonObject |
| 39 | 39 | { |
| 40 | - public $element='contact'; |
|
| 41 | - public $table_element='socpeople'; |
|
| 42 | - public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 40 | + public $element = 'contact'; |
|
| 41 | + public $table_element = 'socpeople'; |
|
| 42 | + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 43 | 43 | public $picto = 'contact'; |
| 44 | 44 | |
| 45 | 45 | |
@@ -47,23 +47,23 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. |
| 49 | 49 | */ |
| 50 | - public $fields=array( |
|
| 51 | - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), |
|
| 52 | - 'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), |
|
| 53 | - 'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1), |
|
| 54 | - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), |
|
| 55 | - 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), |
|
| 56 | - 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), |
|
| 57 | - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), |
|
| 58 | - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), |
|
| 50 | + public $fields = array( |
|
| 51 | + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), |
|
| 52 | + 'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), |
|
| 53 | + 'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1), |
|
| 54 | + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), |
|
| 55 | + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), |
|
| 56 | + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), |
|
| 57 | + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), |
|
| 58 | + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), |
|
| 59 | 59 | //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), |
| 60 | - 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), |
|
| 61 | - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), |
|
| 60 | + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), |
|
| 61 | + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), |
|
| 62 | 62 | //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), |
| 63 | - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), |
|
| 63 | + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), |
|
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | - public $civility_id; // In fact we store civility_code |
|
| 66 | + public $civility_id; // In fact we store civility_code |
|
| 67 | 67 | public $civility_code; |
| 68 | 68 | public $address; |
| 69 | 69 | public $zip; |
@@ -84,14 +84,14 @@ discard block |
||
| 84 | 84 | * @see state |
| 85 | 85 | */ |
| 86 | 86 | public $departement; |
| 87 | - public $state_id; // Id of department |
|
| 88 | - public $state_code; // Code of department |
|
| 89 | - public $state; // Label of department |
|
| 87 | + public $state_id; // Id of department |
|
| 88 | + public $state_code; // Code of department |
|
| 89 | + public $state; // Label of department |
|
| 90 | 90 | |
| 91 | - public $poste; // Position |
|
| 91 | + public $poste; // Position |
|
| 92 | 92 | |
| 93 | - public $socid; // fk_soc |
|
| 94 | - public $statut; // 0=inactif, 1=actif |
|
| 93 | + public $socid; // fk_soc |
|
| 94 | + public $statut; // 0=inactif, 1=actif |
|
| 95 | 95 | |
| 96 | 96 | public $code; |
| 97 | 97 | public $email; |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | public $birthday; |
| 109 | 109 | public $default_lang; |
| 110 | - public $no_email; // 1=Don't send e-mail to this contact, 0=do |
|
| 110 | + public $no_email; // 1=Don't send e-mail to this contact, 0=do |
|
| 111 | 111 | |
| 112 | - public $ref_facturation; // Reference number of invoice for which it is contact |
|
| 113 | - public $ref_contrat; // Nb de reference contrat pour lequel il est contact |
|
| 114 | - public $ref_commande; // Nb de reference commande pour lequel il est contact |
|
| 115 | - public $ref_propal; // Nb de reference propal pour lequel il est contact |
|
| 112 | + public $ref_facturation; // Reference number of invoice for which it is contact |
|
| 113 | + public $ref_contrat; // Nb de reference contrat pour lequel il est contact |
|
| 114 | + public $ref_commande; // Nb de reference commande pour lequel il est contact |
|
| 115 | + public $ref_propal; // Nb de reference propal pour lequel il est contact |
|
| 116 | 116 | |
| 117 | 117 | public $user_id; |
| 118 | 118 | public $user_login; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | // END MODULEBUILDER PROPERTIES |
| 121 | 121 | |
| 122 | 122 | |
| 123 | - public $oldcopy; // To contains a clone of this when we need to save old properties of object |
|
| 123 | + public $oldcopy; // To contains a clone of this when we need to save old properties of object |
|
| 124 | 124 | |
| 125 | 125 | |
| 126 | 126 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | function __construct($db) |
| 135 | 135 | { |
| 136 | 136 | $this->db = $db; |
| 137 | - $this->statut = 1; // By default, status is enabled |
|
| 137 | + $this->statut = 1; // By default, status is enabled |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -146,28 +146,28 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | global $user; |
| 148 | 148 | |
| 149 | - $this->nb=array(); |
|
| 149 | + $this->nb = array(); |
|
| 150 | 150 | $clause = "WHERE"; |
| 151 | 151 | |
| 152 | 152 | $sql = "SELECT count(sp.rowid) as nb"; |
| 153 | - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; |
|
| 153 | + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; |
|
| 154 | 154 | if (!$user->rights->societe->client->voir && !$user->societe_id) |
| 155 | 155 | { |
| 156 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 157 | - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 158 | - $sql.= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 156 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 157 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 158 | + $sql .= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 159 | 159 | $clause = "AND"; |
| 160 | 160 | } |
| 161 | - $sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')'; |
|
| 162 | - $sql.= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; |
|
| 163 | - if ($user->societe_id > 0) $sql.=" AND sp.fk_soc = ".$user->societe_id; |
|
| 161 | + $sql .= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')'; |
|
| 162 | + $sql .= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; |
|
| 163 | + if ($user->societe_id > 0) $sql .= " AND sp.fk_soc = ".$user->societe_id; |
|
| 164 | 164 | |
| 165 | - $resql=$this->db->query($sql); |
|
| 165 | + $resql = $this->db->query($sql); |
|
| 166 | 166 | if ($resql) |
| 167 | 167 | { |
| 168 | - while ($obj=$this->db->fetch_object($resql)) |
|
| 168 | + while ($obj = $this->db->fetch_object($resql)) |
|
| 169 | 169 | { |
| 170 | - $this->nb["contacts"]=$obj->nb; |
|
| 170 | + $this->nb["contacts"] = $obj->nb; |
|
| 171 | 171 | } |
| 172 | 172 | $this->db->free($resql); |
| 173 | 173 | return 1; |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | else |
| 176 | 176 | { |
| 177 | 177 | dol_print_error($this->db); |
| 178 | - $this->error=$this->db->lasterror(); |
|
| 178 | + $this->error = $this->db->lasterror(); |
|
| 179 | 179 | return -1; |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -190,84 +190,84 @@ discard block |
||
| 190 | 190 | { |
| 191 | 191 | global $conf, $langs; |
| 192 | 192 | |
| 193 | - $error=0; |
|
| 194 | - $now=dol_now(); |
|
| 193 | + $error = 0; |
|
| 194 | + $now = dol_now(); |
|
| 195 | 195 | |
| 196 | 196 | $this->db->begin(); |
| 197 | 197 | |
| 198 | 198 | // Clean parameters |
| 199 | - $this->lastname=$this->lastname?trim($this->lastname):trim($this->name); |
|
| 200 | - $this->firstname=trim($this->firstname); |
|
| 201 | - if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords($this->lastname); |
|
| 202 | - if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords($this->firstname); |
|
| 199 | + $this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name); |
|
| 200 | + $this->firstname = trim($this->firstname); |
|
| 201 | + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); |
|
| 202 | + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); |
|
| 203 | 203 | if (empty($this->socid)) $this->socid = 0; |
| 204 | 204 | if (empty($this->priv)) $this->priv = 0; |
| 205 | 205 | if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request |
| 206 | 206 | |
| 207 | - $entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity); |
|
| 207 | + $entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); |
|
| 208 | 208 | |
| 209 | 209 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople ("; |
| 210 | - $sql.= " datec"; |
|
| 211 | - $sql.= ", fk_soc"; |
|
| 212 | - $sql.= ", lastname"; |
|
| 213 | - $sql.= ", firstname"; |
|
| 214 | - $sql.= ", fk_user_creat"; |
|
| 215 | - $sql.= ", priv"; |
|
| 216 | - $sql.= ", statut"; |
|
| 217 | - $sql.= ", canvas"; |
|
| 218 | - $sql.= ", entity"; |
|
| 219 | - $sql.= ", ref_ext"; |
|
| 220 | - $sql.= ", import_key"; |
|
| 221 | - $sql.= ") VALUES ("; |
|
| 222 | - $sql.= "'".$this->db->idate($now)."',"; |
|
| 223 | - if ($this->socid > 0) $sql.= " ".$this->socid.","; |
|
| 224 | - else $sql.= "null,"; |
|
| 225 | - $sql.= "'".$this->db->escape($this->lastname)."',"; |
|
| 226 | - $sql.= "'".$this->db->escape($this->firstname)."',"; |
|
| 227 | - $sql.= " ".($user->id > 0 ? "'".$user->id."'":"null").","; |
|
| 228 | - $sql.= " ".$this->priv.","; |
|
| 229 | - $sql.= " ".$this->statut.","; |
|
| 230 | - $sql.= " ".(! empty($this->canvas)?"'".$this->db->escape($this->canvas)."'":"null").","; |
|
| 231 | - $sql.= " ".$entity.","; |
|
| 232 | - $sql.= "'".$this->db->escape($this->ref_ext)."',"; |
|
| 233 | - $sql.= " ".(! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
| 234 | - $sql.= ")"; |
|
| 210 | + $sql .= " datec"; |
|
| 211 | + $sql .= ", fk_soc"; |
|
| 212 | + $sql .= ", lastname"; |
|
| 213 | + $sql .= ", firstname"; |
|
| 214 | + $sql .= ", fk_user_creat"; |
|
| 215 | + $sql .= ", priv"; |
|
| 216 | + $sql .= ", statut"; |
|
| 217 | + $sql .= ", canvas"; |
|
| 218 | + $sql .= ", entity"; |
|
| 219 | + $sql .= ", ref_ext"; |
|
| 220 | + $sql .= ", import_key"; |
|
| 221 | + $sql .= ") VALUES ("; |
|
| 222 | + $sql .= "'".$this->db->idate($now)."',"; |
|
| 223 | + if ($this->socid > 0) $sql .= " ".$this->socid.","; |
|
| 224 | + else $sql .= "null,"; |
|
| 225 | + $sql .= "'".$this->db->escape($this->lastname)."',"; |
|
| 226 | + $sql .= "'".$this->db->escape($this->firstname)."',"; |
|
| 227 | + $sql .= " ".($user->id > 0 ? "'".$user->id."'" : "null").","; |
|
| 228 | + $sql .= " ".$this->priv.","; |
|
| 229 | + $sql .= " ".$this->statut.","; |
|
| 230 | + $sql .= " ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null").","; |
|
| 231 | + $sql .= " ".$entity.","; |
|
| 232 | + $sql .= "'".$this->db->escape($this->ref_ext)."',"; |
|
| 233 | + $sql .= " ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); |
|
| 234 | + $sql .= ")"; |
|
| 235 | 235 | |
| 236 | 236 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
| 237 | - $resql=$this->db->query($sql); |
|
| 237 | + $resql = $this->db->query($sql); |
|
| 238 | 238 | if ($resql) |
| 239 | 239 | { |
| 240 | 240 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."socpeople"); |
| 241 | 241 | |
| 242 | - if (! $error) |
|
| 242 | + if (!$error) |
|
| 243 | 243 | { |
| 244 | - $result=$this->update($this->id, $user, 1, 'add'); |
|
| 244 | + $result = $this->update($this->id, $user, 1, 'add'); |
|
| 245 | 245 | if ($result < 0) |
| 246 | 246 | { |
| 247 | 247 | $error++; |
| 248 | - $this->error=$this->db->lasterror(); |
|
| 248 | + $this->error = $this->db->lasterror(); |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - if (! $error) |
|
| 252 | + if (!$error) |
|
| 253 | 253 | { |
| 254 | - $result=$this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update |
|
| 254 | + $result = $this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update |
|
| 255 | 255 | if ($result < 0) |
| 256 | 256 | { |
| 257 | 257 | $error++; |
| 258 | - $this->error=$this->db->lasterror(); |
|
| 258 | + $this->error = $this->db->lasterror(); |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - if (! $error) |
|
| 262 | + if (!$error) |
|
| 263 | 263 | { |
| 264 | 264 | // Call trigger |
| 265 | - $result=$this->call_trigger('CONTACT_CREATE',$user); |
|
| 265 | + $result = $this->call_trigger('CONTACT_CREATE', $user); |
|
| 266 | 266 | if ($result < 0) { $error++; } |
| 267 | 267 | // End call triggers |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - if (! $error) |
|
| 270 | + if (!$error) |
|
| 271 | 271 | { |
| 272 | 272 | $this->db->commit(); |
| 273 | 273 | return $this->id; |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | else |
| 283 | 283 | { |
| 284 | - $this->error=$this->db->lasterror(); |
|
| 284 | + $this->error = $this->db->lasterror(); |
|
| 285 | 285 | |
| 286 | 286 | $this->db->rollback(); |
| 287 | 287 | dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); |
@@ -299,29 +299,29 @@ discard block |
||
| 299 | 299 | * @param int $nosyncuser No sync linked user (external users and contacts are linked) |
| 300 | 300 | * @return int <0 if KO, >0 if OK |
| 301 | 301 | */ |
| 302 | - function update($id, $user=null, $notrigger=0, $action='update', $nosyncuser=0) |
|
| 302 | + function update($id, $user = null, $notrigger = 0, $action = 'update', $nosyncuser = 0) |
|
| 303 | 303 | { |
| 304 | 304 | global $conf, $langs, $hookmanager; |
| 305 | 305 | |
| 306 | - $error=0; |
|
| 306 | + $error = 0; |
|
| 307 | 307 | |
| 308 | 308 | $this->id = $id; |
| 309 | 309 | |
| 310 | 310 | // Clean parameters |
| 311 | - $this->lastname=trim($this->lastname)?trim($this->lastname):trim($this->lastname); |
|
| 312 | - $this->firstname=trim($this->firstname); |
|
| 313 | - $this->email=trim($this->email); |
|
| 314 | - $this->phone_pro=trim($this->phone_pro); |
|
| 315 | - $this->phone_perso=trim($this->phone_perso); |
|
| 316 | - $this->phone_mobile=trim($this->phone_mobile); |
|
| 317 | - $this->jabberid=trim($this->jabberid); |
|
| 318 | - $this->skype=trim($this->skype); |
|
| 319 | - $this->photo=trim($this->photo); |
|
| 320 | - $this->fax=trim($this->fax); |
|
| 321 | - $this->zip=(empty($this->zip)?'':$this->zip); |
|
| 322 | - $this->town=(empty($this->town)?'':$this->town); |
|
| 323 | - $this->country_id=($this->country_id > 0?$this->country_id:$this->country_id); |
|
| 324 | - $this->state_id=($this->state_id > 0?$this->state_id:$this->fk_departement); |
|
| 311 | + $this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname); |
|
| 312 | + $this->firstname = trim($this->firstname); |
|
| 313 | + $this->email = trim($this->email); |
|
| 314 | + $this->phone_pro = trim($this->phone_pro); |
|
| 315 | + $this->phone_perso = trim($this->phone_perso); |
|
| 316 | + $this->phone_mobile = trim($this->phone_mobile); |
|
| 317 | + $this->jabberid = trim($this->jabberid); |
|
| 318 | + $this->skype = trim($this->skype); |
|
| 319 | + $this->photo = trim($this->photo); |
|
| 320 | + $this->fax = trim($this->fax); |
|
| 321 | + $this->zip = (empty($this->zip) ? '' : $this->zip); |
|
| 322 | + $this->town = (empty($this->town) ? '' : $this->town); |
|
| 323 | + $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); |
|
| 324 | + $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->fk_departement); |
|
| 325 | 325 | if (empty($this->statut)) $this->statut = 0; |
| 326 | 326 | |
| 327 | 327 | $this->db->begin(); |
@@ -335,24 +335,24 @@ discard block |
||
| 335 | 335 | $sql .= ", address='".$this->db->escape($this->address)."'"; |
| 336 | 336 | $sql .= ", zip='".$this->db->escape($this->zip)."'"; |
| 337 | 337 | $sql .= ", town='".$this->db->escape($this->town)."'"; |
| 338 | - $sql .= ", fk_pays=".($this->country_id>0?$this->country_id:'NULL'); |
|
| 339 | - $sql .= ", fk_departement=".($this->state_id>0?$this->state_id:'NULL'); |
|
| 338 | + $sql .= ", fk_pays=".($this->country_id > 0 ? $this->country_id : 'NULL'); |
|
| 339 | + $sql .= ", fk_departement=".($this->state_id > 0 ? $this->state_id : 'NULL'); |
|
| 340 | 340 | $sql .= ", poste='".$this->db->escape($this->poste)."'"; |
| 341 | 341 | $sql .= ", fax='".$this->db->escape($this->fax)."'"; |
| 342 | 342 | $sql .= ", email='".$this->db->escape($this->email)."'"; |
| 343 | 343 | $sql .= ", skype='".$this->db->escape($this->skype)."'"; |
| 344 | 344 | $sql .= ", photo='".$this->db->escape($this->photo)."'"; |
| 345 | - $sql .= ", note_private = ".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); |
|
| 346 | - $sql .= ", note_public = ".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); |
|
| 347 | - $sql .= ", phone = ".(isset($this->phone_pro)?"'".$this->db->escape($this->phone_pro)."'":"null"); |
|
| 348 | - $sql .= ", phone_perso = ".(isset($this->phone_perso)?"'".$this->db->escape($this->phone_perso)."'":"null"); |
|
| 349 | - $sql .= ", phone_mobile = ".(isset($this->phone_mobile)?"'".$this->db->escape($this->phone_mobile)."'":"null"); |
|
| 350 | - $sql .= ", jabberid = ".(isset($this->jabberid)?"'".$this->db->escape($this->jabberid)."'":"null"); |
|
| 345 | + $sql .= ", note_private = ".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); |
|
| 346 | + $sql .= ", note_public = ".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null"); |
|
| 347 | + $sql .= ", phone = ".(isset($this->phone_pro) ? "'".$this->db->escape($this->phone_pro)."'" : "null"); |
|
| 348 | + $sql .= ", phone_perso = ".(isset($this->phone_perso) ? "'".$this->db->escape($this->phone_perso)."'" : "null"); |
|
| 349 | + $sql .= ", phone_mobile = ".(isset($this->phone_mobile) ? "'".$this->db->escape($this->phone_mobile)."'" : "null"); |
|
| 350 | + $sql .= ", jabberid = ".(isset($this->jabberid) ? "'".$this->db->escape($this->jabberid)."'" : "null"); |
|
| 351 | 351 | $sql .= ", priv = '".$this->db->escape($this->priv)."'"; |
| 352 | 352 | $sql .= ", statut = ".$this->statut; |
| 353 | - $sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"NULL"); |
|
| 354 | - $sql .= ", default_lang=".($this->default_lang?"'".$this->db->escape($this->default_lang)."'":"NULL"); |
|
| 355 | - $sql .= ", no_email=".($this->no_email?"'".$this->db->escape($this->no_email)."'":"0"); |
|
| 353 | + $sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'" : "NULL"); |
|
| 354 | + $sql .= ", default_lang=".($this->default_lang ? "'".$this->db->escape($this->default_lang)."'" : "NULL"); |
|
| 355 | + $sql .= ", no_email=".($this->no_email ? "'".$this->db->escape($this->no_email)."'" : "0"); |
|
| 356 | 356 | $sql .= " WHERE rowid=".$this->db->escape($id); |
| 357 | 357 | |
| 358 | 358 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
@@ -364,17 +364,17 @@ discard block |
||
| 364 | 364 | unset($this->state_code); |
| 365 | 365 | unset($this->state); |
| 366 | 366 | |
| 367 | - $action='update'; |
|
| 367 | + $action = 'update'; |
|
| 368 | 368 | |
| 369 | 369 | // Actions on extra fields (by external module or standard code) |
| 370 | 370 | $hookmanager->initHooks(array('contactdao')); |
| 371 | - $parameters=array('socid'=>$this->id); |
|
| 372 | - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
| 371 | + $parameters = array('socid'=>$this->id); |
|
| 372 | + $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 373 | 373 | if (empty($reshook)) |
| 374 | 374 | { |
| 375 | 375 | if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
| 376 | 376 | { |
| 377 | - $result=$this->insertExtraFields(); |
|
| 377 | + $result = $this->insertExtraFields(); |
|
| 378 | 378 | if ($result < 0) |
| 379 | 379 | { |
| 380 | 380 | $error++; |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | } |
| 384 | 384 | else if ($reshook < 0) $error++; |
| 385 | 385 | |
| 386 | - if (! $error && $this->user_id > 0) |
|
| 386 | + if (!$error && $this->user_id > 0) |
|
| 387 | 387 | { |
| 388 | 388 | $tmpobj = new User($this->db); |
| 389 | 389 | $tmpobj->fetch($this->user_id); |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | } |
| 416 | 416 | if ($tmpobj->zip != $this->zip) |
| 417 | 417 | { |
| 418 | - $tmpobj->state_id=$this->state_id; |
|
| 418 | + $tmpobj->state_id = $this->state_id; |
|
| 419 | 419 | $usermustbemodified++; |
| 420 | 420 | } |
| 421 | 421 | if ($tmpobj->country_id != $this->country_id) |
@@ -435,34 +435,34 @@ discard block |
||
| 435 | 435 | } |
| 436 | 436 | if ($usermustbemodified) |
| 437 | 437 | { |
| 438 | - $result=$tmpobj->update($user, 0, 1, 1, 1); |
|
| 438 | + $result = $tmpobj->update($user, 0, 1, 1, 1); |
|
| 439 | 439 | if ($result < 0) { $error++; } |
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - if (! $error && ! $notrigger) |
|
| 443 | + if (!$error && !$notrigger) |
|
| 444 | 444 | { |
| 445 | 445 | // Call trigger |
| 446 | - $result=$this->call_trigger('CONTACT_MODIFY',$user); |
|
| 446 | + $result = $this->call_trigger('CONTACT_MODIFY', $user); |
|
| 447 | 447 | if ($result < 0) { $error++; } |
| 448 | 448 | // End call triggers |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - if (! $error) |
|
| 451 | + if (!$error) |
|
| 452 | 452 | { |
| 453 | 453 | $this->db->commit(); |
| 454 | 454 | return 1; |
| 455 | 455 | } |
| 456 | 456 | else |
| 457 | 457 | { |
| 458 | - dol_syslog(get_class($this)."::update Error ".$this->error,LOG_ERR); |
|
| 458 | + dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); |
|
| 459 | 459 | $this->db->rollback(); |
| 460 | 460 | return -$error; |
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | 463 | else |
| 464 | 464 | { |
| 465 | - $this->error=$this->db->lasterror().' sql='.$sql; |
|
| 465 | + $this->error = $this->db->lasterror().' sql='.$sql; |
|
| 466 | 466 | $this->db->rollback(); |
| 467 | 467 | return -1; |
| 468 | 468 | } |
@@ -478,13 +478,13 @@ discard block |
||
| 478 | 478 | * 2=Return key only (uid=qqq) |
| 479 | 479 | * @return string DN |
| 480 | 480 | */ |
| 481 | - function _load_ldap_dn($info,$mode=0) |
|
| 481 | + function _load_ldap_dn($info, $mode = 0) |
|
| 482 | 482 | { |
| 483 | 483 | global $conf; |
| 484 | - $dn=''; |
|
| 485 | - if ($mode==0) $dn=$conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN; |
|
| 486 | - if ($mode==1) $dn=$conf->global->LDAP_CONTACT_DN; |
|
| 487 | - if ($mode==2) $dn=$conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS]; |
|
| 484 | + $dn = ''; |
|
| 485 | + if ($mode == 0) $dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN; |
|
| 486 | + if ($mode == 1) $dn = $conf->global->LDAP_CONTACT_DN; |
|
| 487 | + if ($mode == 2) $dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS]; |
|
| 488 | 488 | return $dn; |
| 489 | 489 | } |
| 490 | 490 | |
@@ -496,19 +496,19 @@ discard block |
||
| 496 | 496 | */ |
| 497 | 497 | function _load_ldap_info() |
| 498 | 498 | { |
| 499 | - global $conf,$langs; |
|
| 499 | + global $conf, $langs; |
|
| 500 | 500 | |
| 501 | 501 | $info = array(); |
| 502 | 502 | |
| 503 | 503 | // Object classes |
| 504 | - $info["objectclass"]=explode(',',$conf->global->LDAP_CONTACT_OBJECT_CLASS); |
|
| 504 | + $info["objectclass"] = explode(',', $conf->global->LDAP_CONTACT_OBJECT_CLASS); |
|
| 505 | 505 | |
| 506 | - $this->fullname=$this->getFullName($langs); |
|
| 506 | + $this->fullname = $this->getFullName($langs); |
|
| 507 | 507 | |
| 508 | 508 | // Fields |
| 509 | - if ($this->fullname && ! empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname; |
|
| 510 | - if ($this->lastname && ! empty($conf->global->LDAP_CONTACT_FIELD_NAME)) $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname; |
|
| 511 | - if ($this->firstname && ! empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname; |
|
| 509 | + if ($this->fullname && !empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname; |
|
| 510 | + if ($this->lastname && !empty($conf->global->LDAP_CONTACT_FIELD_NAME)) $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname; |
|
| 511 | + if ($this->firstname && !empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname; |
|
| 512 | 512 | |
| 513 | 513 | if ($this->poste) $info["title"] = $this->poste; |
| 514 | 514 | if ($this->socid > 0) |
@@ -521,17 +521,17 @@ discard block |
||
| 521 | 521 | if ($soc->client == 2) $info["businessCategory"] = "Prospects"; |
| 522 | 522 | if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers"; |
| 523 | 523 | } |
| 524 | - if ($this->address && ! empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address; |
|
| 525 | - if ($this->zip && ! empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip; |
|
| 526 | - if ($this->town && ! empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town; |
|
| 527 | - if ($this->country_code && ! empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code; |
|
| 528 | - if ($this->phone_pro && ! empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro; |
|
| 529 | - if ($this->phone_perso && ! empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso; |
|
| 530 | - if ($this->phone_mobile && ! empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile; |
|
| 531 | - if ($this->fax && ! empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax; |
|
| 532 | - if ($this->skype && ! empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; |
|
| 533 | - if ($this->note_private && ! empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = $this->note_private; |
|
| 534 | - if ($this->email && ! empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email; |
|
| 524 | + if ($this->address && !empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address; |
|
| 525 | + if ($this->zip && !empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip; |
|
| 526 | + if ($this->town && !empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town; |
|
| 527 | + if ($this->country_code && !empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code; |
|
| 528 | + if ($this->phone_pro && !empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro; |
|
| 529 | + if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso; |
|
| 530 | + if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile; |
|
| 531 | + if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax; |
|
| 532 | + if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; |
|
| 533 | + if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = $this->note_private; |
|
| 534 | + if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email; |
|
| 535 | 535 | |
| 536 | 536 | if ($conf->global->LDAP_SERVER_TYPE == 'egroupware') |
| 537 | 537 | { |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | |
| 540 | 540 | $info['uidnumber'] = $this->id; |
| 541 | 541 | |
| 542 | - $info['phpgwTz'] = 0; |
|
| 542 | + $info['phpgwTz'] = 0; |
|
| 543 | 543 | $info['phpgwMailType'] = 'INTERNET'; |
| 544 | 544 | $info['phpgwMailHomeType'] = 'INTERNET'; |
| 545 | 545 | |
@@ -570,26 +570,26 @@ discard block |
||
| 570 | 570 | * @param int $notrigger 0=no, 1=yes |
| 571 | 571 | * @return int <0 if KO, >=0 if OK |
| 572 | 572 | */ |
| 573 | - function update_perso($id, $user=null, $notrigger=0) |
|
| 573 | + function update_perso($id, $user = null, $notrigger = 0) |
|
| 574 | 574 | { |
| 575 | - $error=0; |
|
| 576 | - $result=false; |
|
| 575 | + $error = 0; |
|
| 576 | + $result = false; |
|
| 577 | 577 | |
| 578 | 578 | $this->db->begin(); |
| 579 | 579 | |
| 580 | 580 | // Mis a jour contact |
| 581 | 581 | $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET"; |
| 582 | - $sql.= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); |
|
| 583 | - $sql.= ", photo = ".($this->photo? "'".$this->db->escape($this->photo)."'" : "null"); |
|
| 582 | + $sql .= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); |
|
| 583 | + $sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null"); |
|
| 584 | 584 | if ($user) $sql .= ", fk_user_modif=".$user->id; |
| 585 | - $sql.= " WHERE rowid=".$this->db->escape($id); |
|
| 585 | + $sql .= " WHERE rowid=".$this->db->escape($id); |
|
| 586 | 586 | |
| 587 | 587 | dol_syslog(get_class($this)."::update_perso this->birthday=".$this->birthday." -", LOG_DEBUG); |
| 588 | 588 | $resql = $this->db->query($sql); |
| 589 | - if (! $resql) |
|
| 589 | + if (!$resql) |
|
| 590 | 590 | { |
| 591 | 591 | $error++; |
| 592 | - $this->error=$this->db->lasterror(); |
|
| 592 | + $this->error = $this->db->lasterror(); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | // Mis a jour alerte birthday |
@@ -598,16 +598,16 @@ discard block |
||
| 598 | 598 | //check existing |
| 599 | 599 | $sql_check = "SELECT * FROM ".MAIN_DB_PREFIX."user_alert WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id; |
| 600 | 600 | $result_check = $this->db->query($sql_check); |
| 601 | - if (! $result_check || ($this->db->num_rows($result_check)<1)) |
|
| 601 | + if (!$result_check || ($this->db->num_rows($result_check) < 1)) |
|
| 602 | 602 | { |
| 603 | 603 | //insert |
| 604 | 604 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_alert(type,fk_contact,fk_user) "; |
| 605 | - $sql.= "VALUES (1,".$this->db->escape($id).",".$user->id.")"; |
|
| 605 | + $sql .= "VALUES (1,".$this->db->escape($id).",".$user->id.")"; |
|
| 606 | 606 | $result = $this->db->query($sql); |
| 607 | - if (! $result) |
|
| 607 | + if (!$result) |
|
| 608 | 608 | { |
| 609 | 609 | $error++; |
| 610 | - $this->error=$this->db->lasterror(); |
|
| 610 | + $this->error = $this->db->lasterror(); |
|
| 611 | 611 | } |
| 612 | 612 | } |
| 613 | 613 | else |
@@ -618,31 +618,31 @@ discard block |
||
| 618 | 618 | else |
| 619 | 619 | { |
| 620 | 620 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_alert "; |
| 621 | - $sql.= "WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id; |
|
| 621 | + $sql .= "WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id; |
|
| 622 | 622 | $result = $this->db->query($sql); |
| 623 | - if (! $result) |
|
| 623 | + if (!$result) |
|
| 624 | 624 | { |
| 625 | 625 | $error++; |
| 626 | - $this->error=$this->db->lasterror(); |
|
| 626 | + $this->error = $this->db->lasterror(); |
|
| 627 | 627 | } |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - if (! $error && ! $notrigger) |
|
| 630 | + if (!$error && !$notrigger) |
|
| 631 | 631 | { |
| 632 | 632 | // Call trigger |
| 633 | - $result=$this->call_trigger('CONTACT_MODIFY',$user); |
|
| 633 | + $result = $this->call_trigger('CONTACT_MODIFY', $user); |
|
| 634 | 634 | if ($result < 0) { $error++; } |
| 635 | 635 | // End call triggers |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | - if (! $error) |
|
| 638 | + if (!$error) |
|
| 639 | 639 | { |
| 640 | 640 | $this->db->commit(); |
| 641 | 641 | return 1; |
| 642 | 642 | } |
| 643 | 643 | else |
| 644 | 644 | { |
| 645 | - dol_syslog(get_class($this)."::update Error ".$this->error,LOG_ERR); |
|
| 645 | + dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); |
|
| 646 | 646 | $this->db->rollback(); |
| 647 | 647 | return -$error; |
| 648 | 648 | } |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | * @param string $ref_ext External reference, not given by Dolibarr |
| 658 | 658 | * @return int -1 if KO, 0 if OK but not found, 1 if OK |
| 659 | 659 | */ |
| 660 | - function fetch($id, $user=0, $ref_ext='') |
|
| 660 | + function fetch($id, $user = 0, $ref_ext = '') |
|
| 661 | 661 | { |
| 662 | 662 | global $langs; |
| 663 | 663 | |
@@ -665,89 +665,89 @@ discard block |
||
| 665 | 665 | |
| 666 | 666 | if (empty($id) && empty($ref_ext)) |
| 667 | 667 | { |
| 668 | - $this->error='BadParameter'; |
|
| 668 | + $this->error = 'BadParameter'; |
|
| 669 | 669 | return -1; |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | $langs->load("companies"); |
| 673 | 673 | |
| 674 | 674 | $sql = "SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_id, c.lastname, c.firstname,"; |
| 675 | - $sql.= " c.address, c.statut, c.zip, c.town,"; |
|
| 676 | - $sql.= " c.fk_pays as country_id,"; |
|
| 677 | - $sql.= " c.fk_departement,"; |
|
| 678 | - $sql.= " c.birthday,"; |
|
| 679 | - $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype,"; |
|
| 680 | - $sql.= " c.photo,"; |
|
| 681 | - $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.no_email, c.canvas,"; |
|
| 682 | - $sql.= " c.import_key,"; |
|
| 683 | - $sql.= " co.label as country, co.code as country_code,"; |
|
| 684 | - $sql.= " d.nom as state, d.code_departement as state_code,"; |
|
| 685 | - $sql.= " u.rowid as user_id, u.login as user_login,"; |
|
| 686 | - $sql.= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang"; |
|
| 687 | - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; |
|
| 688 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON c.fk_pays = co.rowid"; |
|
| 689 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid"; |
|
| 690 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; |
|
| 691 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; |
|
| 692 | - if ($id) $sql.= " WHERE c.rowid = ". $id; |
|
| 675 | + $sql .= " c.address, c.statut, c.zip, c.town,"; |
|
| 676 | + $sql .= " c.fk_pays as country_id,"; |
|
| 677 | + $sql .= " c.fk_departement,"; |
|
| 678 | + $sql .= " c.birthday,"; |
|
| 679 | + $sql .= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype,"; |
|
| 680 | + $sql .= " c.photo,"; |
|
| 681 | + $sql .= " c.priv, c.note_private, c.note_public, c.default_lang, c.no_email, c.canvas,"; |
|
| 682 | + $sql .= " c.import_key,"; |
|
| 683 | + $sql .= " co.label as country, co.code as country_code,"; |
|
| 684 | + $sql .= " d.nom as state, d.code_departement as state_code,"; |
|
| 685 | + $sql .= " u.rowid as user_id, u.login as user_login,"; |
|
| 686 | + $sql .= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang"; |
|
| 687 | + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; |
|
| 688 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON c.fk_pays = co.rowid"; |
|
| 689 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid"; |
|
| 690 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; |
|
| 691 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; |
|
| 692 | + if ($id) $sql .= " WHERE c.rowid = ".$id; |
|
| 693 | 693 | elseif ($ref_ext) $sql .= " WHERE c.ref_ext = '".$this->db->escape($ref_ext)."'"; |
| 694 | 694 | |
| 695 | - $resql=$this->db->query($sql); |
|
| 695 | + $resql = $this->db->query($sql); |
|
| 696 | 696 | if ($resql) |
| 697 | 697 | { |
| 698 | 698 | if ($this->db->num_rows($resql)) |
| 699 | 699 | { |
| 700 | 700 | $obj = $this->db->fetch_object($resql); |
| 701 | 701 | |
| 702 | - $this->id = $obj->rowid; |
|
| 703 | - $this->entity = $obj->entity; |
|
| 704 | - $this->ref = $obj->rowid; |
|
| 705 | - $this->ref_ext = $obj->ref_ext; |
|
| 706 | - $this->civility_id = $obj->civility_id; |
|
| 707 | - $this->civility_code = $obj->civility_id; |
|
| 708 | - $this->lastname = $obj->lastname; |
|
| 709 | - $this->firstname = $obj->firstname; |
|
| 710 | - $this->address = $obj->address; |
|
| 711 | - $this->zip = $obj->zip; |
|
| 712 | - $this->town = $obj->town; |
|
| 713 | - |
|
| 714 | - $this->fk_departement = $obj->fk_departement; // deprecated |
|
| 715 | - $this->state_id = $obj->fk_departement; |
|
| 716 | - $this->departement_code = $obj->state_code; // deprecated |
|
| 717 | - $this->state_code = $obj->state_code; |
|
| 718 | - $this->departement = $obj->state; // deprecated |
|
| 719 | - $this->state = $obj->state; |
|
| 702 | + $this->id = $obj->rowid; |
|
| 703 | + $this->entity = $obj->entity; |
|
| 704 | + $this->ref = $obj->rowid; |
|
| 705 | + $this->ref_ext = $obj->ref_ext; |
|
| 706 | + $this->civility_id = $obj->civility_id; |
|
| 707 | + $this->civility_code = $obj->civility_id; |
|
| 708 | + $this->lastname = $obj->lastname; |
|
| 709 | + $this->firstname = $obj->firstname; |
|
| 710 | + $this->address = $obj->address; |
|
| 711 | + $this->zip = $obj->zip; |
|
| 712 | + $this->town = $obj->town; |
|
| 713 | + |
|
| 714 | + $this->fk_departement = $obj->fk_departement; // deprecated |
|
| 715 | + $this->state_id = $obj->fk_departement; |
|
| 716 | + $this->departement_code = $obj->state_code; // deprecated |
|
| 717 | + $this->state_code = $obj->state_code; |
|
| 718 | + $this->departement = $obj->state; // deprecated |
|
| 719 | + $this->state = $obj->state; |
|
| 720 | 720 | |
| 721 | 721 | $this->country_id = $obj->country_id; |
| 722 | - $this->country_code = $obj->country_id?$obj->country_code:''; |
|
| 723 | - $this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; |
|
| 722 | + $this->country_code = $obj->country_id ? $obj->country_code : ''; |
|
| 723 | + $this->country = $obj->country_id ? ($langs->trans('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : ''; |
|
| 724 | 724 | |
| 725 | 725 | $this->socid = $obj->fk_soc; |
| 726 | 726 | $this->socname = $obj->socname; |
| 727 | 727 | $this->poste = $obj->poste; |
| 728 | 728 | $this->statut = $obj->statut; |
| 729 | 729 | |
| 730 | - $this->phone_pro = trim($obj->phone); |
|
| 731 | - $this->fax = trim($obj->fax); |
|
| 732 | - $this->phone_perso = trim($obj->phone_perso); |
|
| 733 | - $this->phone_mobile = trim($obj->phone_mobile); |
|
| 730 | + $this->phone_pro = trim($obj->phone); |
|
| 731 | + $this->fax = trim($obj->fax); |
|
| 732 | + $this->phone_perso = trim($obj->phone_perso); |
|
| 733 | + $this->phone_mobile = trim($obj->phone_mobile); |
|
| 734 | 734 | |
| 735 | 735 | $this->email = $obj->email; |
| 736 | - $this->jabberid = $obj->jabberid; |
|
| 736 | + $this->jabberid = $obj->jabberid; |
|
| 737 | 737 | $this->skype = $obj->skype; |
| 738 | 738 | $this->photo = $obj->photo; |
| 739 | 739 | $this->priv = $obj->priv; |
| 740 | 740 | $this->mail = $obj->email; |
| 741 | 741 | |
| 742 | - $this->birthday = $this->db->jdate($obj->birthday); |
|
| 743 | - $this->note = $obj->note_private; // deprecated |
|
| 742 | + $this->birthday = $this->db->jdate($obj->birthday); |
|
| 743 | + $this->note = $obj->note_private; // deprecated |
|
| 744 | 744 | $this->note_private = $obj->note_private; |
| 745 | - $this->note_public = $obj->note_public; |
|
| 745 | + $this->note_public = $obj->note_public; |
|
| 746 | 746 | $this->default_lang = $obj->default_lang; |
| 747 | - $this->no_email = $obj->no_email; |
|
| 748 | - $this->user_id = $obj->user_id; |
|
| 747 | + $this->no_email = $obj->no_email; |
|
| 748 | + $this->user_id = $obj->user_id; |
|
| 749 | 749 | $this->user_login = $obj->user_login; |
| 750 | - $this->canvas = $obj->canvas; |
|
| 750 | + $this->canvas = $obj->canvas; |
|
| 751 | 751 | |
| 752 | 752 | $this->import_key = $obj->import_key; |
| 753 | 753 | |
@@ -757,9 +757,9 @@ discard block |
||
| 757 | 757 | // Search Dolibarr user linked to this contact |
| 758 | 758 | $sql = "SELECT u.rowid "; |
| 759 | 759 | $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; |
| 760 | - $sql .= " WHERE u.fk_socpeople = ". $this->id; |
|
| 760 | + $sql .= " WHERE u.fk_socpeople = ".$this->id; |
|
| 761 | 761 | |
| 762 | - $resql=$this->db->query($sql); |
|
| 762 | + $resql = $this->db->query($sql); |
|
| 763 | 763 | if ($resql) |
| 764 | 764 | { |
| 765 | 765 | if ($this->db->num_rows($resql)) |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | } |
| 773 | 773 | else |
| 774 | 774 | { |
| 775 | - $this->error=$this->db->error(); |
|
| 775 | + $this->error = $this->db->error(); |
|
| 776 | 776 | return -1; |
| 777 | 777 | } |
| 778 | 778 | |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | $sql .= " FROM ".MAIN_DB_PREFIX."user_alert"; |
| 784 | 784 | $sql .= " WHERE fk_user = ".$user->id." AND fk_contact = ".$this->db->escape($id); |
| 785 | 785 | |
| 786 | - $resql=$this->db->query($sql); |
|
| 786 | + $resql = $this->db->query($sql); |
|
| 787 | 787 | if ($resql) |
| 788 | 788 | { |
| 789 | 789 | if ($this->db->num_rows($resql)) |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | } |
| 797 | 797 | else |
| 798 | 798 | { |
| 799 | - $this->error=$this->db->error(); |
|
| 799 | + $this->error = $this->db->error(); |
|
| 800 | 800 | return -1; |
| 801 | 801 | } |
| 802 | 802 | } |
@@ -809,13 +809,13 @@ discard block |
||
| 809 | 809 | } |
| 810 | 810 | else |
| 811 | 811 | { |
| 812 | - $this->error=$langs->trans("RecordNotFound"); |
|
| 812 | + $this->error = $langs->trans("RecordNotFound"); |
|
| 813 | 813 | return 0; |
| 814 | 814 | } |
| 815 | 815 | } |
| 816 | 816 | else |
| 817 | 817 | { |
| 818 | - $this->error=$this->db->error(); |
|
| 818 | + $this->error = $this->db->error(); |
|
| 819 | 819 | return -1; |
| 820 | 820 | } |
| 821 | 821 | } |
@@ -831,7 +831,7 @@ discard block |
||
| 831 | 831 | unset($this->gender); |
| 832 | 832 | if (in_array($this->civility_id, array('MR'))) { |
| 833 | 833 | $this->gender = 'man'; |
| 834 | - } else if(in_array($this->civility_id, array('MME','MLE'))) { |
|
| 834 | + } else if (in_array($this->civility_id, array('MME', 'MLE'))) { |
|
| 835 | 835 | $this->gender = 'woman'; |
| 836 | 836 | } |
| 837 | 837 | } |
@@ -848,25 +848,25 @@ discard block |
||
| 848 | 848 | function load_ref_elements() |
| 849 | 849 | { |
| 850 | 850 | // Compte les elements pour lesquels il est contact |
| 851 | - $sql ="SELECT tc.element, count(ec.rowid) as nb"; |
|
| 852 | - $sql.=" FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 853 | - $sql.=" WHERE ec.fk_c_type_contact = tc.rowid"; |
|
| 854 | - $sql.=" AND fk_socpeople = ". $this->id; |
|
| 855 | - $sql.=" GROUP BY tc.element"; |
|
| 851 | + $sql = "SELECT tc.element, count(ec.rowid) as nb"; |
|
| 852 | + $sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 853 | + $sql .= " WHERE ec.fk_c_type_contact = tc.rowid"; |
|
| 854 | + $sql .= " AND fk_socpeople = ".$this->id; |
|
| 855 | + $sql .= " GROUP BY tc.element"; |
|
| 856 | 856 | |
| 857 | 857 | dol_syslog(get_class($this)."::load_ref_elements", LOG_DEBUG); |
| 858 | 858 | |
| 859 | - $resql=$this->db->query($sql); |
|
| 859 | + $resql = $this->db->query($sql); |
|
| 860 | 860 | if ($resql) |
| 861 | 861 | { |
| 862 | - while($obj=$this->db->fetch_object($resql)) |
|
| 862 | + while ($obj = $this->db->fetch_object($resql)) |
|
| 863 | 863 | { |
| 864 | 864 | if ($obj->nb) |
| 865 | 865 | { |
| 866 | - if ($obj->element=='facture') $this->ref_facturation = $obj->nb; |
|
| 867 | - if ($obj->element=='contrat') $this->ref_contrat = $obj->nb; |
|
| 868 | - if ($obj->element=='commande') $this->ref_commande = $obj->nb; |
|
| 869 | - if ($obj->element=='propal') $this->ref_propal = $obj->nb; |
|
| 866 | + if ($obj->element == 'facture') $this->ref_facturation = $obj->nb; |
|
| 867 | + if ($obj->element == 'contrat') $this->ref_contrat = $obj->nb; |
|
| 868 | + if ($obj->element == 'commande') $this->ref_commande = $obj->nb; |
|
| 869 | + if ($obj->element == 'propal') $this->ref_propal = $obj->nb; |
|
| 870 | 870 | } |
| 871 | 871 | } |
| 872 | 872 | $this->db->free($resql); |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | } |
| 875 | 875 | else |
| 876 | 876 | { |
| 877 | - $this->error=$this->db->lasterror(); |
|
| 877 | + $this->error = $this->db->lasterror(); |
|
| 878 | 878 | return -1; |
| 879 | 879 | } |
| 880 | 880 | } |
@@ -885,45 +885,45 @@ discard block |
||
| 885 | 885 | * @param int $notrigger Disable all trigger |
| 886 | 886 | * @return int <0 if KO, >0 if OK |
| 887 | 887 | */ |
| 888 | - function delete($notrigger=0) |
|
| 888 | + function delete($notrigger = 0) |
|
| 889 | 889 | { |
| 890 | 890 | global $conf, $langs, $user; |
| 891 | 891 | |
| 892 | - $error=0; |
|
| 892 | + $error = 0; |
|
| 893 | 893 | |
| 894 | 894 | $this->old_lastname = $obj->lastname; |
| 895 | 895 | $this->old_firstname = $obj->firstname; |
| 896 | 896 | |
| 897 | 897 | $this->db->begin(); |
| 898 | 898 | |
| 899 | - if (! $error) |
|
| 899 | + if (!$error) |
|
| 900 | 900 | { |
| 901 | 901 | // Get all rowid of element_contact linked to a type that is link to llx_socpeople |
| 902 | 902 | $sql = "SELECT ec.rowid"; |
| 903 | - $sql.= " FROM ".MAIN_DB_PREFIX."element_contact ec,"; |
|
| 904 | - $sql.= " ".MAIN_DB_PREFIX."c_type_contact tc"; |
|
| 905 | - $sql.= " WHERE ec.fk_socpeople=".$this->id; |
|
| 906 | - $sql.= " AND ec.fk_c_type_contact=tc.rowid"; |
|
| 907 | - $sql.= " AND tc.source='external'"; |
|
| 903 | + $sql .= " FROM ".MAIN_DB_PREFIX."element_contact ec,"; |
|
| 904 | + $sql .= " ".MAIN_DB_PREFIX."c_type_contact tc"; |
|
| 905 | + $sql .= " WHERE ec.fk_socpeople=".$this->id; |
|
| 906 | + $sql .= " AND ec.fk_c_type_contact=tc.rowid"; |
|
| 907 | + $sql .= " AND tc.source='external'"; |
|
| 908 | 908 | dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
| 909 | 909 | $resql = $this->db->query($sql); |
| 910 | 910 | if ($resql) |
| 911 | 911 | { |
| 912 | - $num=$this->db->num_rows($resql); |
|
| 912 | + $num = $this->db->num_rows($resql); |
|
| 913 | 913 | |
| 914 | - $i=0; |
|
| 915 | - while ($i < $num && ! $error) |
|
| 914 | + $i = 0; |
|
| 915 | + while ($i < $num && !$error) |
|
| 916 | 916 | { |
| 917 | 917 | $obj = $this->db->fetch_object($resql); |
| 918 | 918 | |
| 919 | 919 | $sqldel = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; |
| 920 | - $sqldel.=" WHERE rowid = ".$obj->rowid; |
|
| 920 | + $sqldel .= " WHERE rowid = ".$obj->rowid; |
|
| 921 | 921 | dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
| 922 | 922 | $result = $this->db->query($sqldel); |
| 923 | - if (! $result) |
|
| 923 | + if (!$result) |
|
| 924 | 924 | { |
| 925 | 925 | $error++; |
| 926 | - $this->error=$this->db->error().' sql='.$sqldel; |
|
| 926 | + $this->error = $this->db->error().' sql='.$sqldel; |
|
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | $i++; |
@@ -932,52 +932,52 @@ discard block |
||
| 932 | 932 | else |
| 933 | 933 | { |
| 934 | 934 | $error++; |
| 935 | - $this->error=$this->db->error().' sql='.$sql; |
|
| 935 | + $this->error = $this->db->error().' sql='.$sql; |
|
| 936 | 936 | } |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | - if (! $error) |
|
| 939 | + if (!$error) |
|
| 940 | 940 | { |
| 941 | 941 | // Remove category |
| 942 | 942 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_contact WHERE fk_socpeople = ".$this->id; |
| 943 | 943 | dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
| 944 | - $resql=$this->db->query($sql); |
|
| 945 | - if (! $resql) |
|
| 944 | + $resql = $this->db->query($sql); |
|
| 945 | + if (!$resql) |
|
| 946 | 946 | { |
| 947 | 947 | $error++; |
| 948 | 948 | $this->error .= $this->db->lasterror(); |
| 949 | - $errorflag=-1; |
|
| 949 | + $errorflag = -1; |
|
| 950 | 950 | } |
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - if (! $error) |
|
| 953 | + if (!$error) |
|
| 954 | 954 | { |
| 955 | 955 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople"; |
| 956 | 956 | $sql .= " WHERE rowid=".$this->id; |
| 957 | 957 | dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
| 958 | 958 | $result = $this->db->query($sql); |
| 959 | - if (! $result) |
|
| 959 | + if (!$result) |
|
| 960 | 960 | { |
| 961 | 961 | $error++; |
| 962 | - $this->error=$this->db->error().' sql='.$sql; |
|
| 962 | + $this->error = $this->db->error().' sql='.$sql; |
|
| 963 | 963 | } |
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | // Removed extrafields |
| 967 | - if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) { // For avoid conflicts if trigger used |
|
| 968 | - $result=$this->deleteExtraFields($this); |
|
| 967 | + if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) { // For avoid conflicts if trigger used |
|
| 968 | + $result = $this->deleteExtraFields($this); |
|
| 969 | 969 | if ($result < 0) $error++; |
| 970 | 970 | } |
| 971 | 971 | |
| 972 | - if (! $error && ! $notrigger) |
|
| 972 | + if (!$error && !$notrigger) |
|
| 973 | 973 | { |
| 974 | 974 | // Call trigger |
| 975 | - $result=$this->call_trigger('CONTACT_DELETE',$user); |
|
| 975 | + $result = $this->call_trigger('CONTACT_DELETE', $user); |
|
| 976 | 976 | if ($result < 0) { $error++; } |
| 977 | 977 | // End call triggers |
| 978 | 978 | } |
| 979 | 979 | |
| 980 | - if (! $error) |
|
| 980 | + if (!$error) |
|
| 981 | 981 | { |
| 982 | 982 | |
| 983 | 983 | $this->db->commit(); |
@@ -986,7 +986,7 @@ discard block |
||
| 986 | 986 | else |
| 987 | 987 | { |
| 988 | 988 | $this->db->rollback(); |
| 989 | - dol_syslog("Error ".$this->error,LOG_ERR); |
|
| 989 | + dol_syslog("Error ".$this->error, LOG_ERR); |
|
| 990 | 990 | return -1; |
| 991 | 991 | } |
| 992 | 992 | } |
@@ -1001,23 +1001,23 @@ discard block |
||
| 1001 | 1001 | function info($id) |
| 1002 | 1002 | { |
| 1003 | 1003 | $sql = "SELECT c.rowid, c.datec as datec, c.fk_user_creat,"; |
| 1004 | - $sql.= " c.tms as tms, c.fk_user_modif"; |
|
| 1005 | - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; |
|
| 1006 | - $sql.= " WHERE c.rowid = ".$this->db->escape($id); |
|
| 1004 | + $sql .= " c.tms as tms, c.fk_user_modif"; |
|
| 1005 | + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; |
|
| 1006 | + $sql .= " WHERE c.rowid = ".$this->db->escape($id); |
|
| 1007 | 1007 | |
| 1008 | - $resql=$this->db->query($sql); |
|
| 1008 | + $resql = $this->db->query($sql); |
|
| 1009 | 1009 | if ($resql) |
| 1010 | 1010 | { |
| 1011 | 1011 | if ($this->db->num_rows($resql)) |
| 1012 | 1012 | { |
| 1013 | 1013 | $obj = $this->db->fetch_object($resql); |
| 1014 | 1014 | |
| 1015 | - $this->id = $obj->rowid; |
|
| 1015 | + $this->id = $obj->rowid; |
|
| 1016 | 1016 | |
| 1017 | 1017 | if ($obj->fk_user_creat) { |
| 1018 | 1018 | $cuser = new User($this->db); |
| 1019 | 1019 | $cuser->fetch($obj->fk_user_creat); |
| 1020 | - $this->user_creation = $cuser; |
|
| 1020 | + $this->user_creation = $cuser; |
|
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | if ($obj->fk_user_modif) { |
@@ -1046,25 +1046,25 @@ discard block |
||
| 1046 | 1046 | function getNbOfEMailings() |
| 1047 | 1047 | { |
| 1048 | 1048 | $sql = "SELECT count(mc.email) as nb"; |
| 1049 | - $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; |
|
| 1050 | - $sql.= " WHERE mc.email = '".$this->db->escape($this->email)."'"; |
|
| 1051 | - $sql.= " AND mc.statut NOT IN (-1,0)"; // -1 erreur, 0 non envoye, 1 envoye avec succes |
|
| 1049 | + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; |
|
| 1050 | + $sql .= " WHERE mc.email = '".$this->db->escape($this->email)."'"; |
|
| 1051 | + $sql .= " AND mc.statut NOT IN (-1,0)"; // -1 erreur, 0 non envoye, 1 envoye avec succes |
|
| 1052 | 1052 | |
| 1053 | 1053 | dol_syslog(get_class($this)."::getNbOfEMailings", LOG_DEBUG); |
| 1054 | 1054 | |
| 1055 | - $resql=$this->db->query($sql); |
|
| 1055 | + $resql = $this->db->query($sql); |
|
| 1056 | 1056 | |
| 1057 | 1057 | if ($resql) |
| 1058 | 1058 | { |
| 1059 | 1059 | $obj = $this->db->fetch_object($resql); |
| 1060 | - $nb=$obj->nb; |
|
| 1060 | + $nb = $obj->nb; |
|
| 1061 | 1061 | |
| 1062 | 1062 | $this->db->free($resql); |
| 1063 | 1063 | return $nb; |
| 1064 | 1064 | } |
| 1065 | 1065 | else |
| 1066 | 1066 | { |
| 1067 | - $this->error=$this->db->error(); |
|
| 1067 | + $this->error = $this->db->error(); |
|
| 1068 | 1068 | return -1; |
| 1069 | 1069 | } |
| 1070 | 1070 | } |
@@ -1080,70 +1080,70 @@ discard block |
||
| 1080 | 1080 | * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
| 1081 | 1081 | * @return string String with URL |
| 1082 | 1082 | */ |
| 1083 | - function getNomUrl($withpicto=0, $option='', $maxlen=0, $moreparam='', $save_lastsearch_value=-1) |
|
| 1083 | + function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $moreparam = '', $save_lastsearch_value = -1) |
|
| 1084 | 1084 | { |
| 1085 | 1085 | global $conf, $langs, $hookmanager; |
| 1086 | 1086 | |
| 1087 | - $result=''; |
|
| 1087 | + $result = ''; |
|
| 1088 | 1088 | |
| 1089 | - $label = '<u>' . $langs->trans("ShowContact") . '</u>'; |
|
| 1090 | - $label.= '<br><b>' . $langs->trans("Name") . ':</b> '.$this->getFullName($langs); |
|
| 1089 | + $label = '<u>'.$langs->trans("ShowContact").'</u>'; |
|
| 1090 | + $label .= '<br><b>'.$langs->trans("Name").':</b> '.$this->getFullName($langs); |
|
| 1091 | 1091 | //if ($this->civility_id) $label.= '<br><b>' . $langs->trans("Civility") . ':</b> '.$this->civility_id; // TODO Translate cibilty_id code |
| 1092 | - if (! empty($this->poste)) $label.= '<br><b>' . $langs->trans("Poste") . ':</b> '.$this->poste; |
|
| 1093 | - $label.= '<br><b>' . $langs->trans("EMail") . ':</b> '.$this->email; |
|
| 1094 | - $phonelist=array(); |
|
| 1095 | - if ($this->phone_pro) $phonelist[]=$this->phone_pro; |
|
| 1096 | - if ($this->phone_mobile) $phonelist[]=$this->phone_mobile; |
|
| 1097 | - if ($this->phone_perso) $phonelist[]=$this->phone_perso; |
|
| 1098 | - $label.= '<br><b>' . $langs->trans("Phone") . ':</b> '.join(', ',$phonelist); |
|
| 1099 | - $label.= '<br><b>' . $langs->trans("Address") . ':</b> '.dol_format_address($this, 1, ' ', $langs); |
|
| 1092 | + if (!empty($this->poste)) $label .= '<br><b>'.$langs->trans("Poste").':</b> '.$this->poste; |
|
| 1093 | + $label .= '<br><b>'.$langs->trans("EMail").':</b> '.$this->email; |
|
| 1094 | + $phonelist = array(); |
|
| 1095 | + if ($this->phone_pro) $phonelist[] = $this->phone_pro; |
|
| 1096 | + if ($this->phone_mobile) $phonelist[] = $this->phone_mobile; |
|
| 1097 | + if ($this->phone_perso) $phonelist[] = $this->phone_perso; |
|
| 1098 | + $label .= '<br><b>'.$langs->trans("Phone").':</b> '.join(', ', $phonelist); |
|
| 1099 | + $label .= '<br><b>'.$langs->trans("Address").':</b> '.dol_format_address($this, 1, ' ', $langs); |
|
| 1100 | 1100 | |
| 1101 | 1101 | $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; |
| 1102 | 1102 | |
| 1103 | 1103 | if ($option !== 'nolink') |
| 1104 | 1104 | { |
| 1105 | 1105 | // Add param to save lastsearch_values or not |
| 1106 | - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
| 1107 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 1108 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 1106 | + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
|
| 1107 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; |
|
| 1108 | + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; |
|
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | 1111 | $url .= $moreparam; |
| 1112 | 1112 | |
| 1113 | 1113 | $linkstart = '<a href="'.$url.'"'; |
| 1114 | - $linkclose=""; |
|
| 1115 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 1114 | + $linkclose = ""; |
|
| 1115 | + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 1116 | 1116 | { |
| 1117 | - $label=$langs->trans("ShowContact"); |
|
| 1118 | - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1117 | + $label = $langs->trans("ShowContact"); |
|
| 1118 | + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1119 | 1119 | } |
| 1120 | - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1121 | - $linkclose.= ' class="classfortooltip">'; |
|
| 1120 | + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1121 | + $linkclose .= ' class="classfortooltip">'; |
|
| 1122 | 1122 | |
| 1123 | - if (! is_object($hookmanager)) |
|
| 1123 | + if (!is_object($hookmanager)) |
|
| 1124 | 1124 | { |
| 1125 | 1125 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
| 1126 | - $hookmanager=new HookManager($this->db); |
|
| 1126 | + $hookmanager = new HookManager($this->db); |
|
| 1127 | 1127 | } |
| 1128 | 1128 | $hookmanager->initHooks(array('contactdao')); |
| 1129 | - $parameters=array('id'=>$this->id); |
|
| 1130 | - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
| 1129 | + $parameters = array('id'=>$this->id); |
|
| 1130 | + $reshook = $hookmanager->executeHooks('getnomurltooltip', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 1131 | 1131 | if ($reshook > 0) $linkclose = $hookmanager->resPrint; |
| 1132 | 1132 | |
| 1133 | - $linkstart.=$linkclose; |
|
| 1134 | - $linkend='</a>'; |
|
| 1133 | + $linkstart .= $linkclose; |
|
| 1134 | + $linkend = '</a>'; |
|
| 1135 | 1135 | |
| 1136 | 1136 | if ($option == 'xxx') |
| 1137 | 1137 | { |
| 1138 | 1138 | $linkstart = '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$this->id.$moreparam.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; |
| 1139 | - $linkend='</a>'; |
|
| 1139 | + $linkend = '</a>'; |
|
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | 1142 | |
| 1143 | - $result.=$linkstart; |
|
| 1144 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1); |
|
| 1145 | - if ($withpicto != 2) $result.=($maxlen?dol_trunc($this->getFullName($langs),$maxlen):$this->getFullName($langs)); |
|
| 1146 | - $result.=$linkend; |
|
| 1143 | + $result .= $linkstart; |
|
| 1144 | + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip ? 0 : 1); |
|
| 1145 | + if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs)); |
|
| 1146 | + $result .= $linkend; |
|
| 1147 | 1147 | |
| 1148 | 1148 | return $result; |
| 1149 | 1149 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | global $langs; |
| 1159 | 1159 | $langs->load("dict"); |
| 1160 | 1160 | |
| 1161 | - $code=(! empty($this->civility_id)?$this->civility_id:(! empty($this->civilite_id)?$this->civilite_id:'')); |
|
| 1161 | + $code = (!empty($this->civility_id) ? $this->civility_id : (!empty($this->civilite_id) ? $this->civilite_id : '')); |
|
| 1162 | 1162 | if (empty($code)) return ''; |
| 1163 | 1163 | return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); |
| 1164 | 1164 | } |
@@ -1171,7 +1171,7 @@ discard block |
||
| 1171 | 1171 | */ |
| 1172 | 1172 | function getLibStatut($mode) |
| 1173 | 1173 | { |
| 1174 | - return $this->LibStatut($this->statut,$mode); |
|
| 1174 | + return $this->LibStatut($this->statut, $mode); |
|
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | /** |
@@ -1181,40 +1181,40 @@ discard block |
||
| 1181 | 1181 | * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto |
| 1182 | 1182 | * @return string Libelle |
| 1183 | 1183 | */ |
| 1184 | - function LibStatut($statut,$mode) |
|
| 1184 | + function LibStatut($statut, $mode) |
|
| 1185 | 1185 | { |
| 1186 | 1186 | global $langs; |
| 1187 | 1187 | |
| 1188 | 1188 | if ($mode == 0) |
| 1189 | 1189 | { |
| 1190 | - if ($statut==0 || $statut==5) return $langs->trans('Disabled'); |
|
| 1191 | - elseif ($statut==1 || $statut==4) return $langs->trans('Enabled'); |
|
| 1190 | + if ($statut == 0 || $statut == 5) return $langs->trans('Disabled'); |
|
| 1191 | + elseif ($statut == 1 || $statut == 4) return $langs->trans('Enabled'); |
|
| 1192 | 1192 | } |
| 1193 | 1193 | elseif ($mode == 1) |
| 1194 | 1194 | { |
| 1195 | - if ($statut==0 || $statut==5) return $langs->trans('Disabled'); |
|
| 1196 | - elseif ($statut==1 || $statut==4) return $langs->trans('Enabled'); |
|
| 1195 | + if ($statut == 0 || $statut == 5) return $langs->trans('Disabled'); |
|
| 1196 | + elseif ($statut == 1 || $statut == 4) return $langs->trans('Enabled'); |
|
| 1197 | 1197 | } |
| 1198 | 1198 | elseif ($mode == 2) |
| 1199 | 1199 | { |
| 1200 | - if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); |
|
| 1201 | - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); |
|
| 1200 | + if ($statut == 0 || $statut == 5) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); |
|
| 1201 | + elseif ($statut == 1 || $statut == 4) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); |
|
| 1202 | 1202 | |
| 1203 | 1203 | } |
| 1204 | 1204 | elseif ($mode == 3) |
| 1205 | 1205 | { |
| 1206 | - if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"'); |
|
| 1207 | - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"'); |
|
| 1206 | + if ($statut == 0 || $statut == 5) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"'); |
|
| 1207 | + elseif ($statut == 1 || $statut == 4) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"'); |
|
| 1208 | 1208 | } |
| 1209 | 1209 | elseif ($mode == 4) |
| 1210 | 1210 | { |
| 1211 | - if ($statut==0) return img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); |
|
| 1212 | - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); |
|
| 1211 | + if ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); |
|
| 1212 | + elseif ($statut == 1 || $statut == 4) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); |
|
| 1213 | 1213 | } |
| 1214 | 1214 | elseif ($mode == 5) |
| 1215 | 1215 | { |
| 1216 | - if ($statut==0 || $statut==5) return '<span class="hideonsmartphone">'.$langs->trans('Disabled').' </span>'.img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"'); |
|
| 1217 | - elseif ($statut==1 || $statut==4) return '<span class="hideonsmartphone">'.$langs->trans('Enabled').' </span>'.img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"'); |
|
| 1216 | + if ($statut == 0 || $statut == 5) return '<span class="hideonsmartphone">'.$langs->trans('Disabled').' </span>'.img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"'); |
|
| 1217 | + elseif ($statut == 1 || $statut == 4) return '<span class="hideonsmartphone">'.$langs->trans('Enabled').' </span>'.img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"'); |
|
| 1218 | 1218 | } |
| 1219 | 1219 | } |
| 1220 | 1220 | |
@@ -1228,7 +1228,7 @@ discard block |
||
| 1228 | 1228 | function LibPubPriv($statut) |
| 1229 | 1229 | { |
| 1230 | 1230 | global $langs; |
| 1231 | - if ($statut=='1') return $langs->trans('ContactPrivate'); |
|
| 1231 | + if ($statut == '1') return $langs->trans('ContactPrivate'); |
|
| 1232 | 1232 | else return $langs->trans('ContactPublic'); |
| 1233 | 1233 | } |
| 1234 | 1234 | |
@@ -1249,12 +1249,12 @@ discard block |
||
| 1249 | 1249 | if ($resql) |
| 1250 | 1250 | { |
| 1251 | 1251 | $obj = $this->db->fetch_object($resql); |
| 1252 | - if ($obj) $socid=$obj->rowid; |
|
| 1252 | + if ($obj) $socid = $obj->rowid; |
|
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | 1255 | // Initialise parameters |
| 1256 | - $this->id=0; |
|
| 1257 | - $this->specimen=1; |
|
| 1256 | + $this->id = 0; |
|
| 1257 | + $this->specimen = 1; |
|
| 1258 | 1258 | $this->lastname = 'DOLIBARR'; |
| 1259 | 1259 | $this->firstname = 'SPECIMEN'; |
| 1260 | 1260 | $this->address = '21 jump street'; |
@@ -1271,11 +1271,11 @@ discard block |
||
| 1271 | 1271 | $this->phone_mobile = '0909090903'; |
| 1272 | 1272 | $this->fax = '0909090909'; |
| 1273 | 1273 | |
| 1274 | - $this->note_public='This is a comment (public)'; |
|
| 1275 | - $this->note_private='This is a comment (private)'; |
|
| 1274 | + $this->note_public = 'This is a comment (public)'; |
|
| 1275 | + $this->note_private = 'This is a comment (private)'; |
|
| 1276 | 1276 | |
| 1277 | 1277 | $this->socid = $socid; |
| 1278 | - $this->statut=1; |
|
| 1278 | + $this->statut = 1; |
|
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | /** |
@@ -1286,9 +1286,9 @@ discard block |
||
| 1286 | 1286 | */ |
| 1287 | 1287 | function setstatus($statut) |
| 1288 | 1288 | { |
| 1289 | - global $conf,$langs,$user; |
|
| 1289 | + global $conf, $langs, $user; |
|
| 1290 | 1290 | |
| 1291 | - $error=0; |
|
| 1291 | + $error = 0; |
|
| 1292 | 1292 | |
| 1293 | 1293 | // Check parameters |
| 1294 | 1294 | if ($this->statut == $statut) return 0; |
@@ -1298,15 +1298,15 @@ discard block |
||
| 1298 | 1298 | |
| 1299 | 1299 | // Desactive utilisateur |
| 1300 | 1300 | $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople"; |
| 1301 | - $sql.= " SET statut = ".$this->statut; |
|
| 1302 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 1301 | + $sql .= " SET statut = ".$this->statut; |
|
| 1302 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 1303 | 1303 | $result = $this->db->query($sql); |
| 1304 | 1304 | |
| 1305 | 1305 | dol_syslog(get_class($this)."::setstatus", LOG_DEBUG); |
| 1306 | 1306 | if ($result) |
| 1307 | 1307 | { |
| 1308 | 1308 | // Call trigger |
| 1309 | - $result=$this->call_trigger('CONTACT_ENABLEDISABLE',$user); |
|
| 1309 | + $result = $this->call_trigger('CONTACT_ENABLEDISABLE', $user); |
|
| 1310 | 1310 | if ($result < 0) { $error++; } |
| 1311 | 1311 | // End call triggers |
| 1312 | 1312 | } |
@@ -1340,7 +1340,7 @@ discard block |
||
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | 1342 | // Get current categories |
| 1343 | - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; |
|
| 1343 | + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
|
| 1344 | 1344 | $c = new Categorie($this->db); |
| 1345 | 1345 | $existing = $c->containing($this->id, Categorie::TYPE_CONTACT, 'id'); |
| 1346 | 1346 | |
@@ -160,7 +160,9 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | $sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')'; |
| 162 | 162 | $sql.= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; |
| 163 | - if ($user->societe_id > 0) $sql.=" AND sp.fk_soc = ".$user->societe_id; |
|
| 163 | + if ($user->societe_id > 0) { |
|
| 164 | + $sql.=" AND sp.fk_soc = ".$user->societe_id; |
|
| 165 | + } |
|
| 164 | 166 | |
| 165 | 167 | $resql=$this->db->query($sql); |
| 166 | 168 | if ($resql) |
@@ -171,8 +173,7 @@ discard block |
||
| 171 | 173 | } |
| 172 | 174 | $this->db->free($resql); |
| 173 | 175 | return 1; |
| 174 | - } |
|
| 175 | - else |
|
| 176 | + } else |
|
| 176 | 177 | { |
| 177 | 178 | dol_print_error($this->db); |
| 178 | 179 | $this->error=$this->db->lasterror(); |
@@ -198,11 +199,22 @@ discard block |
||
| 198 | 199 | // Clean parameters |
| 199 | 200 | $this->lastname=$this->lastname?trim($this->lastname):trim($this->name); |
| 200 | 201 | $this->firstname=trim($this->firstname); |
| 201 | - if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords($this->lastname); |
|
| 202 | - if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords($this->firstname); |
|
| 203 | - if (empty($this->socid)) $this->socid = 0; |
|
| 204 | - if (empty($this->priv)) $this->priv = 0; |
|
| 205 | - if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request |
|
| 202 | + if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) { |
|
| 203 | + $this->lastname=ucwords($this->lastname); |
|
| 204 | + } |
|
| 205 | + if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) { |
|
| 206 | + $this->firstname=ucwords($this->firstname); |
|
| 207 | + } |
|
| 208 | + if (empty($this->socid)) { |
|
| 209 | + $this->socid = 0; |
|
| 210 | + } |
|
| 211 | + if (empty($this->priv)) { |
|
| 212 | + $this->priv = 0; |
|
| 213 | + } |
|
| 214 | + if (empty($this->statut)) { |
|
| 215 | + $this->statut = 0; |
|
| 216 | + } |
|
| 217 | + // This is to convert '' into '0' to avoid bad sql request |
|
| 206 | 218 | |
| 207 | 219 | $entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity); |
| 208 | 220 | |
@@ -220,8 +232,11 @@ discard block |
||
| 220 | 232 | $sql.= ", import_key"; |
| 221 | 233 | $sql.= ") VALUES ("; |
| 222 | 234 | $sql.= "'".$this->db->idate($now)."',"; |
| 223 | - if ($this->socid > 0) $sql.= " ".$this->socid.","; |
|
| 224 | - else $sql.= "null,"; |
|
| 235 | + if ($this->socid > 0) { |
|
| 236 | + $sql.= " ".$this->socid.","; |
|
| 237 | + } else { |
|
| 238 | + $sql.= "null,"; |
|
| 239 | + } |
|
| 225 | 240 | $sql.= "'".$this->db->escape($this->lastname)."',"; |
| 226 | 241 | $sql.= "'".$this->db->escape($this->firstname)."',"; |
| 227 | 242 | $sql.= " ".($user->id > 0 ? "'".$user->id."'":"null").","; |
@@ -271,15 +286,13 @@ discard block |
||
| 271 | 286 | { |
| 272 | 287 | $this->db->commit(); |
| 273 | 288 | return $this->id; |
| 274 | - } |
|
| 275 | - else |
|
| 289 | + } else |
|
| 276 | 290 | { |
| 277 | 291 | $this->db->rollback(); |
| 278 | 292 | dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); |
| 279 | 293 | return -2; |
| 280 | 294 | } |
| 281 | - } |
|
| 282 | - else |
|
| 295 | + } else |
|
| 283 | 296 | { |
| 284 | 297 | $this->error=$this->db->lasterror(); |
| 285 | 298 | |
@@ -322,13 +335,18 @@ discard block |
||
| 322 | 335 | $this->town=(empty($this->town)?'':$this->town); |
| 323 | 336 | $this->country_id=($this->country_id > 0?$this->country_id:$this->country_id); |
| 324 | 337 | $this->state_id=($this->state_id > 0?$this->state_id:$this->fk_departement); |
| 325 | - if (empty($this->statut)) $this->statut = 0; |
|
| 338 | + if (empty($this->statut)) { |
|
| 339 | + $this->statut = 0; |
|
| 340 | + } |
|
| 326 | 341 | |
| 327 | 342 | $this->db->begin(); |
| 328 | 343 | |
| 329 | 344 | $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET "; |
| 330 | - if ($this->socid > 0) $sql .= " fk_soc='".$this->db->escape($this->socid)."',"; |
|
| 331 | - else if ($this->socid == -1) $sql .= " fk_soc=null,"; |
|
| 345 | + if ($this->socid > 0) { |
|
| 346 | + $sql .= " fk_soc='".$this->db->escape($this->socid)."',"; |
|
| 347 | + } else if ($this->socid == -1) { |
|
| 348 | + $sql .= " fk_soc=null,"; |
|
| 349 | + } |
|
| 332 | 350 | $sql .= " civility='".$this->db->escape($this->civility_id)."'"; |
| 333 | 351 | $sql .= ", lastname='".$this->db->escape($this->lastname)."'"; |
| 334 | 352 | $sql .= ", firstname='".$this->db->escape($this->firstname)."'"; |
@@ -372,16 +390,19 @@ discard block |
||
| 372 | 390 | $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 373 | 391 | if (empty($reshook)) |
| 374 | 392 | { |
| 375 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 393 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 394 | + // For avoid conflicts if trigger used |
|
| 376 | 395 | { |
| 377 | 396 | $result=$this->insertExtraFields(); |
| 397 | + } |
|
| 378 | 398 | if ($result < 0) |
| 379 | 399 | { |
| 380 | 400 | $error++; |
| 381 | 401 | } |
| 382 | 402 | } |
| 403 | + } else if ($reshook < 0) { |
|
| 404 | + $error++; |
|
| 383 | 405 | } |
| 384 | - else if ($reshook < 0) $error++; |
|
| 385 | 406 | |
| 386 | 407 | if (! $error && $this->user_id > 0) |
| 387 | 408 | { |
@@ -452,15 +473,13 @@ discard block |
||
| 452 | 473 | { |
| 453 | 474 | $this->db->commit(); |
| 454 | 475 | return 1; |
| 455 | - } |
|
| 456 | - else |
|
| 476 | + } else |
|
| 457 | 477 | { |
| 458 | 478 | dol_syslog(get_class($this)."::update Error ".$this->error,LOG_ERR); |
| 459 | 479 | $this->db->rollback(); |
| 460 | 480 | return -$error; |
| 461 | 481 | } |
| 462 | - } |
|
| 463 | - else |
|
| 482 | + } else |
|
| 464 | 483 | { |
| 465 | 484 | $this->error=$this->db->lasterror().' sql='.$sql; |
| 466 | 485 | $this->db->rollback(); |
@@ -482,9 +501,15 @@ discard block |
||
| 482 | 501 | { |
| 483 | 502 | global $conf; |
| 484 | 503 | $dn=''; |
| 485 | - if ($mode==0) $dn=$conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN; |
|
| 486 | - if ($mode==1) $dn=$conf->global->LDAP_CONTACT_DN; |
|
| 487 | - if ($mode==2) $dn=$conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS]; |
|
| 504 | + if ($mode==0) { |
|
| 505 | + $dn=$conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN; |
|
| 506 | + } |
|
| 507 | + if ($mode==1) { |
|
| 508 | + $dn=$conf->global->LDAP_CONTACT_DN; |
|
| 509 | + } |
|
| 510 | + if ($mode==2) { |
|
| 511 | + $dn=$conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS]; |
|
| 512 | + } |
|
| 488 | 513 | return $dn; |
| 489 | 514 | } |
| 490 | 515 | |
@@ -506,32 +531,68 @@ discard block |
||
| 506 | 531 | $this->fullname=$this->getFullName($langs); |
| 507 | 532 | |
| 508 | 533 | // Fields |
| 509 | - if ($this->fullname && ! empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname; |
|
| 510 | - if ($this->lastname && ! empty($conf->global->LDAP_CONTACT_FIELD_NAME)) $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname; |
|
| 511 | - if ($this->firstname && ! empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname; |
|
| 534 | + if ($this->fullname && ! empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) { |
|
| 535 | + $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname; |
|
| 536 | + } |
|
| 537 | + if ($this->lastname && ! empty($conf->global->LDAP_CONTACT_FIELD_NAME)) { |
|
| 538 | + $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname; |
|
| 539 | + } |
|
| 540 | + if ($this->firstname && ! empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) { |
|
| 541 | + $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname; |
|
| 542 | + } |
|
| 512 | 543 | |
| 513 | - if ($this->poste) $info["title"] = $this->poste; |
|
| 544 | + if ($this->poste) { |
|
| 545 | + $info["title"] = $this->poste; |
|
| 546 | + } |
|
| 514 | 547 | if ($this->socid > 0) |
| 515 | 548 | { |
| 516 | 549 | $soc = new Societe($this->db); |
| 517 | 550 | $soc->fetch($this->socid); |
| 518 | 551 | |
| 519 | 552 | $info[$conf->global->LDAP_CONTACT_FIELD_COMPANY] = $soc->name; |
| 520 | - if ($soc->client == 1) $info["businessCategory"] = "Customers"; |
|
| 521 | - if ($soc->client == 2) $info["businessCategory"] = "Prospects"; |
|
| 522 | - if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers"; |
|
| 553 | + if ($soc->client == 1) { |
|
| 554 | + $info["businessCategory"] = "Customers"; |
|
| 555 | + } |
|
| 556 | + if ($soc->client == 2) { |
|
| 557 | + $info["businessCategory"] = "Prospects"; |
|
| 558 | + } |
|
| 559 | + if ($soc->fournisseur == 1) { |
|
| 560 | + $info["businessCategory"] = "Suppliers"; |
|
| 561 | + } |
|
| 562 | + } |
|
| 563 | + if ($this->address && ! empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) { |
|
| 564 | + $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address; |
|
| 565 | + } |
|
| 566 | + if ($this->zip && ! empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) { |
|
| 567 | + $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip; |
|
| 568 | + } |
|
| 569 | + if ($this->town && ! empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) { |
|
| 570 | + $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town; |
|
| 571 | + } |
|
| 572 | + if ($this->country_code && ! empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) { |
|
| 573 | + $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code; |
|
| 574 | + } |
|
| 575 | + if ($this->phone_pro && ! empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) { |
|
| 576 | + $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro; |
|
| 577 | + } |
|
| 578 | + if ($this->phone_perso && ! empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) { |
|
| 579 | + $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso; |
|
| 580 | + } |
|
| 581 | + if ($this->phone_mobile && ! empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) { |
|
| 582 | + $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile; |
|
| 583 | + } |
|
| 584 | + if ($this->fax && ! empty($conf->global->LDAP_CONTACT_FIELD_FAX)) { |
|
| 585 | + $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax; |
|
| 586 | + } |
|
| 587 | + if ($this->skype && ! empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) { |
|
| 588 | + $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; |
|
| 589 | + } |
|
| 590 | + if ($this->note_private && ! empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) { |
|
| 591 | + $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = $this->note_private; |
|
| 592 | + } |
|
| 593 | + if ($this->email && ! empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) { |
|
| 594 | + $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email; |
|
| 523 | 595 | } |
| 524 | - if ($this->address && ! empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address; |
|
| 525 | - if ($this->zip && ! empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip; |
|
| 526 | - if ($this->town && ! empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town; |
|
| 527 | - if ($this->country_code && ! empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code; |
|
| 528 | - if ($this->phone_pro && ! empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro; |
|
| 529 | - if ($this->phone_perso && ! empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso; |
|
| 530 | - if ($this->phone_mobile && ! empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile; |
|
| 531 | - if ($this->fax && ! empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax; |
|
| 532 | - if ($this->skype && ! empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; |
|
| 533 | - if ($this->note_private && ! empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = $this->note_private; |
|
| 534 | - if ($this->email && ! empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email; |
|
| 535 | 596 | |
| 536 | 597 | if ($conf->global->LDAP_SERVER_TYPE == 'egroupware') |
| 537 | 598 | { |
@@ -554,8 +615,12 @@ discard block |
||
| 554 | 615 | |
| 555 | 616 | $info["phpgwContactOwner"] = $this->egroupware_id; |
| 556 | 617 | |
| 557 | - if ($this->email) $info["rfc822Mailbox"] = $this->email; |
|
| 558 | - if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile; |
|
| 618 | + if ($this->email) { |
|
| 619 | + $info["rfc822Mailbox"] = $this->email; |
|
| 620 | + } |
|
| 621 | + if ($this->phone_mobile) { |
|
| 622 | + $info["phpgwCellTelephoneNumber"] = $this->phone_mobile; |
|
| 623 | + } |
|
| 559 | 624 | } |
| 560 | 625 | |
| 561 | 626 | return $info; |
@@ -581,7 +646,9 @@ discard block |
||
| 581 | 646 | $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET"; |
| 582 | 647 | $sql.= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); |
| 583 | 648 | $sql.= ", photo = ".($this->photo? "'".$this->db->escape($this->photo)."'" : "null"); |
| 584 | - if ($user) $sql .= ", fk_user_modif=".$user->id; |
|
| 649 | + if ($user) { |
|
| 650 | + $sql .= ", fk_user_modif=".$user->id; |
|
| 651 | + } |
|
| 585 | 652 | $sql.= " WHERE rowid=".$this->db->escape($id); |
| 586 | 653 | |
| 587 | 654 | dol_syslog(get_class($this)."::update_perso this->birthday=".$this->birthday." -", LOG_DEBUG); |
@@ -609,13 +676,11 @@ discard block |
||
| 609 | 676 | $error++; |
| 610 | 677 | $this->error=$this->db->lasterror(); |
| 611 | 678 | } |
| 612 | - } |
|
| 613 | - else |
|
| 679 | + } else |
|
| 614 | 680 | { |
| 615 | 681 | $result = true; |
| 616 | 682 | } |
| 617 | - } |
|
| 618 | - else |
|
| 683 | + } else |
|
| 619 | 684 | { |
| 620 | 685 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_alert "; |
| 621 | 686 | $sql.= "WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id; |
@@ -639,8 +704,7 @@ discard block |
||
| 639 | 704 | { |
| 640 | 705 | $this->db->commit(); |
| 641 | 706 | return 1; |
| 642 | - } |
|
| 643 | - else |
|
| 707 | + } else |
|
| 644 | 708 | { |
| 645 | 709 | dol_syslog(get_class($this)."::update Error ".$this->error,LOG_ERR); |
| 646 | 710 | $this->db->rollback(); |
@@ -689,8 +753,11 @@ discard block |
||
| 689 | 753 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid"; |
| 690 | 754 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; |
| 691 | 755 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; |
| 692 | - if ($id) $sql.= " WHERE c.rowid = ". $id; |
|
| 693 | - elseif ($ref_ext) $sql .= " WHERE c.ref_ext = '".$this->db->escape($ref_ext)."'"; |
|
| 756 | + if ($id) { |
|
| 757 | + $sql.= " WHERE c.rowid = ". $id; |
|
| 758 | + } elseif ($ref_ext) { |
|
| 759 | + $sql .= " WHERE c.ref_ext = '".$this->db->escape($ref_ext)."'"; |
|
| 760 | + } |
|
| 694 | 761 | |
| 695 | 762 | $resql=$this->db->query($sql); |
| 696 | 763 | if ($resql) |
@@ -769,8 +836,7 @@ discard block |
||
| 769 | 836 | $this->user_id = $uobj->rowid; |
| 770 | 837 | } |
| 771 | 838 | $this->db->free($resql); |
| 772 | - } |
|
| 773 | - else |
|
| 839 | + } else |
|
| 774 | 840 | { |
| 775 | 841 | $this->error=$this->db->error(); |
| 776 | 842 | return -1; |
@@ -793,8 +859,7 @@ discard block |
||
| 793 | 859 | $this->birthday_alert = 1; |
| 794 | 860 | } |
| 795 | 861 | $this->db->free($resql); |
| 796 | - } |
|
| 797 | - else |
|
| 862 | + } else |
|
| 798 | 863 | { |
| 799 | 864 | $this->error=$this->db->error(); |
| 800 | 865 | return -1; |
@@ -806,14 +871,12 @@ discard block |
||
| 806 | 871 | $this->fetch_optionals(); |
| 807 | 872 | |
| 808 | 873 | return 1; |
| 809 | - } |
|
| 810 | - else |
|
| 874 | + } else |
|
| 811 | 875 | { |
| 812 | 876 | $this->error=$langs->trans("RecordNotFound"); |
| 813 | 877 | return 0; |
| 814 | 878 | } |
| 815 | - } |
|
| 816 | - else |
|
| 879 | + } else |
|
| 817 | 880 | { |
| 818 | 881 | $this->error=$this->db->error(); |
| 819 | 882 | return -1; |
@@ -863,16 +926,23 @@ discard block |
||
| 863 | 926 | { |
| 864 | 927 | if ($obj->nb) |
| 865 | 928 | { |
| 866 | - if ($obj->element=='facture') $this->ref_facturation = $obj->nb; |
|
| 867 | - if ($obj->element=='contrat') $this->ref_contrat = $obj->nb; |
|
| 868 | - if ($obj->element=='commande') $this->ref_commande = $obj->nb; |
|
| 869 | - if ($obj->element=='propal') $this->ref_propal = $obj->nb; |
|
| 929 | + if ($obj->element=='facture') { |
|
| 930 | + $this->ref_facturation = $obj->nb; |
|
| 931 | + } |
|
| 932 | + if ($obj->element=='contrat') { |
|
| 933 | + $this->ref_contrat = $obj->nb; |
|
| 934 | + } |
|
| 935 | + if ($obj->element=='commande') { |
|
| 936 | + $this->ref_commande = $obj->nb; |
|
| 937 | + } |
|
| 938 | + if ($obj->element=='propal') { |
|
| 939 | + $this->ref_propal = $obj->nb; |
|
| 940 | + } |
|
| 870 | 941 | } |
| 871 | 942 | } |
| 872 | 943 | $this->db->free($resql); |
| 873 | 944 | return 0; |
| 874 | - } |
|
| 875 | - else |
|
| 945 | + } else |
|
| 876 | 946 | { |
| 877 | 947 | $this->error=$this->db->lasterror(); |
| 878 | 948 | return -1; |
@@ -928,8 +998,7 @@ discard block |
||
| 928 | 998 | |
| 929 | 999 | $i++; |
| 930 | 1000 | } |
| 931 | - } |
|
| 932 | - else |
|
| 1001 | + } else |
|
| 933 | 1002 | { |
| 934 | 1003 | $error++; |
| 935 | 1004 | $this->error=$this->db->error().' sql='.$sql; |
@@ -966,7 +1035,9 @@ discard block |
||
| 966 | 1035 | // Removed extrafields |
| 967 | 1036 | if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) { // For avoid conflicts if trigger used |
| 968 | 1037 | $result=$this->deleteExtraFields($this); |
| 969 | - if ($result < 0) $error++; |
|
| 1038 | + if ($result < 0) { |
|
| 1039 | + $error++; |
|
| 1040 | + } |
|
| 970 | 1041 | } |
| 971 | 1042 | |
| 972 | 1043 | if (! $error && ! $notrigger) |
@@ -982,8 +1053,7 @@ discard block |
||
| 982 | 1053 | |
| 983 | 1054 | $this->db->commit(); |
| 984 | 1055 | return 1; |
| 985 | - } |
|
| 986 | - else |
|
| 1056 | + } else |
|
| 987 | 1057 | { |
| 988 | 1058 | $this->db->rollback(); |
| 989 | 1059 | dol_syslog("Error ".$this->error,LOG_ERR); |
@@ -1031,8 +1101,7 @@ discard block |
||
| 1031 | 1101 | } |
| 1032 | 1102 | |
| 1033 | 1103 | $this->db->free($resql); |
| 1034 | - } |
|
| 1035 | - else |
|
| 1104 | + } else |
|
| 1036 | 1105 | { |
| 1037 | 1106 | print $this->db->error(); |
| 1038 | 1107 | } |
@@ -1061,8 +1130,7 @@ discard block |
||
| 1061 | 1130 | |
| 1062 | 1131 | $this->db->free($resql); |
| 1063 | 1132 | return $nb; |
| 1064 | - } |
|
| 1065 | - else |
|
| 1133 | + } else |
|
| 1066 | 1134 | { |
| 1067 | 1135 | $this->error=$this->db->error(); |
| 1068 | 1136 | return -1; |
@@ -1089,12 +1157,20 @@ discard block |
||
| 1089 | 1157 | $label = '<u>' . $langs->trans("ShowContact") . '</u>'; |
| 1090 | 1158 | $label.= '<br><b>' . $langs->trans("Name") . ':</b> '.$this->getFullName($langs); |
| 1091 | 1159 | //if ($this->civility_id) $label.= '<br><b>' . $langs->trans("Civility") . ':</b> '.$this->civility_id; // TODO Translate cibilty_id code |
| 1092 | - if (! empty($this->poste)) $label.= '<br><b>' . $langs->trans("Poste") . ':</b> '.$this->poste; |
|
| 1160 | + if (! empty($this->poste)) { |
|
| 1161 | + $label.= '<br><b>' . $langs->trans("Poste") . ':</b> '.$this->poste; |
|
| 1162 | + } |
|
| 1093 | 1163 | $label.= '<br><b>' . $langs->trans("EMail") . ':</b> '.$this->email; |
| 1094 | 1164 | $phonelist=array(); |
| 1095 | - if ($this->phone_pro) $phonelist[]=$this->phone_pro; |
|
| 1096 | - if ($this->phone_mobile) $phonelist[]=$this->phone_mobile; |
|
| 1097 | - if ($this->phone_perso) $phonelist[]=$this->phone_perso; |
|
| 1165 | + if ($this->phone_pro) { |
|
| 1166 | + $phonelist[]=$this->phone_pro; |
|
| 1167 | + } |
|
| 1168 | + if ($this->phone_mobile) { |
|
| 1169 | + $phonelist[]=$this->phone_mobile; |
|
| 1170 | + } |
|
| 1171 | + if ($this->phone_perso) { |
|
| 1172 | + $phonelist[]=$this->phone_perso; |
|
| 1173 | + } |
|
| 1098 | 1174 | $label.= '<br><b>' . $langs->trans("Phone") . ':</b> '.join(', ',$phonelist); |
| 1099 | 1175 | $label.= '<br><b>' . $langs->trans("Address") . ':</b> '.dol_format_address($this, 1, ' ', $langs); |
| 1100 | 1176 | |
@@ -1104,8 +1180,12 @@ discard block |
||
| 1104 | 1180 | { |
| 1105 | 1181 | // Add param to save lastsearch_values or not |
| 1106 | 1182 | $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
| 1107 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 1108 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 1183 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) { |
|
| 1184 | + $add_save_lastsearch_values=1; |
|
| 1185 | + } |
|
| 1186 | + if ($add_save_lastsearch_values) { |
|
| 1187 | + $url.='&save_lastsearch_values=1'; |
|
| 1188 | + } |
|
| 1109 | 1189 | } |
| 1110 | 1190 | |
| 1111 | 1191 | $url .= $moreparam; |
@@ -1128,7 +1208,9 @@ discard block |
||
| 1128 | 1208 | $hookmanager->initHooks(array('contactdao')); |
| 1129 | 1209 | $parameters=array('id'=>$this->id); |
| 1130 | 1210 | $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 1131 | - if ($reshook > 0) $linkclose = $hookmanager->resPrint; |
|
| 1211 | + if ($reshook > 0) { |
|
| 1212 | + $linkclose = $hookmanager->resPrint; |
|
| 1213 | + } |
|
| 1132 | 1214 | |
| 1133 | 1215 | $linkstart.=$linkclose; |
| 1134 | 1216 | $linkend='</a>'; |
@@ -1141,8 +1223,12 @@ discard block |
||
| 1141 | 1223 | |
| 1142 | 1224 | |
| 1143 | 1225 | $result.=$linkstart; |
| 1144 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1); |
|
| 1145 | - if ($withpicto != 2) $result.=($maxlen?dol_trunc($this->getFullName($langs),$maxlen):$this->getFullName($langs)); |
|
| 1226 | + if ($withpicto) { |
|
| 1227 | + $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1); |
|
| 1228 | + } |
|
| 1229 | + if ($withpicto != 2) { |
|
| 1230 | + $result.=($maxlen?dol_trunc($this->getFullName($langs),$maxlen):$this->getFullName($langs)); |
|
| 1231 | + } |
|
| 1146 | 1232 | $result.=$linkend; |
| 1147 | 1233 | |
| 1148 | 1234 | return $result; |
@@ -1159,7 +1245,9 @@ discard block |
||
| 1159 | 1245 | $langs->load("dict"); |
| 1160 | 1246 | |
| 1161 | 1247 | $code=(! empty($this->civility_id)?$this->civility_id:(! empty($this->civilite_id)?$this->civilite_id:'')); |
| 1162 | - if (empty($code)) return ''; |
|
| 1248 | + if (empty($code)) { |
|
| 1249 | + return ''; |
|
| 1250 | + } |
|
| 1163 | 1251 | return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); |
| 1164 | 1252 | } |
| 1165 | 1253 | |
@@ -1187,34 +1275,47 @@ discard block |
||
| 1187 | 1275 | |
| 1188 | 1276 | if ($mode == 0) |
| 1189 | 1277 | { |
| 1190 | - if ($statut==0 || $statut==5) return $langs->trans('Disabled'); |
|
| 1191 | - elseif ($statut==1 || $statut==4) return $langs->trans('Enabled'); |
|
| 1192 | - } |
|
| 1193 | - elseif ($mode == 1) |
|
| 1278 | + if ($statut==0 || $statut==5) { |
|
| 1279 | + return $langs->trans('Disabled'); |
|
| 1280 | + } elseif ($statut==1 || $statut==4) { |
|
| 1281 | + return $langs->trans('Enabled'); |
|
| 1282 | + } |
|
| 1283 | + } elseif ($mode == 1) |
|
| 1194 | 1284 | { |
| 1195 | - if ($statut==0 || $statut==5) return $langs->trans('Disabled'); |
|
| 1196 | - elseif ($statut==1 || $statut==4) return $langs->trans('Enabled'); |
|
| 1197 | - } |
|
| 1198 | - elseif ($mode == 2) |
|
| 1285 | + if ($statut==0 || $statut==5) { |
|
| 1286 | + return $langs->trans('Disabled'); |
|
| 1287 | + } elseif ($statut==1 || $statut==4) { |
|
| 1288 | + return $langs->trans('Enabled'); |
|
| 1289 | + } |
|
| 1290 | + } elseif ($mode == 2) |
|
| 1199 | 1291 | { |
| 1200 | - if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); |
|
| 1201 | - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); |
|
| 1292 | + if ($statut==0 || $statut==5) { |
|
| 1293 | + return img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); |
|
| 1294 | + } elseif ($statut==1 || $statut==4) { |
|
| 1295 | + return img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); |
|
| 1296 | + } |
|
| 1202 | 1297 | |
| 1203 | - } |
|
| 1204 | - elseif ($mode == 3) |
|
| 1298 | + } elseif ($mode == 3) |
|
| 1205 | 1299 | { |
| 1206 | - if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"'); |
|
| 1207 | - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"'); |
|
| 1208 | - } |
|
| 1209 | - elseif ($mode == 4) |
|
| 1300 | + if ($statut==0 || $statut==5) { |
|
| 1301 | + return img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"'); |
|
| 1302 | + } elseif ($statut==1 || $statut==4) { |
|
| 1303 | + return img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"'); |
|
| 1304 | + } |
|
| 1305 | + } elseif ($mode == 4) |
|
| 1210 | 1306 | { |
| 1211 | - if ($statut==0) return img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); |
|
| 1212 | - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); |
|
| 1213 | - } |
|
| 1214 | - elseif ($mode == 5) |
|
| 1307 | + if ($statut==0) { |
|
| 1308 | + return img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); |
|
| 1309 | + } elseif ($statut==1 || $statut==4) { |
|
| 1310 | + return img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); |
|
| 1311 | + } |
|
| 1312 | + } elseif ($mode == 5) |
|
| 1215 | 1313 | { |
| 1216 | - if ($statut==0 || $statut==5) return '<span class="hideonsmartphone">'.$langs->trans('Disabled').' </span>'.img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"'); |
|
| 1217 | - elseif ($statut==1 || $statut==4) return '<span class="hideonsmartphone">'.$langs->trans('Enabled').' </span>'.img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"'); |
|
| 1314 | + if ($statut==0 || $statut==5) { |
|
| 1315 | + return '<span class="hideonsmartphone">'.$langs->trans('Disabled').' </span>'.img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"'); |
|
| 1316 | + } elseif ($statut==1 || $statut==4) { |
|
| 1317 | + return '<span class="hideonsmartphone">'.$langs->trans('Enabled').' </span>'.img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"'); |
|
| 1318 | + } |
|
| 1218 | 1319 | } |
| 1219 | 1320 | } |
| 1220 | 1321 | |
@@ -1228,8 +1329,11 @@ discard block |
||
| 1228 | 1329 | function LibPubPriv($statut) |
| 1229 | 1330 | { |
| 1230 | 1331 | global $langs; |
| 1231 | - if ($statut=='1') return $langs->trans('ContactPrivate'); |
|
| 1232 | - else return $langs->trans('ContactPublic'); |
|
| 1332 | + if ($statut=='1') { |
|
| 1333 | + return $langs->trans('ContactPrivate'); |
|
| 1334 | + } else { |
|
| 1335 | + return $langs->trans('ContactPublic'); |
|
| 1336 | + } |
|
| 1233 | 1337 | } |
| 1234 | 1338 | |
| 1235 | 1339 | |
@@ -1249,7 +1353,9 @@ discard block |
||
| 1249 | 1353 | if ($resql) |
| 1250 | 1354 | { |
| 1251 | 1355 | $obj = $this->db->fetch_object($resql); |
| 1252 | - if ($obj) $socid=$obj->rowid; |
|
| 1356 | + if ($obj) { |
|
| 1357 | + $socid=$obj->rowid; |
|
| 1358 | + } |
|
| 1253 | 1359 | } |
| 1254 | 1360 | |
| 1255 | 1361 | // Initialise parameters |
@@ -1291,8 +1397,11 @@ discard block |
||
| 1291 | 1397 | $error=0; |
| 1292 | 1398 | |
| 1293 | 1399 | // Check parameters |
| 1294 | - if ($this->statut == $statut) return 0; |
|
| 1295 | - else $this->statut = $statut; |
|
| 1400 | + if ($this->statut == $statut) { |
|
| 1401 | + return 0; |
|
| 1402 | + } else { |
|
| 1403 | + $this->statut = $statut; |
|
| 1404 | + } |
|
| 1296 | 1405 | |
| 1297 | 1406 | $this->db->begin(); |
| 1298 | 1407 | |
@@ -1315,8 +1424,7 @@ discard block |
||
| 1315 | 1424 | { |
| 1316 | 1425 | $this->db->rollback(); |
| 1317 | 1426 | return -$error; |
| 1318 | - } |
|
| 1319 | - else |
|
| 1427 | + } else |
|
| 1320 | 1428 | { |
| 1321 | 1429 | $this->db->commit(); |
| 1322 | 1430 | return 1; |
@@ -426,10 +426,10 @@ |
||
| 426 | 426 | * Show miscellaneous information (payment mode, payment term, ...) |
| 427 | 427 | * |
| 428 | 428 | * @param PDF $pdf Object PDF |
| 429 | - * @param Object $object Object to show |
|
| 429 | + * @param Project $object Object to show |
|
| 430 | 430 | * @param int $posy Y |
| 431 | 431 | * @param Translate $outputlangs Langs object |
| 432 | - * @return void |
|
| 432 | + * @return integer |
|
| 433 | 433 | */ |
| 434 | 434 | function _tableau_info(&$pdf, $object, $posy, $outputlangs) |
| 435 | 435 | { |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @param Project $object Object project a generer |
| 92 | 92 | * @param Translate $outputlangs Lang output object |
| 93 | - * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
| 94 | - * @param int $hidedetails Do not show line details (not used for this template) |
|
| 95 | - * @param int $hidedesc Do not show desc (not used for this template) |
|
| 96 | - * @param int $hideref Do not show ref (not used for this template) |
|
| 97 | - * @param null|array $moreparams More parameters |
|
| 93 | + * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
| 94 | + * @param int $hidedetails Do not show line details (not used for this template) |
|
| 95 | + * @param int $hidedesc Do not show desc (not used for this template) |
|
| 96 | + * @param int $hideref Do not show ref (not used for this template) |
|
| 97 | + * @param null|array $moreparams More parameters |
|
| 98 | 98 | * @return int 1 if OK, <=0 if KO |
| 99 | 99 | */ |
| 100 | 100 | function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null) |
@@ -116,20 +116,20 @@ discard block |
||
| 116 | 116 | { |
| 117 | 117 | //$nblignes = count($object->lines); // This is set later with array of tasks |
| 118 | 118 | |
| 119 | - // Definition of $dir and $file |
|
| 120 | - if ($object->specimen) |
|
| 121 | - { |
|
| 122 | - if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
| 123 | - else $dir = $conf->bank->dir_output; |
|
| 124 | - $file = $dir . "/SPECIMEN.pdf"; |
|
| 125 | - } |
|
| 126 | - else |
|
| 127 | - { |
|
| 128 | - $objectref = dol_sanitizeFileName($object->ref); |
|
| 129 | - if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
| 130 | - else $dir = $conf->bank->dir_output . "/" . $objectref; |
|
| 131 | - $file = $dir . "/" . $langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref . "-".dol_sanitizeFileName($object->rum).".pdf"; |
|
| 132 | - } |
|
| 119 | + // Definition of $dir and $file |
|
| 120 | + if ($object->specimen) |
|
| 121 | + { |
|
| 122 | + if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
| 123 | + else $dir = $conf->bank->dir_output; |
|
| 124 | + $file = $dir . "/SPECIMEN.pdf"; |
|
| 125 | + } |
|
| 126 | + else |
|
| 127 | + { |
|
| 128 | + $objectref = dol_sanitizeFileName($object->ref); |
|
| 129 | + if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
| 130 | + else $dir = $conf->bank->dir_output . "/" . $objectref; |
|
| 131 | + $file = $dir . "/" . $langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref . "-".dol_sanitizeFileName($object->rum).".pdf"; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | if (! file_exists($dir)) |
| 135 | 135 | { |
@@ -153,19 +153,19 @@ discard block |
||
| 153 | 153 | global $action; |
| 154 | 154 | $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
| 155 | 155 | |
| 156 | - $pdf=pdf_getInstance($this->format); |
|
| 157 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
| 158 | - $heightforinfotot = 50; // Height reserved to output the info and total part |
|
| 159 | - $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 |
|
| 160 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
| 161 | - $pdf->SetAutoPageBreak(1,0); |
|
| 156 | + $pdf=pdf_getInstance($this->format); |
|
| 157 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
| 158 | + $heightforinfotot = 50; // Height reserved to output the info and total part |
|
| 159 | + $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 |
|
| 160 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
| 161 | + $pdf->SetAutoPageBreak(1,0); |
|
| 162 | 162 | |
| 163 | - if (class_exists('TCPDF')) |
|
| 164 | - { |
|
| 165 | - $pdf->setPrintHeader(false); |
|
| 166 | - $pdf->setPrintFooter(false); |
|
| 167 | - } |
|
| 168 | - $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
|
| 163 | + if (class_exists('TCPDF')) |
|
| 164 | + { |
|
| 165 | + $pdf->setPrintHeader(false); |
|
| 166 | + $pdf->setPrintFooter(false); |
|
| 167 | + } |
|
| 168 | + $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
|
| 169 | 169 | |
| 170 | 170 | $pdf->Open(); |
| 171 | 171 | $pagenb=0; |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | $tab_top = 50; |
| 192 | 192 | $tab_height = 200; |
| 193 | 193 | $tab_top_newpage = 40; |
| 194 | - $tab_height_newpage = 210; |
|
| 194 | + $tab_height_newpage = 210; |
|
| 195 | 195 | |
| 196 | 196 | // Affiche notes |
| 197 | 197 | if (! empty($object->note_public)) |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | $sepaname = '______________________________________________'; |
| 274 | 274 | if ($thirdparty->id > 0) |
| 275 | 275 | { |
| 276 | - $sepaname = $thirdparty->name.($object->account_owner?' ('.$object->account_owner.')':''); |
|
| 276 | + $sepaname = $thirdparty->name.($object->account_owner?' ('.$object->account_owner.')':''); |
|
| 277 | 277 | } |
| 278 | 278 | $posY=$pdf->GetY(); |
| 279 | 279 | $posY+=3; |
@@ -282,10 +282,10 @@ discard block |
||
| 282 | 282 | $pdf->SetXY(80, $posY); |
| 283 | 283 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0, 'L'); |
| 284 | 284 | |
| 285 | - $address = '______________________________________________'; |
|
| 285 | + $address = '______________________________________________'; |
|
| 286 | 286 | if ($thirdparty->id > 0) |
| 287 | 287 | { |
| 288 | - $address = $thirdparty->getFullAddress(); |
|
| 288 | + $address = $thirdparty->getFullAddress(); |
|
| 289 | 289 | } |
| 290 | 290 | $posY=$pdf->GetY(); |
| 291 | 291 | $posY+=1; |
@@ -295,9 +295,9 @@ discard block |
||
| 295 | 295 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); |
| 296 | 296 | if (preg_match('/_____/', $address)) |
| 297 | 297 | { |
| 298 | - $posY+=6; |
|
| 299 | - $pdf->SetXY(80, $posY); |
|
| 300 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); |
|
| 298 | + $posY+=6; |
|
| 299 | + $pdf->SetXY(80, $posY); |
|
| 300 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | $ban = '__________________________________________________'; |
@@ -339,10 +339,10 @@ discard block |
||
| 339 | 339 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
| 340 | 340 | if (empty($object->frstrecur)) |
| 341 | 341 | { |
| 342 | - $posY+=6; |
|
| 343 | - $pdf->SetXY(80, $posY); |
|
| 344 | - $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')'; |
|
| 345 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
|
| 342 | + $posY+=6; |
|
| 343 | + $pdf->SetXY(80, $posY); |
|
| 344 | + $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')'; |
|
| 345 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | $posY=$pdf->GetY(); |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | { |
| 427 | 427 | global $conf,$mysoc; |
| 428 | 428 | |
| 429 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
| 429 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
| 430 | 430 | |
| 431 | 431 | } |
| 432 | 432 | |
@@ -442,26 +442,26 @@ discard block |
||
| 442 | 442 | */ |
| 443 | 443 | function _tableau_info(&$pdf, $object, $posy, $outputlangs) |
| 444 | 444 | { |
| 445 | - global $conf, $mysoc; |
|
| 445 | + global $conf, $mysoc; |
|
| 446 | 446 | |
| 447 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
| 447 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
| 448 | 448 | |
| 449 | - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?1:$conf->global->PDF_DIFFSIZE_TITLE); |
|
| 449 | + $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?1:$conf->global->PDF_DIFFSIZE_TITLE); |
|
| 450 | 450 | |
| 451 | - $posy+=$this->_signature_area($pdf, $object, $posy, $outputlangs); |
|
| 451 | + $posy+=$this->_signature_area($pdf, $object, $posy, $outputlangs); |
|
| 452 | 452 | |
| 453 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
| 454 | - $pdf->SetFont('','', $default_font_size); |
|
| 455 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0); |
|
| 456 | - $posy=$pdf->GetY()+2; |
|
| 453 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
| 454 | + $pdf->SetFont('','', $default_font_size); |
|
| 455 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0); |
|
| 456 | + $posy=$pdf->GetY()+2; |
|
| 457 | 457 | |
| 458 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
| 459 | - $pdf->SetFont('','', $default_font_size - $diffsizetitle); |
|
| 460 | - $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0); |
|
| 458 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
| 459 | + $pdf->SetFont('','', $default_font_size - $diffsizetitle); |
|
| 460 | + $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0); |
|
| 461 | 461 | $pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0, 'L', 0); |
| 462 | 462 | $posy=$pdf->GetY()+2; |
| 463 | 463 | |
| 464 | - return $posy; |
|
| 464 | + return $posy; |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | |
@@ -477,32 +477,32 @@ discard block |
||
| 477 | 477 | */ |
| 478 | 478 | function _signature_area(&$pdf, $object, $posy, $outputlangs) |
| 479 | 479 | { |
| 480 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
| 481 | - $tab_top = $posy + 4; |
|
| 482 | - $tab_hl = 4; |
|
| 480 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
| 481 | + $tab_top = $posy + 4; |
|
| 482 | + $tab_hl = 4; |
|
| 483 | 483 | |
| 484 | - $posx = $this->marge_gauche; |
|
| 485 | - $pdf->SetXY($posx, $tab_top + 0); |
|
| 484 | + $posx = $this->marge_gauche; |
|
| 485 | + $pdf->SetXY($posx, $tab_top + 0); |
|
| 486 | 486 | |
| 487 | - $pdf->SetFont('','', $default_font_size - 2); |
|
| 487 | + $pdf->SetFont('','', $default_font_size - 2); |
|
| 488 | 488 | |
| 489 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0); |
|
| 490 | - $pdf->MultiCell(100, 3, ' '); |
|
| 491 | - $pdf->MultiCell(100, 3, '______________________', 0, 'L', 0); |
|
| 489 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0); |
|
| 490 | + $pdf->MultiCell(100, 3, ' '); |
|
| 491 | + $pdf->MultiCell(100, 3, '______________________', 0, 'L', 0); |
|
| 492 | 492 | |
| 493 | - $posx = 120; |
|
| 494 | - $largcol = ($this->page_largeur - $this->marge_droite - $posx); |
|
| 495 | - $useborder=0; |
|
| 496 | - $index = 0; |
|
| 497 | - // Total HT |
|
| 498 | - $pdf->SetFillColor(255,255,255); |
|
| 499 | - $pdf->SetXY($posx, $tab_top + 0); |
|
| 500 | - $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1); |
|
| 493 | + $posx = 120; |
|
| 494 | + $largcol = ($this->page_largeur - $this->marge_droite - $posx); |
|
| 495 | + $useborder=0; |
|
| 496 | + $index = 0; |
|
| 497 | + // Total HT |
|
| 498 | + $pdf->SetFillColor(255,255,255); |
|
| 499 | + $pdf->SetXY($posx, $tab_top + 0); |
|
| 500 | + $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1); |
|
| 501 | 501 | |
| 502 | - $pdf->SetXY($posx, $tab_top + $tab_hl); |
|
| 503 | - $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R'); |
|
| 502 | + $pdf->SetXY($posx, $tab_top + $tab_hl); |
|
| 503 | + $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R'); |
|
| 504 | 504 | |
| 505 | - return ($tab_hl*7); |
|
| 505 | + return ($tab_hl*7); |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | $pdf->SetTextColor(0,0,60); |
| 527 | 527 | $pdf->SetFont('','B', $default_font_size + 3); |
| 528 | 528 | |
| 529 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
| 529 | + $posx=$this->page_largeur-$this->marge_droite-100; |
|
| 530 | 530 | $posy=$this->marge_haute; |
| 531 | 531 | |
| 532 | 532 | $pdf->SetXY($this->marge_gauche,$posy); |
@@ -537,8 +537,8 @@ discard block |
||
| 537 | 537 | { |
| 538 | 538 | if (is_readable($logo)) |
| 539 | 539 | { |
| 540 | - $height=pdf_getHeightForLogo($logo); |
|
| 541 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
| 540 | + $height=pdf_getHeightForLogo($logo); |
|
| 541 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
| 542 | 542 | } |
| 543 | 543 | else |
| 544 | 544 | { |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | $daterum = '__________________'; |
| 563 | 563 | if (! empty($object->date_rum)) |
| 564 | 564 | { |
| 565 | - $daterum = dol_print_date($object->date_rum,'day',false,$outputlangs,true); |
|
| 565 | + $daterum = dol_print_date($object->date_rum,'day',false,$outputlangs,true); |
|
| 566 | 566 | } |
| 567 | 567 | else $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true); // For old record, the date_rum was not saved. |
| 568 | 568 | $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . $daterum, '', 'R'); |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | |
| 602 | 602 | /** |
| 603 | 603 | * Show footer of page. Need this->emetteur object |
| 604 | - * |
|
| 604 | + * |
|
| 605 | 605 | * @param PDF $pdf PDF |
| 606 | 606 | * @param Project $object Object to show |
| 607 | 607 | * @param Translate $outputlangs Object lang for output |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | class pdf_sepamandate extends ModeleBankAccountDoc |
| 37 | 37 | { |
| 38 | - var $emetteur; // Objet societe qui emet |
|
| 38 | + var $emetteur; // Objet societe qui emet |
|
| 39 | 39 | var $version = 'dolibarr'; |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | function __construct($db) |
| 47 | 47 | { |
| 48 | - global $conf,$langs,$mysoc; |
|
| 48 | + global $conf, $langs, $mysoc; |
|
| 49 | 49 | |
| 50 | 50 | $langs->load("main"); |
| 51 | 51 | $langs->load("bank"); |
@@ -58,30 +58,30 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | // Dimension page pour format A4 |
| 60 | 60 | $this->type = 'pdf'; |
| 61 | - $formatarray=pdf_getFormat(); |
|
| 61 | + $formatarray = pdf_getFormat(); |
|
| 62 | 62 | $this->page_largeur = $formatarray['width']; |
| 63 | 63 | $this->page_hauteur = $formatarray['height']; |
| 64 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
| 65 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
| 66 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
| 67 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
| 68 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
| 64 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
| 65 | + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; |
|
| 66 | + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; |
|
| 67 | + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; |
|
| 68 | + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; |
|
| 69 | 69 | |
| 70 | - $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
| 71 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
| 72 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
| 70 | + $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
| 71 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
| 72 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
| 73 | 73 | |
| 74 | 74 | // Recupere emmetteur |
| 75 | - $this->emetteur=$mysoc; |
|
| 76 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 75 | + $this->emetteur = $mysoc; |
|
| 76 | + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined |
|
| 77 | 77 | |
| 78 | 78 | // Defini position des colonnes |
| 79 | - $this->posxref=$this->marge_gauche+1; |
|
| 80 | - $this->posxlabel=$this->marge_gauche+25; |
|
| 81 | - $this->posxworkload=$this->marge_gauche+100; |
|
| 82 | - $this->posxprogress=$this->marge_gauche+130; |
|
| 83 | - $this->posxdatestart=$this->marge_gauche+150; |
|
| 84 | - $this->posxdateend=$this->marge_gauche+170; |
|
| 79 | + $this->posxref = $this->marge_gauche + 1; |
|
| 80 | + $this->posxlabel = $this->marge_gauche + 25; |
|
| 81 | + $this->posxworkload = $this->marge_gauche + 100; |
|
| 82 | + $this->posxprogress = $this->marge_gauche + 130; |
|
| 83 | + $this->posxdatestart = $this->marge_gauche + 150; |
|
| 84 | + $this->posxdateend = $this->marge_gauche + 170; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | * @param null|array $moreparams More parameters |
| 98 | 98 | * @return int 1 if OK, <=0 if KO |
| 99 | 99 | */ |
| 100 | - function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null) |
|
| 100 | + function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) |
|
| 101 | 101 | { |
| 102 | 102 | global $conf, $hookmanager, $langs, $user, $mysoc; |
| 103 | 103 | |
| 104 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 104 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
| 105 | 105 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
| 106 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
| 106 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
| 107 | 107 | |
| 108 | 108 | $outputlangs->load("main"); |
| 109 | 109 | $outputlangs->load("dict"); |
@@ -112,30 +112,30 @@ discard block |
||
| 112 | 112 | $outputlangs->load("withdrawals"); |
| 113 | 113 | $outputlangs->load("bills"); |
| 114 | 114 | |
| 115 | - if (! empty($conf->bank->dir_output)) |
|
| 115 | + if (!empty($conf->bank->dir_output)) |
|
| 116 | 116 | { |
| 117 | 117 | //$nblignes = count($object->lines); // This is set later with array of tasks |
| 118 | 118 | |
| 119 | 119 | // Definition of $dir and $file |
| 120 | 120 | if ($object->specimen) |
| 121 | 121 | { |
| 122 | - if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
| 122 | + if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
| 123 | 123 | else $dir = $conf->bank->dir_output; |
| 124 | - $file = $dir . "/SPECIMEN.pdf"; |
|
| 124 | + $file = $dir."/SPECIMEN.pdf"; |
|
| 125 | 125 | } |
| 126 | 126 | else |
| 127 | 127 | { |
| 128 | 128 | $objectref = dol_sanitizeFileName($object->ref); |
| 129 | - if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
| 130 | - else $dir = $conf->bank->dir_output . "/" . $objectref; |
|
| 131 | - $file = $dir . "/" . $langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref . "-".dol_sanitizeFileName($object->rum).".pdf"; |
|
| 129 | + if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
| 130 | + else $dir = $conf->bank->dir_output."/".$objectref; |
|
| 131 | + $file = $dir."/".$langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref."-".dol_sanitizeFileName($object->rum).".pdf"; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if (! file_exists($dir)) |
|
| 134 | + if (!file_exists($dir)) |
|
| 135 | 135 | { |
| 136 | 136 | if (dol_mkdir($dir) < 0) |
| 137 | 137 | { |
| 138 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
| 138 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
| 139 | 139 | return 0; |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -143,22 +143,22 @@ discard block |
||
| 143 | 143 | if (file_exists($dir)) |
| 144 | 144 | { |
| 145 | 145 | // Add pdfgeneration hook |
| 146 | - if (! is_object($hookmanager)) |
|
| 146 | + if (!is_object($hookmanager)) |
|
| 147 | 147 | { |
| 148 | 148 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
| 149 | - $hookmanager=new HookManager($this->db); |
|
| 149 | + $hookmanager = new HookManager($this->db); |
|
| 150 | 150 | } |
| 151 | 151 | $hookmanager->initHooks(array('pdfgeneration')); |
| 152 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
| 152 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
| 153 | 153 | global $action; |
| 154 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 154 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
| 155 | 155 | |
| 156 | - $pdf=pdf_getInstance($this->format); |
|
| 157 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
| 158 | - $heightforinfotot = 50; // Height reserved to output the info and total part |
|
| 159 | - $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 |
|
| 160 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
| 161 | - $pdf->SetAutoPageBreak(1,0); |
|
| 156 | + $pdf = pdf_getInstance($this->format); |
|
| 157 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
| 158 | + $heightforinfotot = 50; // Height reserved to output the info and total part |
|
| 159 | + $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 |
|
| 160 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
| 161 | + $pdf->SetAutoPageBreak(1, 0); |
|
| 162 | 162 | |
| 163 | 163 | if (class_exists('TCPDF')) |
| 164 | 164 | { |
@@ -168,25 +168,25 @@ discard block |
||
| 168 | 168 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
| 169 | 169 | |
| 170 | 170 | $pdf->Open(); |
| 171 | - $pagenb=0; |
|
| 172 | - $pdf->SetDrawColor(128,128,128); |
|
| 171 | + $pagenb = 0; |
|
| 172 | + $pdf->SetDrawColor(128, 128, 128); |
|
| 173 | 173 | |
| 174 | 174 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
| 175 | 175 | $pdf->SetSubject($outputlangs->transnoentities("SepaMandate")); |
| 176 | 176 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
| 177 | 177 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
| 178 | 178 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SepaMandate")); |
| 179 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 179 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 180 | 180 | |
| 181 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
| 181 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
| 182 | 182 | |
| 183 | 183 | // New page |
| 184 | 184 | $pdf->AddPage(); |
| 185 | 185 | $pagenb++; |
| 186 | 186 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
| 187 | - $pdf->SetFont('','', $default_font_size - 1); |
|
| 188 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
| 189 | - $pdf->SetTextColor(0,0,0); |
|
| 187 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
| 188 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
| 189 | + $pdf->SetTextColor(0, 0, 0); |
|
| 190 | 190 | |
| 191 | 191 | $tab_top = 50; |
| 192 | 192 | $tab_height = 200; |
@@ -194,23 +194,23 @@ discard block |
||
| 194 | 194 | $tab_height_newpage = 210; |
| 195 | 195 | |
| 196 | 196 | // Affiche notes |
| 197 | - if (! empty($object->note_public)) |
|
| 197 | + if (!empty($object->note_public)) |
|
| 198 | 198 | { |
| 199 | - $pdf->SetFont('','', $default_font_size - 1); |
|
| 200 | - $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
| 199 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
| 200 | + $pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
| 201 | 201 | $nexY = $pdf->GetY(); |
| 202 | - $height_note=$nexY-($tab_top-2); |
|
| 202 | + $height_note = $nexY - ($tab_top - 2); |
|
| 203 | 203 | |
| 204 | 204 | // Rect prend une longueur en 3eme param |
| 205 | - $pdf->SetDrawColor(192,192,192); |
|
| 206 | - $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
| 205 | + $pdf->SetDrawColor(192, 192, 192); |
|
| 206 | + $pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); |
|
| 207 | 207 | |
| 208 | 208 | $tab_height = $tab_height - $height_note; |
| 209 | - $tab_top = $nexY+6; |
|
| 209 | + $tab_top = $nexY + 6; |
|
| 210 | 210 | } |
| 211 | 211 | else |
| 212 | 212 | { |
| 213 | - $height_note=0; |
|
| 213 | + $height_note = 0; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | $iniY = $tab_top + 7; |
@@ -219,64 +219,64 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | $posY = $curY; |
| 221 | 221 | |
| 222 | - $pdf->SetFont('','', $default_font_size); |
|
| 222 | + $pdf->SetFont('', '', $default_font_size); |
|
| 223 | 223 | |
| 224 | 224 | $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
| 225 | - $posY+=2; |
|
| 225 | + $posY += 2; |
|
| 226 | 226 | |
| 227 | 227 | $pdf->SetXY($this->marge_gauche, $posY); |
| 228 | 228 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("RUMLong").' ('.$outputlangs->transnoentitiesnoconv("RUM").')'.' : '.$object->rum, 0, 'L'); |
| 229 | 229 | |
| 230 | - $posY=$pdf->GetY(); |
|
| 231 | - $posY+=2; |
|
| 230 | + $posY = $pdf->GetY(); |
|
| 231 | + $posY += 2; |
|
| 232 | 232 | $pdf->SetXY($this->marge_gauche, $posY); |
| 233 | - $ics=''; |
|
| 234 | - if (! empty($conf->global->PRELEVEMENT_ICS)) $ics=$conf->global->PRELEVEMENT_ICS; |
|
| 233 | + $ics = ''; |
|
| 234 | + if (!empty($conf->global->PRELEVEMENT_ICS)) $ics = $conf->global->PRELEVEMENT_ICS; |
|
| 235 | 235 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->transnoentitiesnoconv("ICS").')'.' : '.$ics, 0, 'L'); |
| 236 | 236 | |
| 237 | - $posY=$pdf->GetY(); |
|
| 238 | - $posY+=1; |
|
| 237 | + $posY = $pdf->GetY(); |
|
| 238 | + $posY += 1; |
|
| 239 | 239 | $pdf->SetXY($this->marge_gauche, $posY); |
| 240 | 240 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorName").' : '.$mysoc->name, 0, 'L'); |
| 241 | 241 | |
| 242 | - $posY=$pdf->GetY(); |
|
| 243 | - $posY+=1; |
|
| 242 | + $posY = $pdf->GetY(); |
|
| 243 | + $posY += 1; |
|
| 244 | 244 | $pdf->SetXY($this->marge_gauche, $posY); |
| 245 | 245 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L'); |
| 246 | 246 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(), 0, 'L'); |
| 247 | 247 | |
| 248 | - $posY=$pdf->GetY(); |
|
| 249 | - $posY+=3; |
|
| 248 | + $posY = $pdf->GetY(); |
|
| 249 | + $posY += 3; |
|
| 250 | 250 | |
| 251 | 251 | $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
| 252 | 252 | |
| 253 | - $pdf->SetFont('','', $default_font_size - 1); |
|
| 253 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
| 254 | 254 | |
| 255 | - $posY+=8; |
|
| 255 | + $posY += 8; |
|
| 256 | 256 | $pdf->SetXY($this->marge_gauche, $posY); |
| 257 | 257 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv("SEPALegalText", $mysoc->name, $mysoc->name), 0, 'L'); |
| 258 | 258 | |
| 259 | 259 | // Your data form |
| 260 | - $posY=$pdf->GetY(); |
|
| 261 | - $posY+=8; |
|
| 260 | + $posY = $pdf->GetY(); |
|
| 261 | + $posY += 8; |
|
| 262 | 262 | $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
| 263 | - $posY+=2; |
|
| 263 | + $posY += 2; |
|
| 264 | 264 | |
| 265 | - $pdf->SetFont('','', $default_font_size); |
|
| 265 | + $pdf->SetFont('', '', $default_font_size); |
|
| 266 | 266 | |
| 267 | 267 | $pdf->SetXY($this->marge_gauche, $posY); |
| 268 | 268 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFillForm"), 0, 'C'); |
| 269 | 269 | |
| 270 | - $thirdparty=new Societe($this->db); |
|
| 270 | + $thirdparty = new Societe($this->db); |
|
| 271 | 271 | if ($object->socid > 0) $thirdparty->fetch($object->socid); |
| 272 | 272 | |
| 273 | 273 | $sepaname = '______________________________________________'; |
| 274 | 274 | if ($thirdparty->id > 0) |
| 275 | 275 | { |
| 276 | - $sepaname = $thirdparty->name.($object->account_owner?' ('.$object->account_owner.')':''); |
|
| 276 | + $sepaname = $thirdparty->name.($object->account_owner ? ' ('.$object->account_owner.')' : ''); |
|
| 277 | 277 | } |
| 278 | - $posY=$pdf->GetY(); |
|
| 279 | - $posY+=3; |
|
| 278 | + $posY = $pdf->GetY(); |
|
| 279 | + $posY += 3; |
|
| 280 | 280 | $pdf->SetXY($this->marge_gauche, $posY); |
| 281 | 281 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourName").' * : ', 0, 'L'); |
| 282 | 282 | $pdf->SetXY(80, $posY); |
@@ -287,40 +287,40 @@ discard block |
||
| 287 | 287 | { |
| 288 | 288 | $address = $thirdparty->getFullAddress(); |
| 289 | 289 | } |
| 290 | - $posY=$pdf->GetY(); |
|
| 291 | - $posY+=1; |
|
| 290 | + $posY = $pdf->GetY(); |
|
| 291 | + $posY += 1; |
|
| 292 | 292 | $pdf->SetXY($this->marge_gauche, $posY); |
| 293 | 293 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L'); |
| 294 | 294 | $pdf->SetXY(80, $posY); |
| 295 | 295 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); |
| 296 | 296 | if (preg_match('/_____/', $address)) |
| 297 | 297 | { |
| 298 | - $posY+=6; |
|
| 298 | + $posY += 6; |
|
| 299 | 299 | $pdf->SetXY(80, $posY); |
| 300 | 300 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | $ban = '__________________________________________________'; |
| 304 | - if (! empty($object->iban)) $ban = $object->iban; |
|
| 305 | - $posY=$pdf->GetY(); |
|
| 306 | - $posY+=1; |
|
| 304 | + if (!empty($object->iban)) $ban = $object->iban; |
|
| 305 | + $posY = $pdf->GetY(); |
|
| 306 | + $posY += 1; |
|
| 307 | 307 | $pdf->SetXY($this->marge_gauche, $posY); |
| 308 | 308 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBAN").' * : ', 0, 'L'); |
| 309 | 309 | $pdf->SetXY(80, $posY); |
| 310 | 310 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0, 'L'); |
| 311 | 311 | |
| 312 | 312 | $bic = '__________________________________________________'; |
| 313 | - if (! empty($object->bic)) $bic = $object->bic; |
|
| 314 | - $posY=$pdf->GetY(); |
|
| 315 | - $posY+=1; |
|
| 313 | + if (!empty($object->bic)) $bic = $object->bic; |
|
| 314 | + $posY = $pdf->GetY(); |
|
| 315 | + $posY += 1; |
|
| 316 | 316 | $pdf->SetXY($this->marge_gauche, $posY); |
| 317 | 317 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBIC").' * : ', 0, 'L'); |
| 318 | 318 | $pdf->SetXY(80, $posY); |
| 319 | 319 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0, 'L'); |
| 320 | 320 | |
| 321 | 321 | |
| 322 | - $posY=$pdf->GetY(); |
|
| 323 | - $posY+=1; |
|
| 322 | + $posY = $pdf->GetY(); |
|
| 323 | + $posY += 1; |
|
| 324 | 324 | $pdf->SetXY($this->marge_gauche, $posY); |
| 325 | 325 | $txt = $outputlangs->transnoentitiesnoconv("SEPAFrstOrRecur").' * : '; |
| 326 | 326 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | $pdf->SetXY(86, $posY); |
| 331 | 331 | $txt = $langs->transnoentitiesnoconv("ModeRECUR").' '.$langs->transnoentitiesnoconv("or"); |
| 332 | 332 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
| 333 | - $posY+=6; |
|
| 333 | + $posY += 6; |
|
| 334 | 334 | $pdf->Rect(80, $posY, 5, 5); |
| 335 | 335 | $pdf->SetXY(80, $posY); |
| 336 | 336 | if ($object->frstrecur == 'FRST') $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
@@ -339,28 +339,28 @@ discard block |
||
| 339 | 339 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
| 340 | 340 | if (empty($object->frstrecur)) |
| 341 | 341 | { |
| 342 | - $posY+=6; |
|
| 342 | + $posY += 6; |
|
| 343 | 343 | $pdf->SetXY(80, $posY); |
| 344 | 344 | $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')'; |
| 345 | 345 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - $posY=$pdf->GetY(); |
|
| 349 | - $posY+=3; |
|
| 348 | + $posY = $pdf->GetY(); |
|
| 349 | + $posY += 3; |
|
| 350 | 350 | $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
| 351 | - $posY+=3; |
|
| 351 | + $posY += 3; |
|
| 352 | 352 | |
| 353 | 353 | |
| 354 | 354 | // Show square |
| 355 | 355 | if ($pagenb == 1) |
| 356 | 356 | { |
| 357 | 357 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
| 358 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
| 358 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
| 359 | 359 | } |
| 360 | 360 | else |
| 361 | 361 | { |
| 362 | 362 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
| 363 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
| 363 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | /*var_dump($tab_top); |
@@ -370,44 +370,44 @@ discard block |
||
| 370 | 370 | var_dump($bottomlasttab);*/ |
| 371 | 371 | |
| 372 | 372 | // Affiche zone infos |
| 373 | - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
| 373 | + $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
| 374 | 374 | |
| 375 | 375 | /* |
| 376 | 376 | * Pied de page |
| 377 | 377 | */ |
| 378 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
| 379 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
| 378 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
| 379 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
| 380 | 380 | |
| 381 | 381 | $pdf->Close(); |
| 382 | 382 | |
| 383 | - $pdf->Output($file,'F'); |
|
| 383 | + $pdf->Output($file, 'F'); |
|
| 384 | 384 | |
| 385 | 385 | // Add pdfgeneration hook |
| 386 | - if (! is_object($hookmanager)) |
|
| 386 | + if (!is_object($hookmanager)) |
|
| 387 | 387 | { |
| 388 | 388 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
| 389 | - $hookmanager=new HookManager($this->db); |
|
| 389 | + $hookmanager = new HookManager($this->db); |
|
| 390 | 390 | } |
| 391 | 391 | $hookmanager->initHooks(array('pdfgeneration')); |
| 392 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
| 392 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
| 393 | 393 | global $action; |
| 394 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
| 394 | + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 395 | 395 | |
| 396 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 396 | + if (!empty($conf->global->MAIN_UMASK)) |
|
| 397 | 397 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
| 398 | 398 | |
| 399 | 399 | $this->result = array('fullpath'=>$file); |
| 400 | 400 | |
| 401 | - return 1; // Pas d'erreur |
|
| 401 | + return 1; // Pas d'erreur |
|
| 402 | 402 | } |
| 403 | 403 | else |
| 404 | 404 | { |
| 405 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
| 405 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
| 406 | 406 | return 0; |
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR"); |
|
| 410 | + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR"); |
|
| 411 | 411 | return 0; |
| 412 | 412 | } |
| 413 | 413 | |
@@ -424,9 +424,9 @@ discard block |
||
| 424 | 424 | * @param int $hidebottom Hide bottom bar of array |
| 425 | 425 | * @return void |
| 426 | 426 | */ |
| 427 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
| 427 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) |
|
| 428 | 428 | { |
| 429 | - global $conf,$mysoc; |
|
| 429 | + global $conf, $mysoc; |
|
| 430 | 430 | |
| 431 | 431 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
| 432 | 432 | |
@@ -448,20 +448,20 @@ discard block |
||
| 448 | 448 | |
| 449 | 449 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
| 450 | 450 | |
| 451 | - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?1:$conf->global->PDF_DIFFSIZE_TITLE); |
|
| 451 | + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 1 : $conf->global->PDF_DIFFSIZE_TITLE); |
|
| 452 | 452 | |
| 453 | - $posy+=$this->_signature_area($pdf, $object, $posy, $outputlangs); |
|
| 453 | + $posy += $this->_signature_area($pdf, $object, $posy, $outputlangs); |
|
| 454 | 454 | |
| 455 | 455 | $pdf->SetXY($this->marge_gauche, $posy); |
| 456 | - $pdf->SetFont('','', $default_font_size); |
|
| 456 | + $pdf->SetFont('', '', $default_font_size); |
|
| 457 | 457 | $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0); |
| 458 | - $posy=$pdf->GetY()+2; |
|
| 458 | + $posy = $pdf->GetY() + 2; |
|
| 459 | 459 | |
| 460 | 460 | $pdf->SetXY($this->marge_gauche, $posy); |
| 461 | - $pdf->SetFont('','', $default_font_size - $diffsizetitle); |
|
| 461 | + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); |
|
| 462 | 462 | $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0); |
| 463 | 463 | $pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0, 'L', 0); |
| 464 | - $posy=$pdf->GetY()+2; |
|
| 464 | + $posy = $pdf->GetY() + 2; |
|
| 465 | 465 | |
| 466 | 466 | return $posy; |
| 467 | 467 | } |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | $posx = $this->marge_gauche; |
| 487 | 487 | $pdf->SetXY($posx, $tab_top + 0); |
| 488 | 488 | |
| 489 | - $pdf->SetFont('','', $default_font_size - 2); |
|
| 489 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
| 490 | 490 | |
| 491 | 491 | $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0); |
| 492 | 492 | $pdf->MultiCell(100, 3, ' '); |
@@ -494,17 +494,17 @@ discard block |
||
| 494 | 494 | |
| 495 | 495 | $posx = 120; |
| 496 | 496 | $largcol = ($this->page_largeur - $this->marge_droite - $posx); |
| 497 | - $useborder=0; |
|
| 497 | + $useborder = 0; |
|
| 498 | 498 | $index = 0; |
| 499 | 499 | // Total HT |
| 500 | - $pdf->SetFillColor(255,255,255); |
|
| 500 | + $pdf->SetFillColor(255, 255, 255); |
|
| 501 | 501 | $pdf->SetXY($posx, $tab_top + 0); |
| 502 | 502 | $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1); |
| 503 | 503 | |
| 504 | 504 | $pdf->SetXY($posx, $tab_top + $tab_hl); |
| 505 | - $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R'); |
|
| 505 | + $pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R'); |
|
| 506 | 506 | |
| 507 | - return ($tab_hl*7); |
|
| 507 | + return ($tab_hl * 7); |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | |
@@ -519,61 +519,61 @@ discard block |
||
| 519 | 519 | */ |
| 520 | 520 | function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
| 521 | 521 | { |
| 522 | - global $langs,$conf,$mysoc; |
|
| 522 | + global $langs, $conf, $mysoc; |
|
| 523 | 523 | |
| 524 | 524 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
| 525 | 525 | |
| 526 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
| 526 | + pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); |
|
| 527 | 527 | |
| 528 | - $pdf->SetTextColor(0,0,60); |
|
| 529 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
| 528 | + $pdf->SetTextColor(0, 0, 60); |
|
| 529 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
| 530 | 530 | |
| 531 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
| 532 | - $posy=$this->marge_haute; |
|
| 531 | + $posx = $this->page_largeur - $this->marge_droite - 100; |
|
| 532 | + $posy = $this->marge_haute; |
|
| 533 | 533 | |
| 534 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
| 534 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
| 535 | 535 | |
| 536 | 536 | // Logo |
| 537 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
| 537 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
| 538 | 538 | if ($mysoc->logo) |
| 539 | 539 | { |
| 540 | 540 | if (is_readable($logo)) |
| 541 | 541 | { |
| 542 | - $height=pdf_getHeightForLogo($logo); |
|
| 543 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
| 542 | + $height = pdf_getHeightForLogo($logo); |
|
| 543 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
| 544 | 544 | } |
| 545 | 545 | else |
| 546 | 546 | { |
| 547 | - $pdf->SetTextColor(200,0,0); |
|
| 548 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
| 549 | - $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
| 547 | + $pdf->SetTextColor(200, 0, 0); |
|
| 548 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
| 549 | + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); |
|
| 550 | 550 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
| 551 | 551 | } |
| 552 | 552 | } |
| 553 | 553 | else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
| 554 | 554 | |
| 555 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
| 556 | - $pdf->SetXY($posx,$posy); |
|
| 557 | - $pdf->SetTextColor(0,0,60); |
|
| 555 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
| 556 | + $pdf->SetXY($posx, $posy); |
|
| 557 | + $pdf->SetTextColor(0, 0, 60); |
|
| 558 | 558 | $pdf->MultiCell(100, 4, $outputlangs->transnoentities("SepaMandate"), '', 'R'); |
| 559 | - $pdf->SetFont('','', $default_font_size + 2); |
|
| 559 | + $pdf->SetFont('', '', $default_font_size + 2); |
|
| 560 | 560 | |
| 561 | - $posy+=6; |
|
| 562 | - $pdf->SetXY($posx,$posy); |
|
| 563 | - $pdf->SetTextColor(0,0,60); |
|
| 561 | + $posy += 6; |
|
| 562 | + $pdf->SetXY($posx, $posy); |
|
| 563 | + $pdf->SetTextColor(0, 0, 60); |
|
| 564 | 564 | $daterum = '__________________'; |
| 565 | - if (! empty($object->date_rum)) |
|
| 565 | + if (!empty($object->date_rum)) |
|
| 566 | 566 | { |
| 567 | - $daterum = dol_print_date($object->date_rum,'day',false,$outputlangs,true); |
|
| 567 | + $daterum = dol_print_date($object->date_rum, 'day', false, $outputlangs, true); |
|
| 568 | 568 | } |
| 569 | - else $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true); // For old record, the date_rum was not saved. |
|
| 570 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . $daterum, '', 'R'); |
|
| 569 | + else $daterum = dol_print_date($object->datec, 'day', false, $outputlangs, true); // For old record, the date_rum was not saved. |
|
| 570 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".$daterum, '', 'R'); |
|
| 571 | 571 | /*$posy+=6; |
| 572 | 572 | $pdf->SetXY($posx,$posy); |
| 573 | 573 | $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); |
| 574 | 574 | */ |
| 575 | 575 | |
| 576 | - $pdf->SetTextColor(0,0,60); |
|
| 576 | + $pdf->SetTextColor(0, 0, 60); |
|
| 577 | 577 | |
| 578 | 578 | // Add list of linked objects |
| 579 | 579 | /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc.... |
@@ -610,11 +610,11 @@ discard block |
||
| 610 | 610 | * @param int $hidefreetext 1=Hide free text |
| 611 | 611 | * @return integer |
| 612 | 612 | */ |
| 613 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
| 613 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
| 614 | 614 | { |
| 615 | 615 | global $conf; |
| 616 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
| 617 | - return pdf_pagefoot($pdf,$outputlangs,'PAYMENTORDER_FREE_TEXT',null,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
| 616 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
| 617 | + return pdf_pagefoot($pdf, $outputlangs, 'PAYMENTORDER_FREE_TEXT', null, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | } |
@@ -73,7 +73,10 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | // Recupere emmetteur |
| 75 | 75 | $this->emetteur=$mysoc; |
| 76 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 76 | + if (! $this->emetteur->country_code) { |
|
| 77 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 78 | + } |
|
| 79 | + // By default if not defined |
|
| 77 | 80 | |
| 78 | 81 | // Defini position des colonnes |
| 79 | 82 | $this->posxref=$this->marge_gauche+1; |
@@ -101,9 +104,13 @@ discard block |
||
| 101 | 104 | { |
| 102 | 105 | global $conf, $hookmanager, $langs, $user, $mysoc; |
| 103 | 106 | |
| 104 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 107 | + if (! is_object($outputlangs)) { |
|
| 108 | + $outputlangs=$langs; |
|
| 109 | + } |
|
| 105 | 110 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
| 106 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
| 111 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
| 112 | + $outputlangs->charset_output='ISO-8859-1'; |
|
| 113 | + } |
|
| 107 | 114 | |
| 108 | 115 | $outputlangs->load("main"); |
| 109 | 116 | $outputlangs->load("dict"); |
@@ -119,15 +126,20 @@ discard block |
||
| 119 | 126 | // Definition of $dir and $file |
| 120 | 127 | if ($object->specimen) |
| 121 | 128 | { |
| 122 | - if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
| 123 | - else $dir = $conf->bank->dir_output; |
|
| 129 | + if (! empty($moreparams['force_dir_output'])) { |
|
| 130 | + $dir = $moreparams['force_dir_output']; |
|
| 131 | + } else { |
|
| 132 | + $dir = $conf->bank->dir_output; |
|
| 133 | + } |
|
| 124 | 134 | $file = $dir . "/SPECIMEN.pdf"; |
| 125 | - } |
|
| 126 | - else |
|
| 135 | + } else |
|
| 127 | 136 | { |
| 128 | 137 | $objectref = dol_sanitizeFileName($object->ref); |
| 129 | - if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
| 130 | - else $dir = $conf->bank->dir_output . "/" . $objectref; |
|
| 138 | + if (! empty($moreparams['force_dir_output'])) { |
|
| 139 | + $dir = $moreparams['force_dir_output']; |
|
| 140 | + } else { |
|
| 141 | + $dir = $conf->bank->dir_output . "/" . $objectref; |
|
| 142 | + } |
|
| 131 | 143 | $file = $dir . "/" . $langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref . "-".dol_sanitizeFileName($object->rum).".pdf"; |
| 132 | 144 | } |
| 133 | 145 | |
@@ -176,7 +188,9 @@ discard block |
||
| 176 | 188 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
| 177 | 189 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
| 178 | 190 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SepaMandate")); |
| 179 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 191 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
| 192 | + $pdf->SetCompression(false); |
|
| 193 | + } |
|
| 180 | 194 | |
| 181 | 195 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
| 182 | 196 | |
@@ -207,8 +221,7 @@ discard block |
||
| 207 | 221 | |
| 208 | 222 | $tab_height = $tab_height - $height_note; |
| 209 | 223 | $tab_top = $nexY+6; |
| 210 | - } |
|
| 211 | - else |
|
| 224 | + } else |
|
| 212 | 225 | { |
| 213 | 226 | $height_note=0; |
| 214 | 227 | } |
@@ -231,7 +244,9 @@ discard block |
||
| 231 | 244 | $posY+=2; |
| 232 | 245 | $pdf->SetXY($this->marge_gauche, $posY); |
| 233 | 246 | $ics=''; |
| 234 | - if (! empty($conf->global->PRELEVEMENT_ICS)) $ics=$conf->global->PRELEVEMENT_ICS; |
|
| 247 | + if (! empty($conf->global->PRELEVEMENT_ICS)) { |
|
| 248 | + $ics=$conf->global->PRELEVEMENT_ICS; |
|
| 249 | + } |
|
| 235 | 250 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->transnoentitiesnoconv("ICS").')'.' : '.$ics, 0, 'L'); |
| 236 | 251 | |
| 237 | 252 | $posY=$pdf->GetY(); |
@@ -268,7 +283,9 @@ discard block |
||
| 268 | 283 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFillForm"), 0, 'C'); |
| 269 | 284 | |
| 270 | 285 | $thirdparty=new Societe($this->db); |
| 271 | - if ($object->socid > 0) $thirdparty->fetch($object->socid); |
|
| 286 | + if ($object->socid > 0) { |
|
| 287 | + $thirdparty->fetch($object->socid); |
|
| 288 | + } |
|
| 272 | 289 | |
| 273 | 290 | $sepaname = '______________________________________________'; |
| 274 | 291 | if ($thirdparty->id > 0) |
@@ -301,7 +318,9 @@ discard block |
||
| 301 | 318 | } |
| 302 | 319 | |
| 303 | 320 | $ban = '__________________________________________________'; |
| 304 | - if (! empty($object->iban)) $ban = $object->iban; |
|
| 321 | + if (! empty($object->iban)) { |
|
| 322 | + $ban = $object->iban; |
|
| 323 | + } |
|
| 305 | 324 | $posY=$pdf->GetY(); |
| 306 | 325 | $posY+=1; |
| 307 | 326 | $pdf->SetXY($this->marge_gauche, $posY); |
@@ -310,7 +329,9 @@ discard block |
||
| 310 | 329 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0, 'L'); |
| 311 | 330 | |
| 312 | 331 | $bic = '__________________________________________________'; |
| 313 | - if (! empty($object->bic)) $bic = $object->bic; |
|
| 332 | + if (! empty($object->bic)) { |
|
| 333 | + $bic = $object->bic; |
|
| 334 | + } |
|
| 314 | 335 | $posY=$pdf->GetY(); |
| 315 | 336 | $posY+=1; |
| 316 | 337 | $pdf->SetXY($this->marge_gauche, $posY); |
@@ -326,14 +347,18 @@ discard block |
||
| 326 | 347 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
| 327 | 348 | $pdf->Rect(80, $posY, 5, 5); |
| 328 | 349 | $pdf->SetXY(80, $posY); |
| 329 | - if ($object->frstrecur == 'RECUR') $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
|
| 350 | + if ($object->frstrecur == 'RECUR') { |
|
| 351 | + $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
|
| 352 | + } |
|
| 330 | 353 | $pdf->SetXY(86, $posY); |
| 331 | 354 | $txt = $langs->transnoentitiesnoconv("ModeRECUR").' '.$langs->transnoentitiesnoconv("or"); |
| 332 | 355 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
| 333 | 356 | $posY+=6; |
| 334 | 357 | $pdf->Rect(80, $posY, 5, 5); |
| 335 | 358 | $pdf->SetXY(80, $posY); |
| 336 | - if ($object->frstrecur == 'FRST') $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
|
| 359 | + if ($object->frstrecur == 'FRST') { |
|
| 360 | + $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
|
| 361 | + } |
|
| 337 | 362 | $pdf->SetXY(86, $posY); |
| 338 | 363 | $txt = $langs->transnoentitiesnoconv("ModeFRST"); |
| 339 | 364 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
@@ -356,8 +381,7 @@ discard block |
||
| 356 | 381 | { |
| 357 | 382 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
| 358 | 383 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
| 359 | - } |
|
| 360 | - else |
|
| 384 | + } else |
|
| 361 | 385 | { |
| 362 | 386 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
| 363 | 387 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -376,7 +400,9 @@ discard block |
||
| 376 | 400 | * Pied de page |
| 377 | 401 | */ |
| 378 | 402 | $this->_pagefoot($pdf,$object,$outputlangs); |
| 379 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
| 403 | + if (method_exists($pdf,'AliasNbPages')) { |
|
| 404 | + $pdf->AliasNbPages(); |
|
| 405 | + } |
|
| 380 | 406 | |
| 381 | 407 | $pdf->Close(); |
| 382 | 408 | |
@@ -393,14 +419,14 @@ discard block |
||
| 393 | 419 | global $action; |
| 394 | 420 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 395 | 421 | |
| 396 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 397 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 422 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 423 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 424 | + } |
|
| 398 | 425 | |
| 399 | 426 | $this->result = array('fullpath'=>$file); |
| 400 | 427 | |
| 401 | 428 | return 1; // Pas d'erreur |
| 402 | - } |
|
| 403 | - else |
|
| 429 | + } else |
|
| 404 | 430 | { |
| 405 | 431 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 406 | 432 | return 0; |
@@ -541,16 +567,16 @@ discard block |
||
| 541 | 567 | { |
| 542 | 568 | $height=pdf_getHeightForLogo($logo); |
| 543 | 569 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
| 544 | - } |
|
| 545 | - else |
|
| 570 | + } else |
|
| 546 | 571 | { |
| 547 | 572 | $pdf->SetTextColor(200,0,0); |
| 548 | 573 | $pdf->SetFont('','B', $default_font_size - 2); |
| 549 | 574 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
| 550 | 575 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
| 551 | 576 | } |
| 577 | + } else { |
|
| 578 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
| 552 | 579 | } |
| 553 | - else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
| 554 | 580 | |
| 555 | 581 | $pdf->SetFont('','B', $default_font_size + 3); |
| 556 | 582 | $pdf->SetXY($posx,$posy); |
@@ -565,8 +591,10 @@ discard block |
||
| 565 | 591 | if (! empty($object->date_rum)) |
| 566 | 592 | { |
| 567 | 593 | $daterum = dol_print_date($object->date_rum,'day',false,$outputlangs,true); |
| 594 | + } else { |
|
| 595 | + $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true); |
|
| 568 | 596 | } |
| 569 | - else $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true); // For old record, the date_rum was not saved. |
|
| 597 | + // For old record, the date_rum was not saved. |
|
| 570 | 598 | $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . $daterum, '', 'R'); |
| 571 | 599 | /*$posy+=6; |
| 572 | 600 | $pdf->SetXY($posx,$posy); |
@@ -366,10 +366,10 @@ |
||
| 366 | 366 | * Show footer of page. Need this->emetteur object |
| 367 | 367 | * |
| 368 | 368 | * @param PDF $pdf PDF |
| 369 | - * @param Object $object Object to show |
|
| 369 | + * @param string $object Object to show |
|
| 370 | 370 | * @param Translate $outputlangs Object lang for output |
| 371 | 371 | * @param int $hidefreetext 1=Hide free text |
| 372 | - * @return void |
|
| 372 | + * @return integer |
|
| 373 | 373 | */ |
| 374 | 374 | function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
| 375 | 375 | { |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
| 65 | 65 | $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
| 66 | 66 | |
| 67 | - // Recupere emmetteur |
|
| 68 | - $this->emetteur=$mysoc; |
|
| 69 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 67 | + // Recupere emmetteur |
|
| 68 | + $this->emetteur=$mysoc; |
|
| 69 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 70 | 70 | |
| 71 | - // Defini position des colonnes |
|
| 72 | - $this->line_height = 5; |
|
| 71 | + // Defini position des colonnes |
|
| 72 | + $this->line_height = 5; |
|
| 73 | 73 | $this->line_per_page = 40; |
| 74 | 74 | $this->tab_height = 200; //$this->line_height * $this->line_per_page; |
| 75 | 75 | } |
@@ -81,22 +81,22 @@ discard block |
||
| 81 | 81 | * @param string $_dir Directory |
| 82 | 82 | * @param string $number Number |
| 83 | 83 | * @param Translate $outputlangs Lang output object |
| 84 | - * @return int 1=ok, 0=ko |
|
| 84 | + * @return int 1=ok, 0=ko |
|
| 85 | 85 | */ |
| 86 | 86 | function write_file($object, $_dir, $number, $outputlangs) |
| 87 | 87 | { |
| 88 | 88 | global $user,$conf,$langs,$hookmanager; |
| 89 | 89 | |
| 90 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 91 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
| 92 | - $sav_charset_output=$outputlangs->charset_output; |
|
| 93 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
| 90 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 91 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
| 92 | + $sav_charset_output=$outputlangs->charset_output; |
|
| 93 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
| 94 | 94 | |
| 95 | 95 | $outputlangs->load("main"); |
| 96 | 96 | $outputlangs->load("companies"); |
| 97 | 97 | $outputlangs->load("bills"); |
| 98 | 98 | $outputlangs->load("products"); |
| 99 | - $outputlangs->load("compta"); |
|
| 99 | + $outputlangs->load("compta"); |
|
| 100 | 100 | |
| 101 | 101 | $dir = $_dir . "/".get_exdir($number,0,1,0,$object,'cheque').$number; |
| 102 | 102 | |
@@ -125,18 +125,18 @@ discard block |
||
| 125 | 125 | $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
| 126 | 126 | |
| 127 | 127 | // Create PDF instance |
| 128 | - $pdf=pdf_getInstance($this->format); |
|
| 129 | - $heightforinfotot = 50; // Height reserved to output the info and total part |
|
| 130 | - $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 |
|
| 131 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
| 132 | - $pdf->SetAutoPageBreak(1,0); |
|
| 133 | - |
|
| 134 | - if (class_exists('TCPDF')) |
|
| 135 | - { |
|
| 136 | - $pdf->setPrintHeader(false); |
|
| 137 | - $pdf->setPrintFooter(false); |
|
| 138 | - } |
|
| 139 | - $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
|
| 128 | + $pdf=pdf_getInstance($this->format); |
|
| 129 | + $heightforinfotot = 50; // Height reserved to output the info and total part |
|
| 130 | + $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 |
|
| 131 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
| 132 | + $pdf->SetAutoPageBreak(1,0); |
|
| 133 | + |
|
| 134 | + if (class_exists('TCPDF')) |
|
| 135 | + { |
|
| 136 | + $pdf->setPrintHeader(false); |
|
| 137 | + $pdf->setPrintFooter(false); |
|
| 138 | + } |
|
| 139 | + $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
|
| 140 | 140 | |
| 141 | 141 | $pdf->Open(); |
| 142 | 142 | $pagenb=0; |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $pdf->AddPage(); |
| 169 | - $pagenb++; |
|
| 169 | + $pagenb++; |
|
| 170 | 170 | $this->Header($pdf, $pagenb, $pages, $outputlangs); |
| 171 | 171 | |
| 172 | 172 | $this->Body($pdf, $pagenb, $pages, $outputlangs); |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | $this->result = array('fullpath'=>$file); |
| 197 | 197 | |
| 198 | - $outputlangs->charset_output=$sav_charset_output; |
|
| 199 | - return 1; // Pas d'erreur |
|
| 198 | + $outputlangs->charset_output=$sav_charset_output; |
|
| 199 | + return 1; // Pas d'erreur |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | |
@@ -219,47 +219,47 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | $title = $outputlangs->transnoentities("CheckReceipt"); |
| 221 | 221 | $pdf->SetFont('','B', $default_font_size); |
| 222 | - $pdf->SetXY(10,8); |
|
| 223 | - $pdf->MultiCell(0,2,$title,0,'L'); |
|
| 222 | + $pdf->SetXY(10,8); |
|
| 223 | + $pdf->MultiCell(0,2,$title,0,'L'); |
|
| 224 | 224 | |
| 225 | 225 | $pdf->SetFont('','', $default_font_size); |
| 226 | - $pdf->SetXY(10,15); |
|
| 226 | + $pdf->SetXY(10,15); |
|
| 227 | 227 | $pdf->MultiCell(22,2,$outputlangs->transnoentities("Ref"),0,'L'); |
| 228 | - $pdf->SetXY(32,15); |
|
| 228 | + $pdf->SetXY(32,15); |
|
| 229 | 229 | $pdf->SetFont('','', $default_font_size); |
| 230 | - $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext?" - ".$this->ref_ext:'')), 0, 'L'); |
|
| 230 | + $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext?" - ".$this->ref_ext:'')), 0, 'L'); |
|
| 231 | 231 | |
| 232 | 232 | $pdf->SetFont('','', $default_font_size); |
| 233 | - $pdf->SetXY(10,20); |
|
| 234 | - $pdf->MultiCell(22,2,$outputlangs->transnoentities("Date"),0,'L'); |
|
| 235 | - $pdf->SetXY(32,20); |
|
| 236 | - $pdf->SetFont('','', $default_font_size); |
|
| 237 | - $pdf->MultiCell(60, 2, dol_print_date($this->date,"day",false,$outputlangs)); |
|
| 233 | + $pdf->SetXY(10,20); |
|
| 234 | + $pdf->MultiCell(22,2,$outputlangs->transnoentities("Date"),0,'L'); |
|
| 235 | + $pdf->SetXY(32,20); |
|
| 236 | + $pdf->SetFont('','', $default_font_size); |
|
| 237 | + $pdf->MultiCell(60, 2, dol_print_date($this->date,"day",false,$outputlangs)); |
|
| 238 | 238 | |
| 239 | 239 | $pdf->SetFont('','', $default_font_size); |
| 240 | - $pdf->SetXY(10,26); |
|
| 241 | - $pdf->MultiCell(22,2,$outputlangs->transnoentities("Owner"),0,'L'); |
|
| 240 | + $pdf->SetXY(10,26); |
|
| 241 | + $pdf->MultiCell(22,2,$outputlangs->transnoentities("Owner"),0,'L'); |
|
| 242 | 242 | $pdf->SetFont('','', $default_font_size); |
| 243 | - $pdf->SetXY(32,26); |
|
| 244 | - $pdf->MultiCell(60,2,$outputlangs->convToOutputCharset($this->account->proprio),0,'L'); |
|
| 243 | + $pdf->SetXY(32,26); |
|
| 244 | + $pdf->MultiCell(60,2,$outputlangs->convToOutputCharset($this->account->proprio),0,'L'); |
|
| 245 | 245 | |
| 246 | 246 | $pdf->SetFont('','', $default_font_size); |
| 247 | - $pdf->SetXY(10,32); |
|
| 248 | - $pdf->MultiCell(0,2,$outputlangs->transnoentities("Account"),0,'L'); |
|
| 249 | - pdf_bank($pdf,$outputlangs,32,32,$this->account,1); |
|
| 247 | + $pdf->SetXY(10,32); |
|
| 248 | + $pdf->MultiCell(0,2,$outputlangs->transnoentities("Account"),0,'L'); |
|
| 249 | + pdf_bank($pdf,$outputlangs,32,32,$this->account,1); |
|
| 250 | 250 | |
| 251 | 251 | $pdf->SetFont('','', $default_font_size); |
| 252 | - $pdf->SetXY(114,15); |
|
| 252 | + $pdf->SetXY(114,15); |
|
| 253 | 253 | $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Signature"), 0, 'L'); |
| 254 | 254 | |
| 255 | - $pdf->Rect(9, 14, 192, 35); |
|
| 256 | - $pdf->line(9, 19, 112, 19); |
|
| 257 | - $pdf->line(9, 25, 112, 25); |
|
| 258 | - //$pdf->line(9, 31, 201, 31); |
|
| 259 | - $pdf->line(9, 31, 112, 31); |
|
| 255 | + $pdf->Rect(9, 14, 192, 35); |
|
| 256 | + $pdf->line(9, 19, 112, 19); |
|
| 257 | + $pdf->line(9, 25, 112, 25); |
|
| 258 | + //$pdf->line(9, 31, 201, 31); |
|
| 259 | + $pdf->line(9, 31, 112, 31); |
|
| 260 | 260 | |
| 261 | - $pdf->line(30, 14, 30, 49); |
|
| 262 | - $pdf->line(112, 14, 112, 49); |
|
| 261 | + $pdf->line(30, 14, 30, 49); |
|
| 262 | + $pdf->line(112, 14, 112, 49); |
|
| 263 | 263 | |
| 264 | 264 | // Number of cheques |
| 265 | 265 | $posy=51; |
@@ -273,11 +273,11 @@ discard block |
||
| 273 | 273 | $pdf->MultiCell(40, 2, $outputlangs->transnoentities("NumberOfCheques"), 0, 'L'); |
| 274 | 274 | |
| 275 | 275 | $pdf->SetFont('','B', $default_font_size); |
| 276 | - $pdf->SetXY(57,$posy+1); |
|
| 277 | - $pdf->MultiCell(40, 2, $this->nbcheque, 0, 'L'); |
|
| 276 | + $pdf->SetXY(57,$posy+1); |
|
| 277 | + $pdf->MultiCell(40, 2, $this->nbcheque, 0, 'L'); |
|
| 278 | 278 | |
| 279 | 279 | $pdf->SetFont('','', $default_font_size); |
| 280 | - $pdf->SetXY(148,$posy+1); |
|
| 280 | + $pdf->SetXY(148,$posy+1); |
|
| 281 | 281 | $pdf->MultiCell(40, 2, $langs->trans("Total")); |
| 282 | 282 | |
| 283 | 283 | $pdf->SetFont('','B', $default_font_size); |
@@ -291,11 +291,11 @@ discard block |
||
| 291 | 291 | $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10); |
| 292 | 292 | |
| 293 | 293 | $pdf->SetXY(41, $this->tab_top+2); |
| 294 | - $pdf->MultiCell(40,2,$outputlangs->transnoentities("Bank"), 0, 'L'); |
|
| 294 | + $pdf->MultiCell(40,2,$outputlangs->transnoentities("Bank"), 0, 'L'); |
|
| 295 | 295 | $pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10); |
| 296 | 296 | |
| 297 | - $pdf->SetXY(101, $this->tab_top+2); |
|
| 298 | - $pdf->MultiCell(40,2,$outputlangs->transnoentities("CheckTransmitter"), 0, 'L'); |
|
| 297 | + $pdf->SetXY(101, $this->tab_top+2); |
|
| 298 | + $pdf->MultiCell(40,2,$outputlangs->transnoentities("CheckTransmitter"), 0, 'L'); |
|
| 299 | 299 | $pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10); |
| 300 | 300 | |
| 301 | 301 | $pdf->SetXY(180, $this->tab_top+2); |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | $num=count($this->lines); |
| 330 | 330 | for ($j = 0; $j < $num; $j++) |
| 331 | 331 | { |
| 332 | - $lineinpage++; |
|
| 332 | + $lineinpage++; |
|
| 333 | 333 | |
| 334 | 334 | $pdf->SetXY(1, $this->tab_top + 10 + $yp); |
| 335 | 335 | $pdf->MultiCell(8, $this->line_height, $j+1, 0, 'R', 0); |
@@ -350,15 +350,15 @@ discard block |
||
| 350 | 350 | |
| 351 | 351 | if ($lineinpage >= $this->line_per_page && $j < (count($this->lines)-1)) |
| 352 | 352 | { |
| 353 | - $lineinpage=0; $yp=0; |
|
| 354 | - |
|
| 355 | - // New page |
|
| 356 | - $pdf->AddPage(); |
|
| 357 | - $pagenb++; |
|
| 358 | - $this->Header($pdf, $pagenb, $pages, $outputlangs); |
|
| 359 | - $pdf->SetFont('','', $default_font_size - 1); |
|
| 360 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
| 361 | - $pdf->SetTextColor(0,0,0); |
|
| 353 | + $lineinpage=0; $yp=0; |
|
| 354 | + |
|
| 355 | + // New page |
|
| 356 | + $pdf->AddPage(); |
|
| 357 | + $pagenb++; |
|
| 358 | + $this->Header($pdf, $pagenb, $pages, $outputlangs); |
|
| 359 | + $pdf->SetFont('','', $default_font_size - 1); |
|
| 360 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
| 361 | + $pdf->SetTextColor(0,0,0); |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | /** |
| 368 | 368 | * Show footer of page. Need this->emetteur object |
| 369 | - * |
|
| 369 | + * |
|
| 370 | 370 | * @param PDF $pdf PDF |
| 371 | 371 | * @param Object $object Object to show |
| 372 | 372 | * @param Translate $outputlangs Object lang for output |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | $paramfreetext='BANK_CHEQUERECEIPT_FREE_TEXT'; |
| 386 | 386 | if (! empty($conf->global->$paramfreetext)) |
| 387 | 387 | { |
| 388 | - $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
| 388 | + $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | return pdf_pagefoot($pdf,$outputlangs,$newfreetext,$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | class BordereauChequeBlochet extends ModeleChequeReceipts |
| 36 | 36 | { |
| 37 | - var $emetteur; // Objet societe qui emet |
|
| 37 | + var $emetteur; // Objet societe qui emet |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Constructor |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | function __construct($db) |
| 45 | 45 | { |
| 46 | - global $conf,$langs,$mysoc; |
|
| 46 | + global $conf, $langs, $mysoc; |
|
| 47 | 47 | |
| 48 | 48 | $langs->load("main"); |
| 49 | 49 | $langs->load("bills"); |
@@ -55,23 +55,23 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | // Dimension page pour format A4 |
| 57 | 57 | $this->type = 'pdf'; |
| 58 | - $formatarray=pdf_getFormat(); |
|
| 58 | + $formatarray = pdf_getFormat(); |
|
| 59 | 59 | $this->page_largeur = $formatarray['width']; |
| 60 | 60 | $this->page_hauteur = $formatarray['height']; |
| 61 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
| 62 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
| 63 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
| 64 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
| 65 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
| 61 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
| 62 | + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; |
|
| 63 | + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; |
|
| 64 | + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; |
|
| 65 | + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; |
|
| 66 | 66 | |
| 67 | 67 | // Recupere emmetteur |
| 68 | - $this->emetteur=$mysoc; |
|
| 69 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 68 | + $this->emetteur = $mysoc; |
|
| 69 | + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined |
|
| 70 | 70 | |
| 71 | 71 | // Defini position des colonnes |
| 72 | 72 | $this->line_height = 5; |
| 73 | 73 | $this->line_per_page = 40; |
| 74 | - $this->tab_height = 200; //$this->line_height * $this->line_per_page; |
|
| 74 | + $this->tab_height = 200; //$this->line_height * $this->line_per_page; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | function write_file($object, $_dir, $number, $outputlangs) |
| 87 | 87 | { |
| 88 | - global $user,$conf,$langs,$hookmanager; |
|
| 88 | + global $user, $conf, $langs, $hookmanager; |
|
| 89 | 89 | |
| 90 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 90 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
| 91 | 91 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
| 92 | - $sav_charset_output=$outputlangs->charset_output; |
|
| 93 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
| 92 | + $sav_charset_output = $outputlangs->charset_output; |
|
| 93 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
| 94 | 94 | |
| 95 | 95 | $outputlangs->load("main"); |
| 96 | 96 | $outputlangs->load("companies"); |
@@ -98,38 +98,38 @@ discard block |
||
| 98 | 98 | $outputlangs->load("products"); |
| 99 | 99 | $outputlangs->load("compta"); |
| 100 | 100 | |
| 101 | - $dir = $_dir . "/".get_exdir($number,0,1,0,$object,'cheque').$number; |
|
| 101 | + $dir = $_dir."/".get_exdir($number, 0, 1, 0, $object, 'cheque').$number; |
|
| 102 | 102 | |
| 103 | - if (! is_dir($dir)) |
|
| 103 | + if (!is_dir($dir)) |
|
| 104 | 104 | { |
| 105 | - $result=dol_mkdir($dir); |
|
| 105 | + $result = dol_mkdir($dir); |
|
| 106 | 106 | |
| 107 | 107 | if ($result < 0) |
| 108 | 108 | { |
| 109 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
| 109 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
| 110 | 110 | return -1; |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - $file = $dir . "/bordereau-".$number.".pdf"; |
|
| 114 | + $file = $dir."/bordereau-".$number.".pdf"; |
|
| 115 | 115 | |
| 116 | 116 | // Add pdfgeneration hook |
| 117 | - if (! is_object($hookmanager)) |
|
| 117 | + if (!is_object($hookmanager)) |
|
| 118 | 118 | { |
| 119 | 119 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
| 120 | - $hookmanager=new HookManager($this->db); |
|
| 120 | + $hookmanager = new HookManager($this->db); |
|
| 121 | 121 | } |
| 122 | 122 | $hookmanager->initHooks(array('pdfgeneration')); |
| 123 | - $parameters=array('file'=>$file, 'outputlangs'=>$outputlangs); |
|
| 123 | + $parameters = array('file'=>$file, 'outputlangs'=>$outputlangs); |
|
| 124 | 124 | global $action; |
| 125 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 125 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
| 126 | 126 | |
| 127 | 127 | // Create PDF instance |
| 128 | - $pdf=pdf_getInstance($this->format); |
|
| 129 | - $heightforinfotot = 50; // Height reserved to output the info and total part |
|
| 130 | - $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 |
|
| 131 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
| 132 | - $pdf->SetAutoPageBreak(1,0); |
|
| 128 | + $pdf = pdf_getInstance($this->format); |
|
| 129 | + $heightforinfotot = 50; // Height reserved to output the info and total part |
|
| 130 | + $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 |
|
| 131 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
| 132 | + $pdf->SetAutoPageBreak(1, 0); |
|
| 133 | 133 | |
| 134 | 134 | if (class_exists('TCPDF')) |
| 135 | 135 | { |
@@ -139,23 +139,23 @@ discard block |
||
| 139 | 139 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
| 140 | 140 | |
| 141 | 141 | $pdf->Open(); |
| 142 | - $pagenb=0; |
|
| 143 | - $pdf->SetDrawColor(128,128,128); |
|
| 142 | + $pagenb = 0; |
|
| 143 | + $pdf->SetDrawColor(128, 128, 128); |
|
| 144 | 144 | |
| 145 | 145 | $pdf->SetTitle($outputlangs->transnoentities("CheckReceipt")." ".$number); |
| 146 | 146 | $pdf->SetSubject($outputlangs->transnoentities("CheckReceipt")); |
| 147 | 147 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
| 148 | 148 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
| 149 | 149 | $pdf->SetKeyWords($outputlangs->transnoentities("CheckReceipt")." ".$number); |
| 150 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 150 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 151 | 151 | |
| 152 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
| 152 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
| 153 | 153 | |
| 154 | - $nboflines=count($this->lines); |
|
| 154 | + $nboflines = count($this->lines); |
|
| 155 | 155 | |
| 156 | 156 | // Define nb of page |
| 157 | 157 | $pages = intval($nboflines / $this->line_per_page); |
| 158 | - if (($nboflines % $this->line_per_page)>0) |
|
| 158 | + if (($nboflines % $this->line_per_page) > 0) |
|
| 159 | 159 | { |
| 160 | 160 | $pages++; |
| 161 | 161 | } |
@@ -172,31 +172,31 @@ discard block |
||
| 172 | 172 | $this->Body($pdf, $pagenb, $pages, $outputlangs); |
| 173 | 173 | |
| 174 | 174 | // Pied de page |
| 175 | - $this->_pagefoot($pdf,'',$outputlangs); |
|
| 176 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
| 175 | + $this->_pagefoot($pdf, '', $outputlangs); |
|
| 176 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
| 177 | 177 | |
| 178 | 178 | $pdf->Close(); |
| 179 | 179 | |
| 180 | - $pdf->Output($file,'F'); |
|
| 180 | + $pdf->Output($file, 'F'); |
|
| 181 | 181 | |
| 182 | 182 | // Add pdfgeneration hook |
| 183 | - if (! is_object($hookmanager)) |
|
| 183 | + if (!is_object($hookmanager)) |
|
| 184 | 184 | { |
| 185 | 185 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
| 186 | - $hookmanager=new HookManager($this->db); |
|
| 186 | + $hookmanager = new HookManager($this->db); |
|
| 187 | 187 | } |
| 188 | 188 | $hookmanager->initHooks(array('pdfgeneration')); |
| 189 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
| 189 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
| 190 | 190 | global $action; |
| 191 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
| 191 | + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 192 | 192 | |
| 193 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 193 | + if (!empty($conf->global->MAIN_UMASK)) |
|
| 194 | 194 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
| 195 | 195 | |
| 196 | 196 | $this->result = array('fullpath'=>$file); |
| 197 | 197 | |
| 198 | - $outputlangs->charset_output=$sav_charset_output; |
|
| 199 | - return 1; // Pas d'erreur |
|
| 198 | + $outputlangs->charset_output = $sav_charset_output; |
|
| 199 | + return 1; // Pas d'erreur |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | |
@@ -218,38 +218,38 @@ discard block |
||
| 218 | 218 | $outputlangs->load("banks"); |
| 219 | 219 | |
| 220 | 220 | $title = $outputlangs->transnoentities("CheckReceipt"); |
| 221 | - $pdf->SetFont('','B', $default_font_size); |
|
| 222 | - $pdf->SetXY(10,8); |
|
| 223 | - $pdf->MultiCell(0,2,$title,0,'L'); |
|
| 224 | - |
|
| 225 | - $pdf->SetFont('','', $default_font_size); |
|
| 226 | - $pdf->SetXY(10,15); |
|
| 227 | - $pdf->MultiCell(22,2,$outputlangs->transnoentities("Ref"),0,'L'); |
|
| 228 | - $pdf->SetXY(32,15); |
|
| 229 | - $pdf->SetFont('','', $default_font_size); |
|
| 230 | - $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext?" - ".$this->ref_ext:'')), 0, 'L'); |
|
| 231 | - |
|
| 232 | - $pdf->SetFont('','', $default_font_size); |
|
| 233 | - $pdf->SetXY(10,20); |
|
| 234 | - $pdf->MultiCell(22,2,$outputlangs->transnoentities("Date"),0,'L'); |
|
| 235 | - $pdf->SetXY(32,20); |
|
| 236 | - $pdf->SetFont('','', $default_font_size); |
|
| 237 | - $pdf->MultiCell(60, 2, dol_print_date($this->date,"day",false,$outputlangs)); |
|
| 238 | - |
|
| 239 | - $pdf->SetFont('','', $default_font_size); |
|
| 240 | - $pdf->SetXY(10,26); |
|
| 241 | - $pdf->MultiCell(22,2,$outputlangs->transnoentities("Owner"),0,'L'); |
|
| 242 | - $pdf->SetFont('','', $default_font_size); |
|
| 243 | - $pdf->SetXY(32,26); |
|
| 244 | - $pdf->MultiCell(60,2,$outputlangs->convToOutputCharset($this->account->proprio),0,'L'); |
|
| 245 | - |
|
| 246 | - $pdf->SetFont('','', $default_font_size); |
|
| 247 | - $pdf->SetXY(10,32); |
|
| 248 | - $pdf->MultiCell(0,2,$outputlangs->transnoentities("Account"),0,'L'); |
|
| 249 | - pdf_bank($pdf,$outputlangs,32,32,$this->account,1); |
|
| 250 | - |
|
| 251 | - $pdf->SetFont('','', $default_font_size); |
|
| 252 | - $pdf->SetXY(114,15); |
|
| 221 | + $pdf->SetFont('', 'B', $default_font_size); |
|
| 222 | + $pdf->SetXY(10, 8); |
|
| 223 | + $pdf->MultiCell(0, 2, $title, 0, 'L'); |
|
| 224 | + |
|
| 225 | + $pdf->SetFont('', '', $default_font_size); |
|
| 226 | + $pdf->SetXY(10, 15); |
|
| 227 | + $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Ref"), 0, 'L'); |
|
| 228 | + $pdf->SetXY(32, 15); |
|
| 229 | + $pdf->SetFont('', '', $default_font_size); |
|
| 230 | + $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ? " - ".$this->ref_ext : '')), 0, 'L'); |
|
| 231 | + |
|
| 232 | + $pdf->SetFont('', '', $default_font_size); |
|
| 233 | + $pdf->SetXY(10, 20); |
|
| 234 | + $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Date"), 0, 'L'); |
|
| 235 | + $pdf->SetXY(32, 20); |
|
| 236 | + $pdf->SetFont('', '', $default_font_size); |
|
| 237 | + $pdf->MultiCell(60, 2, dol_print_date($this->date, "day", false, $outputlangs)); |
|
| 238 | + |
|
| 239 | + $pdf->SetFont('', '', $default_font_size); |
|
| 240 | + $pdf->SetXY(10, 26); |
|
| 241 | + $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L'); |
|
| 242 | + $pdf->SetFont('', '', $default_font_size); |
|
| 243 | + $pdf->SetXY(32, 26); |
|
| 244 | + $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L'); |
|
| 245 | + |
|
| 246 | + $pdf->SetFont('', '', $default_font_size); |
|
| 247 | + $pdf->SetXY(10, 32); |
|
| 248 | + $pdf->MultiCell(0, 2, $outputlangs->transnoentities("Account"), 0, 'L'); |
|
| 249 | + pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1); |
|
| 250 | + |
|
| 251 | + $pdf->SetFont('', '', $default_font_size); |
|
| 252 | + $pdf->SetXY(114, 15); |
|
| 253 | 253 | $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Signature"), 0, 'L'); |
| 254 | 254 | |
| 255 | 255 | $pdf->Rect(9, 14, 192, 35); |
@@ -262,44 +262,44 @@ discard block |
||
| 262 | 262 | $pdf->line(112, 14, 112, 49); |
| 263 | 263 | |
| 264 | 264 | // Number of cheques |
| 265 | - $posy=51; |
|
| 265 | + $posy = 51; |
|
| 266 | 266 | $pdf->Rect(9, $posy, 192, 6); |
| 267 | - $pdf->line(55, $posy, 55, $posy+6); |
|
| 268 | - $pdf->line(140, $posy, 140, $posy+6); |
|
| 269 | - $pdf->line(170, $posy, 170, $posy+6); |
|
| 267 | + $pdf->line(55, $posy, 55, $posy + 6); |
|
| 268 | + $pdf->line(140, $posy, 140, $posy + 6); |
|
| 269 | + $pdf->line(170, $posy, 170, $posy + 6); |
|
| 270 | 270 | |
| 271 | - $pdf->SetFont('','', $default_font_size); |
|
| 272 | - $pdf->SetXY(10,$posy+1); |
|
| 271 | + $pdf->SetFont('', '', $default_font_size); |
|
| 272 | + $pdf->SetXY(10, $posy + 1); |
|
| 273 | 273 | $pdf->MultiCell(40, 2, $outputlangs->transnoentities("NumberOfCheques"), 0, 'L'); |
| 274 | 274 | |
| 275 | - $pdf->SetFont('','B', $default_font_size); |
|
| 276 | - $pdf->SetXY(57,$posy+1); |
|
| 275 | + $pdf->SetFont('', 'B', $default_font_size); |
|
| 276 | + $pdf->SetXY(57, $posy + 1); |
|
| 277 | 277 | $pdf->MultiCell(40, 2, $this->nbcheque, 0, 'L'); |
| 278 | 278 | |
| 279 | - $pdf->SetFont('','', $default_font_size); |
|
| 280 | - $pdf->SetXY(148,$posy+1); |
|
| 279 | + $pdf->SetFont('', '', $default_font_size); |
|
| 280 | + $pdf->SetXY(148, $posy + 1); |
|
| 281 | 281 | $pdf->MultiCell(40, 2, $langs->trans("Total")); |
| 282 | 282 | |
| 283 | - $pdf->SetFont('','B', $default_font_size); |
|
| 284 | - $pdf->SetXY(170, $posy+1); |
|
| 283 | + $pdf->SetFont('', 'B', $default_font_size); |
|
| 284 | + $pdf->SetXY(170, $posy + 1); |
|
| 285 | 285 | $pdf->MultiCell(31, 2, price($this->amount), 0, 'C', 0); |
| 286 | 286 | |
| 287 | 287 | // Tableau |
| 288 | - $pdf->SetFont('','', $default_font_size - 2); |
|
| 289 | - $pdf->SetXY(11, $this->tab_top+2); |
|
| 290 | - $pdf->MultiCell(40,2,$outputlangs->transnoentities("Num"), 0, 'L'); |
|
| 288 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
| 289 | + $pdf->SetXY(11, $this->tab_top + 2); |
|
| 290 | + $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Num"), 0, 'L'); |
|
| 291 | 291 | $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10); |
| 292 | 292 | |
| 293 | - $pdf->SetXY(41, $this->tab_top+2); |
|
| 294 | - $pdf->MultiCell(40,2,$outputlangs->transnoentities("Bank"), 0, 'L'); |
|
| 293 | + $pdf->SetXY(41, $this->tab_top + 2); |
|
| 294 | + $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Bank"), 0, 'L'); |
|
| 295 | 295 | $pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10); |
| 296 | 296 | |
| 297 | - $pdf->SetXY(101, $this->tab_top+2); |
|
| 298 | - $pdf->MultiCell(40,2,$outputlangs->transnoentities("CheckTransmitter"), 0, 'L'); |
|
| 297 | + $pdf->SetXY(101, $this->tab_top + 2); |
|
| 298 | + $pdf->MultiCell(40, 2, $outputlangs->transnoentities("CheckTransmitter"), 0, 'L'); |
|
| 299 | 299 | $pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10); |
| 300 | 300 | |
| 301 | - $pdf->SetXY(180, $this->tab_top+2); |
|
| 302 | - $pdf->MultiCell(20,2,$outputlangs->transnoentities("Amount"), 0, 'R'); |
|
| 301 | + $pdf->SetXY(180, $this->tab_top + 2); |
|
| 302 | + $pdf->MultiCell(20, 2, $outputlangs->transnoentities("Amount"), 0, 'R'); |
|
| 303 | 303 | $pdf->line(9, $this->tab_top + 8, 201, $this->tab_top + 8); |
| 304 | 304 | |
| 305 | 305 | $pdf->Rect(9, $this->tab_top, 192, $this->tab_height + 10); |
@@ -321,44 +321,44 @@ discard block |
||
| 321 | 321 | // x=30 - Banque |
| 322 | 322 | // x=100 - Emetteur |
| 323 | 323 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
| 324 | - $pdf->SetFont('','', $default_font_size - 1); |
|
| 324 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
| 325 | 325 | $oldprowid = 0; |
| 326 | - $pdf->SetFillColor(220,220,220); |
|
| 326 | + $pdf->SetFillColor(220, 220, 220); |
|
| 327 | 327 | $yp = 0; |
| 328 | - $lineinpage=0; |
|
| 329 | - $num=count($this->lines); |
|
| 328 | + $lineinpage = 0; |
|
| 329 | + $num = count($this->lines); |
|
| 330 | 330 | for ($j = 0; $j < $num; $j++) |
| 331 | 331 | { |
| 332 | 332 | $lineinpage++; |
| 333 | 333 | |
| 334 | 334 | $pdf->SetXY(1, $this->tab_top + 10 + $yp); |
| 335 | - $pdf->MultiCell(8, $this->line_height, $j+1, 0, 'R', 0); |
|
| 335 | + $pdf->MultiCell(8, $this->line_height, $j + 1, 0, 'R', 0); |
|
| 336 | 336 | |
| 337 | 337 | $pdf->SetXY(10, $this->tab_top + 10 + $yp); |
| 338 | - $pdf->MultiCell(30, $this->line_height, $this->lines[$j]->num_chq?$this->lines[$j]->num_chq:'', 0, 'L', 0); |
|
| 338 | + $pdf->MultiCell(30, $this->line_height, $this->lines[$j]->num_chq ? $this->lines[$j]->num_chq : '', 0, 'L', 0); |
|
| 339 | 339 | |
| 340 | 340 | $pdf->SetXY(40, $this->tab_top + 10 + $yp); |
| 341 | - $pdf->MultiCell(70, $this->line_height, dol_trunc($outputlangs->convToOutputCharset($this->lines[$j]->bank_chq),44), 0, 'L', 0); |
|
| 341 | + $pdf->MultiCell(70, $this->line_height, dol_trunc($outputlangs->convToOutputCharset($this->lines[$j]->bank_chq), 44), 0, 'L', 0); |
|
| 342 | 342 | |
| 343 | 343 | $pdf->SetXY(100, $this->tab_top + 10 + $yp); |
| 344 | - $pdf->MultiCell(80, $this->line_height, dol_trunc($outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq),50), 0, 'L', 0); |
|
| 344 | + $pdf->MultiCell(80, $this->line_height, dol_trunc($outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq), 50), 0, 'L', 0); |
|
| 345 | 345 | |
| 346 | 346 | $pdf->SetXY(180, $this->tab_top + 10 + $yp); |
| 347 | 347 | $pdf->MultiCell(20, $this->line_height, price($this->lines[$j]->amount_chq), 0, 'R', 0); |
| 348 | 348 | |
| 349 | 349 | $yp = $yp + $this->line_height; |
| 350 | 350 | |
| 351 | - if ($lineinpage >= $this->line_per_page && $j < (count($this->lines)-1)) |
|
| 351 | + if ($lineinpage >= $this->line_per_page && $j < (count($this->lines) - 1)) |
|
| 352 | 352 | { |
| 353 | - $lineinpage=0; $yp=0; |
|
| 353 | + $lineinpage = 0; $yp = 0; |
|
| 354 | 354 | |
| 355 | 355 | // New page |
| 356 | 356 | $pdf->AddPage(); |
| 357 | 357 | $pagenb++; |
| 358 | 358 | $this->Header($pdf, $pagenb, $pages, $outputlangs); |
| 359 | - $pdf->SetFont('','', $default_font_size - 1); |
|
| 360 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
| 361 | - $pdf->SetTextColor(0,0,0); |
|
| 359 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
| 360 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
| 361 | + $pdf->SetTextColor(0, 0, 0); |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | } |
@@ -373,22 +373,22 @@ discard block |
||
| 373 | 373 | * @param int $hidefreetext 1=Hide free text |
| 374 | 374 | * @return void |
| 375 | 375 | */ |
| 376 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
| 376 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
| 377 | 377 | { |
| 378 | 378 | global $conf; |
| 379 | 379 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
| 380 | 380 | |
| 381 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
| 381 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
| 382 | 382 | |
| 383 | 383 | // Line of free text |
| 384 | - $newfreetext=''; |
|
| 385 | - $paramfreetext='BANK_CHEQUERECEIPT_FREE_TEXT'; |
|
| 386 | - if (! empty($conf->global->$paramfreetext)) |
|
| 384 | + $newfreetext = ''; |
|
| 385 | + $paramfreetext = 'BANK_CHEQUERECEIPT_FREE_TEXT'; |
|
| 386 | + if (!empty($conf->global->$paramfreetext)) |
|
| 387 | 387 | { |
| 388 | - $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
| 388 | + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - return pdf_pagefoot($pdf,$outputlangs,$newfreetext,$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
| 391 | + return pdf_pagefoot($pdf, $outputlangs, $newfreetext, $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | 394 | |
@@ -66,7 +66,10 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | // Recupere emmetteur |
| 68 | 68 | $this->emetteur=$mysoc; |
| 69 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 69 | + if (! $this->emetteur->country_code) { |
|
| 70 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 71 | + } |
|
| 72 | + // By default if not defined |
|
| 70 | 73 | |
| 71 | 74 | // Defini position des colonnes |
| 72 | 75 | $this->line_height = 5; |
@@ -87,10 +90,14 @@ discard block |
||
| 87 | 90 | { |
| 88 | 91 | global $user,$conf,$langs,$hookmanager; |
| 89 | 92 | |
| 90 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 93 | + if (! is_object($outputlangs)) { |
|
| 94 | + $outputlangs=$langs; |
|
| 95 | + } |
|
| 91 | 96 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
| 92 | 97 | $sav_charset_output=$outputlangs->charset_output; |
| 93 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
| 98 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
| 99 | + $outputlangs->charset_output='ISO-8859-1'; |
|
| 100 | + } |
|
| 94 | 101 | |
| 95 | 102 | $outputlangs->load("main"); |
| 96 | 103 | $outputlangs->load("companies"); |
@@ -147,7 +154,9 @@ discard block |
||
| 147 | 154 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
| 148 | 155 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
| 149 | 156 | $pdf->SetKeyWords($outputlangs->transnoentities("CheckReceipt")." ".$number); |
| 150 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 157 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
| 158 | + $pdf->SetCompression(false); |
|
| 159 | + } |
|
| 151 | 160 | |
| 152 | 161 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
| 153 | 162 | |
@@ -173,7 +182,9 @@ discard block |
||
| 173 | 182 | |
| 174 | 183 | // Pied de page |
| 175 | 184 | $this->_pagefoot($pdf,'',$outputlangs); |
| 176 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
| 185 | + if (method_exists($pdf,'AliasNbPages')) { |
|
| 186 | + $pdf->AliasNbPages(); |
|
| 187 | + } |
|
| 177 | 188 | |
| 178 | 189 | $pdf->Close(); |
| 179 | 190 | |
@@ -190,8 +201,9 @@ discard block |
||
| 190 | 201 | global $action; |
| 191 | 202 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 192 | 203 | |
| 193 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 194 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 204 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 205 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 206 | + } |
|
| 195 | 207 | |
| 196 | 208 | $this->result = array('fullpath'=>$file); |
| 197 | 209 | |
@@ -125,7 +125,7 @@ |
||
| 125 | 125 | * Return next value |
| 126 | 126 | * |
| 127 | 127 | * @param Societe $objsoc Object third party |
| 128 | - * @param Object $object Object invoice |
|
| 128 | + * @param string $object Object invoice |
|
| 129 | 129 | * @param string $mode 'next' for next value or 'last' for last value |
| 130 | 130 | * @return string Value if OK, 0 if KO |
| 131 | 131 | */ |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | var $nom = 'Tulip'; |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Returns the description of the model numbering |
|
| 46 | - * |
|
| 47 | - * @return string Description Text |
|
| 48 | - */ |
|
| 44 | + /** |
|
| 45 | + * Returns the description of the model numbering |
|
| 46 | + * |
|
| 47 | + * @return string Description Text |
|
| 48 | + */ |
|
| 49 | 49 | function info() |
| 50 | - { |
|
| 51 | - global $conf,$langs; |
|
| 50 | + { |
|
| 51 | + global $conf,$langs; |
|
| 52 | 52 | |
| 53 | 53 | $langs->load("bills"); |
| 54 | 54 | $langs->load("admin"); |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 61 | 61 | $texte.= '<input type="hidden" name="action" value="updateMask">'; |
| 62 | 62 | $texte.= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">'; |
| 63 | - $texte.= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">'; |
|
| 64 | - $texte.= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">'; |
|
| 63 | + $texte.= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">'; |
|
| 64 | + $texte.= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">'; |
|
| 65 | 65 | $texte.= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">'; |
| 66 | 66 | $texte.= '<table class="nobordernopadding" width="100%">'; |
| 67 | 67 | |
@@ -83,40 +83,40 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | if ($conf->global->MAIN_FEATURE_LEVEL >= 2) |
| 85 | 85 | { |
| 86 | - // Parametrage du prefix des replacement |
|
| 87 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>'; |
|
| 88 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
| 89 | - $texte.= '</tr>'; |
|
| 90 | - |
|
| 91 | - // Parametrage du prefix des avoirs |
|
| 92 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>'; |
|
| 93 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
| 94 | - $texte.= '</tr>'; |
|
| 95 | - |
|
| 96 | - // Parametrage du prefix des acomptes |
|
| 97 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>'; |
|
| 98 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
| 99 | - $texte.= '</tr>'; |
|
| 86 | + // Parametrage du prefix des replacement |
|
| 87 | + $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>'; |
|
| 88 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
| 89 | + $texte.= '</tr>'; |
|
| 90 | + |
|
| 91 | + // Parametrage du prefix des avoirs |
|
| 92 | + $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>'; |
|
| 93 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
| 94 | + $texte.= '</tr>'; |
|
| 95 | + |
|
| 96 | + // Parametrage du prefix des acomptes |
|
| 97 | + $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>'; |
|
| 98 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
| 99 | + $texte.= '</tr>'; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $texte.= '</table>'; |
| 103 | 103 | $texte.= '</form>'; |
| 104 | 104 | |
| 105 | 105 | return $texte; |
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Returns a numbering example |
|
| 110 | - * |
|
| 111 | - * @return string Example |
|
| 112 | - */ |
|
| 113 | - function getExample() |
|
| 114 | - { |
|
| 115 | - global $conf,$langs,$mysoc; |
|
| 116 | - |
|
| 117 | - $old_code_client=$mysoc->code_client; |
|
| 118 | - $mysoc->code_client='CCCCCCCCCC'; |
|
| 119 | - $numExample = $this->getNextValue($mysoc,''); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Returns a numbering example |
|
| 110 | + * |
|
| 111 | + * @return string Example |
|
| 112 | + */ |
|
| 113 | + function getExample() |
|
| 114 | + { |
|
| 115 | + global $conf,$langs,$mysoc; |
|
| 116 | + |
|
| 117 | + $old_code_client=$mysoc->code_client; |
|
| 118 | + $mysoc->code_client='CCCCCCCCCC'; |
|
| 119 | + $numExample = $this->getNextValue($mysoc,''); |
|
| 120 | 120 | $mysoc->code_client=$old_code_client; |
| 121 | 121 | |
| 122 | 122 | if (! $numExample) |
@@ -124,18 +124,18 @@ discard block |
||
| 124 | 124 | $numExample = $langs->trans('NotConfigured'); |
| 125 | 125 | } |
| 126 | 126 | return $numExample; |
| 127 | - } |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | 129 | /** |
| 130 | 130 | * Return next value |
| 131 | 131 | * |
| 132 | 132 | * @param Societe $objsoc Object third party |
| 133 | 133 | * @param Object $object Object invoice |
| 134 | - * @param string $mode 'next' for next value or 'last' for last value |
|
| 135 | - * @return string Value if OK, 0 if KO |
|
| 134 | + * @param string $mode 'next' for next value or 'last' for last value |
|
| 135 | + * @return string Value if OK, 0 if KO |
|
| 136 | 136 | */ |
| 137 | - function getNextValue($objsoc,$object,$mode='next') |
|
| 138 | - { |
|
| 137 | + function getNextValue($objsoc,$object,$mode='next') |
|
| 138 | + { |
|
| 139 | 139 | global $db,$conf; |
| 140 | 140 | |
| 141 | 141 | require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
@@ -165,14 +165,14 @@ discard block |
||
| 165 | 165 | return $numFinal; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - /** |
|
| 168 | + /** |
|
| 169 | 169 | * Return next free value |
| 170 | 170 | * |
| 171 | - * @param Societe $objsoc Object third party |
|
| 172 | - * @param string $objforref Object for number to search |
|
| 173 | - * @param string $mode 'next' for next value or 'last' for last value |
|
| 174 | - * @return string Next free value |
|
| 175 | - */ |
|
| 171 | + * @param Societe $objsoc Object third party |
|
| 172 | + * @param string $objforref Object for number to search |
|
| 173 | + * @param string $mode 'next' for next value or 'last' for last value |
|
| 174 | + * @return string Next free value |
|
| 175 | + */ |
|
| 176 | 176 | function getNumRef($objsoc,$objforref,$mode='next') |
| 177 | 177 | { |
| 178 | 178 | return $this->getNextValue($objsoc,$objforref,$mode); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * \brief File containing the Tulip Class of numbering models of suppliers invoices references |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_invoice/modules_facturefournisseur.php'; |
|
| 30 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php'; |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices |
| 38 | 38 | { |
| 39 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
| 39 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
| 40 | 40 | var $error = ''; |
| 41 | 41 | var $nom = 'Tulip'; |
| 42 | 42 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | function info() |
| 50 | 50 | { |
| 51 | - global $conf,$langs; |
|
| 51 | + global $conf, $langs; |
|
| 52 | 52 | |
| 53 | 53 | $langs->load("bills"); |
| 54 | 54 | $langs->load("admin"); |
@@ -56,51 +56,51 @@ discard block |
||
| 56 | 56 | $form = new Form($this->db); |
| 57 | 57 | |
| 58 | 58 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
| 59 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
| 60 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 61 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
| 62 | - $texte.= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">'; |
|
| 63 | - $texte.= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">'; |
|
| 64 | - $texte.= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">'; |
|
| 65 | - $texte.= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">'; |
|
| 66 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
| 67 | - |
|
| 68 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice")); |
|
| 69 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
| 70 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
| 71 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice")); |
|
| 72 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
| 59 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
| 60 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 61 | + $texte .= '<input type="hidden" name="action" value="updateMask">'; |
|
| 62 | + $texte .= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">'; |
|
| 63 | + $texte .= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">'; |
|
| 64 | + $texte .= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">'; |
|
| 65 | + $texte .= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">'; |
|
| 66 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
| 67 | + |
|
| 68 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice")); |
|
| 69 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
| 70 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
| 71 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice")); |
|
| 72 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
| 73 | 73 | |
| 74 | 74 | // Parametrage du prefix |
| 75 | - $texte.= '<tr><td>'.$langs->trans("Mask"); |
|
| 75 | + $texte .= '<tr><td>'.$langs->trans("Mask"); |
|
| 76 | 76 | //$texte.= ' ('.$langs->trans("InvoiceStandard").')'; |
| 77 | - $texte.= ':</td>'; |
|
| 78 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->SUPPLIER_INVOICE_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
| 77 | + $texte .= ':</td>'; |
|
| 78 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->SUPPLIER_INVOICE_TULIP_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
| 79 | 79 | |
| 80 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
| 80 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
| 81 | 81 | |
| 82 | - $texte.= '</tr>'; |
|
| 82 | + $texte .= '</tr>'; |
|
| 83 | 83 | |
| 84 | 84 | if ($conf->global->MAIN_FEATURE_LEVEL >= 2) |
| 85 | 85 | { |
| 86 | 86 | // Parametrage du prefix des replacement |
| 87 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>'; |
|
| 88 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
| 89 | - $texte.= '</tr>'; |
|
| 87 | + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>'; |
|
| 88 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
| 89 | + $texte .= '</tr>'; |
|
| 90 | 90 | |
| 91 | 91 | // Parametrage du prefix des avoirs |
| 92 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>'; |
|
| 93 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
| 94 | - $texte.= '</tr>'; |
|
| 92 | + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>'; |
|
| 93 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
| 94 | + $texte .= '</tr>'; |
|
| 95 | 95 | |
| 96 | 96 | // Parametrage du prefix des acomptes |
| 97 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>'; |
|
| 98 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
| 99 | - $texte.= '</tr>'; |
|
| 97 | + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>'; |
|
| 98 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
| 99 | + $texte .= '</tr>'; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $texte.= '</table>'; |
|
| 103 | - $texte.= '</form>'; |
|
| 102 | + $texte .= '</table>'; |
|
| 103 | + $texte .= '</form>'; |
|
| 104 | 104 | |
| 105 | 105 | return $texte; |
| 106 | 106 | } |
@@ -112,14 +112,14 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | function getExample() |
| 114 | 114 | { |
| 115 | - global $conf,$langs,$mysoc; |
|
| 115 | + global $conf, $langs, $mysoc; |
|
| 116 | 116 | |
| 117 | - $old_code_client=$mysoc->code_client; |
|
| 118 | - $mysoc->code_client='CCCCCCCCCC'; |
|
| 119 | - $numExample = $this->getNextValue($mysoc,''); |
|
| 120 | - $mysoc->code_client=$old_code_client; |
|
| 117 | + $old_code_client = $mysoc->code_client; |
|
| 118 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
| 119 | + $numExample = $this->getNextValue($mysoc, ''); |
|
| 120 | + $mysoc->code_client = $old_code_client; |
|
| 121 | 121 | |
| 122 | - if (! $numExample) |
|
| 122 | + if (!$numExample) |
|
| 123 | 123 | { |
| 124 | 124 | $numExample = $langs->trans('NotConfigured'); |
| 125 | 125 | } |
@@ -134,33 +134,33 @@ discard block |
||
| 134 | 134 | * @param string $mode 'next' for next value or 'last' for last value |
| 135 | 135 | * @return string Value if OK, 0 if KO |
| 136 | 136 | */ |
| 137 | - function getNextValue($objsoc,$object,$mode='next') |
|
| 137 | + function getNextValue($objsoc, $object, $mode = 'next') |
|
| 138 | 138 | { |
| 139 | - global $db,$conf; |
|
| 139 | + global $db, $conf; |
|
| 140 | 140 | |
| 141 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
| 141 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
| 142 | 142 | |
| 143 | 143 | // Get Mask value |
| 144 | 144 | $mask = ''; |
| 145 | 145 | if (is_object($object) && $object->type == 1) |
| 146 | 146 | { |
| 147 | - $mask=$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK; |
|
| 148 | - if (! $mask) |
|
| 147 | + $mask = $conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK; |
|
| 148 | + if (!$mask) |
|
| 149 | 149 | { |
| 150 | - $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
| 150 | + $mask = $conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | - else if (is_object($object) && $object->type == 2) $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK; |
|
| 154 | - else if (is_object($object) && $object->type == 3) $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK; |
|
| 155 | - else $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
| 156 | - if (! $mask) |
|
| 153 | + else if (is_object($object) && $object->type == 2) $mask = $conf->global->SUPPLIER_CREDIT_TULIP_MASK; |
|
| 154 | + else if (is_object($object) && $object->type == 3) $mask = $conf->global->SUPPLIER_DEPOSIT_TULIP_MASK; |
|
| 155 | + else $mask = $conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
| 156 | + if (!$mask) |
|
| 157 | 157 | { |
| 158 | - $this->error='NotConfigured'; |
|
| 158 | + $this->error = 'NotConfigured'; |
|
| 159 | 159 | return 0; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | // Supplier invoices take invoice date instead of creation date for the mask |
| 163 | - $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date); |
|
| 163 | + $numFinal = get_next_value($db, $mask, 'facture_fourn', 'ref', '', $objsoc, $object->date); |
|
| 164 | 164 | |
| 165 | 165 | return $numFinal; |
| 166 | 166 | } |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | * @param string $mode 'next' for next value or 'last' for last value |
| 174 | 174 | * @return string Next free value |
| 175 | 175 | */ |
| 176 | - function getNumRef($objsoc,$objforref,$mode='next') |
|
| 176 | + function getNumRef($objsoc, $objforref, $mode = 'next') |
|
| 177 | 177 | { |
| 178 | - return $this->getNextValue($objsoc,$objforref,$mode); |
|
| 178 | + return $this->getNextValue($objsoc, $objforref, $mode); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
@@ -149,10 +149,13 @@ |
||
| 149 | 149 | { |
| 150 | 150 | $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
| 151 | 151 | } |
| 152 | + } else if (is_object($object) && $object->type == 2) { |
|
| 153 | + $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK; |
|
| 154 | + } else if (is_object($object) && $object->type == 3) { |
|
| 155 | + $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK; |
|
| 156 | + } else { |
|
| 157 | + $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
| 152 | 158 | } |
| 153 | - else if (is_object($object) && $object->type == 2) $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK; |
|
| 154 | - else if (is_object($object) && $object->type == 3) $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK; |
|
| 155 | - else $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
| 156 | 159 | if (! $mask) |
| 157 | 160 | { |
| 158 | 161 | $this->error='NotConfigured'; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | /** |
| 69 | 69 | * Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering. |
| 70 | 70 | * |
| 71 | - * @return boolean false if conflict, true if ok |
|
| 71 | + * @return false|null false if conflict, true if ok |
|
| 72 | 72 | */ |
| 73 | 73 | function canBeActivated() |
| 74 | 74 | { |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * Return next value |
| 145 | 145 | * |
| 146 | 146 | * @param Societe $objsoc Object third party |
| 147 | - * @param Object $object Object invoice |
|
| 147 | + * @param string $object Object invoice |
|
| 148 | 148 | * @param string $mode 'next' for next value or 'last' for last value |
| 149 | 149 | * @return string Value if OK, 0 if KO |
| 150 | 150 | */ |
@@ -152,9 +152,13 @@ discard block |
||
| 152 | 152 | { |
| 153 | 153 | global $db,$conf; |
| 154 | 154 | |
| 155 | - if ($object->type == 2) $prefix=$this->prefixcreditnote; |
|
| 156 | - else if ($facture->type == 3) $prefix=$this->prefixdeposit; |
|
| 157 | - else $prefix=$this->prefixinvoice; |
|
| 155 | + if ($object->type == 2) { |
|
| 156 | + $prefix=$this->prefixcreditnote; |
|
| 157 | + } else if ($facture->type == 3) { |
|
| 158 | + $prefix=$this->prefixdeposit; |
|
| 159 | + } else { |
|
| 160 | + $prefix=$this->prefixinvoice; |
|
| 161 | + } |
|
| 158 | 162 | |
| 159 | 163 | // D'abord on recupere la valeur max |
| 160 | 164 | $posindice=8; |
@@ -168,18 +172,25 @@ discard block |
||
| 168 | 172 | if ($resql) |
| 169 | 173 | { |
| 170 | 174 | $obj = $db->fetch_object($resql); |
| 171 | - if ($obj) $max = intval($obj->max); |
|
| 172 | - else $max=0; |
|
| 173 | - } |
|
| 174 | - else |
|
| 175 | + if ($obj) { |
|
| 176 | + $max = intval($obj->max); |
|
| 177 | + } else { |
|
| 178 | + $max=0; |
|
| 179 | + } |
|
| 180 | + } else |
|
| 175 | 181 | { |
| 176 | 182 | return -1; |
| 177 | 183 | } |
| 178 | 184 | |
| 179 | 185 | if ($mode == 'last') |
| 180 | 186 | { |
| 181 | - if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
| 182 | - else $num = sprintf("%04s",$max); |
|
| 187 | + if ($max >= (pow(10, 4) - 1)) { |
|
| 188 | + $num=$max; |
|
| 189 | + } |
|
| 190 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
| 191 | + else { |
|
| 192 | + $num = sprintf("%04s",$max); |
|
| 193 | + } |
|
| 183 | 194 | |
| 184 | 195 | $ref=''; |
| 185 | 196 | $sql = "SELECT ref as ref"; |
@@ -192,24 +203,32 @@ discard block |
||
| 192 | 203 | if ($resql) |
| 193 | 204 | { |
| 194 | 205 | $obj = $db->fetch_object($resql); |
| 195 | - if ($obj) $ref = $obj->ref; |
|
| 206 | + if ($obj) { |
|
| 207 | + $ref = $obj->ref; |
|
| 208 | + } |
|
| 209 | + } else { |
|
| 210 | + dol_print_error($db); |
|
| 196 | 211 | } |
| 197 | - else dol_print_error($db); |
|
| 198 | 212 | |
| 199 | 213 | return $ref; |
| 200 | - } |
|
| 201 | - else if ($mode == 'next') |
|
| 214 | + } else if ($mode == 'next') |
|
| 202 | 215 | { |
| 203 | 216 | $date=$object->date; // This is invoice date (not creation date) |
| 204 | 217 | $yymm = strftime("%y%m",$date); |
| 205 | 218 | |
| 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); |
|
| 219 | + if ($max >= (pow(10, 4) - 1)) { |
|
| 220 | + $num=$max+1; |
|
| 221 | + } |
|
| 222 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
| 223 | + else { |
|
| 224 | + $num = sprintf("%04s",$max+1); |
|
| 225 | + } |
|
| 208 | 226 | |
| 209 | 227 | dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
| 210 | 228 | return $prefix.$yymm."-".$num; |
| 229 | + } else { |
|
| 230 | + dol_print_error('','Bad parameter for getNextValue'); |
|
| 211 | 231 | } |
| 212 | - else dol_print_error('','Bad parameter for getNextValue'); |
|
| 213 | 232 | } |
| 214 | 233 | |
| 215 | 234 | |
@@ -41,28 +41,28 @@ discard block |
||
| 41 | 41 | var $prefixdeposit='SD'; |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Return description of numbering model |
|
| 46 | - * |
|
| 47 | - * @return string Text with description |
|
| 48 | - */ |
|
| 49 | - function info() |
|
| 50 | - { |
|
| 51 | - global $langs; |
|
| 44 | + /** |
|
| 45 | + * Return description of numbering model |
|
| 46 | + * |
|
| 47 | + * @return string Text with description |
|
| 48 | + */ |
|
| 49 | + function info() |
|
| 50 | + { |
|
| 51 | + global $langs; |
|
| 52 | 52 | $langs->load("bills"); |
| 53 | - return $langs->trans("CactusNumRefModelDesc1",$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit); |
|
| 54 | - } |
|
| 53 | + return $langs->trans("CactusNumRefModelDesc1",$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Returns a numbering example |
|
| 59 | - * |
|
| 60 | - * @return string Example |
|
| 61 | - */ |
|
| 62 | - function getExample() |
|
| 63 | - { |
|
| 64 | - return $this->prefixinvoice."1301-0001"; |
|
| 65 | - } |
|
| 57 | + /** |
|
| 58 | + * Returns a numbering example |
|
| 59 | + * |
|
| 60 | + * @return string Example |
|
| 61 | + */ |
|
| 62 | + function getExample() |
|
| 63 | + { |
|
| 64 | + return $this->prefixinvoice."1301-0001"; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -138,89 +138,89 @@ discard block |
||
| 138 | 138 | $this->error=$langs->trans('ErrorNumRefModel',$max); |
| 139 | 139 | return false; |
| 140 | 140 | } |
| 141 | - } |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * Return next value |
|
| 143 | + /** |
|
| 144 | + * Return next value |
|
| 145 | 145 | * |
| 146 | 146 | * @param Societe $objsoc Object third party |
| 147 | 147 | * @param Object $object Object invoice |
| 148 | - * @param string $mode 'next' for next value or 'last' for last value |
|
| 148 | + * @param string $mode 'next' for next value or 'last' for last value |
|
| 149 | 149 | * @return string Value if OK, 0 if KO |
| 150 | - */ |
|
| 151 | - function getNextValue($objsoc,$object,$mode='next') |
|
| 152 | - { |
|
| 153 | - global $db,$conf; |
|
| 154 | - |
|
| 155 | - if ($object->type == 2) $prefix=$this->prefixcreditnote; |
|
| 156 | - else if ($facture->type == 3) $prefix=$this->prefixdeposit; |
|
| 157 | - else $prefix=$this->prefixinvoice; |
|
| 158 | - |
|
| 159 | - // D'abord on recupere la valeur max |
|
| 160 | - $posindice=8; |
|
| 161 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 162 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 163 | - $sql.= " WHERE ref LIKE '".$prefix."____-%'"; |
|
| 164 | - $sql.= " AND entity = ".$conf->entity; |
|
| 165 | - |
|
| 166 | - $resql=$db->query($sql); |
|
| 167 | - dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
|
| 168 | - if ($resql) |
|
| 169 | - { |
|
| 170 | - $obj = $db->fetch_object($resql); |
|
| 171 | - if ($obj) $max = intval($obj->max); |
|
| 172 | - else $max=0; |
|
| 173 | - } |
|
| 174 | - else |
|
| 175 | - { |
|
| 176 | - return -1; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - if ($mode == 'last') |
|
| 180 | - { |
|
| 181 | - if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
| 182 | - else $num = sprintf("%04s",$max); |
|
| 183 | - |
|
| 184 | - $ref=''; |
|
| 185 | - $sql = "SELECT ref as ref"; |
|
| 186 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 187 | - $sql.= " WHERE ref LIKE '".$prefix."____-".$num."'"; |
|
| 188 | - $sql.= " AND entity = ".$conf->entity; |
|
| 189 | - |
|
| 190 | - dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
|
| 191 | - $resql=$db->query($sql); |
|
| 192 | - if ($resql) |
|
| 193 | - { |
|
| 194 | - $obj = $db->fetch_object($resql); |
|
| 195 | - if ($obj) $ref = $obj->ref; |
|
| 196 | - } |
|
| 197 | - else dol_print_error($db); |
|
| 198 | - |
|
| 199 | - return $ref; |
|
| 200 | - } |
|
| 201 | - else if ($mode == 'next') |
|
| 202 | - { |
|
| 203 | - $date=$object->date; // This is invoice date (not creation date) |
|
| 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(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
|
| 210 | - return $prefix.$yymm."-".$num; |
|
| 211 | - } |
|
| 212 | - else dol_print_error('','Bad parameter for getNextValue'); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - /** |
|
| 150 | + */ |
|
| 151 | + function getNextValue($objsoc,$object,$mode='next') |
|
| 152 | + { |
|
| 153 | + global $db,$conf; |
|
| 154 | + |
|
| 155 | + if ($object->type == 2) $prefix=$this->prefixcreditnote; |
|
| 156 | + else if ($facture->type == 3) $prefix=$this->prefixdeposit; |
|
| 157 | + else $prefix=$this->prefixinvoice; |
|
| 158 | + |
|
| 159 | + // D'abord on recupere la valeur max |
|
| 160 | + $posindice=8; |
|
| 161 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 162 | + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 163 | + $sql.= " WHERE ref LIKE '".$prefix."____-%'"; |
|
| 164 | + $sql.= " AND entity = ".$conf->entity; |
|
| 165 | + |
|
| 166 | + $resql=$db->query($sql); |
|
| 167 | + dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
|
| 168 | + if ($resql) |
|
| 169 | + { |
|
| 170 | + $obj = $db->fetch_object($resql); |
|
| 171 | + if ($obj) $max = intval($obj->max); |
|
| 172 | + else $max=0; |
|
| 173 | + } |
|
| 174 | + else |
|
| 175 | + { |
|
| 176 | + return -1; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + if ($mode == 'last') |
|
| 180 | + { |
|
| 181 | + if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
| 182 | + else $num = sprintf("%04s",$max); |
|
| 183 | + |
|
| 184 | + $ref=''; |
|
| 185 | + $sql = "SELECT ref as ref"; |
|
| 186 | + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 187 | + $sql.= " WHERE ref LIKE '".$prefix."____-".$num."'"; |
|
| 188 | + $sql.= " AND entity = ".$conf->entity; |
|
| 189 | + |
|
| 190 | + dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
|
| 191 | + $resql=$db->query($sql); |
|
| 192 | + if ($resql) |
|
| 193 | + { |
|
| 194 | + $obj = $db->fetch_object($resql); |
|
| 195 | + if ($obj) $ref = $obj->ref; |
|
| 196 | + } |
|
| 197 | + else dol_print_error($db); |
|
| 198 | + |
|
| 199 | + return $ref; |
|
| 200 | + } |
|
| 201 | + else if ($mode == 'next') |
|
| 202 | + { |
|
| 203 | + $date=$object->date; // This is invoice date (not creation date) |
|
| 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(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
|
| 210 | + return $prefix.$yymm."-".$num; |
|
| 211 | + } |
|
| 212 | + else dol_print_error('','Bad parameter for getNextValue'); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | 217 | * Return next free value |
| 218 | 218 | * |
| 219 | - * @param Societe $objsoc Object third party |
|
| 220 | - * @param string $objforref Object for number to search |
|
| 221 | - * @param string $mode 'next' for next value or 'last' for last value |
|
| 222 | - * @return string Next free value |
|
| 223 | - */ |
|
| 219 | + * @param Societe $objsoc Object third party |
|
| 220 | + * @param string $objforref Object for number to search |
|
| 221 | + * @param string $mode 'next' for next value or 'last' for last value |
|
| 222 | + * @return string Next free value |
|
| 223 | + */ |
|
| 224 | 224 | function getNumRef($objsoc,$objforref,$mode='next') |
| 225 | 225 | { |
| 226 | 226 | return $this->getNextValue($objsoc,$objforref,$mode); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * \brief File containing class for the numbering module Cactus |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_invoice/modules_facturefournisseur.php'; |
|
| 28 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php'; |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices |
| 35 | 35 | { |
| 36 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
| 36 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
| 37 | 37 | var $error = ''; |
| 38 | 38 | var $nom = 'Cactus'; |
| 39 | - var $prefixinvoice='SI'; |
|
| 40 | - var $prefixcreditnote='SA'; |
|
| 41 | - var $prefixdeposit='SD'; |
|
| 39 | + var $prefixinvoice = 'SI'; |
|
| 40 | + var $prefixcreditnote = 'SA'; |
|
| 41 | + var $prefixdeposit = 'SD'; |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | global $langs; |
| 52 | 52 | $langs->load("bills"); |
| 53 | - return $langs->trans("CactusNumRefModelDesc1",$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit); |
|
| 53 | + return $langs->trans("CactusNumRefModelDesc1", $this->prefixinvoice, $this->prefixcreditnote, $this->prefixdeposit); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -72,70 +72,70 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | function canBeActivated() |
| 74 | 74 | { |
| 75 | - global $conf,$langs,$db; |
|
| 75 | + global $conf, $langs, $db; |
|
| 76 | 76 | |
| 77 | 77 | $langs->load("bills"); |
| 78 | 78 | |
| 79 | 79 | // Check invoice num |
| 80 | - $siyymm=''; $max=''; |
|
| 80 | + $siyymm = ''; $max = ''; |
|
| 81 | 81 | |
| 82 | - $posindice=8; |
|
| 82 | + $posindice = 8; |
|
| 83 | 83 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
| 84 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 85 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'"; |
|
| 86 | - $sql.= " AND entity = ".$conf->entity; |
|
| 87 | - $resql=$db->query($sql); |
|
| 84 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 85 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'"; |
|
| 86 | + $sql .= " AND entity = ".$conf->entity; |
|
| 87 | + $resql = $db->query($sql); |
|
| 88 | 88 | if ($resql) |
| 89 | 89 | { |
| 90 | 90 | $row = $db->fetch_row($resql); |
| 91 | - if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } |
|
| 91 | + if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
| 92 | 92 | } |
| 93 | - if ($siyymm && ! preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i',$siyymm)) |
|
| 93 | + if ($siyymm && !preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i', $siyymm)) |
|
| 94 | 94 | { |
| 95 | 95 | $langs->load("errors"); |
| 96 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
| 96 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
| 97 | 97 | return false; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Check credit note num |
| 101 | - $siyymm=''; |
|
| 101 | + $siyymm = ''; |
|
| 102 | 102 | |
| 103 | - $posindice=8; |
|
| 104 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 105 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 106 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'"; |
|
| 107 | - $sql.= " AND entity = ".$conf->entity; |
|
| 103 | + $posindice = 8; |
|
| 104 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 105 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 106 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'"; |
|
| 107 | + $sql .= " AND entity = ".$conf->entity; |
|
| 108 | 108 | |
| 109 | - $resql=$db->query($sql); |
|
| 109 | + $resql = $db->query($sql); |
|
| 110 | 110 | if ($resql) |
| 111 | 111 | { |
| 112 | 112 | $row = $db->fetch_row($resql); |
| 113 | - if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } |
|
| 113 | + if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
| 114 | 114 | } |
| 115 | - if ($siyymm && ! preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i',$siyymm)) |
|
| 115 | + if ($siyymm && !preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i', $siyymm)) |
|
| 116 | 116 | { |
| 117 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
| 117 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // Check deposit num |
| 122 | - $siyymm=''; |
|
| 122 | + $siyymm = ''; |
|
| 123 | 123 | |
| 124 | - $posindice=8; |
|
| 125 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 126 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 127 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'"; |
|
| 128 | - $sql.= " AND entity = ".$conf->entity; |
|
| 124 | + $posindice = 8; |
|
| 125 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 126 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 127 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'"; |
|
| 128 | + $sql .= " AND entity = ".$conf->entity; |
|
| 129 | 129 | |
| 130 | - $resql=$db->query($sql); |
|
| 130 | + $resql = $db->query($sql); |
|
| 131 | 131 | if ($resql) |
| 132 | 132 | { |
| 133 | 133 | $row = $db->fetch_row($resql); |
| 134 | - if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } |
|
| 134 | + if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
| 135 | 135 | } |
| 136 | - if ($siyymm && ! preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i',$siyymm)) |
|
| 136 | + if ($siyymm && !preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i', $siyymm)) |
|
| 137 | 137 | { |
| 138 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
| 138 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
| 139 | 139 | return false; |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -148,28 +148,28 @@ discard block |
||
| 148 | 148 | * @param string $mode 'next' for next value or 'last' for last value |
| 149 | 149 | * @return string Value if OK, 0 if KO |
| 150 | 150 | */ |
| 151 | - function getNextValue($objsoc,$object,$mode='next') |
|
| 151 | + function getNextValue($objsoc, $object, $mode = 'next') |
|
| 152 | 152 | { |
| 153 | - global $db,$conf; |
|
| 153 | + global $db, $conf; |
|
| 154 | 154 | |
| 155 | - if ($object->type == 2) $prefix=$this->prefixcreditnote; |
|
| 156 | - else if ($facture->type == 3) $prefix=$this->prefixdeposit; |
|
| 157 | - else $prefix=$this->prefixinvoice; |
|
| 155 | + if ($object->type == 2) $prefix = $this->prefixcreditnote; |
|
| 156 | + else if ($facture->type == 3) $prefix = $this->prefixdeposit; |
|
| 157 | + else $prefix = $this->prefixinvoice; |
|
| 158 | 158 | |
| 159 | 159 | // D'abord on recupere la valeur max |
| 160 | - $posindice=8; |
|
| 161 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 162 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 163 | - $sql.= " WHERE ref LIKE '".$prefix."____-%'"; |
|
| 164 | - $sql.= " AND entity = ".$conf->entity; |
|
| 160 | + $posindice = 8; |
|
| 161 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 162 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 163 | + $sql .= " WHERE ref LIKE '".$prefix."____-%'"; |
|
| 164 | + $sql .= " AND entity = ".$conf->entity; |
|
| 165 | 165 | |
| 166 | - $resql=$db->query($sql); |
|
| 166 | + $resql = $db->query($sql); |
|
| 167 | 167 | dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
| 168 | 168 | if ($resql) |
| 169 | 169 | { |
| 170 | 170 | $obj = $db->fetch_object($resql); |
| 171 | 171 | if ($obj) $max = intval($obj->max); |
| 172 | - else $max=0; |
|
| 172 | + else $max = 0; |
|
| 173 | 173 | } |
| 174 | 174 | else |
| 175 | 175 | { |
@@ -178,17 +178,17 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | if ($mode == 'last') |
| 180 | 180 | { |
| 181 | - if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
| 182 | - else $num = sprintf("%04s",$max); |
|
| 181 | + if ($max >= (pow(10, 4) - 1)) $num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
| 182 | + else $num = sprintf("%04s", $max); |
|
| 183 | 183 | |
| 184 | - $ref=''; |
|
| 184 | + $ref = ''; |
|
| 185 | 185 | $sql = "SELECT ref as ref"; |
| 186 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 187 | - $sql.= " WHERE ref LIKE '".$prefix."____-".$num."'"; |
|
| 188 | - $sql.= " AND entity = ".$conf->entity; |
|
| 186 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
| 187 | + $sql .= " WHERE ref LIKE '".$prefix."____-".$num."'"; |
|
| 188 | + $sql .= " AND entity = ".$conf->entity; |
|
| 189 | 189 | |
| 190 | 190 | dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
| 191 | - $resql=$db->query($sql); |
|
| 191 | + $resql = $db->query($sql); |
|
| 192 | 192 | if ($resql) |
| 193 | 193 | { |
| 194 | 194 | $obj = $db->fetch_object($resql); |
@@ -200,16 +200,16 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | else if ($mode == 'next') |
| 202 | 202 | { |
| 203 | - $date=$object->date; // This is invoice date (not creation date) |
|
| 204 | - $yymm = strftime("%y%m",$date); |
|
| 203 | + $date = $object->date; // This is invoice date (not creation 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(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
| 210 | 210 | return $prefix.$yymm."-".$num; |
| 211 | 211 | } |
| 212 | - else dol_print_error('','Bad parameter for getNextValue'); |
|
| 212 | + else dol_print_error('', 'Bad parameter for getNextValue'); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | * @param string $mode 'next' for next value or 'last' for last value |
| 222 | 222 | * @return string Next free value |
| 223 | 223 | */ |
| 224 | - function getNumRef($objsoc,$objforref,$mode='next') |
|
| 224 | + function getNumRef($objsoc, $objforref, $mode = 'next') |
|
| 225 | 225 | { |
| 226 | - return $this->getNextValue($objsoc,$objforref,$mode); |
|
| 226 | + return $this->getNextValue($objsoc, $objforref, $mode); |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * @param int $entrepot_id Id of warehouse |
| 366 | 366 | * @param int $origin_line_id Id of source line |
| 367 | 367 | * @param int $qty Quantity |
| 368 | - * @param array $array_options extrafields array |
|
| 368 | + * @param integer $array_options extrafields array |
|
| 369 | 369 | * @return int <0 if KO, line_id if OK |
| 370 | 370 | */ |
| 371 | 371 | function create_line($entrepot_id, $origin_line_id, $qty,$array_options=0) |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | * Create the detail (eat-by date) of the expedition line |
| 420 | 420 | * |
| 421 | 421 | * @param object $line_ext full line informations |
| 422 | - * @param array $array_options extrafields array |
|
| 422 | + * @param integer $array_options extrafields array |
|
| 423 | 423 | * @return int <0 if KO, >0 if OK |
| 424 | 424 | */ |
| 425 | 425 | function create_line_batch($line_ext,$array_options=0) |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | * @param int $entrepot_id Id of warehouse |
| 858 | 858 | * @param int $id Id of source line (order line) |
| 859 | 859 | * @param int $qty Quantity |
| 860 | - * @param array $array_options extrafields array |
|
| 860 | + * @param integer $array_options extrafields array |
|
| 861 | 861 | * @return int <0 if KO, >0 if OK |
| 862 | 862 | */ |
| 863 | 863 | function addline($entrepot_id, $id, $qty,$array_options=0) |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | * Add a shipment line with batch record |
| 928 | 928 | * |
| 929 | 929 | * @param array $dbatch Array of value (key 'detail' -> Array, key 'qty' total quantity for line, key ix_l : original line index) |
| 930 | - * @param array $array_options extrafields array |
|
| 930 | + * @param integer $array_options extrafields array |
|
| 931 | 931 | * @return int <0 if KO, >0 if OK |
| 932 | 932 | */ |
| 933 | 933 | function addline_batch($dbatch,$array_options=0) |
@@ -2268,11 +2268,11 @@ |
||
| 2268 | 2268 | */ |
| 2269 | 2269 | var $libelle; |
| 2270 | 2270 | |
| 2271 | - /** |
|
| 2272 | - * Constructor |
|
| 2273 | - * |
|
| 2274 | - * @param DoliDB $db Database handler |
|
| 2275 | - */ |
|
| 2271 | + /** |
|
| 2272 | + * Constructor |
|
| 2273 | + * |
|
| 2274 | + * @param DoliDB $db Database handler |
|
| 2275 | + */ |
|
| 2276 | 2276 | function __construct($db) |
| 2277 | 2277 | { |
| 2278 | 2278 | $this->db=$db; |
@@ -33,9 +33,15 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; |
| 35 | 35 | require_once DOL_DOCUMENT_ROOT."/core/class/commonobjectline.class.php"; |
| 36 | -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 37 | -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 38 | -if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; |
|
| 36 | +if (! empty($conf->propal->enabled)) { |
|
| 37 | + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 38 | +} |
|
| 39 | +if (! empty($conf->commande->enabled)) { |
|
| 40 | + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 41 | +} |
|
| 42 | +if (! empty($conf->productbatch->enabled)) { |
|
| 43 | + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; |
|
| 44 | +} |
|
| 39 | 45 | |
| 40 | 46 | |
| 41 | 47 | /** |
@@ -178,14 +184,12 @@ discard block |
||
| 178 | 184 | if ( $numref != "") |
| 179 | 185 | { |
| 180 | 186 | return $numref; |
| 181 | - } |
|
| 182 | - else |
|
| 187 | + } else |
|
| 183 | 188 | { |
| 184 | 189 | dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); |
| 185 | 190 | return ""; |
| 186 | 191 | } |
| 187 | - } |
|
| 188 | - else |
|
| 192 | + } else |
|
| 189 | 193 | { |
| 190 | 194 | print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_NUMBER_NotDefined"); |
| 191 | 195 | return ""; |
@@ -211,7 +215,9 @@ discard block |
||
| 211 | 215 | // Clean parameters |
| 212 | 216 | $this->brouillon = 1; |
| 213 | 217 | $this->tracking_number = dol_sanitizeFileName($this->tracking_number); |
| 214 | - if (empty($this->fk_project)) $this->fk_project = 0; |
|
| 218 | + if (empty($this->fk_project)) { |
|
| 219 | + $this->fk_project = 0; |
|
| 220 | + } |
|
| 215 | 221 | |
| 216 | 222 | $this->user = $user; |
| 217 | 223 | |
@@ -292,8 +298,7 @@ discard block |
||
| 292 | 298 | { |
| 293 | 299 | $error++; |
| 294 | 300 | } |
| 295 | - } |
|
| 296 | - else |
|
| 301 | + } else |
|
| 297 | 302 | { // with batch management |
| 298 | 303 | if (! $this->create_line_batch($this->lines[$i],$this->lines[$i]->array_options) > 0) |
| 299 | 304 | { |
@@ -318,16 +323,19 @@ discard block |
||
| 318 | 323 | $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 319 | 324 | if (empty($reshook)) |
| 320 | 325 | { |
| 321 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 326 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 327 | + // For avoid conflicts if trigger used |
|
| 322 | 328 | { |
| 323 | 329 | $result=$this->insertExtraFields(); |
| 330 | + } |
|
| 324 | 331 | if ($result < 0) |
| 325 | 332 | { |
| 326 | 333 | $error++; |
| 327 | 334 | } |
| 328 | 335 | } |
| 336 | + } else if ($reshook < 0) { |
|
| 337 | + $error++; |
|
| 329 | 338 | } |
| 330 | - else if ($reshook < 0) $error++; |
|
| 331 | 339 | |
| 332 | 340 | if (! $error && ! $notrigger) |
| 333 | 341 | { |
@@ -340,8 +348,7 @@ discard block |
||
| 340 | 348 | { |
| 341 | 349 | $this->db->commit(); |
| 342 | 350 | return $this->id; |
| 343 | - } |
|
| 344 | - else |
|
| 351 | + } else |
|
| 345 | 352 | { |
| 346 | 353 | foreach($this->errors as $errmsg) |
| 347 | 354 | { |
@@ -352,24 +359,21 @@ discard block |
||
| 352 | 359 | return -1*$error; |
| 353 | 360 | } |
| 354 | 361 | |
| 355 | - } |
|
| 356 | - else |
|
| 362 | + } else |
|
| 357 | 363 | { |
| 358 | 364 | $error++; |
| 359 | 365 | $this->error=$this->db->lasterror()." - sql=$sql"; |
| 360 | 366 | $this->db->rollback(); |
| 361 | 367 | return -3; |
| 362 | 368 | } |
| 363 | - } |
|
| 364 | - else |
|
| 369 | + } else |
|
| 365 | 370 | { |
| 366 | 371 | $error++; |
| 367 | 372 | $this->error=$this->db->lasterror()." - sql=$sql"; |
| 368 | 373 | $this->db->rollback(); |
| 369 | 374 | return -2; |
| 370 | 375 | } |
| 371 | - } |
|
| 372 | - else |
|
| 376 | + } else |
|
| 373 | 377 | { |
| 374 | 378 | $error++; |
| 375 | 379 | $this->error=$this->db->error()." - sql=$sql"; |
@@ -431,24 +435,28 @@ discard block |
||
| 431 | 435 | if (($line_id = $this->create_line($stockLocation,$line_ext->origin_line_id,$qty,$array_options)) < 0) |
| 432 | 436 | { |
| 433 | 437 | $error++; |
| 434 | - } |
|
| 435 | - else |
|
| 438 | + } else |
|
| 436 | 439 | { |
| 437 | 440 | // create shipment batch lines for stockLocation |
| 438 | 441 | foreach ($tab as $detbatch) |
| 439 | 442 | { |
| 440 | 443 | if ($detbatch->entrepot_id == $stockLocation){ |
| 441 | - if (! ($detbatch->create($line_id) >0)) // Create an expeditionlinebatch |
|
| 444 | + if (! ($detbatch->create($line_id) >0)) { |
|
| 445 | + // Create an expeditionlinebatch |
|
| 442 | 446 | { |
| 443 | 447 | $error++; |
| 444 | 448 | } |
| 449 | + } |
|
| 445 | 450 | } |
| 446 | 451 | } |
| 447 | 452 | } |
| 448 | 453 | } |
| 449 | 454 | |
| 450 | - if (! $error) return 1; |
|
| 451 | - else return -1; |
|
| 455 | + if (! $error) { |
|
| 456 | + return 1; |
|
| 457 | + } else { |
|
| 458 | + return -1; |
|
| 459 | + } |
|
| 452 | 460 | } |
| 453 | 461 | |
| 454 | 462 | /** |
@@ -465,7 +473,9 @@ discard block |
||
| 465 | 473 | global $conf; |
| 466 | 474 | |
| 467 | 475 | // Check parameters |
| 468 | - if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; |
|
| 476 | + if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) { |
|
| 477 | + return -1; |
|
| 478 | + } |
|
| 469 | 479 | |
| 470 | 480 | $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.billed"; |
| 471 | 481 | $sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; |
@@ -479,10 +489,18 @@ discard block |
||
| 479 | 489 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; |
| 480 | 490 | $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; |
| 481 | 491 | $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; |
| 482 | - if ($id) $sql.= " AND e.rowid=".$id; |
|
| 483 | - if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'"; |
|
| 484 | - if ($ref_ext) $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; |
|
| 485 | - if ($ref_int) $sql.= " AND e.ref_int='".$this->db->escape($ref_int)."'"; |
|
| 492 | + if ($id) { |
|
| 493 | + $sql.= " AND e.rowid=".$id; |
|
| 494 | + } |
|
| 495 | + if ($ref) { |
|
| 496 | + $sql.= " AND e.ref='".$this->db->escape($ref)."'"; |
|
| 497 | + } |
|
| 498 | + if ($ref_ext) { |
|
| 499 | + $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; |
|
| 500 | + } |
|
| 501 | + if ($ref_int) { |
|
| 502 | + $sql.= " AND e.ref_int='".$this->db->escape($ref_int)."'"; |
|
| 503 | + } |
|
| 486 | 504 | |
| 487 | 505 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
| 488 | 506 | $result = $this->db->query($sql); |
@@ -537,7 +555,9 @@ discard block |
||
| 537 | 555 | |
| 538 | 556 | $this->db->free($result); |
| 539 | 557 | |
| 540 | - if ($this->statut == 0) $this->brouillon = 1; |
|
| 558 | + if ($this->statut == 0) { |
|
| 559 | + $this->brouillon = 1; |
|
| 560 | + } |
|
| 541 | 561 | |
| 542 | 562 | // Tracking url |
| 543 | 563 | $this->GetUrlTrackingStatus($obj->tracking_number); |
@@ -564,15 +584,13 @@ discard block |
||
| 564 | 584 | } |
| 565 | 585 | |
| 566 | 586 | return 1; |
| 567 | - } |
|
| 568 | - else |
|
| 587 | + } else |
|
| 569 | 588 | { |
| 570 | 589 | dol_syslog(get_class($this).'::Fetch no expedition found', LOG_ERR); |
| 571 | 590 | $this->error='Delivery with id '.$id.' not found'; |
| 572 | 591 | return 0; |
| 573 | 592 | } |
| 574 | - } |
|
| 575 | - else |
|
| 593 | + } else |
|
| 576 | 594 | { |
| 577 | 595 | $this->error=$this->db->error(); |
| 578 | 596 | return -1; |
@@ -621,11 +639,12 @@ discard block |
||
| 621 | 639 | $result=$soc->set_as_client(); |
| 622 | 640 | |
| 623 | 641 | // Define new ref |
| 624 | - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life |
|
| 642 | + if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { |
|
| 643 | + // empty should not happened, but when it occurs, the test save life |
|
| 625 | 644 | { |
| 626 | 645 | $numref = $this->getNextNumRef($soc); |
| 627 | 646 | } |
| 628 | - else |
|
| 647 | + } else |
|
| 629 | 648 | { |
| 630 | 649 | $numref = "EXP".$this->id; |
| 631 | 650 | } |
@@ -677,12 +696,13 @@ discard block |
||
| 677 | 696 | if (empty($obj->edbrowid)) |
| 678 | 697 | { |
| 679 | 698 | $qty = $obj->qty; |
| 680 | - } |
|
| 681 | - else |
|
| 699 | + } else |
|
| 682 | 700 | { |
| 683 | 701 | $qty = $obj->edbqty; |
| 684 | 702 | } |
| 685 | - if ($qty <= 0) continue; |
|
| 703 | + if ($qty <= 0) { |
|
| 704 | + continue; |
|
| 705 | + } |
|
| 686 | 706 | dol_syslog(get_class($this)."::valid movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid); |
| 687 | 707 | |
| 688 | 708 | //var_dump($this->lines[$i]); |
@@ -701,8 +721,7 @@ discard block |
||
| 701 | 721 | $this->errors = array_merge($this->errors, $mouvS->errors); |
| 702 | 722 | break; |
| 703 | 723 | } |
| 704 | - } |
|
| 705 | - else |
|
| 724 | + } else |
|
| 706 | 725 | { |
| 707 | 726 | // line with batch detail |
| 708 | 727 | |
@@ -717,8 +736,7 @@ discard block |
||
| 717 | 736 | } |
| 718 | 737 | } |
| 719 | 738 | } |
| 720 | - } |
|
| 721 | - else |
|
| 739 | + } else |
|
| 722 | 740 | { |
| 723 | 741 | $this->db->rollback(); |
| 724 | 742 | $this->error=$this->db->error(); |
@@ -789,8 +807,7 @@ discard block |
||
| 789 | 807 | { |
| 790 | 808 | $this->db->commit(); |
| 791 | 809 | return 1; |
| 792 | - } |
|
| 793 | - else |
|
| 810 | + } else |
|
| 794 | 811 | { |
| 795 | 812 | foreach($this->errors as $errmsg) |
| 796 | 813 | { |
@@ -824,16 +841,17 @@ discard block |
||
| 824 | 841 | if ($result > 0) |
| 825 | 842 | { |
| 826 | 843 | return $result; |
| 827 | - } |
|
| 828 | - else |
|
| 844 | + } else |
|
| 829 | 845 | { |
| 830 | 846 | $this->error=$delivery->error; |
| 831 | 847 | return $result; |
| 832 | 848 | } |
| 849 | + } else { |
|
| 850 | + return 0; |
|
| 833 | 851 | } |
| 834 | - else return 0; |
|
| 852 | + } else { |
|
| 853 | + return 0; |
|
| 835 | 854 | } |
| 836 | - else return 0; |
|
| 837 | 855 | } |
| 838 | 856 | |
| 839 | 857 | /** |
@@ -881,9 +899,9 @@ discard block |
||
| 881 | 899 | if ($entrepot_id > 0) { |
| 882 | 900 | $product->load_stock('warehouseopen'); |
| 883 | 901 | $product_stock = $product->stock_warehouse[$entrepot_id]->real; |
| 902 | + } else { |
|
| 903 | + $product_stock = $product->stock_reel; |
|
| 884 | 904 | } |
| 885 | - else |
|
| 886 | - $product_stock = $product->stock_reel; |
|
| 887 | 905 | |
| 888 | 906 | $product_type=$product->type; |
| 889 | 907 | if ($product_type == 0 && $product_stock < $qty) |
@@ -904,8 +922,10 @@ discard block |
||
| 904 | 922 | } |
| 905 | 923 | |
| 906 | 924 | // extrafields |
| 907 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used |
|
| 925 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) { |
|
| 926 | + // For avoid conflicts if trigger used |
|
| 908 | 927 | $line->array_options = $array_options; |
| 928 | + } |
|
| 909 | 929 | |
| 910 | 930 | $this->lines[$num] = $line; |
| 911 | 931 | } |
@@ -969,8 +989,10 @@ discard block |
||
| 969 | 989 | $line->detail_batch=$tab; |
| 970 | 990 | |
| 971 | 991 | // extrafields |
| 972 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used |
|
| 992 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) { |
|
| 993 | + // For avoid conflicts if trigger used |
|
| 973 | 994 | $line->array_options = $array_options; |
| 995 | + } |
|
| 974 | 996 | |
| 975 | 997 | //var_dump($line); |
| 976 | 998 | $this->lines[$num] = $line; |
@@ -992,25 +1014,63 @@ discard block |
||
| 992 | 1014 | |
| 993 | 1015 | // Clean parameters |
| 994 | 1016 | |
| 995 | - if (isset($this->ref)) $this->ref=trim($this->ref); |
|
| 996 | - if (isset($this->entity)) $this->entity=trim($this->entity); |
|
| 997 | - if (isset($this->ref_customer)) $this->ref_customer=trim($this->ref_customer); |
|
| 998 | - if (isset($this->socid)) $this->socid=trim($this->socid); |
|
| 999 | - if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); |
|
| 1000 | - if (isset($this->fk_user_valid)) $this->fk_user_valid=trim($this->fk_user_valid); |
|
| 1001 | - if (isset($this->fk_delivery_address)) $this->fk_delivery_address=trim($this->fk_delivery_address); |
|
| 1002 | - if (isset($this->shipping_method_id)) $this->shipping_method_id=trim($this->shipping_method_id); |
|
| 1003 | - if (isset($this->tracking_number)) $this->tracking_number=trim($this->tracking_number); |
|
| 1004 | - if (isset($this->statut)) $this->statut=(int) $this->statut; |
|
| 1005 | - if (isset($this->trueDepth)) $this->trueDepth=trim($this->trueDepth); |
|
| 1006 | - if (isset($this->trueWidth)) $this->trueWidth=trim($this->trueWidth); |
|
| 1007 | - if (isset($this->trueHeight)) $this->trueHeight=trim($this->trueHeight); |
|
| 1008 | - if (isset($this->size_units)) $this->size_units=trim($this->size_units); |
|
| 1009 | - if (isset($this->weight_units)) $this->weight_units=trim($this->weight_units); |
|
| 1010 | - if (isset($this->trueWeight)) $this->weight=trim($this->trueWeight); |
|
| 1011 | - if (isset($this->note_private)) $this->note=trim($this->note_private); |
|
| 1012 | - if (isset($this->note_public)) $this->note=trim($this->note_public); |
|
| 1013 | - if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); |
|
| 1017 | + if (isset($this->ref)) { |
|
| 1018 | + $this->ref=trim($this->ref); |
|
| 1019 | + } |
|
| 1020 | + if (isset($this->entity)) { |
|
| 1021 | + $this->entity=trim($this->entity); |
|
| 1022 | + } |
|
| 1023 | + if (isset($this->ref_customer)) { |
|
| 1024 | + $this->ref_customer=trim($this->ref_customer); |
|
| 1025 | + } |
|
| 1026 | + if (isset($this->socid)) { |
|
| 1027 | + $this->socid=trim($this->socid); |
|
| 1028 | + } |
|
| 1029 | + if (isset($this->fk_user_author)) { |
|
| 1030 | + $this->fk_user_author=trim($this->fk_user_author); |
|
| 1031 | + } |
|
| 1032 | + if (isset($this->fk_user_valid)) { |
|
| 1033 | + $this->fk_user_valid=trim($this->fk_user_valid); |
|
| 1034 | + } |
|
| 1035 | + if (isset($this->fk_delivery_address)) { |
|
| 1036 | + $this->fk_delivery_address=trim($this->fk_delivery_address); |
|
| 1037 | + } |
|
| 1038 | + if (isset($this->shipping_method_id)) { |
|
| 1039 | + $this->shipping_method_id=trim($this->shipping_method_id); |
|
| 1040 | + } |
|
| 1041 | + if (isset($this->tracking_number)) { |
|
| 1042 | + $this->tracking_number=trim($this->tracking_number); |
|
| 1043 | + } |
|
| 1044 | + if (isset($this->statut)) { |
|
| 1045 | + $this->statut=(int) $this->statut; |
|
| 1046 | + } |
|
| 1047 | + if (isset($this->trueDepth)) { |
|
| 1048 | + $this->trueDepth=trim($this->trueDepth); |
|
| 1049 | + } |
|
| 1050 | + if (isset($this->trueWidth)) { |
|
| 1051 | + $this->trueWidth=trim($this->trueWidth); |
|
| 1052 | + } |
|
| 1053 | + if (isset($this->trueHeight)) { |
|
| 1054 | + $this->trueHeight=trim($this->trueHeight); |
|
| 1055 | + } |
|
| 1056 | + if (isset($this->size_units)) { |
|
| 1057 | + $this->size_units=trim($this->size_units); |
|
| 1058 | + } |
|
| 1059 | + if (isset($this->weight_units)) { |
|
| 1060 | + $this->weight_units=trim($this->weight_units); |
|
| 1061 | + } |
|
| 1062 | + if (isset($this->trueWeight)) { |
|
| 1063 | + $this->weight=trim($this->trueWeight); |
|
| 1064 | + } |
|
| 1065 | + if (isset($this->note_private)) { |
|
| 1066 | + $this->note=trim($this->note_private); |
|
| 1067 | + } |
|
| 1068 | + if (isset($this->note_public)) { |
|
| 1069 | + $this->note=trim($this->note_public); |
|
| 1070 | + } |
|
| 1071 | + if (isset($this->modelpdf)) { |
|
| 1072 | + $this->modelpdf=trim($this->modelpdf); |
|
| 1073 | + } |
|
| 1014 | 1074 | |
| 1015 | 1075 | |
| 1016 | 1076 | |
@@ -1074,8 +1134,7 @@ discard block |
||
| 1074 | 1134 | } |
| 1075 | 1135 | $this->db->rollback(); |
| 1076 | 1136 | return -1*$error; |
| 1077 | - } |
|
| 1078 | - else |
|
| 1137 | + } else |
|
| 1079 | 1138 | { |
| 1080 | 1139 | $this->db->commit(); |
| 1081 | 1140 | return 1; |
@@ -1155,8 +1214,7 @@ discard block |
||
| 1155 | 1214 | $error++;$this->errors=$this->errors + $mouvS->errors; |
| 1156 | 1215 | break; |
| 1157 | 1216 | } |
| 1158 | - } |
|
| 1159 | - else |
|
| 1217 | + } else |
|
| 1160 | 1218 | { |
| 1161 | 1219 | // We increment stock of batches |
| 1162 | 1220 | // We use warehouse selected for each line |
@@ -1169,11 +1227,13 @@ discard block |
||
| 1169 | 1227 | break; |
| 1170 | 1228 | } |
| 1171 | 1229 | } |
| 1172 | - if ($error) break; // break for loop incase of error |
|
| 1230 | + if ($error) { |
|
| 1231 | + break; |
|
| 1232 | + } |
|
| 1233 | + // break for loop incase of error |
|
| 1173 | 1234 | } |
| 1174 | 1235 | } |
| 1175 | - } |
|
| 1176 | - else |
|
| 1236 | + } else |
|
| 1177 | 1237 | { |
| 1178 | 1238 | $error++;$this->errors[]="Error ".$this->db->lasterror(); |
| 1179 | 1239 | } |
@@ -1197,7 +1257,9 @@ discard block |
||
| 1197 | 1257 | { |
| 1198 | 1258 | // Delete linked object |
| 1199 | 1259 | $res = $this->deleteObjectLinked(); |
| 1200 | - if ($res < 0) $error++; |
|
| 1260 | + if ($res < 0) { |
|
| 1261 | + $error++; |
|
| 1262 | + } |
|
| 1201 | 1263 | |
| 1202 | 1264 | if (! $error) |
| 1203 | 1265 | { |
@@ -1215,10 +1277,12 @@ discard block |
||
| 1215 | 1277 | { |
| 1216 | 1278 | $this->fetch_origin(); |
| 1217 | 1279 | $origin=$this->origin; |
| 1218 | - if ($this->$origin->statut == Commande::STATUS_SHIPMENTONPROCESS) // If order source of shipment is "shipment in progress" |
|
| 1280 | + if ($this->$origin->statut == Commande::STATUS_SHIPMENTONPROCESS) { |
|
| 1281 | + // If order source of shipment is "shipment in progress" |
|
| 1219 | 1282 | { |
| 1220 | 1283 | // Check if there is no more shipment. If not, we can move back status of order to "validated" instead of "shipment in progress" |
| 1221 | 1284 | $this->$origin->loadExpeditions(); |
| 1285 | + } |
|
| 1222 | 1286 | //var_dump($this->$origin->expeditions);exit; |
| 1223 | 1287 | if (count($this->$origin->expeditions) <= 0) |
| 1224 | 1288 | { |
@@ -1255,35 +1319,30 @@ discard block |
||
| 1255 | 1319 | } |
| 1256 | 1320 | |
| 1257 | 1321 | return 1; |
| 1258 | - } |
|
| 1259 | - else |
|
| 1322 | + } else |
|
| 1260 | 1323 | { |
| 1261 | 1324 | $this->db->rollback(); |
| 1262 | 1325 | return -1; |
| 1263 | 1326 | } |
| 1264 | - } |
|
| 1265 | - else |
|
| 1327 | + } else |
|
| 1266 | 1328 | { |
| 1267 | 1329 | $this->error=$this->db->lasterror()." - sql=$sql"; |
| 1268 | 1330 | $this->db->rollback(); |
| 1269 | 1331 | return -3; |
| 1270 | 1332 | } |
| 1271 | - } |
|
| 1272 | - else |
|
| 1333 | + } else |
|
| 1273 | 1334 | { |
| 1274 | 1335 | $this->error=$this->db->lasterror()." - sql=$sql"; |
| 1275 | 1336 | $this->db->rollback(); |
| 1276 | 1337 | return -2; |
| 1277 | 1338 | } |
| 1278 | - } |
|
| 1279 | - else |
|
| 1339 | + } else |
|
| 1280 | 1340 | { |
| 1281 | 1341 | $this->error=$this->db->lasterror()." - sql=$sql"; |
| 1282 | 1342 | $this->db->rollback(); |
| 1283 | 1343 | return -1; |
| 1284 | 1344 | } |
| 1285 | - } |
|
| 1286 | - else |
|
| 1345 | + } else |
|
| 1287 | 1346 | { |
| 1288 | 1347 | $this->db->rollback(); |
| 1289 | 1348 | return -1; |
@@ -1435,8 +1494,7 @@ discard block |
||
| 1435 | 1494 | if ($originline != $obj->fk_origin_line) |
| 1436 | 1495 | { |
| 1437 | 1496 | $line->detail_batch = $newdetailbatch; |
| 1438 | - } |
|
| 1439 | - else |
|
| 1497 | + } else |
|
| 1440 | 1498 | { |
| 1441 | 1499 | $line->detail_batch = array_merge($line->detail_batch, $newdetailbatch); |
| 1442 | 1500 | } |
@@ -1447,8 +1505,7 @@ discard block |
||
| 1447 | 1505 | { |
| 1448 | 1506 | $this->lines[$lineindex] = $line; |
| 1449 | 1507 | $lineindex++; |
| 1450 | - } |
|
| 1451 | - else |
|
| 1508 | + } else |
|
| 1452 | 1509 | { |
| 1453 | 1510 | $line->total_ht += $tabprice[0]; |
| 1454 | 1511 | $line->total_localtax1 += $tabprice[9]; |
@@ -1462,8 +1519,7 @@ discard block |
||
| 1462 | 1519 | } |
| 1463 | 1520 | $this->db->free($resql); |
| 1464 | 1521 | return 1; |
| 1465 | - } |
|
| 1466 | - else |
|
| 1522 | + } else |
|
| 1467 | 1523 | { |
| 1468 | 1524 | $this->error=$this->db->error(); |
| 1469 | 1525 | return -3; |
@@ -1496,14 +1552,12 @@ discard block |
||
| 1496 | 1552 | |
| 1497 | 1553 | $this->db->commit(); |
| 1498 | 1554 | return 1; |
| 1499 | - } |
|
| 1500 | - else |
|
| 1555 | + } else |
|
| 1501 | 1556 | { |
| 1502 | 1557 | $this->db->rollback(); |
| 1503 | 1558 | return -1; |
| 1504 | 1559 | } |
| 1505 | - } |
|
| 1506 | - else |
|
| 1560 | + } else |
|
| 1507 | 1561 | { |
| 1508 | 1562 | $this->error='ErrorDeleteLineNotAllowedByObjectStatus'; |
| 1509 | 1563 | return -2; |
@@ -1533,14 +1587,20 @@ discard block |
||
| 1533 | 1587 | |
| 1534 | 1588 | $url = DOL_URL_ROOT.'/expedition/card.php?id='.$this->id; |
| 1535 | 1589 | |
| 1536 | - if ($short) return $url; |
|
| 1590 | + if ($short) { |
|
| 1591 | + return $url; |
|
| 1592 | + } |
|
| 1537 | 1593 | |
| 1538 | 1594 | if ($option !== 'nolink') |
| 1539 | 1595 | { |
| 1540 | 1596 | // Add param to save lastsearch_values or not |
| 1541 | 1597 | $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
| 1542 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 1543 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 1598 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) { |
|
| 1599 | + $add_save_lastsearch_values=1; |
|
| 1600 | + } |
|
| 1601 | + if ($add_save_lastsearch_values) { |
|
| 1602 | + $url.='&save_lastsearch_values=1'; |
|
| 1603 | + } |
|
| 1544 | 1604 | } |
| 1545 | 1605 | |
| 1546 | 1606 | $linkclose=''; |
@@ -1559,8 +1619,12 @@ discard block |
||
| 1559 | 1619 | $linkend='</a>'; |
| 1560 | 1620 | |
| 1561 | 1621 | $result .= $linkstart; |
| 1562 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
| 1563 | - if ($withpicto != 2) $result.= $this->ref; |
|
| 1622 | + if ($withpicto) { |
|
| 1623 | + $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
| 1624 | + } |
|
| 1625 | + if ($withpicto != 2) { |
|
| 1626 | + $result.= $this->ref; |
|
| 1627 | + } |
|
| 1564 | 1628 | $result .= $linkend; |
| 1565 | 1629 | |
| 1566 | 1630 | return $result; |
@@ -1590,33 +1654,63 @@ discard block |
||
| 1590 | 1654 | |
| 1591 | 1655 | if ($mode==0) |
| 1592 | 1656 | { |
| 1593 | - if ($statut==0) return $langs->trans($this->statuts[$statut]); |
|
| 1594 | - if ($statut==1) return $langs->trans($this->statuts[$statut]); |
|
| 1595 | - if ($statut==2) return $langs->trans($this->statuts[$statut]); |
|
| 1657 | + if ($statut==0) { |
|
| 1658 | + return $langs->trans($this->statuts[$statut]); |
|
| 1659 | + } |
|
| 1660 | + if ($statut==1) { |
|
| 1661 | + return $langs->trans($this->statuts[$statut]); |
|
| 1662 | + } |
|
| 1663 | + if ($statut==2) { |
|
| 1664 | + return $langs->trans($this->statuts[$statut]); |
|
| 1665 | + } |
|
| 1596 | 1666 | } |
| 1597 | 1667 | if ($mode==1) |
| 1598 | 1668 | { |
| 1599 | - if ($statut==0) return $langs->trans($this->statutshorts[$statut]); |
|
| 1600 | - if ($statut==1) return $langs->trans($this->statutshorts[$statut]); |
|
| 1601 | - if ($statut==2) return $langs->trans($this->statutshorts[$statut]); |
|
| 1669 | + if ($statut==0) { |
|
| 1670 | + return $langs->trans($this->statutshorts[$statut]); |
|
| 1671 | + } |
|
| 1672 | + if ($statut==1) { |
|
| 1673 | + return $langs->trans($this->statutshorts[$statut]); |
|
| 1674 | + } |
|
| 1675 | + if ($statut==2) { |
|
| 1676 | + return $langs->trans($this->statutshorts[$statut]); |
|
| 1677 | + } |
|
| 1602 | 1678 | } |
| 1603 | 1679 | if ($mode == 3) |
| 1604 | 1680 | { |
| 1605 | - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0'); |
|
| 1606 | - if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4'); |
|
| 1607 | - if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6'); |
|
| 1681 | + if ($statut==0) { |
|
| 1682 | + return img_picto($langs->trans($this->statuts[$statut]),'statut0'); |
|
| 1683 | + } |
|
| 1684 | + if ($statut==1) { |
|
| 1685 | + return img_picto($langs->trans($this->statuts[$statut]),'statut4'); |
|
| 1686 | + } |
|
| 1687 | + if ($statut==2) { |
|
| 1688 | + return img_picto($langs->trans($this->statuts[$statut]),'statut6'); |
|
| 1689 | + } |
|
| 1608 | 1690 | } |
| 1609 | 1691 | if ($mode == 4) |
| 1610 | 1692 | { |
| 1611 | - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); |
|
| 1612 | - if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); |
|
| 1613 | - if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]); |
|
| 1693 | + if ($statut==0) { |
|
| 1694 | + return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); |
|
| 1695 | + } |
|
| 1696 | + if ($statut==1) { |
|
| 1697 | + return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); |
|
| 1698 | + } |
|
| 1699 | + if ($statut==2) { |
|
| 1700 | + return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]); |
|
| 1701 | + } |
|
| 1614 | 1702 | } |
| 1615 | 1703 | if ($mode == 5) |
| 1616 | 1704 | { |
| 1617 | - if ($statut==0) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0'); |
|
| 1618 | - if ($statut==1) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut4'); |
|
| 1619 | - if ($statut==2) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6'); |
|
| 1705 | + if ($statut==0) { |
|
| 1706 | + return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0'); |
|
| 1707 | + } |
|
| 1708 | + if ($statut==1) { |
|
| 1709 | + return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut4'); |
|
| 1710 | + } |
|
| 1711 | + if ($statut==2) { |
|
| 1712 | + return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6'); |
|
| 1713 | + } |
|
| 1620 | 1714 | } |
| 1621 | 1715 | } |
| 1622 | 1716 | |
@@ -1721,14 +1815,12 @@ discard block |
||
| 1721 | 1815 | { |
| 1722 | 1816 | $this->date_delivery = $date_livraison; |
| 1723 | 1817 | return 1; |
| 1724 | - } |
|
| 1725 | - else |
|
| 1818 | + } else |
|
| 1726 | 1819 | { |
| 1727 | 1820 | $this->error=$this->db->error(); |
| 1728 | 1821 | return -1; |
| 1729 | 1822 | } |
| 1730 | - } |
|
| 1731 | - else |
|
| 1823 | + } else |
|
| 1732 | 1824 | { |
| 1733 | 1825 | return -2; |
| 1734 | 1826 | } |
@@ -1775,7 +1867,9 @@ discard block |
||
| 1775 | 1867 | |
| 1776 | 1868 | $sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active"; |
| 1777 | 1869 | $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; |
| 1778 | - if ($id!='') $sql.= " WHERE em.rowid=".$id; |
|
| 1870 | + if ($id!='') { |
|
| 1871 | + $sql.= " WHERE em.rowid=".$id; |
|
| 1872 | + } |
|
| 1779 | 1873 | |
| 1780 | 1874 | $resql = $this->db->query($sql); |
| 1781 | 1875 | if ($resql) |
@@ -1808,8 +1902,7 @@ discard block |
||
| 1808 | 1902 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)"; |
| 1809 | 1903 | $sql.=" VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; |
| 1810 | 1904 | $resql = $this->db->query($sql); |
| 1811 | - } |
|
| 1812 | - else |
|
| 1905 | + } else |
|
| 1813 | 1906 | { |
| 1814 | 1907 | $sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET"; |
| 1815 | 1908 | $sql.= " code='".$this->db->escape($this->update['code'])."'"; |
@@ -1819,7 +1912,9 @@ discard block |
||
| 1819 | 1912 | $sql.= " WHERE rowid=".$id; |
| 1820 | 1913 | $resql = $this->db->query($sql); |
| 1821 | 1914 | } |
| 1822 | - if ($resql < 0) dol_print_error($this->db,''); |
|
| 1915 | + if ($resql < 0) { |
|
| 1916 | + dol_print_error($this->db,''); |
|
| 1917 | + } |
|
| 1823 | 1918 | } |
| 1824 | 1919 | |
| 1825 | 1920 | /** |
@@ -1883,8 +1978,7 @@ discard block |
||
| 1883 | 1978 | { |
| 1884 | 1979 | $url = str_replace('{TRACKID}', $value, $tracking); |
| 1885 | 1980 | $this->tracking_url = sprintf('<a target="_blank" href="%s">'.($value?$value:'url').'</a>',$url,$url); |
| 1886 | - } |
|
| 1887 | - else |
|
| 1981 | + } else |
|
| 1888 | 1982 | { |
| 1889 | 1983 | $this->tracking_url = $value; |
| 1890 | 1984 | } |
@@ -1969,12 +2063,13 @@ discard block |
||
| 1969 | 2063 | if (empty($obj->edbrowid)) |
| 1970 | 2064 | { |
| 1971 | 2065 | $qty = $obj->qty; |
| 1972 | - } |
|
| 1973 | - else |
|
| 2066 | + } else |
|
| 1974 | 2067 | { |
| 1975 | 2068 | $qty = $obj->edbqty; |
| 1976 | 2069 | } |
| 1977 | - if ($qty <= 0) continue; |
|
| 2070 | + if ($qty <= 0) { |
|
| 2071 | + continue; |
|
| 2072 | + } |
|
| 1978 | 2073 | dol_syslog(get_class($this)."::valid movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid); |
| 1979 | 2074 | |
| 1980 | 2075 | $mouvS = new MouvementStock($this->db); |
@@ -1991,8 +2086,7 @@ discard block |
||
| 1991 | 2086 | $this->errors = $mouvS->errors; |
| 1992 | 2087 | $error++; break; |
| 1993 | 2088 | } |
| 1994 | - } |
|
| 1995 | - else |
|
| 2089 | + } else |
|
| 1996 | 2090 | { |
| 1997 | 2091 | // line with batch detail |
| 1998 | 2092 | |
@@ -2005,8 +2099,7 @@ discard block |
||
| 2005 | 2099 | } |
| 2006 | 2100 | } |
| 2007 | 2101 | } |
| 2008 | - } |
|
| 2009 | - else |
|
| 2102 | + } else |
|
| 2010 | 2103 | { |
| 2011 | 2104 | $this->error=$this->db->lasterror(); |
| 2012 | 2105 | $error++; |
@@ -2021,8 +2114,7 @@ discard block |
||
| 2021 | 2114 | $error++; |
| 2022 | 2115 | } |
| 2023 | 2116 | } |
| 2024 | - } |
|
| 2025 | - else |
|
| 2117 | + } else |
|
| 2026 | 2118 | { |
| 2027 | 2119 | dol_print_error($this->db); |
| 2028 | 2120 | $error++; |
@@ -2032,8 +2124,7 @@ discard block |
||
| 2032 | 2124 | { |
| 2033 | 2125 | $this->db->commit(); |
| 2034 | 2126 | return 1; |
| 2035 | - } |
|
| 2036 | - else |
|
| 2127 | + } else |
|
| 2037 | 2128 | { |
| 2038 | 2129 | $this->db->rollback(); |
| 2039 | 2130 | return -1; |
@@ -2075,8 +2166,7 @@ discard block |
||
| 2075 | 2166 | if (empty($error)) { |
| 2076 | 2167 | $this->db->commit(); |
| 2077 | 2168 | return 1; |
| 2078 | - } |
|
| 2079 | - else |
|
| 2169 | + } else |
|
| 2080 | 2170 | { |
| 2081 | 2171 | $this->db->rollback(); |
| 2082 | 2172 | return -1; |
@@ -2140,12 +2230,13 @@ discard block |
||
| 2140 | 2230 | if (empty($obj->edbrowid)) |
| 2141 | 2231 | { |
| 2142 | 2232 | $qty = $obj->qty; |
| 2143 | - } |
|
| 2144 | - else |
|
| 2233 | + } else |
|
| 2145 | 2234 | { |
| 2146 | 2235 | $qty = $obj->edbqty; |
| 2147 | 2236 | } |
| 2148 | - if ($qty <= 0) continue; |
|
| 2237 | + if ($qty <= 0) { |
|
| 2238 | + continue; |
|
| 2239 | + } |
|
| 2149 | 2240 | dol_syslog(get_class($this)."::reopen expedition movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid); |
| 2150 | 2241 | |
| 2151 | 2242 | //var_dump($this->lines[$i]); |
@@ -2163,8 +2254,7 @@ discard block |
||
| 2163 | 2254 | $this->errors = $mouvS->errors; |
| 2164 | 2255 | $error++; break; |
| 2165 | 2256 | } |
| 2166 | - } |
|
| 2167 | - else |
|
| 2257 | + } else |
|
| 2168 | 2258 | { |
| 2169 | 2259 | // line with batch detail |
| 2170 | 2260 | |
@@ -2177,8 +2267,7 @@ discard block |
||
| 2177 | 2267 | } |
| 2178 | 2268 | } |
| 2179 | 2269 | } |
| 2180 | - } |
|
| 2181 | - else |
|
| 2270 | + } else |
|
| 2182 | 2271 | { |
| 2183 | 2272 | $this->error=$this->db->lasterror(); |
| 2184 | 2273 | $error++; |
@@ -2203,8 +2292,7 @@ discard block |
||
| 2203 | 2292 | { |
| 2204 | 2293 | $this->db->commit(); |
| 2205 | 2294 | return 1; |
| 2206 | - } |
|
| 2207 | - else |
|
| 2295 | + } else |
|
| 2208 | 2296 | { |
| 2209 | 2297 | $this->db->rollback(); |
| 2210 | 2298 | return -1; |
@@ -2363,8 +2451,7 @@ discard block |
||
| 2363 | 2451 | $this->db->free($result); |
| 2364 | 2452 | |
| 2365 | 2453 | return 1; |
| 2366 | - } |
|
| 2367 | - else |
|
| 2454 | + } else |
|
| 2368 | 2455 | { |
| 2369 | 2456 | $this->errors[] = $this->db->lasterror(); |
| 2370 | 2457 | $this->error = $this->db->lasterror(); |
@@ -2392,7 +2479,9 @@ discard block |
||
| 2392 | 2479 | return -1; |
| 2393 | 2480 | } |
| 2394 | 2481 | // Clean parameters |
| 2395 | - if (empty($this->entrepot_id)) $this->entrepot_id='null'; |
|
| 2482 | + if (empty($this->entrepot_id)) { |
|
| 2483 | + $this->entrepot_id='null'; |
|
| 2484 | + } |
|
| 2396 | 2485 | |
| 2397 | 2486 | $this->db->begin(); |
| 2398 | 2487 | |
@@ -2413,9 +2502,11 @@ discard block |
||
| 2413 | 2502 | if ($resql) |
| 2414 | 2503 | { |
| 2415 | 2504 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet"); |
| 2416 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 2505 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 2506 | + // For avoid conflicts if trigger used |
|
| 2417 | 2507 | { |
| 2418 | 2508 | $result=$this->insertExtraFields(); |
| 2509 | + } |
|
| 2419 | 2510 | if ($result < 0) |
| 2420 | 2511 | { |
| 2421 | 2512 | $error++; |
@@ -2446,8 +2537,7 @@ discard block |
||
| 2446 | 2537 | } |
| 2447 | 2538 | $this->db->rollback(); |
| 2448 | 2539 | return -1*$error; |
| 2449 | - } |
|
| 2450 | - else |
|
| 2540 | + } else |
|
| 2451 | 2541 | { |
| 2452 | 2542 | $error++; |
| 2453 | 2543 | } |
@@ -2487,9 +2577,11 @@ discard block |
||
| 2487 | 2577 | if (! $error && $this->db->query($sql)) |
| 2488 | 2578 | { |
| 2489 | 2579 | // Remove extrafields |
| 2490 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 2580 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 2581 | + // For avoid conflicts if trigger used |
|
| 2491 | 2582 | { |
| 2492 | 2583 | $result=$this->deleteExtraFields(); |
| 2584 | + } |
|
| 2493 | 2585 | if ($result < 0) |
| 2494 | 2586 | { |
| 2495 | 2587 | $this->errors[]=$this->error; |
@@ -2507,8 +2599,7 @@ discard block |
||
| 2507 | 2599 | } |
| 2508 | 2600 | // End call triggers |
| 2509 | 2601 | } |
| 2510 | - } |
|
| 2511 | - else |
|
| 2602 | + } else |
|
| 2512 | 2603 | { |
| 2513 | 2604 | $this->errors[]=$this->db->lasterror()." - sql=$sql"; |
| 2514 | 2605 | $error++; |
@@ -2517,8 +2608,7 @@ discard block |
||
| 2517 | 2608 | if (! $error) { |
| 2518 | 2609 | $this->db->commit(); |
| 2519 | 2610 | return 1; |
| 2520 | - } |
|
| 2521 | - else |
|
| 2611 | + } else |
|
| 2522 | 2612 | { |
| 2523 | 2613 | foreach($this->errors as $errmsg) |
| 2524 | 2614 | { |
@@ -2548,21 +2638,24 @@ discard block |
||
| 2548 | 2638 | $this->db->begin(); |
| 2549 | 2639 | |
| 2550 | 2640 | // Clean parameters |
| 2551 | - if (empty($this->qty)) $this->qty=0; |
|
| 2641 | + if (empty($this->qty)) { |
|
| 2642 | + $this->qty=0; |
|
| 2643 | + } |
|
| 2552 | 2644 | $qty=price2num($this->qty); |
| 2553 | 2645 | $remainingQty = 0; |
| 2554 | 2646 | $batch = null; |
| 2555 | 2647 | $batch_id = null; |
| 2556 | 2648 | $expedition_batch_id = null; |
| 2557 | - if (is_array($this->detail_batch)) // array of ExpeditionLineBatch |
|
| 2649 | + if (is_array($this->detail_batch)) { |
|
| 2650 | + // array of ExpeditionLineBatch |
|
| 2558 | 2651 | { |
| 2559 | 2652 | if (count($this->detail_batch) > 1) |
| 2560 | 2653 | { |
| 2561 | 2654 | dol_syslog(get_class($this).'::update only possible for one batch', LOG_ERR); |
| 2655 | + } |
|
| 2562 | 2656 | $this->errors[]='ErrorBadParameters'; |
| 2563 | 2657 | $error++; |
| 2564 | - } |
|
| 2565 | - else |
|
| 2658 | + } else |
|
| 2566 | 2659 | { |
| 2567 | 2660 | $batch = $this->detail_batch[0]->batch; |
| 2568 | 2661 | $batch_id = $this->detail_batch[0]->fk_origin_stock; |
@@ -2575,8 +2668,7 @@ discard block |
||
| 2575 | 2668 | } |
| 2576 | 2669 | $qty = price2num($this->detail_batch[0]->dluo_qty); |
| 2577 | 2670 | } |
| 2578 | - } |
|
| 2579 | - else if (! empty($this->detail_batch)) |
|
| 2671 | + } else if (! empty($this->detail_batch)) |
|
| 2580 | 2672 | { |
| 2581 | 2673 | $batch = $this->detail_batch->batch; |
| 2582 | 2674 | $batch_id = $this->detail_batch->fk_origin_stock; |
@@ -2617,8 +2709,7 @@ discard block |
||
| 2617 | 2709 | { |
| 2618 | 2710 | $this->errors[]=$this->db->lasterror()." - ExpeditionLineBatch::fetchAll"; |
| 2619 | 2711 | $error++; |
| 2620 | - } |
|
| 2621 | - else |
|
| 2712 | + } else |
|
| 2622 | 2713 | { |
| 2623 | 2714 | // caculate new total line qty |
| 2624 | 2715 | foreach ($lotArray as $lot) |
@@ -2686,12 +2777,13 @@ discard block |
||
| 2686 | 2777 | { |
| 2687 | 2778 | $this->errors[]=$this->db->lasterror()." - sql=$sql"; |
| 2688 | 2779 | $error++; |
| 2689 | - } |
|
| 2690 | - else |
|
| 2780 | + } else |
|
| 2691 | 2781 | { |
| 2692 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 2782 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 2783 | + // For avoid conflicts if trigger used |
|
| 2693 | 2784 | { |
| 2694 | 2785 | $result=$this->insertExtraFields(); |
| 2786 | + } |
|
| 2695 | 2787 | if ($result < 0) |
| 2696 | 2788 | { |
| 2697 | 2789 | $this->errors[]=$this->error; |
@@ -2714,8 +2806,7 @@ discard block |
||
| 2714 | 2806 | if (!$error) { |
| 2715 | 2807 | $this->db->commit(); |
| 2716 | 2808 | return 1; |
| 2717 | - } |
|
| 2718 | - else |
|
| 2809 | + } else |
|
| 2719 | 2810 | { |
| 2720 | 2811 | foreach($this->errors as $errmsg) |
| 2721 | 2812 | { |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; |
| 35 | 35 | require_once DOL_DOCUMENT_ROOT."/core/class/commonobjectline.class.php"; |
| 36 | -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 37 | -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 38 | -if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; |
|
| 36 | +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 37 | +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 38 | +if (!empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | class Expedition extends CommonObject |
| 45 | 45 | { |
| 46 | - public $element="shipping"; |
|
| 47 | - public $fk_element="fk_expedition"; |
|
| 48 | - public $table_element="expedition"; |
|
| 49 | - public $table_element_line="expeditiondet"; |
|
| 50 | - public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 46 | + public $element = "shipping"; |
|
| 47 | + public $fk_element = "fk_expedition"; |
|
| 48 | + public $table_element = "expedition"; |
|
| 49 | + public $table_element_line = "expeditiondet"; |
|
| 50 | + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 51 | 51 | public $picto = 'sending'; |
| 52 | 52 | |
| 53 | 53 | var $socid; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | var $ref_int; |
| 56 | 56 | var $brouillon; |
| 57 | 57 | var $entrepot_id; |
| 58 | - var $lines=array(); |
|
| 58 | + var $lines = array(); |
|
| 59 | 59 | var $tracking_number; |
| 60 | 60 | var $tracking_url; |
| 61 | 61 | var $billed; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | // A denormalized value |
| 73 | 73 | var $trueSize; |
| 74 | 74 | |
| 75 | - var $date_delivery; // Date delivery planed |
|
| 75 | + var $date_delivery; // Date delivery planed |
|
| 76 | 76 | /** |
| 77 | 77 | * @deprecated |
| 78 | 78 | * @see date_shipping |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | var $date_valid; |
| 93 | 93 | |
| 94 | 94 | var $meths; |
| 95 | - var $listmeths; // List of carriers |
|
| 95 | + var $listmeths; // List of carriers |
|
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | const STATUS_DRAFT = 0; |
@@ -162,26 +162,26 @@ discard block |
||
| 162 | 162 | $dir = dol_buildpath($reldir."core/modules/expedition/"); |
| 163 | 163 | |
| 164 | 164 | // Load file with numbering class (if found) |
| 165 | - $mybool|=@include_once $dir.$file; |
|
| 165 | + $mybool |= @include_once $dir.$file; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if (! $mybool) |
|
| 168 | + if (!$mybool) |
|
| 169 | 169 | { |
| 170 | - dol_print_error('',"Failed to include file ".$file); |
|
| 170 | + dol_print_error('', "Failed to include file ".$file); |
|
| 171 | 171 | return ''; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $obj = new $classname(); |
| 175 | 175 | $numref = ""; |
| 176 | - $numref = $obj->getNextValue($soc,$this); |
|
| 176 | + $numref = $obj->getNextValue($soc, $this); |
|
| 177 | 177 | |
| 178 | - if ( $numref != "") |
|
| 178 | + if ($numref != "") |
|
| 179 | 179 | { |
| 180 | 180 | return $numref; |
| 181 | 181 | } |
| 182 | 182 | else |
| 183 | 183 | { |
| 184 | - dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); |
|
| 184 | + dol_print_error($this->db, get_class($this)."::getNextNumRef ".$obj->error); |
|
| 185 | 185 | return ""; |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -199,13 +199,13 @@ discard block |
||
| 199 | 199 | * @param int $notrigger 1=Does not execute triggers, 0= execute triggers |
| 200 | 200 | * @return int <0 si erreur, id expedition creee si ok |
| 201 | 201 | */ |
| 202 | - function create($user, $notrigger=0) |
|
| 202 | + function create($user, $notrigger = 0) |
|
| 203 | 203 | { |
| 204 | 204 | global $conf, $hookmanager; |
| 205 | 205 | |
| 206 | - $now=dol_now(); |
|
| 206 | + $now = dol_now(); |
|
| 207 | 207 | |
| 208 | - require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php'; |
|
| 208 | + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; |
|
| 209 | 209 | $error = 0; |
| 210 | 210 | |
| 211 | 211 | // Clean parameters |
@@ -219,90 +219,90 @@ discard block |
||
| 219 | 219 | $this->db->begin(); |
| 220 | 220 | |
| 221 | 221 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition ("; |
| 222 | - $sql.= "ref"; |
|
| 223 | - $sql.= ", entity"; |
|
| 224 | - $sql.= ", ref_customer"; |
|
| 225 | - $sql.= ", ref_int"; |
|
| 226 | - $sql.= ", date_creation"; |
|
| 227 | - $sql.= ", fk_user_author"; |
|
| 228 | - $sql.= ", date_expedition"; |
|
| 229 | - $sql.= ", date_delivery"; |
|
| 230 | - $sql.= ", fk_soc"; |
|
| 231 | - $sql.= ", fk_projet"; |
|
| 232 | - $sql.= ", fk_address"; |
|
| 233 | - $sql.= ", fk_shipping_method"; |
|
| 234 | - $sql.= ", tracking_number"; |
|
| 235 | - $sql.= ", weight"; |
|
| 236 | - $sql.= ", size"; |
|
| 237 | - $sql.= ", width"; |
|
| 238 | - $sql.= ", height"; |
|
| 239 | - $sql.= ", weight_units"; |
|
| 240 | - $sql.= ", size_units"; |
|
| 241 | - $sql.= ", note_private"; |
|
| 242 | - $sql.= ", note_public"; |
|
| 243 | - $sql.= ", model_pdf"; |
|
| 244 | - $sql.= ", fk_incoterms, location_incoterms"; |
|
| 245 | - $sql.= ") VALUES ("; |
|
| 246 | - $sql.= "'(PROV)'"; |
|
| 247 | - $sql.= ", ".$conf->entity; |
|
| 248 | - $sql.= ", ".($this->ref_customer?"'".$this->db->escape($this->ref_customer)."'":"null"); |
|
| 249 | - $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); |
|
| 250 | - $sql.= ", '".$this->db->idate($now)."'"; |
|
| 251 | - $sql.= ", ".$user->id; |
|
| 252 | - $sql.= ", ".($this->date_expedition>0?"'".$this->db->idate($this->date_expedition)."'":"null"); |
|
| 253 | - $sql.= ", ".($this->date_delivery>0?"'".$this->db->idate($this->date_delivery)."'":"null"); |
|
| 254 | - $sql.= ", ".$this->socid; |
|
| 255 | - $sql.= ", ".$this->fk_project; |
|
| 256 | - $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:"null"); |
|
| 257 | - $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:"null"); |
|
| 258 | - $sql.= ", '".$this->db->escape($this->tracking_number)."'"; |
|
| 259 | - $sql.= ", ".$this->weight; |
|
| 260 | - $sql.= ", ".$this->sizeS; // TODO Should use this->trueDepth |
|
| 261 | - $sql.= ", ".$this->sizeW; // TODO Should use this->trueWidth |
|
| 262 | - $sql.= ", ".$this->sizeH; // TODO Should use this->trueHeight |
|
| 263 | - $sql.= ", ".$this->weight_units; |
|
| 264 | - $sql.= ", ".$this->size_units; |
|
| 265 | - $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); |
|
| 266 | - $sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); |
|
| 267 | - $sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null"); |
|
| 268 | - $sql.= ", ".(int) $this->fk_incoterms; |
|
| 269 | - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; |
|
| 270 | - $sql.= ")"; |
|
| 222 | + $sql .= "ref"; |
|
| 223 | + $sql .= ", entity"; |
|
| 224 | + $sql .= ", ref_customer"; |
|
| 225 | + $sql .= ", ref_int"; |
|
| 226 | + $sql .= ", date_creation"; |
|
| 227 | + $sql .= ", fk_user_author"; |
|
| 228 | + $sql .= ", date_expedition"; |
|
| 229 | + $sql .= ", date_delivery"; |
|
| 230 | + $sql .= ", fk_soc"; |
|
| 231 | + $sql .= ", fk_projet"; |
|
| 232 | + $sql .= ", fk_address"; |
|
| 233 | + $sql .= ", fk_shipping_method"; |
|
| 234 | + $sql .= ", tracking_number"; |
|
| 235 | + $sql .= ", weight"; |
|
| 236 | + $sql .= ", size"; |
|
| 237 | + $sql .= ", width"; |
|
| 238 | + $sql .= ", height"; |
|
| 239 | + $sql .= ", weight_units"; |
|
| 240 | + $sql .= ", size_units"; |
|
| 241 | + $sql .= ", note_private"; |
|
| 242 | + $sql .= ", note_public"; |
|
| 243 | + $sql .= ", model_pdf"; |
|
| 244 | + $sql .= ", fk_incoterms, location_incoterms"; |
|
| 245 | + $sql .= ") VALUES ("; |
|
| 246 | + $sql .= "'(PROV)'"; |
|
| 247 | + $sql .= ", ".$conf->entity; |
|
| 248 | + $sql .= ", ".($this->ref_customer ? "'".$this->db->escape($this->ref_customer)."'" : "null"); |
|
| 249 | + $sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null"); |
|
| 250 | + $sql .= ", '".$this->db->idate($now)."'"; |
|
| 251 | + $sql .= ", ".$user->id; |
|
| 252 | + $sql .= ", ".($this->date_expedition > 0 ? "'".$this->db->idate($this->date_expedition)."'" : "null"); |
|
| 253 | + $sql .= ", ".($this->date_delivery > 0 ? "'".$this->db->idate($this->date_delivery)."'" : "null"); |
|
| 254 | + $sql .= ", ".$this->socid; |
|
| 255 | + $sql .= ", ".$this->fk_project; |
|
| 256 | + $sql .= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null"); |
|
| 257 | + $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : "null"); |
|
| 258 | + $sql .= ", '".$this->db->escape($this->tracking_number)."'"; |
|
| 259 | + $sql .= ", ".$this->weight; |
|
| 260 | + $sql .= ", ".$this->sizeS; // TODO Should use this->trueDepth |
|
| 261 | + $sql .= ", ".$this->sizeW; // TODO Should use this->trueWidth |
|
| 262 | + $sql .= ", ".$this->sizeH; // TODO Should use this->trueHeight |
|
| 263 | + $sql .= ", ".$this->weight_units; |
|
| 264 | + $sql .= ", ".$this->size_units; |
|
| 265 | + $sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); |
|
| 266 | + $sql .= ", ".(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null"); |
|
| 267 | + $sql .= ", ".(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null"); |
|
| 268 | + $sql .= ", ".(int) $this->fk_incoterms; |
|
| 269 | + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; |
|
| 270 | + $sql .= ")"; |
|
| 271 | 271 | |
| 272 | 272 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
| 273 | - $resql=$this->db->query($sql); |
|
| 273 | + $resql = $this->db->query($sql); |
|
| 274 | 274 | if ($resql) |
| 275 | 275 | { |
| 276 | 276 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expedition"); |
| 277 | 277 | |
| 278 | 278 | $sql = "UPDATE ".MAIN_DB_PREFIX."expedition"; |
| 279 | - $sql.= " SET ref = '(PROV".$this->id.")'"; |
|
| 280 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 279 | + $sql .= " SET ref = '(PROV".$this->id.")'"; |
|
| 280 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 281 | 281 | |
| 282 | 282 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
| 283 | 283 | if ($this->db->query($sql)) |
| 284 | 284 | { |
| 285 | 285 | // Insertion des lignes |
| 286 | - $num=count($this->lines); |
|
| 286 | + $num = count($this->lines); |
|
| 287 | 287 | for ($i = 0; $i < $num; $i++) |
| 288 | 288 | { |
| 289 | - if (! isset($this->lines[$i]->detail_batch)) |
|
| 289 | + if (!isset($this->lines[$i]->detail_batch)) |
|
| 290 | 290 | { // no batch management |
| 291 | - if (! $this->create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty, $this->lines[$i]->array_options) > 0) |
|
| 291 | + if (!$this->create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty, $this->lines[$i]->array_options) > 0) |
|
| 292 | 292 | { |
| 293 | 293 | $error++; |
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | else |
| 297 | 297 | { // with batch management |
| 298 | - if (! $this->create_line_batch($this->lines[$i],$this->lines[$i]->array_options) > 0) |
|
| 298 | + if (!$this->create_line_batch($this->lines[$i], $this->lines[$i]->array_options) > 0) |
|
| 299 | 299 | { |
| 300 | 300 | $error++; |
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if (! $error && $this->id && $this->origin_id) |
|
| 305 | + if (!$error && $this->id && $this->origin_id) |
|
| 306 | 306 | { |
| 307 | 307 | $ret = $this->add_object_linked(); |
| 308 | 308 | if (!$ret) |
@@ -314,13 +314,13 @@ discard block |
||
| 314 | 314 | // Actions on extra fields (by external module or standard code) |
| 315 | 315 | // TODO le hook fait double emploi avec le trigger !! |
| 316 | 316 | $hookmanager->initHooks(array('expeditiondao')); |
| 317 | - $parameters=array('socid'=>$this->id); |
|
| 318 | - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
| 317 | + $parameters = array('socid'=>$this->id); |
|
| 318 | + $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 319 | 319 | if (empty($reshook)) |
| 320 | 320 | { |
| 321 | 321 | if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
| 322 | 322 | { |
| 323 | - $result=$this->insertExtraFields(); |
|
| 323 | + $result = $this->insertExtraFields(); |
|
| 324 | 324 | if ($result < 0) |
| 325 | 325 | { |
| 326 | 326 | $error++; |
@@ -329,34 +329,34 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | else if ($reshook < 0) $error++; |
| 331 | 331 | |
| 332 | - if (! $error && ! $notrigger) |
|
| 332 | + if (!$error && !$notrigger) |
|
| 333 | 333 | { |
| 334 | 334 | // Call trigger |
| 335 | - $result=$this->call_trigger('SHIPPING_CREATE',$user); |
|
| 335 | + $result = $this->call_trigger('SHIPPING_CREATE', $user); |
|
| 336 | 336 | if ($result < 0) { $error++; } |
| 337 | 337 | // End call triggers |
| 338 | 338 | |
| 339 | - if (! $error) |
|
| 339 | + if (!$error) |
|
| 340 | 340 | { |
| 341 | 341 | $this->db->commit(); |
| 342 | 342 | return $this->id; |
| 343 | 343 | } |
| 344 | 344 | else |
| 345 | 345 | { |
| 346 | - foreach($this->errors as $errmsg) |
|
| 346 | + foreach ($this->errors as $errmsg) |
|
| 347 | 347 | { |
| 348 | 348 | dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
| 349 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 349 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 350 | 350 | } |
| 351 | 351 | $this->db->rollback(); |
| 352 | - return -1*$error; |
|
| 352 | + return -1 * $error; |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | } |
| 356 | 356 | else |
| 357 | 357 | { |
| 358 | 358 | $error++; |
| 359 | - $this->error=$this->db->lasterror()." - sql=$sql"; |
|
| 359 | + $this->error = $this->db->lasterror()." - sql=$sql"; |
|
| 360 | 360 | $this->db->rollback(); |
| 361 | 361 | return -3; |
| 362 | 362 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | else |
| 365 | 365 | { |
| 366 | 366 | $error++; |
| 367 | - $this->error=$this->db->lasterror()." - sql=$sql"; |
|
| 367 | + $this->error = $this->db->lasterror()." - sql=$sql"; |
|
| 368 | 368 | $this->db->rollback(); |
| 369 | 369 | return -2; |
| 370 | 370 | } |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | else |
| 373 | 373 | { |
| 374 | 374 | $error++; |
| 375 | - $this->error=$this->db->error()." - sql=$sql"; |
|
| 375 | + $this->error = $this->db->error()." - sql=$sql"; |
|
| 376 | 376 | $this->db->rollback(); |
| 377 | 377 | return -1; |
| 378 | 378 | } |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | * @param array $array_options extrafields array |
| 388 | 388 | * @return int <0 if KO, line_id if OK |
| 389 | 389 | */ |
| 390 | - function create_line($entrepot_id, $origin_line_id, $qty,$array_options=0) |
|
| 390 | + function create_line($entrepot_id, $origin_line_id, $qty, $array_options = 0) |
|
| 391 | 391 | { |
| 392 | 392 | $expeditionline = new ExpeditionLigne($this->db); |
| 393 | 393 | $expeditionline->fk_expedition = $this->id; |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | |
| 399 | 399 | if (($lineId = $expeditionline->insert()) < 0) |
| 400 | 400 | { |
| 401 | - $this->error[]=$expeditionline->error; |
|
| 401 | + $this->error[] = $expeditionline->error; |
|
| 402 | 402 | } |
| 403 | 403 | return $lineId; |
| 404 | 404 | } |
@@ -411,12 +411,12 @@ discard block |
||
| 411 | 411 | * @param array $array_options extrafields array |
| 412 | 412 | * @return int <0 if KO, >0 if OK |
| 413 | 413 | */ |
| 414 | - function create_line_batch($line_ext,$array_options=0) |
|
| 414 | + function create_line_batch($line_ext, $array_options = 0) |
|
| 415 | 415 | { |
| 416 | 416 | $error = 0; |
| 417 | 417 | $stockLocationQty = array(); // associated array with batch qty in stock location |
| 418 | 418 | |
| 419 | - $tab=$line_ext->detail_batch; |
|
| 419 | + $tab = $line_ext->detail_batch; |
|
| 420 | 420 | // create stockLocation Qty array |
| 421 | 421 | foreach ($tab as $detbatch) |
| 422 | 422 | { |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | // create shipment lines |
| 429 | 429 | foreach ($stockLocationQty as $stockLocation => $qty) |
| 430 | 430 | { |
| 431 | - if (($line_id = $this->create_line($stockLocation,$line_ext->origin_line_id,$qty,$array_options)) < 0) |
|
| 431 | + if (($line_id = $this->create_line($stockLocation, $line_ext->origin_line_id, $qty, $array_options)) < 0) |
|
| 432 | 432 | { |
| 433 | 433 | $error++; |
| 434 | 434 | } |
@@ -437,8 +437,8 @@ discard block |
||
| 437 | 437 | // create shipment batch lines for stockLocation |
| 438 | 438 | foreach ($tab as $detbatch) |
| 439 | 439 | { |
| 440 | - if ($detbatch->entrepot_id == $stockLocation){ |
|
| 441 | - if (! ($detbatch->create($line_id) >0)) // Create an expeditionlinebatch |
|
| 440 | + if ($detbatch->entrepot_id == $stockLocation) { |
|
| 441 | + if (!($detbatch->create($line_id) > 0)) // Create an expeditionlinebatch |
|
| 442 | 442 | { |
| 443 | 443 | $error++; |
| 444 | 444 | } |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - if (! $error) return 1; |
|
| 450 | + if (!$error) return 1; |
|
| 451 | 451 | else return -1; |
| 452 | 452 | } |
| 453 | 453 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | * @param string $ref_int Internal reference of other object |
| 461 | 461 | * @return int >0 if OK, 0 if not found, <0 if KO |
| 462 | 462 | */ |
| 463 | - function fetch($id, $ref='', $ref_ext='', $ref_int='') |
|
| 463 | + function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') |
|
| 464 | 464 | { |
| 465 | 465 | global $conf; |
| 466 | 466 | |
@@ -468,21 +468,21 @@ discard block |
||
| 468 | 468 | if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; |
| 469 | 469 | |
| 470 | 470 | $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.billed"; |
| 471 | - $sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; |
|
| 472 | - $sql.= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; |
|
| 473 | - $sql.= ", e.fk_shipping_method, e.tracking_number"; |
|
| 474 | - $sql.= ", el.fk_source as origin_id, el.sourcetype as origin"; |
|
| 475 | - $sql.= ", e.note_private, e.note_public"; |
|
| 476 | - $sql.= ', e.fk_incoterms, e.location_incoterms'; |
|
| 477 | - $sql.= ', i.libelle as libelle_incoterms'; |
|
| 478 | - $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; |
|
| 479 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; |
|
| 480 | - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; |
|
| 481 | - $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; |
|
| 482 | - if ($id) $sql.= " AND e.rowid=".$id; |
|
| 483 | - if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'"; |
|
| 484 | - if ($ref_ext) $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; |
|
| 485 | - if ($ref_int) $sql.= " AND e.ref_int='".$this->db->escape($ref_int)."'"; |
|
| 471 | + $sql .= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; |
|
| 472 | + $sql .= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; |
|
| 473 | + $sql .= ", e.fk_shipping_method, e.tracking_number"; |
|
| 474 | + $sql .= ", el.fk_source as origin_id, el.sourcetype as origin"; |
|
| 475 | + $sql .= ", e.note_private, e.note_public"; |
|
| 476 | + $sql .= ', e.fk_incoterms, e.location_incoterms'; |
|
| 477 | + $sql .= ', i.libelle as libelle_incoterms'; |
|
| 478 | + $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; |
|
| 479 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; |
|
| 480 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; |
|
| 481 | + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; |
|
| 482 | + if ($id) $sql .= " AND e.rowid=".$id; |
|
| 483 | + if ($ref) $sql .= " AND e.ref='".$this->db->escape($ref)."'"; |
|
| 484 | + if ($ref_ext) $sql .= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; |
|
| 485 | + if ($ref_int) $sql .= " AND e.ref_int='".$this->db->escape($ref_int)."'"; |
|
| 486 | 486 | |
| 487 | 487 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
| 488 | 488 | $result = $this->db->query($sql); |
@@ -495,21 +495,21 @@ discard block |
||
| 495 | 495 | $this->id = $obj->rowid; |
| 496 | 496 | $this->ref = $obj->ref; |
| 497 | 497 | $this->socid = $obj->socid; |
| 498 | - $this->ref_customer = $obj->ref_customer; |
|
| 498 | + $this->ref_customer = $obj->ref_customer; |
|
| 499 | 499 | $this->ref_ext = $obj->ref_ext; |
| 500 | 500 | $this->ref_int = $obj->ref_int; |
| 501 | 501 | $this->statut = $obj->fk_statut; |
| 502 | 502 | $this->user_author_id = $obj->fk_user_author; |
| 503 | 503 | $this->date_creation = $this->db->jdate($obj->date_creation); |
| 504 | - $this->date = $this->db->jdate($obj->date_expedition); // TODO deprecated |
|
| 505 | - $this->date_expedition = $this->db->jdate($obj->date_expedition); // TODO deprecated |
|
| 506 | - $this->date_shipping = $this->db->jdate($obj->date_expedition); // Date real |
|
| 507 | - $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed |
|
| 504 | + $this->date = $this->db->jdate($obj->date_expedition); // TODO deprecated |
|
| 505 | + $this->date_expedition = $this->db->jdate($obj->date_expedition); // TODO deprecated |
|
| 506 | + $this->date_shipping = $this->db->jdate($obj->date_expedition); // Date real |
|
| 507 | + $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed |
|
| 508 | 508 | $this->fk_delivery_address = $obj->fk_address; |
| 509 | 509 | $this->modelpdf = $obj->model_pdf; |
| 510 | - $this->shipping_method_id = $obj->fk_shipping_method; |
|
| 510 | + $this->shipping_method_id = $obj->fk_shipping_method; |
|
| 511 | 511 | $this->tracking_number = $obj->tracking_number; |
| 512 | - $this->origin = ($obj->origin?$obj->origin:'commande'); // For compatibility |
|
| 512 | + $this->origin = ($obj->origin ? $obj->origin : 'commande'); // For compatibility |
|
| 513 | 513 | $this->origin_id = $obj->origin_id; |
| 514 | 514 | $this->billed = $obj->billed; |
| 515 | 515 | |
@@ -527,8 +527,8 @@ discard block |
||
| 527 | 527 | $this->note_private = $obj->note_private; |
| 528 | 528 | |
| 529 | 529 | // A denormalized value |
| 530 | - $this->trueSize = $obj->size."x".$obj->width."x".$obj->height; |
|
| 531 | - $this->size_units = $obj->size_units; |
|
| 530 | + $this->trueSize = $obj->size."x".$obj->width."x".$obj->height; |
|
| 531 | + $this->size_units = $obj->size_units; |
|
| 532 | 532 | |
| 533 | 533 | //Incoterms |
| 534 | 534 | $this->fk_incoterms = $obj->fk_incoterms; |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | /* |
| 546 | 546 | * Thirparty |
| 547 | 547 | */ |
| 548 | - $result=$this->fetch_thirdparty(); |
|
| 548 | + $result = $this->fetch_thirdparty(); |
|
| 549 | 549 | |
| 550 | 550 | // Retreive all extrafield |
| 551 | 551 | // fetch optionals attributes and labels |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | /* |
| 555 | 555 | * Lines |
| 556 | 556 | */ |
| 557 | - $result=$this->fetch_lines(); |
|
| 557 | + $result = $this->fetch_lines(); |
|
| 558 | 558 | if ($result < 0) |
| 559 | 559 | { |
| 560 | 560 | return -3; |
@@ -565,13 +565,13 @@ discard block |
||
| 565 | 565 | else |
| 566 | 566 | { |
| 567 | 567 | dol_syslog(get_class($this).'::Fetch no expedition found', LOG_ERR); |
| 568 | - $this->error='Delivery with id '.$id.' not found'; |
|
| 568 | + $this->error = 'Delivery with id '.$id.' not found'; |
|
| 569 | 569 | return 0; |
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | else |
| 573 | 573 | { |
| 574 | - $this->error=$this->db->error(); |
|
| 574 | + $this->error = $this->db->error(); |
|
| 575 | 575 | return -1; |
| 576 | 576 | } |
| 577 | 577 | } |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | * @param int $notrigger 1=Does not execute triggers, 0= execute triggers |
| 584 | 584 | * @return int <0 if OK, >0 if KO |
| 585 | 585 | */ |
| 586 | - function valid($user, $notrigger=0) |
|
| 586 | + function valid($user, $notrigger = 0) |
|
| 587 | 587 | { |
| 588 | 588 | global $conf, $langs; |
| 589 | 589 | |
@@ -598,10 +598,10 @@ discard block |
||
| 598 | 598 | return 0; |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->creer)) |
|
| 602 | - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate)))) |
|
| 601 | + if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->creer)) |
|
| 602 | + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->shipping_advance->validate)))) |
|
| 603 | 603 | { |
| 604 | - $this->error='Permission denied'; |
|
| 604 | + $this->error = 'Permission denied'; |
|
| 605 | 605 | dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); |
| 606 | 606 | return -1; |
| 607 | 607 | } |
@@ -615,10 +615,10 @@ discard block |
||
| 615 | 615 | $soc->fetch($this->socid); |
| 616 | 616 | |
| 617 | 617 | // Class of company linked to order |
| 618 | - $result=$soc->set_as_client(); |
|
| 618 | + $result = $soc->set_as_client(); |
|
| 619 | 619 | |
| 620 | 620 | // Define new ref |
| 621 | - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life |
|
| 621 | + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life |
|
| 622 | 622 | { |
| 623 | 623 | $numref = $this->getNextNumRef($soc); |
| 624 | 624 | } |
@@ -628,26 +628,26 @@ discard block |
||
| 628 | 628 | } |
| 629 | 629 | $this->newref = $numref; |
| 630 | 630 | |
| 631 | - $now=dol_now(); |
|
| 631 | + $now = dol_now(); |
|
| 632 | 632 | |
| 633 | 633 | // Validate |
| 634 | 634 | $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; |
| 635 | - $sql.= " ref='".$numref."'"; |
|
| 636 | - $sql.= ", fk_statut = 1"; |
|
| 637 | - $sql.= ", date_valid = '".$this->db->idate($now)."'"; |
|
| 638 | - $sql.= ", fk_user_valid = ".$user->id; |
|
| 639 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 635 | + $sql .= " ref='".$numref."'"; |
|
| 636 | + $sql .= ", fk_statut = 1"; |
|
| 637 | + $sql .= ", date_valid = '".$this->db->idate($now)."'"; |
|
| 638 | + $sql .= ", fk_user_valid = ".$user->id; |
|
| 639 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 640 | 640 | |
| 641 | 641 | dol_syslog(get_class($this)."::valid update expedition", LOG_DEBUG); |
| 642 | - $resql=$this->db->query($sql); |
|
| 643 | - if (! $resql) |
|
| 642 | + $resql = $this->db->query($sql); |
|
| 643 | + if (!$resql) |
|
| 644 | 644 | { |
| 645 | - $this->error=$this->db->lasterror(); |
|
| 645 | + $this->error = $this->db->lasterror(); |
|
| 646 | 646 | $error++; |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | // If stock increment is done on sending (recommanded choice) |
| 650 | - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) |
|
| 650 | + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) |
|
| 651 | 651 | { |
| 652 | 652 | require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; |
| 653 | 653 | |
@@ -655,16 +655,16 @@ discard block |
||
| 655 | 655 | |
| 656 | 656 | // Loop on each product line to add a stock movement |
| 657 | 657 | $sql = "SELECT cd.fk_product, cd.subprice,"; |
| 658 | - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; |
|
| 659 | - $sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; |
|
| 660 | - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; |
|
| 661 | - $sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
| 662 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; |
|
| 663 | - $sql.= " WHERE ed.fk_expedition = ".$this->id; |
|
| 664 | - $sql.= " AND cd.rowid = ed.fk_origin_line"; |
|
| 658 | + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; |
|
| 659 | + $sql .= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; |
|
| 660 | + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; |
|
| 661 | + $sql .= " ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
| 662 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; |
|
| 663 | + $sql .= " WHERE ed.fk_expedition = ".$this->id; |
|
| 664 | + $sql .= " AND cd.rowid = ed.fk_origin_line"; |
|
| 665 | 665 | |
| 666 | 666 | dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); |
| 667 | - $resql=$this->db->query($sql); |
|
| 667 | + $resql = $this->db->query($sql); |
|
| 668 | 668 | if ($resql) |
| 669 | 669 | { |
| 670 | 670 | $cpt = $this->db->num_rows($resql); |
@@ -691,10 +691,10 @@ discard block |
||
| 691 | 691 | // line without batch detail |
| 692 | 692 | |
| 693 | 693 | // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. |
| 694 | - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref)); |
|
| 694 | + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr", $numref)); |
|
| 695 | 695 | if ($result < 0) { |
| 696 | 696 | $error++; |
| 697 | - $this->errors[]=$mouvS->error; |
|
| 697 | + $this->errors[] = $mouvS->error; |
|
| 698 | 698 | $this->errors = array_merge($this->errors, $mouvS->errors); |
| 699 | 699 | break; |
| 700 | 700 | } |
@@ -705,10 +705,10 @@ discard block |
||
| 705 | 705 | |
| 706 | 706 | // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. |
| 707 | 707 | // Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) |
| 708 | - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); |
|
| 708 | + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); |
|
| 709 | 709 | if ($result < 0) { |
| 710 | 710 | $error++; |
| 711 | - $this->errors[]=$mouvS->error; |
|
| 711 | + $this->errors[] = $mouvS->error; |
|
| 712 | 712 | $this->errors = array_merge($this->errors, $mouvS->errors); |
| 713 | 713 | break; |
| 714 | 714 | } |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | else |
| 719 | 719 | { |
| 720 | 720 | $this->db->rollback(); |
| 721 | - $this->error=$this->db->error(); |
|
| 721 | + $this->error = $this->db->error(); |
|
| 722 | 722 | return -2; |
| 723 | 723 | } |
| 724 | 724 | |
@@ -727,20 +727,20 @@ discard block |
||
| 727 | 727 | // Change status of order to "shipment in process" |
| 728 | 728 | $ret = $this->setStatut(Commande::STATUS_SHIPMENTONPROCESS, $this->origin_id, $this->origin); |
| 729 | 729 | |
| 730 | - if (! $ret) |
|
| 730 | + if (!$ret) |
|
| 731 | 731 | { |
| 732 | 732 | $error++; |
| 733 | 733 | } |
| 734 | 734 | |
| 735 | - if (! $error && ! $notrigger) |
|
| 735 | + if (!$error && !$notrigger) |
|
| 736 | 736 | { |
| 737 | 737 | // Call trigger |
| 738 | - $result=$this->call_trigger('SHIPPING_VALIDATE',$user); |
|
| 738 | + $result = $this->call_trigger('SHIPPING_VALIDATE', $user); |
|
| 739 | 739 | if ($result < 0) { $error++; } |
| 740 | 740 | // End call triggers |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - if (! $error) |
|
| 743 | + if (!$error) |
|
| 744 | 744 | { |
| 745 | 745 | $this->oldref = $this->ref; |
| 746 | 746 | |
@@ -761,13 +761,13 @@ discard block |
||
| 761 | 761 | { |
| 762 | 762 | dol_syslog("Rename ok"); |
| 763 | 763 | // Rename docs starting with $oldref with $newref |
| 764 | - $listoffiles=dol_dir_list($conf->expedition->dir_output.'/sending/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); |
|
| 765 | - foreach($listoffiles as $fileentry) |
|
| 764 | + $listoffiles = dol_dir_list($conf->expedition->dir_output.'/sending/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); |
|
| 765 | + foreach ($listoffiles as $fileentry) |
|
| 766 | 766 | { |
| 767 | - $dirsource=$fileentry['name']; |
|
| 768 | - $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource); |
|
| 769 | - $dirsource=$fileentry['path'].'/'.$dirsource; |
|
| 770 | - $dirdest=$fileentry['path'].'/'.$dirdest; |
|
| 767 | + $dirsource = $fileentry['name']; |
|
| 768 | + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); |
|
| 769 | + $dirsource = $fileentry['path'].'/'.$dirsource; |
|
| 770 | + $dirdest = $fileentry['path'].'/'.$dirdest; |
|
| 771 | 771 | @rename($dirsource, $dirdest); |
| 772 | 772 | } |
| 773 | 773 | } |
@@ -776,26 +776,26 @@ discard block |
||
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | // Set new ref and current status |
| 779 | - if (! $error) |
|
| 779 | + if (!$error) |
|
| 780 | 780 | { |
| 781 | 781 | $this->ref = $numref; |
| 782 | 782 | $this->statut = 1; |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | - if (! $error) |
|
| 785 | + if (!$error) |
|
| 786 | 786 | { |
| 787 | 787 | $this->db->commit(); |
| 788 | 788 | return 1; |
| 789 | 789 | } |
| 790 | 790 | else |
| 791 | 791 | { |
| 792 | - foreach($this->errors as $errmsg) |
|
| 792 | + foreach ($this->errors as $errmsg) |
|
| 793 | 793 | { |
| 794 | 794 | dol_syslog(get_class($this)."::valid ".$errmsg, LOG_ERR); |
| 795 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 795 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 796 | 796 | } |
| 797 | 797 | $this->db->rollback(); |
| 798 | - return -1*$error; |
|
| 798 | + return -1 * $error; |
|
| 799 | 799 | } |
| 800 | 800 | } |
| 801 | 801 | |
@@ -817,14 +817,14 @@ discard block |
||
| 817 | 817 | // Expedition validee |
| 818 | 818 | include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; |
| 819 | 819 | $delivery = new Livraison($this->db); |
| 820 | - $result=$delivery->create_from_sending($user, $this->id); |
|
| 820 | + $result = $delivery->create_from_sending($user, $this->id); |
|
| 821 | 821 | if ($result > 0) |
| 822 | 822 | { |
| 823 | 823 | return $result; |
| 824 | 824 | } |
| 825 | 825 | else |
| 826 | 826 | { |
| 827 | - $this->error=$delivery->error; |
|
| 827 | + $this->error = $delivery->error; |
|
| 828 | 828 | return $result; |
| 829 | 829 | } |
| 830 | 830 | } |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | * @param array $array_options extrafields array |
| 845 | 845 | * @return int <0 if KO, >0 if OK |
| 846 | 846 | */ |
| 847 | - function addline($entrepot_id, $id, $qty,$array_options=0) |
|
| 847 | + function addline($entrepot_id, $id, $qty, $array_options = 0) |
|
| 848 | 848 | { |
| 849 | 849 | global $conf, $langs; |
| 850 | 850 | |
@@ -858,22 +858,22 @@ discard block |
||
| 858 | 858 | $orderline = new OrderLine($this->db); |
| 859 | 859 | $orderline->fetch($id); |
| 860 | 860 | |
| 861 | - if (! empty($conf->stock->enabled) && ! empty($orderline->fk_product)) |
|
| 861 | + if (!empty($conf->stock->enabled) && !empty($orderline->fk_product)) |
|
| 862 | 862 | { |
| 863 | 863 | $fk_product = $orderline->fk_product; |
| 864 | 864 | |
| 865 | - if (! ($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS)) |
|
| 865 | + if (!($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS)) |
|
| 866 | 866 | { |
| 867 | 867 | $langs->load("errors"); |
| 868 | - $this->error=$langs->trans("ErrorWarehouseRequiredIntoShipmentLine"); |
|
| 868 | + $this->error = $langs->trans("ErrorWarehouseRequiredIntoShipmentLine"); |
|
| 869 | 869 | return -1; |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) |
| 873 | 873 | { |
| 874 | 874 | // Check must be done for stock of product into warehouse if $entrepot_id defined |
| 875 | - $product=new Product($this->db); |
|
| 876 | - $result=$product->fetch($fk_product); |
|
| 875 | + $product = new Product($this->db); |
|
| 876 | + $result = $product->fetch($fk_product); |
|
| 877 | 877 | |
| 878 | 878 | if ($entrepot_id > 0) { |
| 879 | 879 | $product->load_stock('warehouseopen'); |
@@ -882,11 +882,11 @@ discard block |
||
| 882 | 882 | else |
| 883 | 883 | $product_stock = $product->stock_reel; |
| 884 | 884 | |
| 885 | - $product_type=$product->type; |
|
| 885 | + $product_type = $product->type; |
|
| 886 | 886 | if ($product_type == 0 && $product_stock < $qty) |
| 887 | 887 | { |
| 888 | 888 | $langs->load("errors"); |
| 889 | - $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $product->ref); |
|
| 889 | + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $product->ref); |
|
| 890 | 890 | $this->db->rollback(); |
| 891 | 891 | return -3; |
| 892 | 892 | } |
@@ -894,14 +894,14 @@ discard block |
||
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | // If product need a batch number, we should not have called this function but addline_batch instead. |
| 897 | - if (! empty($conf->productbatch->enabled) && ! empty($orderline->fk_product) && ! empty($orderline->product_tobatch)) |
|
| 897 | + if (!empty($conf->productbatch->enabled) && !empty($orderline->fk_product) && !empty($orderline->product_tobatch)) |
|
| 898 | 898 | { |
| 899 | - $this->error='ADDLINE_WAS_CALLED_INSTEAD_OF_ADDLINEBATCH'; |
|
| 899 | + $this->error = 'ADDLINE_WAS_CALLED_INSTEAD_OF_ADDLINEBATCH'; |
|
| 900 | 900 | return -4; |
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | // extrafields |
| 904 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used |
|
| 904 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used |
|
| 905 | 905 | $line->array_options = $array_options; |
| 906 | 906 | |
| 907 | 907 | $this->lines[$num] = $line; |
@@ -914,32 +914,32 @@ discard block |
||
| 914 | 914 | * @param array $array_options extrafields array |
| 915 | 915 | * @return int <0 if KO, >0 if OK |
| 916 | 916 | */ |
| 917 | - function addline_batch($dbatch,$array_options=0) |
|
| 917 | + function addline_batch($dbatch, $array_options = 0) |
|
| 918 | 918 | { |
| 919 | - global $conf,$langs; |
|
| 919 | + global $conf, $langs; |
|
| 920 | 920 | |
| 921 | 921 | $num = count($this->lines); |
| 922 | - if ($dbatch['qty']>0) |
|
| 922 | + if ($dbatch['qty'] > 0) |
|
| 923 | 923 | { |
| 924 | 924 | $line = new ExpeditionLigne($this->db); |
| 925 | - $tab=array(); |
|
| 925 | + $tab = array(); |
|
| 926 | 926 | foreach ($dbatch['detail'] as $key=>$value) |
| 927 | 927 | { |
| 928 | - if ($value['q']>0) |
|
| 928 | + if ($value['q'] > 0) |
|
| 929 | 929 | { |
| 930 | 930 | // $value['q']=qty to move |
| 931 | 931 | // $value['id_batch']=id into llx_product_batch of record to move |
| 932 | 932 | //var_dump($value); |
| 933 | 933 | |
| 934 | 934 | $linebatch = new ExpeditionLineBatch($this->db); |
| 935 | - $ret=$linebatch->fetchFromStock($value['id_batch']); // load serial, sellby, eatby |
|
| 936 | - if ($ret<0) |
|
| 935 | + $ret = $linebatch->fetchFromStock($value['id_batch']); // load serial, sellby, eatby |
|
| 936 | + if ($ret < 0) |
|
| 937 | 937 | { |
| 938 | - $this->error=$linebatch->error; |
|
| 938 | + $this->error = $linebatch->error; |
|
| 939 | 939 | return -1; |
| 940 | 940 | } |
| 941 | - $linebatch->dluo_qty=$value['q']; |
|
| 942 | - $tab[]=$linebatch; |
|
| 941 | + $linebatch->dluo_qty = $value['q']; |
|
| 942 | + $tab[] = $linebatch; |
|
| 943 | 943 | |
| 944 | 944 | if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) |
| 945 | 945 | { |
@@ -950,7 +950,7 @@ discard block |
||
| 950 | 950 | if ($prod_batch->qty < $linebatch->dluo_qty) |
| 951 | 951 | { |
| 952 | 952 | $langs->load("errors"); |
| 953 | - $this->errors[]=$langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $prod_batch->fk_product); |
|
| 953 | + $this->errors[] = $langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $prod_batch->fk_product); |
|
| 954 | 954 | dol_syslog(get_class($this)."::addline_batch error=Product ".$prod_batch->batch.": ".$this->errorsToString(), LOG_ERR); |
| 955 | 955 | $this->db->rollback(); |
| 956 | 956 | return -1; |
@@ -963,10 +963,10 @@ discard block |
||
| 963 | 963 | $line->entrepot_id = $linebatch->entrepot_id; |
| 964 | 964 | $line->origin_line_id = $dbatch['ix_l']; |
| 965 | 965 | $line->qty = $dbatch['qty']; |
| 966 | - $line->detail_batch=$tab; |
|
| 966 | + $line->detail_batch = $tab; |
|
| 967 | 967 | |
| 968 | 968 | // extrafields |
| 969 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used |
|
| 969 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used |
|
| 970 | 970 | $line->array_options = $array_options; |
| 971 | 971 | |
| 972 | 972 | //var_dump($line); |
@@ -982,32 +982,32 @@ discard block |
||
| 982 | 982 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
| 983 | 983 | * @return int <0 if KO, >0 if OK |
| 984 | 984 | */ |
| 985 | - function update($user=null, $notrigger=0) |
|
| 985 | + function update($user = null, $notrigger = 0) |
|
| 986 | 986 | { |
| 987 | 987 | global $conf; |
| 988 | - $error=0; |
|
| 988 | + $error = 0; |
|
| 989 | 989 | |
| 990 | 990 | // Clean parameters |
| 991 | 991 | |
| 992 | - if (isset($this->ref)) $this->ref=trim($this->ref); |
|
| 993 | - if (isset($this->entity)) $this->entity=trim($this->entity); |
|
| 994 | - if (isset($this->ref_customer)) $this->ref_customer=trim($this->ref_customer); |
|
| 995 | - if (isset($this->socid)) $this->socid=trim($this->socid); |
|
| 996 | - if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); |
|
| 997 | - if (isset($this->fk_user_valid)) $this->fk_user_valid=trim($this->fk_user_valid); |
|
| 998 | - if (isset($this->fk_delivery_address)) $this->fk_delivery_address=trim($this->fk_delivery_address); |
|
| 999 | - if (isset($this->shipping_method_id)) $this->shipping_method_id=trim($this->shipping_method_id); |
|
| 1000 | - if (isset($this->tracking_number)) $this->tracking_number=trim($this->tracking_number); |
|
| 1001 | - if (isset($this->statut)) $this->statut=(int) $this->statut; |
|
| 1002 | - if (isset($this->trueDepth)) $this->trueDepth=trim($this->trueDepth); |
|
| 1003 | - if (isset($this->trueWidth)) $this->trueWidth=trim($this->trueWidth); |
|
| 1004 | - if (isset($this->trueHeight)) $this->trueHeight=trim($this->trueHeight); |
|
| 1005 | - if (isset($this->size_units)) $this->size_units=trim($this->size_units); |
|
| 1006 | - if (isset($this->weight_units)) $this->weight_units=trim($this->weight_units); |
|
| 1007 | - if (isset($this->trueWeight)) $this->weight=trim($this->trueWeight); |
|
| 1008 | - if (isset($this->note_private)) $this->note=trim($this->note_private); |
|
| 1009 | - if (isset($this->note_public)) $this->note=trim($this->note_public); |
|
| 1010 | - if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); |
|
| 992 | + if (isset($this->ref)) $this->ref = trim($this->ref); |
|
| 993 | + if (isset($this->entity)) $this->entity = trim($this->entity); |
|
| 994 | + if (isset($this->ref_customer)) $this->ref_customer = trim($this->ref_customer); |
|
| 995 | + if (isset($this->socid)) $this->socid = trim($this->socid); |
|
| 996 | + if (isset($this->fk_user_author)) $this->fk_user_author = trim($this->fk_user_author); |
|
| 997 | + if (isset($this->fk_user_valid)) $this->fk_user_valid = trim($this->fk_user_valid); |
|
| 998 | + if (isset($this->fk_delivery_address)) $this->fk_delivery_address = trim($this->fk_delivery_address); |
|
| 999 | + if (isset($this->shipping_method_id)) $this->shipping_method_id = trim($this->shipping_method_id); |
|
| 1000 | + if (isset($this->tracking_number)) $this->tracking_number = trim($this->tracking_number); |
|
| 1001 | + if (isset($this->statut)) $this->statut = (int) $this->statut; |
|
| 1002 | + if (isset($this->trueDepth)) $this->trueDepth = trim($this->trueDepth); |
|
| 1003 | + if (isset($this->trueWidth)) $this->trueWidth = trim($this->trueWidth); |
|
| 1004 | + if (isset($this->trueHeight)) $this->trueHeight = trim($this->trueHeight); |
|
| 1005 | + if (isset($this->size_units)) $this->size_units = trim($this->size_units); |
|
| 1006 | + if (isset($this->weight_units)) $this->weight_units = trim($this->weight_units); |
|
| 1007 | + if (isset($this->trueWeight)) $this->weight = trim($this->trueWeight); |
|
| 1008 | + if (isset($this->note_private)) $this->note = trim($this->note_private); |
|
| 1009 | + if (isset($this->note_public)) $this->note = trim($this->note_public); |
|
| 1010 | + if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); |
|
| 1011 | 1011 | |
| 1012 | 1012 | |
| 1013 | 1013 | |
@@ -1017,45 +1017,45 @@ discard block |
||
| 1017 | 1017 | // Update request |
| 1018 | 1018 | $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; |
| 1019 | 1019 | |
| 1020 | - $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; |
|
| 1021 | - $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; |
|
| 1022 | - $sql.= " ref_customer=".(isset($this->ref_customer)?"'".$this->db->escape($this->ref_customer)."'":"null").","; |
|
| 1023 | - $sql.= " fk_soc=".(isset($this->socid)?$this->socid:"null").","; |
|
| 1024 | - $sql.= " date_creation=".(dol_strlen($this->date_creation)!=0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; |
|
| 1025 | - $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; |
|
| 1026 | - $sql.= " date_valid=".(dol_strlen($this->date_valid)!=0 ? "'".$this->db->idate($this->date_valid)."'" : 'null').","; |
|
| 1027 | - $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->fk_user_valid:"null").","; |
|
| 1028 | - $sql.= " date_expedition=".(dol_strlen($this->date_expedition)!=0 ? "'".$this->db->idate($this->date_expedition)."'" : 'null').","; |
|
| 1029 | - $sql.= " date_delivery=".(dol_strlen($this->date_delivery)!=0 ? "'".$this->db->idate($this->date_delivery)."'" : 'null').","; |
|
| 1030 | - $sql.= " fk_address=".(isset($this->fk_delivery_address)?$this->fk_delivery_address:"null").","; |
|
| 1031 | - $sql.= " fk_shipping_method=".((isset($this->shipping_method_id) && $this->shipping_method_id > 0)?$this->shipping_method_id:"null").","; |
|
| 1032 | - $sql.= " tracking_number=".(isset($this->tracking_number)?"'".$this->db->escape($this->tracking_number)."'":"null").","; |
|
| 1033 | - $sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").","; |
|
| 1034 | - $sql.= " height=".(($this->trueHeight != '')?$this->trueHeight:"null").","; |
|
| 1035 | - $sql.= " width=".(($this->trueWidth != '')?$this->trueWidth:"null").","; |
|
| 1036 | - $sql.= " size_units=".(isset($this->size_units)?$this->size_units:"null").","; |
|
| 1037 | - $sql.= " size=".(($this->trueDepth != '')?$this->trueDepth:"null").","; |
|
| 1038 | - $sql.= " weight_units=".(isset($this->weight_units)?$this->weight_units:"null").","; |
|
| 1039 | - $sql.= " weight=".(($this->trueWeight != '')?$this->trueWeight:"null").","; |
|
| 1040 | - $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; |
|
| 1041 | - $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; |
|
| 1042 | - $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; |
|
| 1043 | - $sql.= " entity=".$conf->entity; |
|
| 1044 | - |
|
| 1045 | - $sql.= " WHERE rowid=".$this->id; |
|
| 1020 | + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; |
|
| 1021 | + $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; |
|
| 1022 | + $sql .= " ref_customer=".(isset($this->ref_customer) ? "'".$this->db->escape($this->ref_customer)."'" : "null").","; |
|
| 1023 | + $sql .= " fk_soc=".(isset($this->socid) ? $this->socid : "null").","; |
|
| 1024 | + $sql .= " date_creation=".(dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; |
|
| 1025 | + $sql .= " fk_user_author=".(isset($this->fk_user_author) ? $this->fk_user_author : "null").","; |
|
| 1026 | + $sql .= " date_valid=".(dol_strlen($this->date_valid) != 0 ? "'".$this->db->idate($this->date_valid)."'" : 'null').","; |
|
| 1027 | + $sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? $this->fk_user_valid : "null").","; |
|
| 1028 | + $sql .= " date_expedition=".(dol_strlen($this->date_expedition) != 0 ? "'".$this->db->idate($this->date_expedition)."'" : 'null').","; |
|
| 1029 | + $sql .= " date_delivery=".(dol_strlen($this->date_delivery) != 0 ? "'".$this->db->idate($this->date_delivery)."'" : 'null').","; |
|
| 1030 | + $sql .= " fk_address=".(isset($this->fk_delivery_address) ? $this->fk_delivery_address : "null").","; |
|
| 1031 | + $sql .= " fk_shipping_method=".((isset($this->shipping_method_id) && $this->shipping_method_id > 0) ? $this->shipping_method_id : "null").","; |
|
| 1032 | + $sql .= " tracking_number=".(isset($this->tracking_number) ? "'".$this->db->escape($this->tracking_number)."'" : "null").","; |
|
| 1033 | + $sql .= " fk_statut=".(isset($this->statut) ? $this->statut : "null").","; |
|
| 1034 | + $sql .= " height=".(($this->trueHeight != '') ? $this->trueHeight : "null").","; |
|
| 1035 | + $sql .= " width=".(($this->trueWidth != '') ? $this->trueWidth : "null").","; |
|
| 1036 | + $sql .= " size_units=".(isset($this->size_units) ? $this->size_units : "null").","; |
|
| 1037 | + $sql .= " size=".(($this->trueDepth != '') ? $this->trueDepth : "null").","; |
|
| 1038 | + $sql .= " weight_units=".(isset($this->weight_units) ? $this->weight_units : "null").","; |
|
| 1039 | + $sql .= " weight=".(($this->trueWeight != '') ? $this->trueWeight : "null").","; |
|
| 1040 | + $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; |
|
| 1041 | + $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; |
|
| 1042 | + $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; |
|
| 1043 | + $sql .= " entity=".$conf->entity; |
|
| 1044 | + |
|
| 1045 | + $sql .= " WHERE rowid=".$this->id; |
|
| 1046 | 1046 | |
| 1047 | 1047 | $this->db->begin(); |
| 1048 | 1048 | |
| 1049 | 1049 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
| 1050 | 1050 | $resql = $this->db->query($sql); |
| 1051 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
| 1051 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
| 1052 | 1052 | |
| 1053 | - if (! $error) |
|
| 1053 | + if (!$error) |
|
| 1054 | 1054 | { |
| 1055 | - if (! $notrigger) |
|
| 1055 | + if (!$notrigger) |
|
| 1056 | 1056 | { |
| 1057 | 1057 | // Call trigger |
| 1058 | - $result=$this->call_trigger('SHIPPING_MODIFY',$user); |
|
| 1058 | + $result = $this->call_trigger('SHIPPING_MODIFY', $user); |
|
| 1059 | 1059 | if ($result < 0) { $error++; } |
| 1060 | 1060 | // End call triggers |
| 1061 | 1061 | } |
@@ -1064,13 +1064,13 @@ discard block |
||
| 1064 | 1064 | // Commit or rollback |
| 1065 | 1065 | if ($error) |
| 1066 | 1066 | { |
| 1067 | - foreach($this->errors as $errmsg) |
|
| 1067 | + foreach ($this->errors as $errmsg) |
|
| 1068 | 1068 | { |
| 1069 | 1069 | dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
| 1070 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 1070 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 1071 | 1071 | } |
| 1072 | 1072 | $this->db->rollback(); |
| 1073 | - return -1*$error; |
|
| 1073 | + return -1 * $error; |
|
| 1074 | 1074 | } |
| 1075 | 1075 | else |
| 1076 | 1076 | { |
@@ -1093,14 +1093,14 @@ discard block |
||
| 1093 | 1093 | { |
| 1094 | 1094 | require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; |
| 1095 | 1095 | } |
| 1096 | - $error=0; |
|
| 1097 | - $this->error=''; |
|
| 1096 | + $error = 0; |
|
| 1097 | + $this->error = ''; |
|
| 1098 | 1098 | |
| 1099 | 1099 | // Add a protection to refuse deleting if shipment has at least one delivery |
| 1100 | - $this->fetchObjectLinked($this->id, 'shipping', 0, 'delivery'); // Get deliveries linked to this shipment |
|
| 1100 | + $this->fetchObjectLinked($this->id, 'shipping', 0, 'delivery'); // Get deliveries linked to this shipment |
|
| 1101 | 1101 | if (count($this->linkedObjectsIds) > 0) |
| 1102 | 1102 | { |
| 1103 | - $this->error='ErrorThereIsSomeDeliveries'; |
|
| 1103 | + $this->error = 'ErrorThereIsSomeDeliveries'; |
|
| 1104 | 1104 | return -1; |
| 1105 | 1105 | } |
| 1106 | 1106 | |
@@ -1114,13 +1114,13 @@ discard block |
||
| 1114 | 1114 | |
| 1115 | 1115 | // Loop on each product line to add a stock movement |
| 1116 | 1116 | $sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.rowid as expeditiondet_id"; |
| 1117 | - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; |
|
| 1118 | - $sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
| 1119 | - $sql.= " WHERE ed.fk_expedition = ".$this->id; |
|
| 1120 | - $sql.= " AND cd.rowid = ed.fk_origin_line"; |
|
| 1117 | + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; |
|
| 1118 | + $sql .= " ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
| 1119 | + $sql .= " WHERE ed.fk_expedition = ".$this->id; |
|
| 1120 | + $sql .= " AND cd.rowid = ed.fk_origin_line"; |
|
| 1121 | 1121 | |
| 1122 | 1122 | dol_syslog(get_class($this)."::delete select details", LOG_DEBUG); |
| 1123 | - $resql=$this->db->query($sql); |
|
| 1123 | + $resql = $this->db->query($sql); |
|
| 1124 | 1124 | if ($resql) |
| 1125 | 1125 | { |
| 1126 | 1126 | $cpt = $this->db->num_rows($resql); |
@@ -1136,20 +1136,20 @@ discard block |
||
| 1136 | 1136 | $lotArray = null; |
| 1137 | 1137 | if ($conf->productbatch->enabled) |
| 1138 | 1138 | { |
| 1139 | - $lotArray = ExpeditionLineBatch::fetchAll($this->db,$obj->expeditiondet_id); |
|
| 1140 | - if (! is_array($lotArray)) |
|
| 1139 | + $lotArray = ExpeditionLineBatch::fetchAll($this->db, $obj->expeditiondet_id); |
|
| 1140 | + if (!is_array($lotArray)) |
|
| 1141 | 1141 | { |
| 1142 | - $error++;$this->errors[]="Error ".$this->db->lasterror(); |
|
| 1142 | + $error++; $this->errors[] = "Error ".$this->db->lasterror(); |
|
| 1143 | 1143 | } |
| 1144 | 1144 | } |
| 1145 | 1145 | if (empty($lotArray)) { |
| 1146 | 1146 | // no lot/serial |
| 1147 | 1147 | // We increment stock of product (and sub-products) |
| 1148 | 1148 | // We use warehouse selected for each line |
| 1149 | - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ShipmentDeletedInDolibarr", $this->ref)); // Price is set to 0, because we don't want to see WAP changed |
|
| 1149 | + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ShipmentDeletedInDolibarr", $this->ref)); // Price is set to 0, because we don't want to see WAP changed |
|
| 1150 | 1150 | if ($result < 0) |
| 1151 | 1151 | { |
| 1152 | - $error++;$this->errors=$this->errors + $mouvS->errors; |
|
| 1152 | + $error++; $this->errors = $this->errors + $mouvS->errors; |
|
| 1153 | 1153 | break; |
| 1154 | 1154 | } |
| 1155 | 1155 | } |
@@ -1157,12 +1157,12 @@ discard block |
||
| 1157 | 1157 | { |
| 1158 | 1158 | // We increment stock of batches |
| 1159 | 1159 | // We use warehouse selected for each line |
| 1160 | - foreach($lotArray as $lot) |
|
| 1160 | + foreach ($lotArray as $lot) |
|
| 1161 | 1161 | { |
| 1162 | - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $lot->dluo_qty, 0, $langs->trans("ShipmentDeletedInDolibarr", $this->ref), $lot->eatby, $lot->sellby, $lot->batch); // Price is set to 0, because we don't want to see WAP changed |
|
| 1162 | + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $lot->dluo_qty, 0, $langs->trans("ShipmentDeletedInDolibarr", $this->ref), $lot->eatby, $lot->sellby, $lot->batch); // Price is set to 0, because we don't want to see WAP changed |
|
| 1163 | 1163 | if ($result < 0) |
| 1164 | 1164 | { |
| 1165 | - $error++;$this->errors=$this->errors + $mouvS->errors; |
|
| 1165 | + $error++; $this->errors = $this->errors + $mouvS->errors; |
|
| 1166 | 1166 | break; |
| 1167 | 1167 | } |
| 1168 | 1168 | } |
@@ -1172,46 +1172,46 @@ discard block |
||
| 1172 | 1172 | } |
| 1173 | 1173 | else |
| 1174 | 1174 | { |
| 1175 | - $error++;$this->errors[]="Error ".$this->db->lasterror(); |
|
| 1175 | + $error++; $this->errors[] = "Error ".$this->db->lasterror(); |
|
| 1176 | 1176 | } |
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | // delete batch expedition line |
| 1180 | - if (! $error && $conf->productbatch->enabled) |
|
| 1180 | + if (!$error && $conf->productbatch->enabled) |
|
| 1181 | 1181 | { |
| 1182 | - if (ExpeditionLineBatch::deletefromexp($this->db,$this->id) < 0) |
|
| 1182 | + if (ExpeditionLineBatch::deletefromexp($this->db, $this->id) < 0) |
|
| 1183 | 1183 | { |
| 1184 | - $error++;$this->errors[]="Error ".$this->db->lasterror(); |
|
| 1184 | + $error++; $this->errors[] = "Error ".$this->db->lasterror(); |
|
| 1185 | 1185 | } |
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | - if (! $error) |
|
| 1188 | + if (!$error) |
|
| 1189 | 1189 | { |
| 1190 | 1190 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet"; |
| 1191 | - $sql.= " WHERE fk_expedition = ".$this->id; |
|
| 1191 | + $sql .= " WHERE fk_expedition = ".$this->id; |
|
| 1192 | 1192 | |
| 1193 | - if ( $this->db->query($sql) ) |
|
| 1193 | + if ($this->db->query($sql)) |
|
| 1194 | 1194 | { |
| 1195 | 1195 | // Delete linked object |
| 1196 | 1196 | $res = $this->deleteObjectLinked(); |
| 1197 | 1197 | if ($res < 0) $error++; |
| 1198 | 1198 | |
| 1199 | - if (! $error) |
|
| 1199 | + if (!$error) |
|
| 1200 | 1200 | { |
| 1201 | 1201 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition"; |
| 1202 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 1202 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 1203 | 1203 | |
| 1204 | 1204 | if ($this->db->query($sql)) |
| 1205 | 1205 | { |
| 1206 | 1206 | // Call trigger |
| 1207 | - $result=$this->call_trigger('SHIPPING_DELETE',$user); |
|
| 1207 | + $result = $this->call_trigger('SHIPPING_DELETE', $user); |
|
| 1208 | 1208 | if ($result < 0) { $error++; } |
| 1209 | 1209 | // End call triggers |
| 1210 | 1210 | |
| 1211 | - if (! empty($this->origin) && $this->origin_id > 0) |
|
| 1211 | + if (!empty($this->origin) && $this->origin_id > 0) |
|
| 1212 | 1212 | { |
| 1213 | 1213 | $this->fetch_origin(); |
| 1214 | - $origin=$this->origin; |
|
| 1214 | + $origin = $this->origin; |
|
| 1215 | 1215 | if ($this->$origin->statut == Commande::STATUS_SHIPMENTONPROCESS) // If order source of shipment is "shipment in progress" |
| 1216 | 1216 | { |
| 1217 | 1217 | // Check if there is no more shipment. If not, we can move back status of order to "validated" instead of "shipment in progress" |
@@ -1224,19 +1224,19 @@ discard block |
||
| 1224 | 1224 | } |
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | - if (! $error) |
|
| 1227 | + if (!$error) |
|
| 1228 | 1228 | { |
| 1229 | 1229 | $this->db->commit(); |
| 1230 | 1230 | |
| 1231 | 1231 | // We delete PDFs |
| 1232 | 1232 | $ref = dol_sanitizeFileName($this->ref); |
| 1233 | - if (! empty($conf->expedition->dir_output)) |
|
| 1233 | + if (!empty($conf->expedition->dir_output)) |
|
| 1234 | 1234 | { |
| 1235 | - $dir = $conf->expedition->dir_output . '/sending/' . $ref ; |
|
| 1236 | - $file = $dir . '/' . $ref . '.pdf'; |
|
| 1235 | + $dir = $conf->expedition->dir_output.'/sending/'.$ref; |
|
| 1236 | + $file = $dir.'/'.$ref.'.pdf'; |
|
| 1237 | 1237 | if (file_exists($file)) |
| 1238 | 1238 | { |
| 1239 | - if (! dol_delete_file($file)) |
|
| 1239 | + if (!dol_delete_file($file)) |
|
| 1240 | 1240 | { |
| 1241 | 1241 | return 0; |
| 1242 | 1242 | } |
@@ -1245,7 +1245,7 @@ discard block |
||
| 1245 | 1245 | { |
| 1246 | 1246 | if (!dol_delete_dir_recursive($dir)) |
| 1247 | 1247 | { |
| 1248 | - $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); |
|
| 1248 | + $this->error = $langs->trans("ErrorCanNotDeleteDir", $dir); |
|
| 1249 | 1249 | return 0; |
| 1250 | 1250 | } |
| 1251 | 1251 | } |
@@ -1261,21 +1261,21 @@ discard block |
||
| 1261 | 1261 | } |
| 1262 | 1262 | else |
| 1263 | 1263 | { |
| 1264 | - $this->error=$this->db->lasterror()." - sql=$sql"; |
|
| 1264 | + $this->error = $this->db->lasterror()." - sql=$sql"; |
|
| 1265 | 1265 | $this->db->rollback(); |
| 1266 | 1266 | return -3; |
| 1267 | 1267 | } |
| 1268 | 1268 | } |
| 1269 | 1269 | else |
| 1270 | 1270 | { |
| 1271 | - $this->error=$this->db->lasterror()." - sql=$sql"; |
|
| 1271 | + $this->error = $this->db->lasterror()." - sql=$sql"; |
|
| 1272 | 1272 | $this->db->rollback(); |
| 1273 | 1273 | return -2; |
| 1274 | 1274 | } |
| 1275 | 1275 | } |
| 1276 | 1276 | else |
| 1277 | 1277 | { |
| 1278 | - $this->error=$this->db->lasterror()." - sql=$sql"; |
|
| 1278 | + $this->error = $this->db->lasterror()." - sql=$sql"; |
|
| 1279 | 1279 | $this->db->rollback(); |
| 1280 | 1280 | return -1; |
| 1281 | 1281 | } |
@@ -1299,17 +1299,17 @@ discard block |
||
| 1299 | 1299 | // TODO: recuperer les champs du document associe a part |
| 1300 | 1300 | |
| 1301 | 1301 | $sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked, cd.product_type"; |
| 1302 | - $sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva"; |
|
| 1303 | - $sql.= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.info_bits, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; |
|
| 1304 | - $sql.= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc"; |
|
| 1305 | - $sql.= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; |
|
| 1306 | - $sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type"; |
|
| 1307 | - $sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch"; |
|
| 1308 | - $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."commandedet as cd"; |
|
| 1309 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; |
|
| 1310 | - $sql.= " WHERE ed.fk_expedition = ".$this->id; |
|
| 1311 | - $sql.= " AND ed.fk_origin_line = cd.rowid"; |
|
| 1312 | - $sql.= " ORDER BY cd.rang, ed.fk_origin_line"; |
|
| 1302 | + $sql .= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva"; |
|
| 1303 | + $sql .= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.info_bits, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; |
|
| 1304 | + $sql .= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc"; |
|
| 1305 | + $sql .= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; |
|
| 1306 | + $sql .= ", p.ref as product_ref, p.label as product_label, p.fk_product_type"; |
|
| 1307 | + $sql .= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch"; |
|
| 1308 | + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."commandedet as cd"; |
|
| 1309 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; |
|
| 1310 | + $sql .= " WHERE ed.fk_expedition = ".$this->id; |
|
| 1311 | + $sql .= " AND ed.fk_origin_line = cd.rowid"; |
|
| 1312 | + $sql .= " ORDER BY cd.rang, ed.fk_origin_line"; |
|
| 1313 | 1313 | |
| 1314 | 1314 | dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); |
| 1315 | 1315 | $resql = $this->db->query($sql); |
@@ -1333,8 +1333,8 @@ discard block |
||
| 1333 | 1333 | $obj = $this->db->fetch_object($resql); |
| 1334 | 1334 | |
| 1335 | 1335 | if ($originline == $obj->fk_origin_line) { |
| 1336 | - $line->entrepot_id = 0; // entrepod_id in details_entrepot |
|
| 1337 | - $line->qty_shipped += $obj->qty_shipped; |
|
| 1336 | + $line->entrepot_id = 0; // entrepod_id in details_entrepot |
|
| 1337 | + $line->qty_shipped += $obj->qty_shipped; |
|
| 1338 | 1338 | } else { |
| 1339 | 1339 | $line = new ExpeditionLigne($this->db); |
| 1340 | 1340 | $line->entrepot_id = $obj->fk_entrepot; |
@@ -1348,24 +1348,24 @@ discard block |
||
| 1348 | 1348 | $line->details_entrepot[] = $detail_entrepot; |
| 1349 | 1349 | |
| 1350 | 1350 | $line->line_id = $obj->line_id; |
| 1351 | - $line->rowid = $obj->line_id; // TODO deprecated |
|
| 1351 | + $line->rowid = $obj->line_id; // TODO deprecated |
|
| 1352 | 1352 | $line->id = $obj->line_id; |
| 1353 | 1353 | |
| 1354 | - $line->fk_origin = 'orderline'; |
|
| 1354 | + $line->fk_origin = 'orderline'; |
|
| 1355 | 1355 | $line->fk_origin_line = $obj->fk_origin_line; |
| 1356 | - $line->origin_line_id = $obj->fk_origin_line; // TODO deprecated |
|
| 1356 | + $line->origin_line_id = $obj->fk_origin_line; // TODO deprecated |
|
| 1357 | 1357 | |
| 1358 | - $line->fk_expedition = $this->id; // id of parent |
|
| 1358 | + $line->fk_expedition = $this->id; // id of parent |
|
| 1359 | 1359 | |
| 1360 | 1360 | $line->product_type = $obj->product_type; |
| 1361 | 1361 | $line->fk_product = $obj->fk_product; |
| 1362 | 1362 | $line->fk_product_type = $obj->fk_product_type; |
| 1363 | - $line->ref = $obj->product_ref; // TODO deprecated |
|
| 1364 | - $line->product_ref = $obj->product_ref; |
|
| 1365 | - $line->product_label = $obj->product_label; |
|
| 1366 | - $line->libelle = $obj->product_label; // TODO deprecated |
|
| 1367 | - $line->product_tobatch = $obj->product_tobatch; |
|
| 1368 | - $line->label = $obj->custom_label; |
|
| 1363 | + $line->ref = $obj->product_ref; // TODO deprecated |
|
| 1364 | + $line->product_ref = $obj->product_ref; |
|
| 1365 | + $line->product_label = $obj->product_label; |
|
| 1366 | + $line->libelle = $obj->product_label; // TODO deprecated |
|
| 1367 | + $line->product_tobatch = $obj->product_tobatch; |
|
| 1368 | + $line->label = $obj->custom_label; |
|
| 1369 | 1369 | $line->description = $obj->description; |
| 1370 | 1370 | $line->qty_asked = $obj->qty_asked; |
| 1371 | 1371 | $line->weight = $obj->weight; |
@@ -1373,44 +1373,44 @@ discard block |
||
| 1373 | 1373 | $line->length = $obj->length; |
| 1374 | 1374 | $line->length_units = $obj->length_units; |
| 1375 | 1375 | $line->surface = $obj->surface; |
| 1376 | - $line->surface_units = $obj->surface_units; |
|
| 1376 | + $line->surface_units = $obj->surface_units; |
|
| 1377 | 1377 | $line->volume = $obj->volume; |
| 1378 | 1378 | $line->volume_units = $obj->volume_units; |
| 1379 | 1379 | |
| 1380 | - $line->pa_ht = $obj->pa_ht; |
|
| 1380 | + $line->pa_ht = $obj->pa_ht; |
|
| 1381 | 1381 | |
| 1382 | 1382 | // Local taxes |
| 1383 | - $localtax_array=array(0=>$obj->localtax1_type, 1=>$obj->localtax1_tx, 2=>$obj->localtax2_type, 3=>$obj->localtax2_tx); |
|
| 1383 | + $localtax_array = array(0=>$obj->localtax1_type, 1=>$obj->localtax1_tx, 2=>$obj->localtax2_type, 3=>$obj->localtax2_tx); |
|
| 1384 | 1384 | $localtax1_tx = get_localtax($obj->tva_tx, 1, $this->thirdparty); |
| 1385 | 1385 | $localtax2_tx = get_localtax($obj->tva_tx, 2, $this->thirdparty); |
| 1386 | 1386 | |
| 1387 | 1387 | // For invoicing |
| 1388 | - $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $localtax1_tx, $localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc, $localtax_array); // We force type to 0 |
|
| 1389 | - $line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements) |
|
| 1390 | - $line->qty = $line->qty_shipped; |
|
| 1391 | - $line->total_ht = $tabprice[0]; |
|
| 1388 | + $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $localtax1_tx, $localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc, $localtax_array); // We force type to 0 |
|
| 1389 | + $line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements) |
|
| 1390 | + $line->qty = $line->qty_shipped; |
|
| 1391 | + $line->total_ht = $tabprice[0]; |
|
| 1392 | 1392 | $line->total_localtax1 = $tabprice[9]; |
| 1393 | 1393 | $line->total_localtax2 = $tabprice[10]; |
| 1394 | 1394 | $line->total_ttc = $tabprice[2]; |
| 1395 | 1395 | $line->total_tva = $tabprice[1]; |
| 1396 | - $line->vat_src_code = $obj->vat_src_code; |
|
| 1397 | - $line->tva_tx = $obj->tva_tx; |
|
| 1396 | + $line->vat_src_code = $obj->vat_src_code; |
|
| 1397 | + $line->tva_tx = $obj->tva_tx; |
|
| 1398 | 1398 | $line->localtax1_tx = $obj->localtax1_tx; |
| 1399 | 1399 | $line->localtax2_tx = $obj->localtax2_tx; |
| 1400 | - $line->info_bits = $obj->info_bits; |
|
| 1401 | - $line->price = $obj->price; |
|
| 1402 | - $line->subprice = $obj->subprice; |
|
| 1403 | - $line->remise_percent = $obj->remise_percent; |
|
| 1400 | + $line->info_bits = $obj->info_bits; |
|
| 1401 | + $line->price = $obj->price; |
|
| 1402 | + $line->subprice = $obj->subprice; |
|
| 1403 | + $line->remise_percent = $obj->remise_percent; |
|
| 1404 | 1404 | |
| 1405 | - $this->total_ht+= $tabprice[0]; |
|
| 1406 | - $this->total_tva+= $tabprice[1]; |
|
| 1407 | - $this->total_ttc+= $tabprice[2]; |
|
| 1408 | - $this->total_localtax1+= $tabprice[9]; |
|
| 1409 | - $this->total_localtax2+= $tabprice[10]; |
|
| 1405 | + $this->total_ht += $tabprice[0]; |
|
| 1406 | + $this->total_tva += $tabprice[1]; |
|
| 1407 | + $this->total_ttc += $tabprice[2]; |
|
| 1408 | + $this->total_localtax1 += $tabprice[9]; |
|
| 1409 | + $this->total_localtax2 += $tabprice[10]; |
|
| 1410 | 1410 | |
| 1411 | 1411 | // Multicurrency |
| 1412 | - $this->fk_multicurrency = $obj->fk_multicurrency; |
|
| 1413 | - $this->multicurrency_code = $obj->multicurrency_code; |
|
| 1412 | + $this->fk_multicurrency = $obj->fk_multicurrency; |
|
| 1413 | + $this->multicurrency_code = $obj->multicurrency_code; |
|
| 1414 | 1414 | $this->multicurrency_subprice = $obj->multicurrency_subprice; |
| 1415 | 1415 | $this->multicurrency_total_ht = $obj->multicurrency_total_ht; |
| 1416 | 1416 | $this->multicurrency_total_tva = $obj->multicurrency_total_tva; |
@@ -1422,7 +1422,7 @@ discard block |
||
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | 1424 | // Detail of batch |
| 1425 | - if (! empty($conf->productbatch->enabled) && $obj->line_id > 0 && $obj->product_tobatch > 0) |
|
| 1425 | + if (!empty($conf->productbatch->enabled) && $obj->line_id > 0 && $obj->product_tobatch > 0) |
|
| 1426 | 1426 | { |
| 1427 | 1427 | require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; |
| 1428 | 1428 | |
@@ -1447,7 +1447,7 @@ discard block |
||
| 1447 | 1447 | } |
| 1448 | 1448 | else |
| 1449 | 1449 | { |
| 1450 | - $line->total_ht += $tabprice[0]; |
|
| 1450 | + $line->total_ht += $tabprice[0]; |
|
| 1451 | 1451 | $line->total_localtax1 += $tabprice[9]; |
| 1452 | 1452 | $line->total_localtax2 += $tabprice[10]; |
| 1453 | 1453 | $line->total_ttc += $tabprice[2]; |
@@ -1462,7 +1462,7 @@ discard block |
||
| 1462 | 1462 | } |
| 1463 | 1463 | else |
| 1464 | 1464 | { |
| 1465 | - $this->error=$this->db->error(); |
|
| 1465 | + $this->error = $this->db->error(); |
|
| 1466 | 1466 | return -3; |
| 1467 | 1467 | } |
| 1468 | 1468 | } |
@@ -1482,7 +1482,7 @@ discard block |
||
| 1482 | 1482 | { |
| 1483 | 1483 | $this->db->begin(); |
| 1484 | 1484 | |
| 1485 | - $line=new ExpeditionLigne($this->db); |
|
| 1485 | + $line = new ExpeditionLigne($this->db); |
|
| 1486 | 1486 | |
| 1487 | 1487 | // For triggers |
| 1488 | 1488 | $line->fetch($lineid); |
@@ -1502,7 +1502,7 @@ discard block |
||
| 1502 | 1502 | } |
| 1503 | 1503 | else |
| 1504 | 1504 | { |
| 1505 | - $this->error='ErrorDeleteLineNotAllowedByObjectStatus'; |
|
| 1505 | + $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; |
|
| 1506 | 1506 | return -2; |
| 1507 | 1507 | } |
| 1508 | 1508 | } |
@@ -1519,13 +1519,13 @@ discard block |
||
| 1519 | 1519 | * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
| 1520 | 1520 | * @return string String with URL |
| 1521 | 1521 | */ |
| 1522 | - function getNomUrl($withpicto=0, $option='', $max=0, $short=0, $notooltip=0, $save_lastsearch_value=-1) |
|
| 1522 | + function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1) |
|
| 1523 | 1523 | { |
| 1524 | 1524 | global $langs; |
| 1525 | 1525 | |
| 1526 | - $result=''; |
|
| 1527 | - $label = '<u>' . $langs->trans("ShowSending") . '</u>'; |
|
| 1528 | - $label .= '<br><b>' . $langs->trans('Ref') . ':</b> '.$this->ref; |
|
| 1526 | + $result = ''; |
|
| 1527 | + $label = '<u>'.$langs->trans("ShowSending").'</u>'; |
|
| 1528 | + $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref; |
|
| 1529 | 1529 | $label .= '<br><b>'.$langs->trans('RefCustomer').':</b> '.($this->ref_customer ? $this->ref_customer : $this->ref_client); |
| 1530 | 1530 | |
| 1531 | 1531 | $url = DOL_URL_ROOT.'/expedition/card.php?id='.$this->id; |
@@ -1535,29 +1535,29 @@ discard block |
||
| 1535 | 1535 | if ($option !== 'nolink') |
| 1536 | 1536 | { |
| 1537 | 1537 | // Add param to save lastsearch_values or not |
| 1538 | - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
| 1539 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 1540 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 1538 | + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
|
| 1539 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; |
|
| 1540 | + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; |
|
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | - $linkclose=''; |
|
| 1543 | + $linkclose = ''; |
|
| 1544 | 1544 | if (empty($notooltip)) |
| 1545 | 1545 | { |
| 1546 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 1546 | + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 1547 | 1547 | { |
| 1548 | - $label=$langs->trans("ShowSending"); |
|
| 1549 | - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1548 | + $label = $langs->trans("ShowSending"); |
|
| 1549 | + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1550 | 1550 | } |
| 1551 | - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1552 | - $linkclose.=' class="classfortooltip"'; |
|
| 1551 | + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1552 | + $linkclose .= ' class="classfortooltip"'; |
|
| 1553 | 1553 | } |
| 1554 | 1554 | |
| 1555 | 1555 | $linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; |
| 1556 | - $linkend='</a>'; |
|
| 1556 | + $linkend = '</a>'; |
|
| 1557 | 1557 | |
| 1558 | 1558 | $result .= $linkstart; |
| 1559 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
| 1560 | - if ($withpicto != 2) $result.= $this->ref; |
|
| 1559 | + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
| 1560 | + if ($withpicto != 2) $result .= $this->ref; |
|
| 1561 | 1561 | $result .= $linkend; |
| 1562 | 1562 | |
| 1563 | 1563 | return $result; |
@@ -1569,9 +1569,9 @@ discard block |
||
| 1569 | 1569 | * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto |
| 1570 | 1570 | * @return string Libelle |
| 1571 | 1571 | */ |
| 1572 | - function getLibStatut($mode=0) |
|
| 1572 | + function getLibStatut($mode = 0) |
|
| 1573 | 1573 | { |
| 1574 | - return $this->LibStatut($this->statut,$mode); |
|
| 1574 | + return $this->LibStatut($this->statut, $mode); |
|
| 1575 | 1575 | } |
| 1576 | 1576 | |
| 1577 | 1577 | /** |
@@ -1581,39 +1581,39 @@ discard block |
||
| 1581 | 1581 | * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto |
| 1582 | 1582 | * @return string Label of status |
| 1583 | 1583 | */ |
| 1584 | - function LibStatut($statut,$mode) |
|
| 1584 | + function LibStatut($statut, $mode) |
|
| 1585 | 1585 | { |
| 1586 | 1586 | global $langs; |
| 1587 | 1587 | |
| 1588 | - if ($mode==0) |
|
| 1588 | + if ($mode == 0) |
|
| 1589 | 1589 | { |
| 1590 | - if ($statut==0) return $langs->trans($this->statuts[$statut]); |
|
| 1591 | - if ($statut==1) return $langs->trans($this->statuts[$statut]); |
|
| 1592 | - if ($statut==2) return $langs->trans($this->statuts[$statut]); |
|
| 1590 | + if ($statut == 0) return $langs->trans($this->statuts[$statut]); |
|
| 1591 | + if ($statut == 1) return $langs->trans($this->statuts[$statut]); |
|
| 1592 | + if ($statut == 2) return $langs->trans($this->statuts[$statut]); |
|
| 1593 | 1593 | } |
| 1594 | - if ($mode==1) |
|
| 1594 | + if ($mode == 1) |
|
| 1595 | 1595 | { |
| 1596 | - if ($statut==0) return $langs->trans($this->statutshorts[$statut]); |
|
| 1597 | - if ($statut==1) return $langs->trans($this->statutshorts[$statut]); |
|
| 1598 | - if ($statut==2) return $langs->trans($this->statutshorts[$statut]); |
|
| 1596 | + if ($statut == 0) return $langs->trans($this->statutshorts[$statut]); |
|
| 1597 | + if ($statut == 1) return $langs->trans($this->statutshorts[$statut]); |
|
| 1598 | + if ($statut == 2) return $langs->trans($this->statutshorts[$statut]); |
|
| 1599 | 1599 | } |
| 1600 | 1600 | if ($mode == 3) |
| 1601 | 1601 | { |
| 1602 | - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0'); |
|
| 1603 | - if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4'); |
|
| 1604 | - if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6'); |
|
| 1602 | + if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0'); |
|
| 1603 | + if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4'); |
|
| 1604 | + if ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); |
|
| 1605 | 1605 | } |
| 1606 | 1606 | if ($mode == 4) |
| 1607 | 1607 | { |
| 1608 | - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); |
|
| 1609 | - if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); |
|
| 1610 | - if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]); |
|
| 1608 | + if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); |
|
| 1609 | + if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); |
|
| 1610 | + if ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); |
|
| 1611 | 1611 | } |
| 1612 | 1612 | if ($mode == 5) |
| 1613 | 1613 | { |
| 1614 | - if ($statut==0) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0'); |
|
| 1615 | - if ($statut==1) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut4'); |
|
| 1616 | - if ($statut==2) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6'); |
|
| 1614 | + if ($statut == 0) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut0'); |
|
| 1615 | + if ($statut == 1) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut4'); |
|
| 1616 | + if ($statut == 2) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); |
|
| 1617 | 1617 | } |
| 1618 | 1618 | } |
| 1619 | 1619 | |
@@ -1628,7 +1628,7 @@ discard block |
||
| 1628 | 1628 | { |
| 1629 | 1629 | global $langs; |
| 1630 | 1630 | |
| 1631 | - $now=dol_now(); |
|
| 1631 | + $now = dol_now(); |
|
| 1632 | 1632 | |
| 1633 | 1633 | dol_syslog(get_class($this)."::initAsSpecimen"); |
| 1634 | 1634 | |
@@ -1636,8 +1636,8 @@ discard block |
||
| 1636 | 1636 | $num_prods = 0; |
| 1637 | 1637 | $prodids = array(); |
| 1638 | 1638 | $sql = "SELECT rowid"; |
| 1639 | - $sql.= " FROM ".MAIN_DB_PREFIX."product"; |
|
| 1640 | - $sql.= " WHERE entity IN (".getEntity('product').")"; |
|
| 1639 | + $sql .= " FROM ".MAIN_DB_PREFIX."product"; |
|
| 1640 | + $sql .= " WHERE entity IN (".getEntity('product').")"; |
|
| 1641 | 1641 | $resql = $this->db->query($sql); |
| 1642 | 1642 | if ($resql) |
| 1643 | 1643 | { |
@@ -1651,20 +1651,20 @@ discard block |
||
| 1651 | 1651 | } |
| 1652 | 1652 | } |
| 1653 | 1653 | |
| 1654 | - $order=new Commande($this->db); |
|
| 1654 | + $order = new Commande($this->db); |
|
| 1655 | 1655 | $order->initAsSpecimen(); |
| 1656 | 1656 | |
| 1657 | 1657 | // Initialise parametres |
| 1658 | - $this->id=0; |
|
| 1658 | + $this->id = 0; |
|
| 1659 | 1659 | $this->ref = 'SPECIMEN'; |
| 1660 | - $this->specimen=1; |
|
| 1660 | + $this->specimen = 1; |
|
| 1661 | 1661 | $this->statut = 1; |
| 1662 | 1662 | $this->livraison_id = 0; |
| 1663 | 1663 | $this->date = $now; |
| 1664 | 1664 | $this->date_creation = $now; |
| 1665 | 1665 | $this->date_valid = $now; |
| 1666 | 1666 | $this->date_delivery = $now; |
| 1667 | - $this->date_expedition = $now + 24*3600; |
|
| 1667 | + $this->date_expedition = $now + 24 * 3600; |
|
| 1668 | 1668 | |
| 1669 | 1669 | $this->entrepot_id = 0; |
| 1670 | 1670 | $this->fk_delivery_address = 0; |
@@ -1676,22 +1676,22 @@ discard block |
||
| 1676 | 1676 | $this->origin_id = 1; |
| 1677 | 1677 | $this->origin = 'commande'; |
| 1678 | 1678 | |
| 1679 | - $this->note_private = 'Private note'; |
|
| 1680 | - $this->note_public = 'Public note'; |
|
| 1679 | + $this->note_private = 'Private note'; |
|
| 1680 | + $this->note_public = 'Public note'; |
|
| 1681 | 1681 | |
| 1682 | 1682 | $nbp = 5; |
| 1683 | 1683 | $xnbp = 0; |
| 1684 | 1684 | while ($xnbp < $nbp) |
| 1685 | 1685 | { |
| 1686 | - $line=new ExpeditionLigne($this->db); |
|
| 1687 | - $line->desc=$langs->trans("Description")." ".$xnbp; |
|
| 1688 | - $line->libelle=$langs->trans("Description")." ".$xnbp; |
|
| 1689 | - $line->qty=10; |
|
| 1690 | - $line->qty_asked=5; |
|
| 1691 | - $line->qty_shipped=4; |
|
| 1692 | - $line->fk_product=$this->commande->lines[$xnbp]->fk_product; |
|
| 1693 | - |
|
| 1694 | - $this->lines[]=$line; |
|
| 1686 | + $line = new ExpeditionLigne($this->db); |
|
| 1687 | + $line->desc = $langs->trans("Description")." ".$xnbp; |
|
| 1688 | + $line->libelle = $langs->trans("Description")." ".$xnbp; |
|
| 1689 | + $line->qty = 10; |
|
| 1690 | + $line->qty_asked = 5; |
|
| 1691 | + $line->qty_shipped = 4; |
|
| 1692 | + $line->fk_product = $this->commande->lines[$xnbp]->fk_product; |
|
| 1693 | + |
|
| 1694 | + $this->lines[] = $line; |
|
| 1695 | 1695 | $xnbp++; |
| 1696 | 1696 | } |
| 1697 | 1697 | |
@@ -1709,11 +1709,11 @@ discard block |
||
| 1709 | 1709 | if ($user->rights->expedition->creer) |
| 1710 | 1710 | { |
| 1711 | 1711 | $sql = "UPDATE ".MAIN_DB_PREFIX."expedition"; |
| 1712 | - $sql.= " SET date_delivery = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); |
|
| 1713 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 1712 | + $sql .= " SET date_delivery = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); |
|
| 1713 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 1714 | 1714 | |
| 1715 | 1715 | dol_syslog(get_class($this)."::set_date_livraison", LOG_DEBUG); |
| 1716 | - $resql=$this->db->query($sql); |
|
| 1716 | + $resql = $this->db->query($sql); |
|
| 1717 | 1717 | if ($resql) |
| 1718 | 1718 | { |
| 1719 | 1719 | $this->date_delivery = $date_livraison; |
@@ -1721,7 +1721,7 @@ discard block |
||
| 1721 | 1721 | } |
| 1722 | 1722 | else |
| 1723 | 1723 | { |
| 1724 | - $this->error=$this->db->error(); |
|
| 1724 | + $this->error = $this->db->error(); |
|
| 1725 | 1725 | return -1; |
| 1726 | 1726 | } |
| 1727 | 1727 | } |
@@ -1742,17 +1742,17 @@ discard block |
||
| 1742 | 1742 | $this->meths = array(); |
| 1743 | 1743 | |
| 1744 | 1744 | $sql = "SELECT em.rowid, em.code, em.libelle"; |
| 1745 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; |
|
| 1746 | - $sql.= " WHERE em.active = 1"; |
|
| 1747 | - $sql.= " ORDER BY em.libelle ASC"; |
|
| 1745 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; |
|
| 1746 | + $sql .= " WHERE em.active = 1"; |
|
| 1747 | + $sql .= " ORDER BY em.libelle ASC"; |
|
| 1748 | 1748 | |
| 1749 | 1749 | $resql = $this->db->query($sql); |
| 1750 | 1750 | if ($resql) |
| 1751 | 1751 | { |
| 1752 | 1752 | while ($obj = $this->db->fetch_object($resql)) |
| 1753 | 1753 | { |
| 1754 | - $label=$langs->trans('SendingMethod'.$obj->code); |
|
| 1755 | - $this->meths[$obj->rowid] = ($label != 'SendingMethod'.$obj->code?$label:$obj->libelle); |
|
| 1754 | + $label = $langs->trans('SendingMethod'.$obj->code); |
|
| 1755 | + $this->meths[$obj->rowid] = ($label != 'SendingMethod'.$obj->code ? $label : $obj->libelle); |
|
| 1756 | 1756 | } |
| 1757 | 1757 | } |
| 1758 | 1758 | } |
@@ -1763,16 +1763,16 @@ discard block |
||
| 1763 | 1763 | * @param id $id only this carrier, all if none |
| 1764 | 1764 | * @return void |
| 1765 | 1765 | */ |
| 1766 | - function list_delivery_methods($id='') |
|
| 1766 | + function list_delivery_methods($id = '') |
|
| 1767 | 1767 | { |
| 1768 | 1768 | global $langs; |
| 1769 | 1769 | |
| 1770 | 1770 | $this->listmeths = array(); |
| 1771 | - $i=0; |
|
| 1771 | + $i = 0; |
|
| 1772 | 1772 | |
| 1773 | 1773 | $sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active"; |
| 1774 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; |
|
| 1775 | - if ($id!='') $sql.= " WHERE em.rowid=".$id; |
|
| 1774 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; |
|
| 1775 | + if ($id != '') $sql .= " WHERE em.rowid=".$id; |
|
| 1776 | 1776 | |
| 1777 | 1777 | $resql = $this->db->query($sql); |
| 1778 | 1778 | if ($resql) |
@@ -1781,8 +1781,8 @@ discard block |
||
| 1781 | 1781 | { |
| 1782 | 1782 | $this->listmeths[$i]['rowid'] = $obj->rowid; |
| 1783 | 1783 | $this->listmeths[$i]['code'] = $obj->code; |
| 1784 | - $label=$langs->trans('SendingMethod'.$obj->code); |
|
| 1785 | - $this->listmeths[$i]['libelle'] = ($label != 'SendingMethod'.$obj->code?$label:$obj->libelle); |
|
| 1784 | + $label = $langs->trans('SendingMethod'.$obj->code); |
|
| 1785 | + $this->listmeths[$i]['libelle'] = ($label != 'SendingMethod'.$obj->code ? $label : $obj->libelle); |
|
| 1786 | 1786 | $this->listmeths[$i]['description'] = $obj->description; |
| 1787 | 1787 | $this->listmeths[$i]['tracking'] = $obj->tracking; |
| 1788 | 1788 | $this->listmeths[$i]['active'] = $obj->active; |
@@ -1798,25 +1798,25 @@ discard block |
||
| 1798 | 1798 | * |
| 1799 | 1799 | * @return void |
| 1800 | 1800 | */ |
| 1801 | - function update_delivery_method($id='') |
|
| 1801 | + function update_delivery_method($id = '') |
|
| 1802 | 1802 | { |
| 1803 | - if ($id=='') |
|
| 1803 | + if ($id == '') |
|
| 1804 | 1804 | { |
| 1805 | 1805 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)"; |
| 1806 | - $sql.=" VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; |
|
| 1806 | + $sql .= " VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; |
|
| 1807 | 1807 | $resql = $this->db->query($sql); |
| 1808 | 1808 | } |
| 1809 | 1809 | else |
| 1810 | 1810 | { |
| 1811 | 1811 | $sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET"; |
| 1812 | - $sql.= " code='".$this->db->escape($this->update['code'])."'"; |
|
| 1813 | - $sql.= ",libelle='".$this->db->escape($this->update['libelle'])."'"; |
|
| 1814 | - $sql.= ",description='".$this->db->escape($this->update['description'])."'"; |
|
| 1815 | - $sql.= ",tracking='".$this->db->escape($this->update['tracking'])."'"; |
|
| 1816 | - $sql.= " WHERE rowid=".$id; |
|
| 1812 | + $sql .= " code='".$this->db->escape($this->update['code'])."'"; |
|
| 1813 | + $sql .= ",libelle='".$this->db->escape($this->update['libelle'])."'"; |
|
| 1814 | + $sql .= ",description='".$this->db->escape($this->update['description'])."'"; |
|
| 1815 | + $sql .= ",tracking='".$this->db->escape($this->update['tracking'])."'"; |
|
| 1816 | + $sql .= " WHERE rowid=".$id; |
|
| 1817 | 1817 | $resql = $this->db->query($sql); |
| 1818 | 1818 | } |
| 1819 | - if ($resql < 0) dol_print_error($this->db,''); |
|
| 1819 | + if ($resql < 0) dol_print_error($this->db, ''); |
|
| 1820 | 1820 | } |
| 1821 | 1821 | |
| 1822 | 1822 | /** |
@@ -1829,7 +1829,7 @@ discard block |
||
| 1829 | 1829 | function activ_delivery_method($id) |
| 1830 | 1830 | { |
| 1831 | 1831 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; |
| 1832 | - $sql.= ' WHERE rowid='.$id; |
|
| 1832 | + $sql .= ' WHERE rowid='.$id; |
|
| 1833 | 1833 | |
| 1834 | 1834 | $resql = $this->db->query($sql); |
| 1835 | 1835 | |
@@ -1845,7 +1845,7 @@ discard block |
||
| 1845 | 1845 | function disable_delivery_method($id) |
| 1846 | 1846 | { |
| 1847 | 1847 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; |
| 1848 | - $sql.= ' WHERE rowid='.$id; |
|
| 1848 | + $sql .= ' WHERE rowid='.$id; |
|
| 1849 | 1849 | |
| 1850 | 1850 | $resql = $this->db->query($sql); |
| 1851 | 1851 | |
@@ -1858,13 +1858,13 @@ discard block |
||
| 1858 | 1858 | * @param string $value Value |
| 1859 | 1859 | * @return void |
| 1860 | 1860 | */ |
| 1861 | - function GetUrlTrackingStatus($value='') |
|
| 1861 | + function GetUrlTrackingStatus($value = '') |
|
| 1862 | 1862 | { |
| 1863 | - if (! empty($this->shipping_method_id)) |
|
| 1863 | + if (!empty($this->shipping_method_id)) |
|
| 1864 | 1864 | { |
| 1865 | 1865 | $sql = "SELECT em.code, em.tracking"; |
| 1866 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; |
|
| 1867 | - $sql.= " WHERE em.rowid = ".$this->shipping_method_id; |
|
| 1866 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; |
|
| 1867 | + $sql .= " WHERE em.rowid = ".$this->shipping_method_id; |
|
| 1868 | 1868 | |
| 1869 | 1869 | $resql = $this->db->query($sql); |
| 1870 | 1870 | if ($resql) |
@@ -1879,7 +1879,7 @@ discard block |
||
| 1879 | 1879 | if (!empty($tracking) && !empty($value)) |
| 1880 | 1880 | { |
| 1881 | 1881 | $url = str_replace('{TRACKID}', $value, $tracking); |
| 1882 | - $this->tracking_url = sprintf('<a target="_blank" href="%s">'.($value?$value:'url').'</a>',$url,$url); |
|
| 1882 | + $this->tracking_url = sprintf('<a target="_blank" href="%s">'.($value ? $value : 'url').'</a>', $url, $url); |
|
| 1883 | 1883 | } |
| 1884 | 1884 | else |
| 1885 | 1885 | { |
@@ -1894,16 +1894,16 @@ discard block |
||
| 1894 | 1894 | */ |
| 1895 | 1895 | function setClosed() |
| 1896 | 1896 | { |
| 1897 | - global $conf,$langs,$user; |
|
| 1897 | + global $conf, $langs, $user; |
|
| 1898 | 1898 | |
| 1899 | - $error=0; |
|
| 1899 | + $error = 0; |
|
| 1900 | 1900 | |
| 1901 | 1901 | $this->db->begin(); |
| 1902 | 1902 | |
| 1903 | 1903 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut='.self::STATUS_CLOSED; |
| 1904 | 1904 | $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; |
| 1905 | 1905 | |
| 1906 | - $resql=$this->db->query($sql); |
|
| 1906 | + $resql = $this->db->query($sql); |
|
| 1907 | 1907 | if ($resql) |
| 1908 | 1908 | { |
| 1909 | 1909 | // Set order billed if 100% of order is shipped (qty in shipment lines match qty in order lines) |
@@ -1912,17 +1912,17 @@ discard block |
||
| 1912 | 1912 | $order = new Commande($this->db); |
| 1913 | 1913 | $order->fetch($this->origin_id); |
| 1914 | 1914 | |
| 1915 | - $order->loadExpeditions(self::STATUS_CLOSED); // Fill $order->expeditions = array(orderlineid => qty) |
|
| 1915 | + $order->loadExpeditions(self::STATUS_CLOSED); // Fill $order->expeditions = array(orderlineid => qty) |
|
| 1916 | 1916 | |
| 1917 | 1917 | $shipments_match_order = 1; |
| 1918 | - foreach($order->lines as $line) |
|
| 1918 | + foreach ($order->lines as $line) |
|
| 1919 | 1919 | { |
| 1920 | 1920 | $lineid = $line->id; |
| 1921 | 1921 | $qty = $line->qty; |
| 1922 | - if (($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $order->expeditions[$lineid] != $qty) |
|
| 1922 | + if (($line->product_type == 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $order->expeditions[$lineid] != $qty) |
|
| 1923 | 1923 | { |
| 1924 | 1924 | $shipments_match_order = 0; |
| 1925 | - $text='Qty for order line id '.$lineid.' is '.$qty.'. However in the shipments with status Expedition::STATUS_CLOSED='.self::STATUS_CLOSED.' we have qty = '.$order->expeditions[$lineid].', so we can t close order'; |
|
| 1925 | + $text = 'Qty for order line id '.$lineid.' is '.$qty.'. However in the shipments with status Expedition::STATUS_CLOSED='.self::STATUS_CLOSED.' we have qty = '.$order->expeditions[$lineid].', so we can t close order'; |
|
| 1926 | 1926 | dol_syslog($text); |
| 1927 | 1927 | break; |
| 1928 | 1928 | } |
@@ -1934,11 +1934,11 @@ discard block |
||
| 1934 | 1934 | } |
| 1935 | 1935 | } |
| 1936 | 1936 | |
| 1937 | - $this->statut=self::STATUS_CLOSED; |
|
| 1937 | + $this->statut = self::STATUS_CLOSED; |
|
| 1938 | 1938 | |
| 1939 | 1939 | |
| 1940 | 1940 | // If stock increment is done on closing |
| 1941 | - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) |
|
| 1941 | + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) |
|
| 1942 | 1942 | { |
| 1943 | 1943 | require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; |
| 1944 | 1944 | |
@@ -1947,16 +1947,16 @@ discard block |
||
| 1947 | 1947 | // Loop on each product line to add a stock movement |
| 1948 | 1948 | // TODO possibilite d'expedier a partir d'une propale ou autre origine ? |
| 1949 | 1949 | $sql = "SELECT cd.fk_product, cd.subprice,"; |
| 1950 | - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; |
|
| 1951 | - $sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; |
|
| 1952 | - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; |
|
| 1953 | - $sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
| 1954 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; |
|
| 1955 | - $sql.= " WHERE ed.fk_expedition = ".$this->id; |
|
| 1956 | - $sql.= " AND cd.rowid = ed.fk_origin_line"; |
|
| 1950 | + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; |
|
| 1951 | + $sql .= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; |
|
| 1952 | + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; |
|
| 1953 | + $sql .= " ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
| 1954 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; |
|
| 1955 | + $sql .= " WHERE ed.fk_expedition = ".$this->id; |
|
| 1956 | + $sql .= " AND cd.rowid = ed.fk_origin_line"; |
|
| 1957 | 1957 | |
| 1958 | 1958 | dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); |
| 1959 | - $resql=$this->db->query($sql); |
|
| 1959 | + $resql = $this->db->query($sql); |
|
| 1960 | 1960 | if ($resql) |
| 1961 | 1961 | { |
| 1962 | 1962 | $cpt = $this->db->num_rows($resql); |
@@ -1982,7 +1982,7 @@ discard block |
||
| 1982 | 1982 | // line without batch detail |
| 1983 | 1983 | |
| 1984 | 1984 | // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record |
| 1985 | - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr",$numref)); |
|
| 1985 | + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $numref)); |
|
| 1986 | 1986 | if ($result < 0) { |
| 1987 | 1987 | $this->error = $mouvS->error; |
| 1988 | 1988 | $this->errors = $mouvS->errors; |
@@ -1994,7 +1994,7 @@ discard block |
||
| 1994 | 1994 | // line with batch detail |
| 1995 | 1995 | |
| 1996 | 1996 | // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record |
| 1997 | - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr",$numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); |
|
| 1997 | + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); |
|
| 1998 | 1998 | if ($result < 0) { |
| 1999 | 1999 | $this->error = $mouvS->error; |
| 2000 | 2000 | $this->errors = $mouvS->errors; |
@@ -2005,15 +2005,15 @@ discard block |
||
| 2005 | 2005 | } |
| 2006 | 2006 | else |
| 2007 | 2007 | { |
| 2008 | - $this->error=$this->db->lasterror(); |
|
| 2008 | + $this->error = $this->db->lasterror(); |
|
| 2009 | 2009 | $error++; |
| 2010 | 2010 | } |
| 2011 | 2011 | } |
| 2012 | 2012 | |
| 2013 | 2013 | // Call trigger |
| 2014 | - if (! $error) |
|
| 2014 | + if (!$error) |
|
| 2015 | 2015 | { |
| 2016 | - $result=$this->call_trigger('SHIPPING_CLOSED',$user); |
|
| 2016 | + $result = $this->call_trigger('SHIPPING_CLOSED', $user); |
|
| 2017 | 2017 | if ($result < 0) { |
| 2018 | 2018 | $error++; |
| 2019 | 2019 | } |
@@ -2025,7 +2025,7 @@ discard block |
||
| 2025 | 2025 | $error++; |
| 2026 | 2026 | } |
| 2027 | 2027 | |
| 2028 | - if (! $error) |
|
| 2028 | + if (!$error) |
|
| 2029 | 2029 | { |
| 2030 | 2030 | $this->db->commit(); |
| 2031 | 2031 | return 1; |
@@ -2045,28 +2045,28 @@ discard block |
||
| 2045 | 2045 | function set_billed() |
| 2046 | 2046 | { |
| 2047 | 2047 | global $user; |
| 2048 | - $error=0; |
|
| 2048 | + $error = 0; |
|
| 2049 | 2049 | |
| 2050 | 2050 | $this->db->begin(); |
| 2051 | 2051 | |
| 2052 | - $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed |
|
| 2052 | + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed |
|
| 2053 | 2053 | $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; |
| 2054 | 2054 | |
| 2055 | - $resql=$this->db->query($sql); |
|
| 2055 | + $resql = $this->db->query($sql); |
|
| 2056 | 2056 | if ($resql) |
| 2057 | 2057 | { |
| 2058 | - $this->statut=2; |
|
| 2059 | - $this->billed=1; |
|
| 2058 | + $this->statut = 2; |
|
| 2059 | + $this->billed = 1; |
|
| 2060 | 2060 | |
| 2061 | 2061 | // Call trigger |
| 2062 | - $result=$this->call_trigger('SHIPPING_BILLED',$user); |
|
| 2062 | + $result = $this->call_trigger('SHIPPING_BILLED', $user); |
|
| 2063 | 2063 | if ($result < 0) { |
| 2064 | 2064 | $error++; |
| 2065 | 2065 | } |
| 2066 | 2066 | |
| 2067 | 2067 | } else { |
| 2068 | 2068 | $error++; |
| 2069 | - $this->errors[]=$this->db->lasterror; |
|
| 2069 | + $this->errors[] = $this->db->lasterror; |
|
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | 2072 | if (empty($error)) { |
@@ -2087,9 +2087,9 @@ discard block |
||
| 2087 | 2087 | */ |
| 2088 | 2088 | function reOpen() |
| 2089 | 2089 | { |
| 2090 | - global $conf,$langs,$user; |
|
| 2090 | + global $conf, $langs, $user; |
|
| 2091 | 2091 | |
| 2092 | - $error=0; |
|
| 2092 | + $error = 0; |
|
| 2093 | 2093 | |
| 2094 | 2094 | // Protection. This avoid to move stock later when we should not |
| 2095 | 2095 | if ($this->statut == self::STATUS_VALIDATED) |
@@ -2102,14 +2102,14 @@ discard block |
||
| 2102 | 2102 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1'; |
| 2103 | 2103 | $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; |
| 2104 | 2104 | |
| 2105 | - $resql=$this->db->query($sql); |
|
| 2105 | + $resql = $this->db->query($sql); |
|
| 2106 | 2106 | if ($resql) |
| 2107 | 2107 | { |
| 2108 | - $this->statut=1; |
|
| 2109 | - $this->billed=0; |
|
| 2108 | + $this->statut = 1; |
|
| 2109 | + $this->billed = 0; |
|
| 2110 | 2110 | |
| 2111 | 2111 | // If stock increment is done on closing |
| 2112 | - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) |
|
| 2112 | + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) |
|
| 2113 | 2113 | { |
| 2114 | 2114 | require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; |
| 2115 | 2115 | |
@@ -2118,16 +2118,16 @@ discard block |
||
| 2118 | 2118 | // Loop on each product line to add a stock movement |
| 2119 | 2119 | // TODO possibilite d'expedier a partir d'une propale ou autre origine |
| 2120 | 2120 | $sql = "SELECT cd.fk_product, cd.subprice,"; |
| 2121 | - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; |
|
| 2122 | - $sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; |
|
| 2123 | - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; |
|
| 2124 | - $sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
| 2125 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; |
|
| 2126 | - $sql.= " WHERE ed.fk_expedition = ".$this->id; |
|
| 2127 | - $sql.= " AND cd.rowid = ed.fk_origin_line"; |
|
| 2121 | + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; |
|
| 2122 | + $sql .= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; |
|
| 2123 | + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; |
|
| 2124 | + $sql .= " ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
| 2125 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; |
|
| 2126 | + $sql .= " WHERE ed.fk_expedition = ".$this->id; |
|
| 2127 | + $sql .= " AND cd.rowid = ed.fk_origin_line"; |
|
| 2128 | 2128 | |
| 2129 | 2129 | dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); |
| 2130 | - $resql=$this->db->query($sql); |
|
| 2130 | + $resql = $this->db->query($sql); |
|
| 2131 | 2131 | if ($resql) |
| 2132 | 2132 | { |
| 2133 | 2133 | $cpt = $this->db->num_rows($resql); |
@@ -2154,7 +2154,7 @@ discard block |
||
| 2154 | 2154 | // line without batch detail |
| 2155 | 2155 | |
| 2156 | 2156 | // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record |
| 2157 | - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr",$numref)); |
|
| 2157 | + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr", $numref)); |
|
| 2158 | 2158 | if ($result < 0) { |
| 2159 | 2159 | $this->error = $mouvS->error; |
| 2160 | 2160 | $this->errors = $mouvS->errors; |
@@ -2166,7 +2166,7 @@ discard block |
||
| 2166 | 2166 | // line with batch detail |
| 2167 | 2167 | |
| 2168 | 2168 | // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record |
| 2169 | - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr",$numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); |
|
| 2169 | + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); |
|
| 2170 | 2170 | if ($result < 0) { |
| 2171 | 2171 | $this->error = $mouvS->error; |
| 2172 | 2172 | $this->errors = $mouvS->errors; |
@@ -2177,15 +2177,15 @@ discard block |
||
| 2177 | 2177 | } |
| 2178 | 2178 | else |
| 2179 | 2179 | { |
| 2180 | - $this->error=$this->db->lasterror(); |
|
| 2180 | + $this->error = $this->db->lasterror(); |
|
| 2181 | 2181 | $error++; |
| 2182 | 2182 | } |
| 2183 | 2183 | } |
| 2184 | 2184 | |
| 2185 | - if (! $error) |
|
| 2185 | + if (!$error) |
|
| 2186 | 2186 | { |
| 2187 | 2187 | // Call trigger |
| 2188 | - $result=$this->call_trigger('SHIPPING_REOPEN',$user); |
|
| 2188 | + $result = $this->call_trigger('SHIPPING_REOPEN', $user); |
|
| 2189 | 2189 | if ($result < 0) { |
| 2190 | 2190 | $error++; |
| 2191 | 2191 | } |
@@ -2193,10 +2193,10 @@ discard block |
||
| 2193 | 2193 | |
| 2194 | 2194 | } else { |
| 2195 | 2195 | $error++; |
| 2196 | - $this->errors[]=$this->db->lasterror(); |
|
| 2196 | + $this->errors[] = $this->db->lasterror(); |
|
| 2197 | 2197 | } |
| 2198 | 2198 | |
| 2199 | - if (! $error) |
|
| 2199 | + if (!$error) |
|
| 2200 | 2200 | { |
| 2201 | 2201 | $this->db->commit(); |
| 2202 | 2202 | return 1; |
@@ -2218,19 +2218,19 @@ discard block |
||
| 2218 | 2218 | * @param int $hideref Hide ref |
| 2219 | 2219 | * @return int 0 if KO, 1 if OK |
| 2220 | 2220 | */ |
| 2221 | - public function generateDocument($modele, $outputlangs,$hidedetails=0, $hidedesc=0, $hideref=0) |
|
| 2221 | + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
| 2222 | 2222 | { |
| 2223 | - global $conf,$langs; |
|
| 2223 | + global $conf, $langs; |
|
| 2224 | 2224 | |
| 2225 | 2225 | $langs->load("sendings"); |
| 2226 | 2226 | |
| 2227 | - if (! dol_strlen($modele)) { |
|
| 2227 | + if (!dol_strlen($modele)) { |
|
| 2228 | 2228 | |
| 2229 | 2229 | $modele = 'rouget'; |
| 2230 | 2230 | |
| 2231 | 2231 | if ($this->modelpdf) { |
| 2232 | 2232 | $modele = $this->modelpdf; |
| 2233 | - } elseif (! empty($conf->global->EXPEDITION_ADDON_PDF)) { |
|
| 2233 | + } elseif (!empty($conf->global->EXPEDITION_ADDON_PDF)) { |
|
| 2234 | 2234 | $modele = $conf->global->EXPEDITION_ADDON_PDF; |
| 2235 | 2235 | } |
| 2236 | 2236 | } |
@@ -2266,8 +2266,8 @@ discard block |
||
| 2266 | 2266 | */ |
| 2267 | 2267 | class ExpeditionLigne extends CommonObjectLine |
| 2268 | 2268 | { |
| 2269 | - public $element='expeditiondet'; |
|
| 2270 | - public $table_element='expeditiondet'; |
|
| 2269 | + public $element = 'expeditiondet'; |
|
| 2270 | + public $table_element = 'expeditiondet'; |
|
| 2271 | 2271 | |
| 2272 | 2272 | public $fk_origin_line; |
| 2273 | 2273 | |
@@ -2300,11 +2300,11 @@ discard block |
||
| 2300 | 2300 | |
| 2301 | 2301 | // Invoicing |
| 2302 | 2302 | var $remise_percent; |
| 2303 | - var $total_ht; // Total net of tax |
|
| 2304 | - var $total_ttc; // Total with tax |
|
| 2305 | - var $total_tva; // Total VAT |
|
| 2306 | - var $total_localtax1; // Total Local tax 1 |
|
| 2307 | - var $total_localtax2; // Total Local tax 2 |
|
| 2303 | + var $total_ht; // Total net of tax |
|
| 2304 | + var $total_ttc; // Total with tax |
|
| 2305 | + var $total_tva; // Total VAT |
|
| 2306 | + var $total_localtax1; // Total Local tax 1 |
|
| 2307 | + var $total_localtax2; // Total Local tax 2 |
|
| 2308 | 2308 | |
| 2309 | 2309 | |
| 2310 | 2310 | |
@@ -2332,7 +2332,7 @@ discard block |
||
| 2332 | 2332 | */ |
| 2333 | 2333 | function __construct($db) |
| 2334 | 2334 | { |
| 2335 | - $this->db=$db; |
|
| 2335 | + $this->db = $db; |
|
| 2336 | 2336 | } |
| 2337 | 2337 | |
| 2338 | 2338 | /** |
@@ -2344,18 +2344,18 @@ discard block |
||
| 2344 | 2344 | function fetch($rowid) |
| 2345 | 2345 | { |
| 2346 | 2346 | $sql = 'SELECT ed.rowid, ed.fk_expedition, ed.fk_entrepot, ed.fk_origin_line, ed.qty, ed.rang'; |
| 2347 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as ed'; |
|
| 2348 | - $sql.= ' WHERE ed.rowid = '.$rowid; |
|
| 2347 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as ed'; |
|
| 2348 | + $sql .= ' WHERE ed.rowid = '.$rowid; |
|
| 2349 | 2349 | $result = $this->db->query($sql); |
| 2350 | 2350 | if ($result) |
| 2351 | 2351 | { |
| 2352 | 2352 | $objp = $this->db->fetch_object($result); |
| 2353 | - $this->id = $objp->rowid; |
|
| 2354 | - $this->fk_expedition = $objp->fk_expedition; |
|
| 2355 | - $this->entrepot_id = $objp->fk_entrepot; |
|
| 2356 | - $this->fk_origin_line = $objp->fk_origin_line; |
|
| 2357 | - $this->qty = $objp->qty; |
|
| 2358 | - $this->rang = $objp->rang; |
|
| 2353 | + $this->id = $objp->rowid; |
|
| 2354 | + $this->fk_expedition = $objp->fk_expedition; |
|
| 2355 | + $this->entrepot_id = $objp->fk_entrepot; |
|
| 2356 | + $this->fk_origin_line = $objp->fk_origin_line; |
|
| 2357 | + $this->qty = $objp->qty; |
|
| 2358 | + $this->rang = $objp->rang; |
|
| 2359 | 2359 | |
| 2360 | 2360 | $this->db->free($result); |
| 2361 | 2361 | |
@@ -2376,11 +2376,11 @@ discard block |
||
| 2376 | 2376 | * @param int $notrigger 1 = disable triggers |
| 2377 | 2377 | * @return int <0 if KO, line id >0 if OK |
| 2378 | 2378 | */ |
| 2379 | - function insert($user=null, $notrigger=0) |
|
| 2379 | + function insert($user = null, $notrigger = 0) |
|
| 2380 | 2380 | { |
| 2381 | 2381 | global $langs, $conf; |
| 2382 | 2382 | |
| 2383 | - $error=0; |
|
| 2383 | + $error = 0; |
|
| 2384 | 2384 | |
| 2385 | 2385 | // Check parameters |
| 2386 | 2386 | if (empty($this->fk_expedition) || empty($this->fk_origin_line) || empty($this->qty)) |
@@ -2389,21 +2389,21 @@ discard block |
||
| 2389 | 2389 | return -1; |
| 2390 | 2390 | } |
| 2391 | 2391 | // Clean parameters |
| 2392 | - if (empty($this->entrepot_id)) $this->entrepot_id='null'; |
|
| 2392 | + if (empty($this->entrepot_id)) $this->entrepot_id = 'null'; |
|
| 2393 | 2393 | |
| 2394 | 2394 | $this->db->begin(); |
| 2395 | 2395 | |
| 2396 | 2396 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet ("; |
| 2397 | - $sql.= "fk_expedition"; |
|
| 2398 | - $sql.= ", fk_entrepot"; |
|
| 2399 | - $sql.= ", fk_origin_line"; |
|
| 2400 | - $sql.= ", qty"; |
|
| 2401 | - $sql.= ") VALUES ("; |
|
| 2402 | - $sql.= $this->fk_expedition; |
|
| 2403 | - $sql.= ", ".$this->entrepot_id; |
|
| 2404 | - $sql.= ", ".$this->fk_origin_line; |
|
| 2405 | - $sql.= ", ".$this->qty; |
|
| 2406 | - $sql.= ")"; |
|
| 2397 | + $sql .= "fk_expedition"; |
|
| 2398 | + $sql .= ", fk_entrepot"; |
|
| 2399 | + $sql .= ", fk_origin_line"; |
|
| 2400 | + $sql .= ", qty"; |
|
| 2401 | + $sql .= ") VALUES ("; |
|
| 2402 | + $sql .= $this->fk_expedition; |
|
| 2403 | + $sql .= ", ".$this->entrepot_id; |
|
| 2404 | + $sql .= ", ".$this->fk_origin_line; |
|
| 2405 | + $sql .= ", ".$this->qty; |
|
| 2406 | + $sql .= ")"; |
|
| 2407 | 2407 | |
| 2408 | 2408 | dol_syslog(get_class($this)."::insert", LOG_DEBUG); |
| 2409 | 2409 | $resql = $this->db->query($sql); |
@@ -2412,37 +2412,37 @@ discard block |
||
| 2412 | 2412 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet"); |
| 2413 | 2413 | if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
| 2414 | 2414 | { |
| 2415 | - $result=$this->insertExtraFields(); |
|
| 2415 | + $result = $this->insertExtraFields(); |
|
| 2416 | 2416 | if ($result < 0) |
| 2417 | 2417 | { |
| 2418 | 2418 | $error++; |
| 2419 | 2419 | } |
| 2420 | 2420 | } |
| 2421 | 2421 | |
| 2422 | - if (! $error && ! $notrigger) |
|
| 2422 | + if (!$error && !$notrigger) |
|
| 2423 | 2423 | { |
| 2424 | 2424 | // Call trigger |
| 2425 | - $result=$this->call_trigger('LINESHIPPING_INSERT',$user); |
|
| 2425 | + $result = $this->call_trigger('LINESHIPPING_INSERT', $user); |
|
| 2426 | 2426 | if ($result < 0) |
| 2427 | 2427 | { |
| 2428 | - $this->errors[]=$this->error; |
|
| 2428 | + $this->errors[] = $this->error; |
|
| 2429 | 2429 | $error++; |
| 2430 | 2430 | } |
| 2431 | 2431 | // End call triggers |
| 2432 | 2432 | } |
| 2433 | 2433 | |
| 2434 | - if (! $error) { |
|
| 2434 | + if (!$error) { |
|
| 2435 | 2435 | $this->db->commit(); |
| 2436 | 2436 | return $this->id; |
| 2437 | 2437 | } |
| 2438 | 2438 | |
| 2439 | - foreach($this->errors as $errmsg) |
|
| 2439 | + foreach ($this->errors as $errmsg) |
|
| 2440 | 2440 | { |
| 2441 | 2441 | dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
| 2442 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 2442 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 2443 | 2443 | } |
| 2444 | 2444 | $this->db->rollback(); |
| 2445 | - return -1*$error; |
|
| 2445 | + return -1 * $error; |
|
| 2446 | 2446 | } |
| 2447 | 2447 | else |
| 2448 | 2448 | { |
@@ -2461,7 +2461,7 @@ discard block |
||
| 2461 | 2461 | { |
| 2462 | 2462 | global $conf; |
| 2463 | 2463 | |
| 2464 | - $error=0; |
|
| 2464 | + $error = 0; |
|
| 2465 | 2465 | |
| 2466 | 2466 | $this->db->begin(); |
| 2467 | 2467 | |
@@ -2469,37 +2469,37 @@ discard block |
||
| 2469 | 2469 | if ($conf->productbatch->enabled) |
| 2470 | 2470 | { |
| 2471 | 2471 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_batch"; |
| 2472 | - $sql.= " WHERE fk_expeditiondet = ".$this->id; |
|
| 2472 | + $sql .= " WHERE fk_expeditiondet = ".$this->id; |
|
| 2473 | 2473 | |
| 2474 | 2474 | if (!$this->db->query($sql)) |
| 2475 | 2475 | { |
| 2476 | - $this->errors[]=$this->db->lasterror()." - sql=$sql"; |
|
| 2476 | + $this->errors[] = $this->db->lasterror()." - sql=$sql"; |
|
| 2477 | 2477 | $error++; |
| 2478 | 2478 | } |
| 2479 | 2479 | } |
| 2480 | 2480 | |
| 2481 | 2481 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet"; |
| 2482 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 2482 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 2483 | 2483 | |
| 2484 | - if (! $error && $this->db->query($sql)) |
|
| 2484 | + if (!$error && $this->db->query($sql)) |
|
| 2485 | 2485 | { |
| 2486 | 2486 | // Remove extrafields |
| 2487 | 2487 | if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
| 2488 | 2488 | { |
| 2489 | - $result=$this->deleteExtraFields(); |
|
| 2489 | + $result = $this->deleteExtraFields(); |
|
| 2490 | 2490 | if ($result < 0) |
| 2491 | 2491 | { |
| 2492 | - $this->errors[]=$this->error; |
|
| 2492 | + $this->errors[] = $this->error; |
|
| 2493 | 2493 | $error++; |
| 2494 | 2494 | } |
| 2495 | 2495 | } |
| 2496 | - if (! $error && ! $notrigger) |
|
| 2496 | + if (!$error && !$notrigger) |
|
| 2497 | 2497 | { |
| 2498 | 2498 | // Call trigger |
| 2499 | - $result=$this->call_trigger('LINESHIPPING_DELETE',$user); |
|
| 2499 | + $result = $this->call_trigger('LINESHIPPING_DELETE', $user); |
|
| 2500 | 2500 | if ($result < 0) |
| 2501 | 2501 | { |
| 2502 | - $this->errors[]=$this->error; |
|
| 2502 | + $this->errors[] = $this->error; |
|
| 2503 | 2503 | $error++; |
| 2504 | 2504 | } |
| 2505 | 2505 | // End call triggers |
@@ -2507,23 +2507,23 @@ discard block |
||
| 2507 | 2507 | } |
| 2508 | 2508 | else |
| 2509 | 2509 | { |
| 2510 | - $this->errors[]=$this->db->lasterror()." - sql=$sql"; |
|
| 2510 | + $this->errors[] = $this->db->lasterror()." - sql=$sql"; |
|
| 2511 | 2511 | $error++; |
| 2512 | 2512 | } |
| 2513 | 2513 | |
| 2514 | - if (! $error) { |
|
| 2514 | + if (!$error) { |
|
| 2515 | 2515 | $this->db->commit(); |
| 2516 | 2516 | return 1; |
| 2517 | 2517 | } |
| 2518 | 2518 | else |
| 2519 | 2519 | { |
| 2520 | - foreach($this->errors as $errmsg) |
|
| 2520 | + foreach ($this->errors as $errmsg) |
|
| 2521 | 2521 | { |
| 2522 | 2522 | dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
| 2523 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 2523 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 2524 | 2524 | } |
| 2525 | 2525 | $this->db->rollback(); |
| 2526 | - return -1*$error; |
|
| 2526 | + return -1 * $error; |
|
| 2527 | 2527 | } |
| 2528 | 2528 | } |
| 2529 | 2529 | |
@@ -2538,15 +2538,15 @@ discard block |
||
| 2538 | 2538 | { |
| 2539 | 2539 | global $conf; |
| 2540 | 2540 | |
| 2541 | - $error=0; |
|
| 2541 | + $error = 0; |
|
| 2542 | 2542 | |
| 2543 | 2543 | dol_syslog(get_class($this)."::update id=$this->id, entrepot_id=$this->entrepot_id, product_id=$this->fk_product, qty=$this->qty"); |
| 2544 | 2544 | |
| 2545 | 2545 | $this->db->begin(); |
| 2546 | 2546 | |
| 2547 | 2547 | // Clean parameters |
| 2548 | - if (empty($this->qty)) $this->qty=0; |
|
| 2549 | - $qty=price2num($this->qty); |
|
| 2548 | + if (empty($this->qty)) $this->qty = 0; |
|
| 2549 | + $qty = price2num($this->qty); |
|
| 2550 | 2550 | $remainingQty = 0; |
| 2551 | 2551 | $batch = null; |
| 2552 | 2552 | $batch_id = null; |
@@ -2556,7 +2556,7 @@ discard block |
||
| 2556 | 2556 | if (count($this->detail_batch) > 1) |
| 2557 | 2557 | { |
| 2558 | 2558 | dol_syslog(get_class($this).'::update only possible for one batch', LOG_ERR); |
| 2559 | - $this->errors[]='ErrorBadParameters'; |
|
| 2559 | + $this->errors[] = 'ErrorBadParameters'; |
|
| 2560 | 2560 | $error++; |
| 2561 | 2561 | } |
| 2562 | 2562 | else |
@@ -2567,13 +2567,13 @@ discard block |
||
| 2567 | 2567 | if ($this->entrepot_id != $this->detail_batch[0]->entrepot_id) |
| 2568 | 2568 | { |
| 2569 | 2569 | dol_syslog(get_class($this).'::update only possible for batch of same warehouse', LOG_ERR); |
| 2570 | - $this->errors[]='ErrorBadParameters'; |
|
| 2570 | + $this->errors[] = 'ErrorBadParameters'; |
|
| 2571 | 2571 | $error++; |
| 2572 | 2572 | } |
| 2573 | 2573 | $qty = price2num($this->detail_batch[0]->dluo_qty); |
| 2574 | 2574 | } |
| 2575 | 2575 | } |
| 2576 | - else if (! empty($this->detail_batch)) |
|
| 2576 | + else if (!empty($this->detail_batch)) |
|
| 2577 | 2577 | { |
| 2578 | 2578 | $batch = $this->detail_batch->batch; |
| 2579 | 2579 | $batch_id = $this->detail_batch->fk_origin_stock; |
@@ -2581,38 +2581,38 @@ discard block |
||
| 2581 | 2581 | if ($this->entrepot_id != $this->detail_batch->entrepot_id) |
| 2582 | 2582 | { |
| 2583 | 2583 | dol_syslog(get_class($this).'::update only possible for batch of same warehouse', LOG_ERR); |
| 2584 | - $this->errors[]='ErrorBadParameters'; |
|
| 2584 | + $this->errors[] = 'ErrorBadParameters'; |
|
| 2585 | 2585 | $error++; |
| 2586 | 2586 | } |
| 2587 | 2587 | $qty = price2num($this->detail_batch->dluo_qty); |
| 2588 | 2588 | } |
| 2589 | 2589 | |
| 2590 | 2590 | // check parameters |
| 2591 | - if (! isset($this->id) || ! isset($this->entrepot_id)) |
|
| 2591 | + if (!isset($this->id) || !isset($this->entrepot_id)) |
|
| 2592 | 2592 | { |
| 2593 | 2593 | dol_syslog(get_class($this).'::update missing line id and/or warehouse id', LOG_ERR); |
| 2594 | - $this->errors[]='ErrorMandatoryParametersNotProvided'; |
|
| 2594 | + $this->errors[] = 'ErrorMandatoryParametersNotProvided'; |
|
| 2595 | 2595 | $error++; |
| 2596 | 2596 | return -1; |
| 2597 | 2597 | } |
| 2598 | 2598 | |
| 2599 | 2599 | // update lot |
| 2600 | 2600 | |
| 2601 | - if (! empty($batch) && $conf->productbatch->enabled) |
|
| 2601 | + if (!empty($batch) && $conf->productbatch->enabled) |
|
| 2602 | 2602 | { |
| 2603 | 2603 | dol_syslog(get_class($this)."::update expedition batch id=$expedition_batch_id, batch_id=$batch_id, batch=$batch"); |
| 2604 | 2604 | |
| 2605 | 2605 | if (empty($batch_id) || empty($this->fk_product)) { |
| 2606 | 2606 | dol_syslog(get_class($this).'::update missing fk_origin_stock (batch_id) and/or fk_product', LOG_ERR); |
| 2607 | - $this->errors[]='ErrorMandatoryParametersNotProvided'; |
|
| 2607 | + $this->errors[] = 'ErrorMandatoryParametersNotProvided'; |
|
| 2608 | 2608 | $error++; |
| 2609 | 2609 | } |
| 2610 | 2610 | |
| 2611 | 2611 | // fetch remaining lot qty |
| 2612 | 2612 | require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; |
| 2613 | - if (! $error && ($lotArray = ExpeditionLineBatch::fetchAll($this->db, $this->id)) < 0) |
|
| 2613 | + if (!$error && ($lotArray = ExpeditionLineBatch::fetchAll($this->db, $this->id)) < 0) |
|
| 2614 | 2614 | { |
| 2615 | - $this->errors[]=$this->db->lasterror()." - ExpeditionLineBatch::fetchAll"; |
|
| 2615 | + $this->errors[] = $this->db->lasterror()." - ExpeditionLineBatch::fetchAll"; |
|
| 2616 | 2616 | $error++; |
| 2617 | 2617 | } |
| 2618 | 2618 | else |
@@ -2632,25 +2632,25 @@ discard block |
||
| 2632 | 2632 | // fetch from product_lot |
| 2633 | 2633 | require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; |
| 2634 | 2634 | $lot = new Productlot($this->db); |
| 2635 | - if ($lot->fetch(0,$this->fk_product,$batch) < 0) |
|
| 2635 | + if ($lot->fetch(0, $this->fk_product, $batch) < 0) |
|
| 2636 | 2636 | { |
| 2637 | 2637 | $this->errors[] = $lot->errors; |
| 2638 | 2638 | $error++; |
| 2639 | 2639 | } |
| 2640 | - if (! $error && ! empty($expedition_batch_id)) |
|
| 2640 | + if (!$error && !empty($expedition_batch_id)) |
|
| 2641 | 2641 | { |
| 2642 | 2642 | // delete lot expedition line |
| 2643 | 2643 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_batch"; |
| 2644 | - $sql.= " WHERE fk_expeditiondet = ".$this->id; |
|
| 2645 | - $sql.= " AND rowid = ".$expedition_batch_id; |
|
| 2644 | + $sql .= " WHERE fk_expeditiondet = ".$this->id; |
|
| 2645 | + $sql .= " AND rowid = ".$expedition_batch_id; |
|
| 2646 | 2646 | |
| 2647 | 2647 | if (!$this->db->query($sql)) |
| 2648 | 2648 | { |
| 2649 | - $this->errors[]=$this->db->lasterror()." - sql=$sql"; |
|
| 2649 | + $this->errors[] = $this->db->lasterror()." - sql=$sql"; |
|
| 2650 | 2650 | $error++; |
| 2651 | 2651 | } |
| 2652 | 2652 | } |
| 2653 | - if (! $error && $this->detail_batch->dluo_qty > 0) |
|
| 2653 | + if (!$error && $this->detail_batch->dluo_qty > 0) |
|
| 2654 | 2654 | { |
| 2655 | 2655 | // create lot expedition line |
| 2656 | 2656 | if (isset($lot->id)) |
@@ -2664,46 +2664,46 @@ discard block |
||
| 2664 | 2664 | $shipmentLot->fk_origin_stock = $batch_id; |
| 2665 | 2665 | if ($shipmentLot->create($this->id) < 0) |
| 2666 | 2666 | { |
| 2667 | - $this->errors[]=$shipmentLot->errors; |
|
| 2667 | + $this->errors[] = $shipmentLot->errors; |
|
| 2668 | 2668 | $error++; |
| 2669 | 2669 | } |
| 2670 | 2670 | } |
| 2671 | 2671 | } |
| 2672 | 2672 | } |
| 2673 | 2673 | } |
| 2674 | - if (! $error) |
|
| 2674 | + if (!$error) |
|
| 2675 | 2675 | { |
| 2676 | 2676 | // update line |
| 2677 | 2677 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; |
| 2678 | - $sql.= " fk_entrepot = ".($this->entrepot_id > 0 ? $this->entrepot_id : 'null'); |
|
| 2679 | - $sql.= " , qty = ".$qty; |
|
| 2680 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 2678 | + $sql .= " fk_entrepot = ".($this->entrepot_id > 0 ? $this->entrepot_id : 'null'); |
|
| 2679 | + $sql .= " , qty = ".$qty; |
|
| 2680 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 2681 | 2681 | |
| 2682 | 2682 | if (!$this->db->query($sql)) |
| 2683 | 2683 | { |
| 2684 | - $this->errors[]=$this->db->lasterror()." - sql=$sql"; |
|
| 2684 | + $this->errors[] = $this->db->lasterror()." - sql=$sql"; |
|
| 2685 | 2685 | $error++; |
| 2686 | 2686 | } |
| 2687 | 2687 | else |
| 2688 | 2688 | { |
| 2689 | 2689 | if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
| 2690 | 2690 | { |
| 2691 | - $result=$this->insertExtraFields(); |
|
| 2691 | + $result = $this->insertExtraFields(); |
|
| 2692 | 2692 | if ($result < 0) |
| 2693 | 2693 | { |
| 2694 | - $this->errors[]=$this->error; |
|
| 2694 | + $this->errors[] = $this->error; |
|
| 2695 | 2695 | $error++; |
| 2696 | 2696 | } |
| 2697 | 2697 | } |
| 2698 | 2698 | } |
| 2699 | 2699 | } |
| 2700 | - if (! $error && ! $notrigger) |
|
| 2700 | + if (!$error && !$notrigger) |
|
| 2701 | 2701 | { |
| 2702 | 2702 | // Call trigger |
| 2703 | - $result=$this->call_trigger('LINESHIPPING_UPDATE',$user); |
|
| 2703 | + $result = $this->call_trigger('LINESHIPPING_UPDATE', $user); |
|
| 2704 | 2704 | if ($result < 0) |
| 2705 | 2705 | { |
| 2706 | - $this->errors[]=$this->error; |
|
| 2706 | + $this->errors[] = $this->error; |
|
| 2707 | 2707 | $error++; |
| 2708 | 2708 | } |
| 2709 | 2709 | // End call triggers |
@@ -2714,13 +2714,13 @@ discard block |
||
| 2714 | 2714 | } |
| 2715 | 2715 | else |
| 2716 | 2716 | { |
| 2717 | - foreach($this->errors as $errmsg) |
|
| 2717 | + foreach ($this->errors as $errmsg) |
|
| 2718 | 2718 | { |
| 2719 | 2719 | dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
| 2720 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 2720 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 2721 | 2721 | } |
| 2722 | 2722 | $this->db->rollback(); |
| 2723 | - return -1*$error; |
|
| 2723 | + return -1 * $error; |
|
| 2724 | 2724 | } |
| 2725 | 2725 | } |
| 2726 | 2726 | } |
@@ -277,7 +277,7 @@ |
||
| 277 | 277 | /** |
| 278 | 278 | * Clean sensible object datas |
| 279 | 279 | * |
| 280 | - * @param Object $object Object to clean |
|
| 280 | + * @param FactureFournisseur $object Object to clean |
|
| 281 | 281 | * @return array Array of cleaned object properties |
| 282 | 282 | */ |
| 283 | 283 | function _cleanObjectDatas($object) { |
@@ -105,24 +105,47 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | // If the internal user must only see his customers, force searching by him |
| 107 | 107 | $search_sale = 0; |
| 108 | - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; |
|
| 108 | + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { |
|
| 109 | + $search_sale = DolibarrApiAccess::$user->id; |
|
| 110 | + } |
|
| 109 | 111 | |
| 110 | 112 | $sql = "SELECT t.rowid"; |
| 111 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
| 113 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { |
|
| 114 | + $sql .= ", sc.fk_soc, sc.fk_user"; |
|
| 115 | + } |
|
| 116 | + // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
| 112 | 117 | $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as t"; |
| 113 | 118 | |
| 114 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 119 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { |
|
| 120 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 121 | + } |
|
| 122 | + // We need this table joined to the select in order to filter by sale |
|
| 115 | 123 | |
| 116 | 124 | $sql.= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')'; |
| 117 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 118 | - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; |
|
| 119 | - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale |
|
| 125 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { |
|
| 126 | + $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 127 | + } |
|
| 128 | + if ($socids) { |
|
| 129 | + $sql.= " AND t.fk_soc IN (".$socids.")"; |
|
| 130 | + } |
|
| 131 | + if ($search_sale > 0) { |
|
| 132 | + $sql.= " AND t.rowid = sc.fk_soc"; |
|
| 133 | + } |
|
| 134 | + // Join for the needed table to filter by sale |
|
| 120 | 135 | |
| 121 | 136 | // Filter by status |
| 122 | - if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; |
|
| 123 | - if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)"; |
|
| 124 | - if ($status == 'paid') $sql.= " AND t.fk_statut IN (2)"; |
|
| 125 | - if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (3)"; |
|
| 137 | + if ($status == 'draft') { |
|
| 138 | + $sql.= " AND t.fk_statut IN (0)"; |
|
| 139 | + } |
|
| 140 | + if ($status == 'unpaid') { |
|
| 141 | + $sql.= " AND t.fk_statut IN (1)"; |
|
| 142 | + } |
|
| 143 | + if ($status == 'paid') { |
|
| 144 | + $sql.= " AND t.fk_statut IN (2)"; |
|
| 145 | + } |
|
| 146 | + if ($status == 'cancelled') { |
|
| 147 | + $sql.= " AND t.fk_statut IN (3)"; |
|
| 148 | + } |
|
| 126 | 149 | // Insert sale filter |
| 127 | 150 | if ($search_sale > 0) |
| 128 | 151 | { |
@@ -165,8 +188,7 @@ discard block |
||
| 165 | 188 | } |
| 166 | 189 | $i++; |
| 167 | 190 | } |
| 168 | - } |
|
| 169 | - else { |
|
| 191 | + } else { |
|
| 170 | 192 | throw new RestException(503, 'Error when retrieve supplier invoice list : '.$db->lasterror()); |
| 171 | 193 | } |
| 172 | 194 | if( ! count($obj_ret)) { |
@@ -233,12 +255,15 @@ discard block |
||
| 233 | 255 | } |
| 234 | 256 | |
| 235 | 257 | foreach($request_data as $field => $value) { |
| 236 | - if ($field == 'id') continue; |
|
| 258 | + if ($field == 'id') { |
|
| 259 | + continue; |
|
| 260 | + } |
|
| 237 | 261 | $this->invoice->$field = $value; |
| 238 | 262 | } |
| 239 | 263 | |
| 240 | - if($this->invoice->update($id, DolibarrApiAccess::$user)) |
|
| 241 | - return $this->get ($id); |
|
| 264 | + if($this->invoice->update($id, DolibarrApiAccess::$user)) { |
|
| 265 | + return $this->get ($id); |
|
| 266 | + } |
|
| 242 | 267 | |
| 243 | 268 | return false; |
| 244 | 269 | } |
@@ -352,8 +377,9 @@ discard block |
||
| 352 | 377 | { |
| 353 | 378 | $invoice = array(); |
| 354 | 379 | foreach (SupplierInvoices::$FIELDS as $field) { |
| 355 | - if (!isset($data[$field])) |
|
| 356 | - throw new RestException(400, "$field field missing"); |
|
| 380 | + if (!isset($data[$field])) { |
|
| 381 | + throw new RestException(400, "$field field missing"); |
|
| 382 | + } |
|
| 357 | 383 | $invoice[$field] = $data[$field]; |
| 358 | 384 | } |
| 359 | 385 | return $invoice; |
@@ -63,16 +63,16 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | function get($id) |
| 65 | 65 | { |
| 66 | - if(! DolibarrApiAccess::$user->rights->fournisseur->facture->lire) { |
|
| 66 | + if (!DolibarrApiAccess::$user->rights->fournisseur->facture->lire) { |
|
| 67 | 67 | throw new RestException(401); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $result = $this->invoice->fetch($id); |
| 71 | - if( ! $result ) { |
|
| 71 | + if (!$result) { |
|
| 72 | 72 | throw new RestException(404, 'Supplier invoice not found'); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) { |
|
| 75 | + if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { |
|
| 76 | 76 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @throws RestException |
| 98 | 98 | */ |
| 99 | - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') { |
|
| 99 | + function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') { |
|
| 100 | 100 | global $db, $conf; |
| 101 | 101 | |
| 102 | 102 | $obj_ret = array(); |
@@ -106,24 +106,24 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | // If the internal user must only see his customers, force searching by him |
| 108 | 108 | $search_sale = 0; |
| 109 | - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; |
|
| 109 | + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; |
|
| 110 | 110 | |
| 111 | 111 | $sql = "SELECT t.rowid"; |
| 112 | 112 | if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
| 113 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as t"; |
|
| 113 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t"; |
|
| 114 | 114 | |
| 115 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 115 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 116 | 116 | |
| 117 | - $sql.= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')'; |
|
| 118 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 119 | - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; |
|
| 120 | - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale |
|
| 117 | + $sql .= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')'; |
|
| 118 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; |
|
| 119 | + if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; |
|
| 120 | + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale |
|
| 121 | 121 | |
| 122 | 122 | // Filter by status |
| 123 | - if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; |
|
| 124 | - if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)"; |
|
| 125 | - if ($status == 'paid') $sql.= " AND t.fk_statut IN (2)"; |
|
| 126 | - if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (3)"; |
|
| 123 | + if ($status == 'draft') $sql .= " AND t.fk_statut IN (0)"; |
|
| 124 | + if ($status == 'unpaid') $sql .= " AND t.fk_statut IN (1)"; |
|
| 125 | + if ($status == 'paid') $sql .= " AND t.fk_statut IN (2)"; |
|
| 126 | + if ($status == 'cancelled') $sql .= " AND t.fk_statut IN (3)"; |
|
| 127 | 127 | // Insert sale filter |
| 128 | 128 | if ($search_sale > 0) |
| 129 | 129 | { |
@@ -132,23 +132,23 @@ discard block |
||
| 132 | 132 | // Add sql filters |
| 133 | 133 | if ($sqlfilters) |
| 134 | 134 | { |
| 135 | - if (! DolibarrApi::_checkFilters($sqlfilters)) |
|
| 135 | + if (!DolibarrApi::_checkFilters($sqlfilters)) |
|
| 136 | 136 | { |
| 137 | 137 | throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); |
| 138 | 138 | } |
| 139 | - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 140 | - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
| 139 | + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 140 | + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - $sql.= $db->order($sortfield, $sortorder); |
|
| 144 | - if ($limit) { |
|
| 143 | + $sql .= $db->order($sortfield, $sortorder); |
|
| 144 | + if ($limit) { |
|
| 145 | 145 | if ($page < 0) |
| 146 | 146 | { |
| 147 | 147 | $page = 0; |
| 148 | 148 | } |
| 149 | 149 | $offset = $limit * $page; |
| 150 | 150 | |
| 151 | - $sql.= $db->plimit($limit + 1, $offset); |
|
| 151 | + $sql .= $db->plimit($limit + 1, $offset); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | $result = $db->query($sql); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | { |
| 162 | 162 | $obj = $db->fetch_object($result); |
| 163 | 163 | $invoice_static = new FactureFournisseur($db); |
| 164 | - if($invoice_static->fetch($obj->rowid)) { |
|
| 164 | + if ($invoice_static->fetch($obj->rowid)) { |
|
| 165 | 165 | $obj_ret[] = $this->_cleanObjectDatas($invoice_static); |
| 166 | 166 | } |
| 167 | 167 | $i++; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | else { |
| 171 | 171 | throw new RestException(503, 'Error when retrieve supplier invoice list : '.$db->lasterror()); |
| 172 | 172 | } |
| 173 | - if( ! count($obj_ret)) { |
|
| 173 | + if (!count($obj_ret)) { |
|
| 174 | 174 | throw new RestException(404, 'No supplier invoice found'); |
| 175 | 175 | } |
| 176 | 176 | return $obj_ret; |
@@ -184,16 +184,16 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | function post($request_data = NULL) |
| 186 | 186 | { |
| 187 | - if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { |
|
| 187 | + if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { |
|
| 188 | 188 | throw new RestException(401, "Insuffisant rights"); |
| 189 | 189 | } |
| 190 | 190 | // Check mandatory fields |
| 191 | 191 | $result = $this->_validate($request_data); |
| 192 | 192 | |
| 193 | - foreach($request_data as $field => $value) { |
|
| 193 | + foreach ($request_data as $field => $value) { |
|
| 194 | 194 | $this->invoice->$field = $value; |
| 195 | 195 | } |
| 196 | - if(! array_keys($request_data,'date')) { |
|
| 196 | + if (!array_keys($request_data, 'date')) { |
|
| 197 | 197 | $this->invoice->date = dol_now(); |
| 198 | 198 | } |
| 199 | 199 | /* We keep lines as an array |
@@ -220,26 +220,26 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | function put($id, $request_data = NULL) |
| 222 | 222 | { |
| 223 | - if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { |
|
| 223 | + if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { |
|
| 224 | 224 | throw new RestException(401); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | $result = $this->invoice->fetch($id); |
| 228 | - if( ! $result ) { |
|
| 228 | + if (!$result) { |
|
| 229 | 229 | throw new RestException(404, 'Supplier invoice not found'); |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) { |
|
| 232 | + if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { |
|
| 233 | 233 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - foreach($request_data as $field => $value) { |
|
| 236 | + foreach ($request_data as $field => $value) { |
|
| 237 | 237 | if ($field == 'id') continue; |
| 238 | 238 | $this->invoice->$field = $value; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if($this->invoice->update($id, DolibarrApiAccess::$user)) |
|
| 242 | - return $this->get ($id); |
|
| 241 | + if ($this->invoice->update($id, DolibarrApiAccess::$user)) |
|
| 242 | + return $this->get($id); |
|
| 243 | 243 | |
| 244 | 244 | return false; |
| 245 | 245 | } |
@@ -252,19 +252,19 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | function delete($id) |
| 254 | 254 | { |
| 255 | - if(! DolibarrApiAccess::$user->rights->fournisseur->facture->supprimer) { |
|
| 255 | + if (!DolibarrApiAccess::$user->rights->fournisseur->facture->supprimer) { |
|
| 256 | 256 | throw new RestException(401); |
| 257 | 257 | } |
| 258 | 258 | $result = $this->invoice->fetch($id); |
| 259 | - if( ! $result ) { |
|
| 259 | + if (!$result) { |
|
| 260 | 260 | throw new RestException(404, 'Supplier invoice not found'); |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) { |
|
| 263 | + if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { |
|
| 264 | 264 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if( $this->invoice->delete(DolibarrApiAccess::$user) < 0) |
|
| 267 | + if ($this->invoice->delete(DolibarrApiAccess::$user) < 0) |
|
| 268 | 268 | { |
| 269 | 269 | throw new RestException(500); |
| 270 | 270 | } |
@@ -296,17 +296,17 @@ discard block |
||
| 296 | 296 | * "notrigger": 0 |
| 297 | 297 | * } |
| 298 | 298 | */ |
| 299 | - function validate($id, $idwarehouse=0, $notrigger=0) |
|
| 299 | + function validate($id, $idwarehouse = 0, $notrigger = 0) |
|
| 300 | 300 | { |
| 301 | - if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { |
|
| 301 | + if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { |
|
| 302 | 302 | throw new RestException(401); |
| 303 | 303 | } |
| 304 | 304 | $result = $this->invoice->fetch($id); |
| 305 | - if( ! $result ) { |
|
| 305 | + if (!$result) { |
|
| 306 | 306 | throw new RestException(404, 'Invoice not found'); |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) { |
|
| 309 | + if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { |
|
| 310 | 310 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 311 | 311 | } |
| 312 | 312 | |
@@ -28,49 +28,49 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | class SupplierInvoices extends DolibarrApi |
| 30 | 30 | { |
| 31 | - /** |
|
| 32 | - * |
|
| 33 | - * @var array $FIELDS Mandatory fields, checked when create and update object |
|
| 34 | - */ |
|
| 35 | - static $FIELDS = array( |
|
| 36 | - 'socid' |
|
| 37 | - ); |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @var FactureFournisseur $invoice {@type FactureFournisseur} |
|
| 41 | - */ |
|
| 42 | - public $invoice; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Constructor |
|
| 46 | - */ |
|
| 47 | - function __construct() |
|
| 48 | - { |
|
| 31 | + /** |
|
| 32 | + * |
|
| 33 | + * @var array $FIELDS Mandatory fields, checked when create and update object |
|
| 34 | + */ |
|
| 35 | + static $FIELDS = array( |
|
| 36 | + 'socid' |
|
| 37 | + ); |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @var FactureFournisseur $invoice {@type FactureFournisseur} |
|
| 41 | + */ |
|
| 42 | + public $invoice; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Constructor |
|
| 46 | + */ |
|
| 47 | + function __construct() |
|
| 48 | + { |
|
| 49 | 49 | global $db, $conf; |
| 50 | 50 | $this->db = $db; |
| 51 | - $this->invoice = new FactureFournisseur($this->db); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Get properties of a supplier invoice object |
|
| 56 | - * |
|
| 57 | - * Return an array with supplier invoice information |
|
| 58 | - * |
|
| 59 | - * @param int $id ID of supplier invoice |
|
| 60 | - * @return array|mixed data without useless information |
|
| 61 | - * |
|
| 62 | - * @throws RestException |
|
| 63 | - */ |
|
| 64 | - function get($id) |
|
| 65 | - { |
|
| 51 | + $this->invoice = new FactureFournisseur($this->db); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Get properties of a supplier invoice object |
|
| 56 | + * |
|
| 57 | + * Return an array with supplier invoice information |
|
| 58 | + * |
|
| 59 | + * @param int $id ID of supplier invoice |
|
| 60 | + * @return array|mixed data without useless information |
|
| 61 | + * |
|
| 62 | + * @throws RestException |
|
| 63 | + */ |
|
| 64 | + function get($id) |
|
| 65 | + { |
|
| 66 | 66 | if(! DolibarrApiAccess::$user->rights->fournisseur->facture->lire) { |
| 67 | 67 | throw new RestException(401); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - $result = $this->invoice->fetch($id); |
|
| 71 | - if( ! $result ) { |
|
| 72 | - throw new RestException(404, 'Supplier invoice not found'); |
|
| 73 | - } |
|
| 70 | + $result = $this->invoice->fetch($id); |
|
| 71 | + if( ! $result ) { |
|
| 72 | + throw new RestException(404, 'Supplier invoice not found'); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) { |
| 76 | 76 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
@@ -78,125 +78,125 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $this->invoice->fetchObjectLinked(); |
| 80 | 80 | return $this->_cleanObjectDatas($this->invoice); |
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * List invoices |
|
| 85 | - * |
|
| 86 | - * Get a list of supplier invoices |
|
| 87 | - * |
|
| 88 | - * @param string $sortfield Sort field |
|
| 89 | - * @param string $sortorder Sort order |
|
| 90 | - * @param int $limit Limit for list |
|
| 91 | - * @param int $page Page number |
|
| 92 | - * @param string $thirdparty_ids Thirdparty ids to filter invoices of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} |
|
| 93 | - * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled |
|
| 94 | - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" |
|
| 95 | - * @return array Array of invoice objects |
|
| 96 | - * |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * List invoices |
|
| 85 | + * |
|
| 86 | + * Get a list of supplier invoices |
|
| 87 | + * |
|
| 88 | + * @param string $sortfield Sort field |
|
| 89 | + * @param string $sortorder Sort order |
|
| 90 | + * @param int $limit Limit for list |
|
| 91 | + * @param int $page Page number |
|
| 92 | + * @param string $thirdparty_ids Thirdparty ids to filter invoices of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} |
|
| 93 | + * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled |
|
| 94 | + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" |
|
| 95 | + * @return array Array of invoice objects |
|
| 96 | + * |
|
| 97 | 97 | * @throws RestException |
| 98 | - */ |
|
| 99 | - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') { |
|
| 100 | - global $db, $conf; |
|
| 98 | + */ |
|
| 99 | + function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') { |
|
| 100 | + global $db, $conf; |
|
| 101 | 101 | |
| 102 | - $obj_ret = array(); |
|
| 102 | + $obj_ret = array(); |
|
| 103 | 103 | |
| 104 | - // case of external user, $thirdparty_ids param is ignored and replaced by user's socid |
|
| 105 | - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; |
|
| 104 | + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid |
|
| 105 | + $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; |
|
| 106 | 106 | |
| 107 | - // If the internal user must only see his customers, force searching by him |
|
| 108 | - $search_sale = 0; |
|
| 109 | - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; |
|
| 107 | + // If the internal user must only see his customers, force searching by him |
|
| 108 | + $search_sale = 0; |
|
| 109 | + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; |
|
| 110 | 110 | |
| 111 | - $sql = "SELECT t.rowid"; |
|
| 112 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
| 113 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as t"; |
|
| 111 | + $sql = "SELECT t.rowid"; |
|
| 112 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
| 113 | + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as t"; |
|
| 114 | 114 | |
| 115 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 115 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 116 | 116 | |
| 117 | - $sql.= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')'; |
|
| 118 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 119 | - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; |
|
| 120 | - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale |
|
| 117 | + $sql.= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')'; |
|
| 118 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 119 | + if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; |
|
| 120 | + if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale |
|
| 121 | 121 | |
| 122 | 122 | // Filter by status |
| 123 | - if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; |
|
| 124 | - if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)"; |
|
| 125 | - if ($status == 'paid') $sql.= " AND t.fk_statut IN (2)"; |
|
| 126 | - if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (3)"; |
|
| 127 | - // Insert sale filter |
|
| 128 | - if ($search_sale > 0) |
|
| 129 | - { |
|
| 130 | - $sql .= " AND sc.fk_user = ".$search_sale; |
|
| 131 | - } |
|
| 132 | - // Add sql filters |
|
| 133 | - if ($sqlfilters) |
|
| 134 | - { |
|
| 135 | - if (! DolibarrApi::_checkFilters($sqlfilters)) |
|
| 136 | - { |
|
| 137 | - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); |
|
| 138 | - } |
|
| 139 | - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 140 | - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - $sql.= $db->order($sortfield, $sortorder); |
|
| 144 | - if ($limit) { |
|
| 145 | - if ($page < 0) |
|
| 146 | - { |
|
| 147 | - $page = 0; |
|
| 148 | - } |
|
| 149 | - $offset = $limit * $page; |
|
| 150 | - |
|
| 151 | - $sql.= $db->plimit($limit + 1, $offset); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - $result = $db->query($sql); |
|
| 155 | - if ($result) |
|
| 156 | - { |
|
| 157 | - $i = 0; |
|
| 158 | - $num = $db->num_rows($result); |
|
| 159 | - $min = min($num, ($limit <= 0 ? $num : $limit)); |
|
| 160 | - while ($i < $min) |
|
| 161 | - { |
|
| 162 | - $obj = $db->fetch_object($result); |
|
| 163 | - $invoice_static = new FactureFournisseur($db); |
|
| 164 | - if($invoice_static->fetch($obj->rowid)) { |
|
| 165 | - $obj_ret[] = $this->_cleanObjectDatas($invoice_static); |
|
| 166 | - } |
|
| 167 | - $i++; |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - else { |
|
| 171 | - throw new RestException(503, 'Error when retrieve supplier invoice list : '.$db->lasterror()); |
|
| 172 | - } |
|
| 173 | - if( ! count($obj_ret)) { |
|
| 174 | - throw new RestException(404, 'No supplier invoice found'); |
|
| 175 | - } |
|
| 123 | + if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; |
|
| 124 | + if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)"; |
|
| 125 | + if ($status == 'paid') $sql.= " AND t.fk_statut IN (2)"; |
|
| 126 | + if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (3)"; |
|
| 127 | + // Insert sale filter |
|
| 128 | + if ($search_sale > 0) |
|
| 129 | + { |
|
| 130 | + $sql .= " AND sc.fk_user = ".$search_sale; |
|
| 131 | + } |
|
| 132 | + // Add sql filters |
|
| 133 | + if ($sqlfilters) |
|
| 134 | + { |
|
| 135 | + if (! DolibarrApi::_checkFilters($sqlfilters)) |
|
| 136 | + { |
|
| 137 | + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); |
|
| 138 | + } |
|
| 139 | + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 140 | + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + $sql.= $db->order($sortfield, $sortorder); |
|
| 144 | + if ($limit) { |
|
| 145 | + if ($page < 0) |
|
| 146 | + { |
|
| 147 | + $page = 0; |
|
| 148 | + } |
|
| 149 | + $offset = $limit * $page; |
|
| 150 | + |
|
| 151 | + $sql.= $db->plimit($limit + 1, $offset); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + $result = $db->query($sql); |
|
| 155 | + if ($result) |
|
| 156 | + { |
|
| 157 | + $i = 0; |
|
| 158 | + $num = $db->num_rows($result); |
|
| 159 | + $min = min($num, ($limit <= 0 ? $num : $limit)); |
|
| 160 | + while ($i < $min) |
|
| 161 | + { |
|
| 162 | + $obj = $db->fetch_object($result); |
|
| 163 | + $invoice_static = new FactureFournisseur($db); |
|
| 164 | + if($invoice_static->fetch($obj->rowid)) { |
|
| 165 | + $obj_ret[] = $this->_cleanObjectDatas($invoice_static); |
|
| 166 | + } |
|
| 167 | + $i++; |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + else { |
|
| 171 | + throw new RestException(503, 'Error when retrieve supplier invoice list : '.$db->lasterror()); |
|
| 172 | + } |
|
| 173 | + if( ! count($obj_ret)) { |
|
| 174 | + throw new RestException(404, 'No supplier invoice found'); |
|
| 175 | + } |
|
| 176 | 176 | return $obj_ret; |
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * Create supplier invoice object |
|
| 181 | - * |
|
| 182 | - * @param array $request_data Request datas |
|
| 183 | - * @return int ID of supplier invoice |
|
| 184 | - */ |
|
| 185 | - function post($request_data = NULL) |
|
| 186 | - { |
|
| 187 | - if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * Create supplier invoice object |
|
| 181 | + * |
|
| 182 | + * @param array $request_data Request datas |
|
| 183 | + * @return int ID of supplier invoice |
|
| 184 | + */ |
|
| 185 | + function post($request_data = NULL) |
|
| 186 | + { |
|
| 187 | + if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { |
|
| 188 | 188 | throw new RestException(401, "Insuffisant rights"); |
| 189 | 189 | } |
| 190 | - // Check mandatory fields |
|
| 191 | - $result = $this->_validate($request_data); |
|
| 192 | - |
|
| 193 | - foreach($request_data as $field => $value) { |
|
| 194 | - $this->invoice->$field = $value; |
|
| 195 | - } |
|
| 196 | - if(! array_keys($request_data,'date')) { |
|
| 197 | - $this->invoice->date = dol_now(); |
|
| 198 | - } |
|
| 199 | - /* We keep lines as an array |
|
| 190 | + // Check mandatory fields |
|
| 191 | + $result = $this->_validate($request_data); |
|
| 192 | + |
|
| 193 | + foreach($request_data as $field => $value) { |
|
| 194 | + $this->invoice->$field = $value; |
|
| 195 | + } |
|
| 196 | + if(! array_keys($request_data,'date')) { |
|
| 197 | + $this->invoice->date = dol_now(); |
|
| 198 | + } |
|
| 199 | + /* We keep lines as an array |
|
| 200 | 200 | if (isset($request_data["lines"])) { |
| 201 | 201 | $lines = array(); |
| 202 | 202 | foreach ($request_data["lines"] as $line) { |
@@ -205,162 +205,162 @@ discard block |
||
| 205 | 205 | $this->invoice->lines = $lines; |
| 206 | 206 | }*/ |
| 207 | 207 | |
| 208 | - if ($this->invoice->create(DolibarrApiAccess::$user) < 0) { |
|
| 209 | - throw new RestException(500, "Error creating order", array_merge(array($this->invoice->error), $this->invoice->errors)); |
|
| 210 | - } |
|
| 211 | - return $this->invoice->id; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * Update supplier invoice |
|
| 216 | - * |
|
| 217 | - * @param int $id Id of supplier invoice to update |
|
| 218 | - * @param array $request_data Datas |
|
| 219 | - * @return int |
|
| 220 | - */ |
|
| 221 | - function put($id, $request_data = NULL) |
|
| 222 | - { |
|
| 223 | - if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { |
|
| 208 | + if ($this->invoice->create(DolibarrApiAccess::$user) < 0) { |
|
| 209 | + throw new RestException(500, "Error creating order", array_merge(array($this->invoice->error), $this->invoice->errors)); |
|
| 210 | + } |
|
| 211 | + return $this->invoice->id; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * Update supplier invoice |
|
| 216 | + * |
|
| 217 | + * @param int $id Id of supplier invoice to update |
|
| 218 | + * @param array $request_data Datas |
|
| 219 | + * @return int |
|
| 220 | + */ |
|
| 221 | + function put($id, $request_data = NULL) |
|
| 222 | + { |
|
| 223 | + if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { |
|
| 224 | 224 | throw new RestException(401); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - $result = $this->invoice->fetch($id); |
|
| 228 | - if( ! $result ) { |
|
| 229 | - throw new RestException(404, 'Supplier invoice not found'); |
|
| 230 | - } |
|
| 227 | + $result = $this->invoice->fetch($id); |
|
| 228 | + if( ! $result ) { |
|
| 229 | + throw new RestException(404, 'Supplier invoice not found'); |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | 232 | if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) { |
| 233 | 233 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - foreach($request_data as $field => $value) { |
|
| 237 | - if ($field == 'id') continue; |
|
| 238 | - $this->invoice->$field = $value; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - if($this->invoice->update($id, DolibarrApiAccess::$user)) |
|
| 242 | - return $this->get ($id); |
|
| 243 | - |
|
| 244 | - return false; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * Delete supplier invoice |
|
| 249 | - * |
|
| 250 | - * @param int $id Supplier invoice ID |
|
| 251 | - * @return type |
|
| 252 | - */ |
|
| 253 | - function delete($id) |
|
| 254 | - { |
|
| 255 | - if(! DolibarrApiAccess::$user->rights->fournisseur->facture->supprimer) { |
|
| 236 | + foreach($request_data as $field => $value) { |
|
| 237 | + if ($field == 'id') continue; |
|
| 238 | + $this->invoice->$field = $value; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + if($this->invoice->update($id, DolibarrApiAccess::$user)) |
|
| 242 | + return $this->get ($id); |
|
| 243 | + |
|
| 244 | + return false; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * Delete supplier invoice |
|
| 249 | + * |
|
| 250 | + * @param int $id Supplier invoice ID |
|
| 251 | + * @return type |
|
| 252 | + */ |
|
| 253 | + function delete($id) |
|
| 254 | + { |
|
| 255 | + if(! DolibarrApiAccess::$user->rights->fournisseur->facture->supprimer) { |
|
| 256 | 256 | throw new RestException(401); |
| 257 | 257 | } |
| 258 | - $result = $this->invoice->fetch($id); |
|
| 259 | - if( ! $result ) { |
|
| 260 | - throw new RestException(404, 'Supplier invoice not found'); |
|
| 261 | - } |
|
| 258 | + $result = $this->invoice->fetch($id); |
|
| 259 | + if( ! $result ) { |
|
| 260 | + throw new RestException(404, 'Supplier invoice not found'); |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | 263 | if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) { |
| 264 | 264 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if( $this->invoice->delete(DolibarrApiAccess::$user) < 0) |
|
| 268 | - { |
|
| 269 | - throw new RestException(500); |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - return array( |
|
| 273 | - 'success' => array( |
|
| 274 | - 'code' => 200, |
|
| 275 | - 'message' => 'Supplier invoice deleted' |
|
| 276 | - ) |
|
| 277 | - ); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * Validate an order |
|
| 283 | - * |
|
| 284 | - * @param int $id Order ID |
|
| 285 | - * @param int $idwarehouse Warehouse ID |
|
| 286 | - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers |
|
| 287 | - * |
|
| 288 | - * @url POST {id}/validate |
|
| 289 | - * |
|
| 290 | - * @return array |
|
| 291 | - * FIXME An error 403 is returned if the request has an empty body. |
|
| 292 | - * Error message: "Forbidden: Content type `text/plain` is not supported." |
|
| 293 | - * Workaround: send this in the body |
|
| 294 | - * { |
|
| 295 | - * "idwarehouse": 0, |
|
| 296 | - * "notrigger": 0 |
|
| 297 | - * } |
|
| 298 | - */ |
|
| 299 | - function validate($id, $idwarehouse=0, $notrigger=0) |
|
| 300 | - { |
|
| 301 | - if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { |
|
| 302 | - throw new RestException(401); |
|
| 303 | - } |
|
| 304 | - $result = $this->invoice->fetch($id); |
|
| 305 | - if( ! $result ) { |
|
| 306 | - throw new RestException(404, 'Invoice not found'); |
|
| 307 | - } |
|
| 267 | + if( $this->invoice->delete(DolibarrApiAccess::$user) < 0) |
|
| 268 | + { |
|
| 269 | + throw new RestException(500); |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + return array( |
|
| 273 | + 'success' => array( |
|
| 274 | + 'code' => 200, |
|
| 275 | + 'message' => 'Supplier invoice deleted' |
|
| 276 | + ) |
|
| 277 | + ); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + |
|
| 281 | + /** |
|
| 282 | + * Validate an order |
|
| 283 | + * |
|
| 284 | + * @param int $id Order ID |
|
| 285 | + * @param int $idwarehouse Warehouse ID |
|
| 286 | + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers |
|
| 287 | + * |
|
| 288 | + * @url POST {id}/validate |
|
| 289 | + * |
|
| 290 | + * @return array |
|
| 291 | + * FIXME An error 403 is returned if the request has an empty body. |
|
| 292 | + * Error message: "Forbidden: Content type `text/plain` is not supported." |
|
| 293 | + * Workaround: send this in the body |
|
| 294 | + * { |
|
| 295 | + * "idwarehouse": 0, |
|
| 296 | + * "notrigger": 0 |
|
| 297 | + * } |
|
| 298 | + */ |
|
| 299 | + function validate($id, $idwarehouse=0, $notrigger=0) |
|
| 300 | + { |
|
| 301 | + if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { |
|
| 302 | + throw new RestException(401); |
|
| 303 | + } |
|
| 304 | + $result = $this->invoice->fetch($id); |
|
| 305 | + if( ! $result ) { |
|
| 306 | + throw new RestException(404, 'Invoice not found'); |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | 309 | if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) { |
| 310 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); |
|
| 314 | - if ($result == 0) { |
|
| 315 | - throw new RestException(304, 'Error nothing done. May be object is already validated'); |
|
| 316 | - } |
|
| 317 | - if ($result < 0) { |
|
| 318 | - throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - return array( |
|
| 322 | - 'success' => array( |
|
| 323 | - 'code' => 200, |
|
| 324 | - 'message' => 'Invoice validated (Ref='.$this->invoice->ref.')' |
|
| 325 | - ) |
|
| 326 | - ); |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * Clean sensible object datas |
|
| 331 | - * |
|
| 332 | - * @param Object $object Object to clean |
|
| 333 | - * @return array Array of cleaned object properties |
|
| 334 | - */ |
|
| 335 | - function _cleanObjectDatas($object) { |
|
| 336 | - |
|
| 337 | - $object = parent::_cleanObjectDatas($object); |
|
| 338 | - |
|
| 339 | - unset($object->rowid); |
|
| 340 | - unset($object->barcode_type); |
|
| 341 | - unset($object->barcode_type_code); |
|
| 342 | - unset($object->barcode_type_label); |
|
| 343 | - unset($object->barcode_type_coder); |
|
| 344 | - |
|
| 345 | - return $object; |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * Validate fields before create or update object |
|
| 350 | - * |
|
| 351 | - * @param array $data Datas to validate |
|
| 352 | - * @return array |
|
| 353 | - * |
|
| 354 | - * @throws RestException |
|
| 355 | - */ |
|
| 356 | - function _validate($data) |
|
| 357 | - { |
|
| 358 | - $invoice = array(); |
|
| 359 | - foreach (SupplierInvoices::$FIELDS as $field) { |
|
| 360 | - if (!isset($data[$field])) |
|
| 361 | - throw new RestException(400, "$field field missing"); |
|
| 362 | - $invoice[$field] = $data[$field]; |
|
| 363 | - } |
|
| 364 | - return $invoice; |
|
| 365 | - } |
|
| 310 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); |
|
| 314 | + if ($result == 0) { |
|
| 315 | + throw new RestException(304, 'Error nothing done. May be object is already validated'); |
|
| 316 | + } |
|
| 317 | + if ($result < 0) { |
|
| 318 | + throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + return array( |
|
| 322 | + 'success' => array( |
|
| 323 | + 'code' => 200, |
|
| 324 | + 'message' => 'Invoice validated (Ref='.$this->invoice->ref.')' |
|
| 325 | + ) |
|
| 326 | + ); |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * Clean sensible object datas |
|
| 331 | + * |
|
| 332 | + * @param Object $object Object to clean |
|
| 333 | + * @return array Array of cleaned object properties |
|
| 334 | + */ |
|
| 335 | + function _cleanObjectDatas($object) { |
|
| 336 | + |
|
| 337 | + $object = parent::_cleanObjectDatas($object); |
|
| 338 | + |
|
| 339 | + unset($object->rowid); |
|
| 340 | + unset($object->barcode_type); |
|
| 341 | + unset($object->barcode_type_code); |
|
| 342 | + unset($object->barcode_type_label); |
|
| 343 | + unset($object->barcode_type_coder); |
|
| 344 | + |
|
| 345 | + return $object; |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * Validate fields before create or update object |
|
| 350 | + * |
|
| 351 | + * @param array $data Datas to validate |
|
| 352 | + * @return array |
|
| 353 | + * |
|
| 354 | + * @throws RestException |
|
| 355 | + */ |
|
| 356 | + function _validate($data) |
|
| 357 | + { |
|
| 358 | + $invoice = array(); |
|
| 359 | + foreach (SupplierInvoices::$FIELDS as $field) { |
|
| 360 | + if (!isset($data[$field])) |
|
| 361 | + throw new RestException(400, "$field field missing"); |
|
| 362 | + $invoice[$field] = $data[$field]; |
|
| 363 | + } |
|
| 364 | + return $invoice; |
|
| 365 | + } |
|
| 366 | 366 | } |
@@ -446,7 +446,7 @@ |
||
| 446 | 446 | * Build a HTML select list of element of same thirdparty to suggest to link them to project |
| 447 | 447 | * |
| 448 | 448 | * @param string $table_element Table of the element to update |
| 449 | - * @param string $socid If of thirdparty to use as filter or 'id1,id2,...' |
|
| 449 | + * @param integer $socid If of thirdparty to use as filter or 'id1,id2,...' |
|
| 450 | 450 | * @param string $morecss More CSS |
| 451 | 451 | * @param int $limitonstatus Add filters to limit length of list to opened status (for example to avoid ERR_RESPONSE_HEADERS_TOO_BIG on project/element.php page). TODO To implement |
| 452 | 452 | * @return int|string The HTML select list of element or '' if nothing or -1 if KO |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | if (empty($nooutput)) |
| 106 | 106 | { |
| 107 | - print $out; |
|
| 108 | - return ''; |
|
| 107 | + print $out; |
|
| 108 | + return ''; |
|
| 109 | 109 | } |
| 110 | 110 | else return $out; |
| 111 | 111 | } |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | * @param int $option_only Return only html options lines without the select tag |
| 121 | 121 | * @param int $show_empty Add an empty line |
| 122 | 122 | * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) |
| 123 | - * @param int $forcefocus Force focus on field (works with javascript only) |
|
| 124 | - * @param int $disabled Disabled |
|
| 123 | + * @param int $forcefocus Force focus on field (works with javascript only) |
|
| 124 | + * @param int $disabled Disabled |
|
| 125 | 125 | * @param int $mode 0 for HTML mode and 1 for array return (to be used by json_encode for example) |
| 126 | 126 | * @param string $filterkey Key to filter |
| 127 | 127 | * @param int $nooutput No print output. Return it only. |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | if (empty($htmlid)) $htmlid = $htmlname; |
| 140 | 140 | |
| 141 | 141 | $out=''; |
| 142 | - $outarray=array(); |
|
| 142 | + $outarray=array(); |
|
| 143 | 143 | |
| 144 | 144 | $hideunselectables = false; |
| 145 | 145 | if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; |
| 160 | 160 | if ($socid > 0) |
| 161 | 161 | { |
| 162 | - if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; |
|
| 163 | - else if ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. |
|
| 164 | - { |
|
| 165 | - $sql.= " AND (p.fk_soc IN (".$socid.", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") OR p.fk_soc IS NULL)"; |
|
| 166 | - } |
|
| 162 | + if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; |
|
| 163 | + else if ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. |
|
| 164 | + { |
|
| 165 | + $sql.= " AND (p.fk_soc IN (".$socid.", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") OR p.fk_soc IS NULL)"; |
|
| 166 | + } |
|
| 167 | 167 | } |
| 168 | 168 | if (!empty($filterkey)) $sql .= natural_search(array('p.title', 'p.ref'), $filterkey); |
| 169 | 169 | $sql.= " ORDER BY p.ref ASC"; |
@@ -175,9 +175,9 @@ discard block |
||
| 175 | 175 | if (! empty($conf->use_javascript_ajax)) |
| 176 | 176 | { |
| 177 | 177 | include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
| 178 | - $comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus); |
|
| 179 | - $out.=$comboenhancement; |
|
| 180 | - $morecss='minwidth100 maxwidth500'; |
|
| 178 | + $comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus); |
|
| 179 | + $out.=$comboenhancement; |
|
| 180 | + $morecss='minwidth100 maxwidth500'; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | if (empty($option_only)) { |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | $labeltoshow.=', '.dol_trunc($obj->title, $maxlength); |
| 213 | 213 | if ($obj->name) |
| 214 | 214 | { |
| 215 | - $labeltoshow.=' - '.$obj->name; |
|
| 216 | - if ($obj->name_alias) $labeltoshow.=' ('.$obj->name_alias.')'; |
|
| 215 | + $labeltoshow.=' - '.$obj->name; |
|
| 216 | + if ($obj->name_alias) $labeltoshow.=' ('.$obj->name_alias.')'; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | $disabled=0; |
@@ -276,8 +276,8 @@ discard block |
||
| 276 | 276 | if (empty($option_only)) $out.= '</select>'; |
| 277 | 277 | if (empty($nooutput)) |
| 278 | 278 | { |
| 279 | - print $out; |
|
| 280 | - return ''; |
|
| 279 | + print $out; |
|
| 280 | + return ''; |
|
| 281 | 281 | } |
| 282 | 282 | else return $out; |
| 283 | 283 | } else { |
@@ -301,8 +301,8 @@ discard block |
||
| 301 | 301 | * @param int $option_only Return only html options lines without the select tag |
| 302 | 302 | * @param string $show_empty Add an empty line ('1' or string to show for empty line) |
| 303 | 303 | * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) |
| 304 | - * @param int $forcefocus Force focus on field (works with javascript only) |
|
| 305 | - * @param int $disabled Disabled |
|
| 304 | + * @param int $forcefocus Force focus on field (works with javascript only) |
|
| 305 | + * @param int $disabled Disabled |
|
| 306 | 306 | * @param string $morecss More css added to the select component |
| 307 | 307 | * @return int Nbr of project if OK, <0 if KO |
| 308 | 308 | */ |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | if (! empty($conf->use_javascript_ajax)) |
| 345 | 345 | { |
| 346 | 346 | include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
| 347 | - $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); |
|
| 348 | - $out.=$comboenhancement; |
|
| 349 | - $morecss='minwidth200 maxwidth500'; |
|
| 347 | + $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); |
|
| 348 | + $out.=$comboenhancement; |
|
| 349 | + $morecss='minwidth200 maxwidth500'; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | if (empty($option_only)) { |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | break; |
| 484 | 484 | case "commande_fourn": |
| 485 | 485 | case "commande_fournisseur": |
| 486 | - $sql = "SELECT t.rowid, t.ref, t.ref_supplier"; |
|
| 486 | + $sql = "SELECT t.rowid, t.ref, t.ref_supplier"; |
|
| 487 | 487 | break; |
| 488 | 488 | case "facture_rec": |
| 489 | 489 | $sql = "SELECT t.rowid, t.titre as ref"; |
@@ -500,10 +500,10 @@ discard block |
||
| 500 | 500 | break;*/ |
| 501 | 501 | return ''; |
| 502 | 502 | case "commande": |
| 503 | - case "contrat": |
|
| 503 | + case "contrat": |
|
| 504 | 504 | case "fichinter": |
| 505 | - $sql = "SELECT t.rowid, t.ref"; |
|
| 506 | - break; |
|
| 505 | + $sql = "SELECT t.rowid, t.ref"; |
|
| 506 | + break; |
|
| 507 | 507 | case 'stock_mouvement': |
| 508 | 508 | $sql = 'SELECT t.rowid, t.label as ref'; |
| 509 | 509 | $projectkey='fk_origin'; |
@@ -522,8 +522,8 @@ discard block |
||
| 522 | 522 | $sql.= " WHERE ".$projectkey." is null"; |
| 523 | 523 | if (! empty($socid) && $linkedtothirdparty) |
| 524 | 524 | { |
| 525 | - if (is_numeric($socid)) $sql.= " AND t.fk_soc=".$socid; |
|
| 526 | - else $sql.= " AND t.fk_soc IN (".$socid.")"; |
|
| 525 | + if (is_numeric($socid)) $sql.= " AND t.fk_soc=".$socid; |
|
| 526 | + else $sql.= " AND t.fk_soc IN (".$socid.")"; |
|
| 527 | 527 | } |
| 528 | 528 | if (! in_array($table_element, array('expensereport_det','stock_mouvement'))) $sql.= ' AND t.entity IN ('.getEntity('project').')'; |
| 529 | 529 | if ($linkedtothirdparty) $sql.=" AND s.rowid = t.fk_soc"; |
@@ -63,42 +63,42 @@ discard block |
||
| 63 | 63 | * @param int $htmlid Html id to use instead of htmlname |
| 64 | 64 | * @return string Return html content |
| 65 | 65 | */ |
| 66 | - function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlength=16, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0, $mode = 0, $filterkey = '', $nooutput=0, $forceaddid=0, $morecss='', $htmlid='') |
|
| 66 | + function select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '') |
|
| 67 | 67 | { |
| 68 | - global $langs,$conf,$form; |
|
| 68 | + global $langs, $conf, $form; |
|
| 69 | 69 | |
| 70 | - $out=''; |
|
| 70 | + $out = ''; |
|
| 71 | 71 | |
| 72 | - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) |
|
| 72 | + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) |
|
| 73 | 73 | { |
| 74 | - $placeholder=''; |
|
| 74 | + $placeholder = ''; |
|
| 75 | 75 | |
| 76 | 76 | if ($selected && empty($selected_input_value)) |
| 77 | 77 | { |
| 78 | 78 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 79 | 79 | $project = new Project($this->db); |
| 80 | 80 | $project->fetch($selected); |
| 81 | - $selected_input_value=$project->ref; |
|
| 81 | + $selected_input_value = $project->ref; |
|
| 82 | 82 | } |
| 83 | - $urloption='socid='.$socid.'&htmlname='.$htmlname.'&discardclosed='.$discard_closed; |
|
| 84 | - $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array( |
|
| 83 | + $urloption = 'socid='.$socid.'&htmlname='.$htmlname.'&discardclosed='.$discard_closed; |
|
| 84 | + $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array( |
|
| 85 | 85 | // 'update' => array( |
| 86 | 86 | // 'projectid' => 'id' |
| 87 | 87 | // ) |
| 88 | 88 | )); |
| 89 | 89 | |
| 90 | - $out.='<input type="text" class="minwidth200'.($morecss?' '.$morecss:'').'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />'; |
|
| 90 | + $out .= '<input type="text" class="minwidth200'.($morecss ? ' '.$morecss : '').'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />'; |
|
| 91 | 91 | } |
| 92 | 92 | else |
| 93 | 93 | { |
| 94 | - $out.=$this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, $discard_closed, $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid); |
|
| 94 | + $out .= $this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, $discard_closed, $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid); |
|
| 95 | 95 | } |
| 96 | 96 | if ($discard_closed) |
| 97 | 97 | { |
| 98 | 98 | if (class_exists('Form')) |
| 99 | 99 | { |
| 100 | - if (empty($form)) $form=new Form($this->db); |
|
| 101 | - $out.=$form->textwithpicto('', $langs->trans("ClosedProjectsAreHidden")); |
|
| 100 | + if (empty($form)) $form = new Form($this->db); |
|
| 101 | + $out .= $form->textwithpicto('', $langs->trans("ClosedProjectsAreHidden")); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
@@ -130,61 +130,61 @@ discard block |
||
| 130 | 130 | * @param string $morecss More CSS |
| 131 | 131 | * @return int Nb of project if OK, <0 if KO |
| 132 | 132 | */ |
| 133 | - function select_projects_list($socid=-1, $selected='', $htmlname='projectid', $maxlength=24, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0, $mode=0, $filterkey = '', $nooutput=0, $forceaddid=0, $htmlid='', $morecss='maxwidth500') |
|
| 133 | + function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500') |
|
| 134 | 134 | { |
| 135 | - global $user,$conf,$langs; |
|
| 135 | + global $user, $conf, $langs; |
|
| 136 | 136 | |
| 137 | 137 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 138 | 138 | |
| 139 | 139 | if (empty($htmlid)) $htmlid = $htmlname; |
| 140 | 140 | |
| 141 | - $out=''; |
|
| 142 | - $outarray=array(); |
|
| 141 | + $out = ''; |
|
| 142 | + $outarray = array(); |
|
| 143 | 143 | |
| 144 | 144 | $hideunselectables = false; |
| 145 | - if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; |
|
| 145 | + if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; |
|
| 146 | 146 | |
| 147 | 147 | $projectsListId = false; |
| 148 | 148 | if (empty($user->rights->projet->all->lire)) |
| 149 | 149 | { |
| 150 | - $projectstatic=new Project($this->db); |
|
| 151 | - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); |
|
| 150 | + $projectstatic = new Project($this->db); |
|
| 151 | + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // Search all projects |
| 155 | 155 | $sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name, s.name_alias'; |
| 156 | - $sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p LEFT JOIN '.MAIN_DB_PREFIX .'societe as s ON s.rowid = p.fk_soc'; |
|
| 157 | - $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
|
| 158 | - if ($projectsListId !== false) $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
| 159 | - if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; |
|
| 156 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as p LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; |
|
| 157 | + $sql .= " WHERE p.entity IN (".getEntity('project').")"; |
|
| 158 | + if ($projectsListId !== false) $sql .= " AND p.rowid IN (".$projectsListId.")"; |
|
| 159 | + if ($socid == 0) $sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; |
|
| 160 | 160 | if ($socid > 0) |
| 161 | 161 | { |
| 162 | - if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; |
|
| 162 | + if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql .= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; |
|
| 163 | 163 | else if ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. |
| 164 | 164 | { |
| 165 | - $sql.= " AND (p.fk_soc IN (".$socid.", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") OR p.fk_soc IS NULL)"; |
|
| 165 | + $sql .= " AND (p.fk_soc IN (".$socid.", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") OR p.fk_soc IS NULL)"; |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | if (!empty($filterkey)) $sql .= natural_search(array('p.title', 'p.ref'), $filterkey); |
| 169 | - $sql.= " ORDER BY p.ref ASC"; |
|
| 169 | + $sql .= " ORDER BY p.ref ASC"; |
|
| 170 | 170 | |
| 171 | - $resql=$this->db->query($sql); |
|
| 171 | + $resql = $this->db->query($sql); |
|
| 172 | 172 | if ($resql) |
| 173 | 173 | { |
| 174 | 174 | // Use select2 selector |
| 175 | - if (! empty($conf->use_javascript_ajax)) |
|
| 175 | + if (!empty($conf->use_javascript_ajax)) |
|
| 176 | 176 | { |
| 177 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 177 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
| 178 | 178 | $comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus); |
| 179 | - $out.=$comboenhancement; |
|
| 180 | - $morecss='minwidth100 maxwidth500'; |
|
| 179 | + $out .= $comboenhancement; |
|
| 180 | + $morecss = 'minwidth100 maxwidth500'; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | if (empty($option_only)) { |
| 184 | - $out.= '<select class="flat'.($morecss?' '.$morecss:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlid.'" name="'.$htmlname.'">'; |
|
| 184 | + $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').' id="'.$htmlid.'" name="'.$htmlname.'">'; |
|
| 185 | 185 | } |
| 186 | 186 | if (!empty($show_empty)) { |
| 187 | - $out.= '<option value="0"> </option>'; |
|
| 187 | + $out .= '<option value="0"> </option>'; |
|
| 188 | 188 | } |
| 189 | 189 | $num = $this->db->num_rows($resql); |
| 190 | 190 | $i = 0; |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | { |
| 195 | 195 | $obj = $this->db->fetch_object($resql); |
| 196 | 196 | // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. |
| 197 | - if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire) |
|
| 197 | + if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->rights->societe->lire) |
|
| 198 | 198 | { |
| 199 | 199 | // Do nothing |
| 200 | 200 | } |
@@ -206,56 +206,56 @@ discard block |
||
| 206 | 206 | continue; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - $labeltoshow=dol_trunc($obj->ref,18); |
|
| 209 | + $labeltoshow = dol_trunc($obj->ref, 18); |
|
| 210 | 210 | //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; |
| 211 | 211 | //else $labeltoshow.=' ('.$langs->trans("Private").')'; |
| 212 | - $labeltoshow.=', '.dol_trunc($obj->title, $maxlength); |
|
| 212 | + $labeltoshow .= ', '.dol_trunc($obj->title, $maxlength); |
|
| 213 | 213 | if ($obj->name) |
| 214 | 214 | { |
| 215 | - $labeltoshow.=' - '.$obj->name; |
|
| 216 | - if ($obj->name_alias) $labeltoshow.=' ('.$obj->name_alias.')'; |
|
| 215 | + $labeltoshow .= ' - '.$obj->name; |
|
| 216 | + if ($obj->name_alias) $labeltoshow .= ' ('.$obj->name_alias.')'; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - $disabled=0; |
|
| 219 | + $disabled = 0; |
|
| 220 | 220 | if ($obj->fk_statut == 0) |
| 221 | 221 | { |
| 222 | - $disabled=1; |
|
| 223 | - $labeltoshow.=' - '.$langs->trans("Draft"); |
|
| 222 | + $disabled = 1; |
|
| 223 | + $labeltoshow .= ' - '.$langs->trans("Draft"); |
|
| 224 | 224 | } |
| 225 | 225 | else if ($obj->fk_statut == 2) |
| 226 | 226 | { |
| 227 | - if ($discard_close == 2) $disabled=1; |
|
| 228 | - $labeltoshow.=' - '.$langs->trans("Closed"); |
|
| 227 | + if ($discard_close == 2) $disabled = 1; |
|
| 228 | + $labeltoshow .= ' - '.$langs->trans("Closed"); |
|
| 229 | 229 | } |
| 230 | - else if ( empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
| 230 | + else if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
| 231 | 231 | { |
| 232 | - $disabled=1; |
|
| 233 | - $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); |
|
| 232 | + $disabled = 1; |
|
| 233 | + $labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany"); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | if (!empty($selected) && $selected == $obj->rowid) |
| 237 | 237 | { |
| 238 | - $out.= '<option value="'.$obj->rowid.'" selected'; |
|
| 238 | + $out .= '<option value="'.$obj->rowid.'" selected'; |
|
| 239 | 239 | //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled |
| 240 | - $out.= '>'.$labeltoshow.'</option>'; |
|
| 240 | + $out .= '>'.$labeltoshow.'</option>'; |
|
| 241 | 241 | } |
| 242 | 242 | else |
| 243 | 243 | { |
| 244 | 244 | if ($hideunselectables && $disabled && ($selected != $obj->rowid)) |
| 245 | 245 | { |
| 246 | - $resultat=''; |
|
| 246 | + $resultat = ''; |
|
| 247 | 247 | } |
| 248 | 248 | else |
| 249 | 249 | { |
| 250 | - $resultat='<option value="'.$obj->rowid.'"'; |
|
| 251 | - if ($disabled) $resultat.=' disabled'; |
|
| 250 | + $resultat = '<option value="'.$obj->rowid.'"'; |
|
| 251 | + if ($disabled) $resultat .= ' disabled'; |
|
| 252 | 252 | //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')'; |
| 253 | 253 | //else $labeltoshow.=' ('.$langs->trans("Private").')'; |
| 254 | - $resultat.='>'; |
|
| 255 | - $resultat.=$labeltoshow; |
|
| 256 | - $resultat.='</option>'; |
|
| 254 | + $resultat .= '>'; |
|
| 255 | + $resultat .= $labeltoshow; |
|
| 256 | + $resultat .= '</option>'; |
|
| 257 | 257 | } |
| 258 | - $out.= $resultat; |
|
| 258 | + $out .= $resultat; |
|
| 259 | 259 | |
| 260 | 260 | $outarray[] = array( |
| 261 | 261 | 'key' => (int) $obj->rowid, |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | $this->db->free($resql); |
| 274 | 274 | |
| 275 | 275 | if (!$mode) { |
| 276 | - if (empty($option_only)) $out.= '</select>'; |
|
| 276 | + if (empty($option_only)) $out .= '</select>'; |
|
| 277 | 277 | if (empty($nooutput)) |
| 278 | 278 | { |
| 279 | 279 | print $out; |
@@ -306,57 +306,57 @@ discard block |
||
| 306 | 306 | * @param string $morecss More css added to the select component |
| 307 | 307 | * @return int Nbr of project if OK, <0 if KO |
| 308 | 308 | */ |
| 309 | - function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500') |
|
| 309 | + function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500') |
|
| 310 | 310 | { |
| 311 | - global $user,$conf,$langs; |
|
| 311 | + global $user, $conf, $langs; |
|
| 312 | 312 | |
| 313 | 313 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 314 | 314 | |
| 315 | - $out=''; |
|
| 315 | + $out = ''; |
|
| 316 | 316 | |
| 317 | 317 | $hideunselectables = false; |
| 318 | - if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; |
|
| 318 | + if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; |
|
| 319 | 319 | |
| 320 | 320 | $projectsListId = false; |
| 321 | 321 | if (empty($user->rights->projet->all->lire)) |
| 322 | 322 | { |
| 323 | - $projectstatic=new Project($this->db); |
|
| 324 | - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); |
|
| 323 | + $projectstatic = new Project($this->db); |
|
| 324 | + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | // Search all projects |
| 328 | 328 | $sql = 'SELECT t.rowid, t.ref as tref, t.label as tlabel, p.ref, p.title, p.fk_soc, p.fk_statut, p.public,'; |
| 329 | - $sql.= ' s.nom as name'; |
|
| 330 | - $sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p'; |
|
| 331 | - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; |
|
| 332 | - $sql.= ', '.MAIN_DB_PREFIX.'projet_task as t'; |
|
| 333 | - $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
|
| 334 | - $sql.= " AND t.fk_projet = p.rowid"; |
|
| 335 | - if ($projectsListId !== false) $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
| 336 | - if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; |
|
| 337 | - if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; |
|
| 338 | - $sql.= " ORDER BY p.ref, t.ref ASC"; |
|
| 339 | - |
|
| 340 | - $resql=$this->db->query($sql); |
|
| 329 | + $sql .= ' s.nom as name'; |
|
| 330 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as p'; |
|
| 331 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; |
|
| 332 | + $sql .= ', '.MAIN_DB_PREFIX.'projet_task as t'; |
|
| 333 | + $sql .= " WHERE p.entity IN (".getEntity('project').")"; |
|
| 334 | + $sql .= " AND t.fk_projet = p.rowid"; |
|
| 335 | + if ($projectsListId !== false) $sql .= " AND p.rowid IN (".$projectsListId.")"; |
|
| 336 | + if ($socid == 0) $sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; |
|
| 337 | + if ($socid > 0) $sql .= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; |
|
| 338 | + $sql .= " ORDER BY p.ref, t.ref ASC"; |
|
| 339 | + |
|
| 340 | + $resql = $this->db->query($sql); |
|
| 341 | 341 | if ($resql) |
| 342 | 342 | { |
| 343 | 343 | // Use select2 selector |
| 344 | - if (! empty($conf->use_javascript_ajax)) |
|
| 344 | + if (!empty($conf->use_javascript_ajax)) |
|
| 345 | 345 | { |
| 346 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 346 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
| 347 | 347 | $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); |
| 348 | - $out.=$comboenhancement; |
|
| 349 | - $morecss='minwidth200 maxwidth500'; |
|
| 348 | + $out .= $comboenhancement; |
|
| 349 | + $morecss = 'minwidth200 maxwidth500'; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | if (empty($option_only)) { |
| 353 | - $out.= '<select class="valignmiddle flat'.($morecss?' '.$morecss:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlname.'" name="'.$htmlname.'">'; |
|
| 353 | + $out .= '<select class="valignmiddle flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').' id="'.$htmlname.'" name="'.$htmlname.'">'; |
|
| 354 | 354 | } |
| 355 | - if (! empty($show_empty)) { |
|
| 356 | - $out.= '<option value="0" class="optiongrey">'; |
|
| 357 | - if (! is_numeric($show_empty)) $out.=$show_empty; |
|
| 358 | - else $out.=' '; |
|
| 359 | - $out.= '</option>'; |
|
| 355 | + if (!empty($show_empty)) { |
|
| 356 | + $out .= '<option value="0" class="optiongrey">'; |
|
| 357 | + if (!is_numeric($show_empty)) $out .= $show_empty; |
|
| 358 | + else $out .= ' '; |
|
| 359 | + $out .= '</option>'; |
|
| 360 | 360 | } |
| 361 | 361 | $num = $this->db->num_rows($resql); |
| 362 | 362 | $i = 0; |
@@ -378,62 +378,62 @@ discard block |
||
| 378 | 378 | continue; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - $labeltoshow=dol_trunc($obj->ref,18); // Project ref |
|
| 381 | + $labeltoshow = dol_trunc($obj->ref, 18); // Project ref |
|
| 382 | 382 | //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; |
| 383 | 383 | //else $labeltoshow.=' ('.$langs->trans("Private").')'; |
| 384 | - $labeltoshow.=' '.dol_trunc($obj->title,$maxlength); |
|
| 384 | + $labeltoshow .= ' '.dol_trunc($obj->title, $maxlength); |
|
| 385 | 385 | |
| 386 | - if ($obj->name) $labeltoshow.=' ('.$obj->name.')'; |
|
| 386 | + if ($obj->name) $labeltoshow .= ' ('.$obj->name.')'; |
|
| 387 | 387 | |
| 388 | - $disabled=0; |
|
| 388 | + $disabled = 0; |
|
| 389 | 389 | if ($obj->fk_statut == 0) |
| 390 | 390 | { |
| 391 | - $disabled=1; |
|
| 392 | - $labeltoshow.=' - '.$langs->trans("Draft"); |
|
| 391 | + $disabled = 1; |
|
| 392 | + $labeltoshow .= ' - '.$langs->trans("Draft"); |
|
| 393 | 393 | } |
| 394 | 394 | else if ($obj->fk_statut == 2) |
| 395 | 395 | { |
| 396 | - if ($discard_closed == 2) $disabled=1; |
|
| 397 | - $labeltoshow.=' - '.$langs->trans("Closed"); |
|
| 396 | + if ($discard_closed == 2) $disabled = 1; |
|
| 397 | + $labeltoshow .= ' - '.$langs->trans("Closed"); |
|
| 398 | 398 | } |
| 399 | - else if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
| 399 | + else if ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
| 400 | 400 | { |
| 401 | - $disabled=1; |
|
| 402 | - $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); |
|
| 401 | + $disabled = 1; |
|
| 402 | + $labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany"); |
|
| 403 | 403 | } |
| 404 | 404 | // Label for task |
| 405 | - $labeltoshow.=' - '.$obj->tref.' '.dol_trunc($obj->tlabel,$maxlength); |
|
| 405 | + $labeltoshow .= ' - '.$obj->tref.' '.dol_trunc($obj->tlabel, $maxlength); |
|
| 406 | 406 | |
| 407 | 407 | if (!empty($selected) && $selected == $obj->rowid) |
| 408 | 408 | { |
| 409 | - $out.= '<option value="'.$obj->rowid.'" selected'; |
|
| 409 | + $out .= '<option value="'.$obj->rowid.'" selected'; |
|
| 410 | 410 | //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled |
| 411 | - $out.= '>'.$labeltoshow.'</option>'; |
|
| 411 | + $out .= '>'.$labeltoshow.'</option>'; |
|
| 412 | 412 | } |
| 413 | 413 | else |
| 414 | 414 | { |
| 415 | 415 | if ($hideunselectables && $disabled && ($selected != $obj->rowid)) |
| 416 | 416 | { |
| 417 | - $resultat=''; |
|
| 417 | + $resultat = ''; |
|
| 418 | 418 | } |
| 419 | 419 | else |
| 420 | 420 | { |
| 421 | - $resultat='<option value="'.$obj->rowid.'"'; |
|
| 422 | - if ($disabled) $resultat.=' disabled'; |
|
| 421 | + $resultat = '<option value="'.$obj->rowid.'"'; |
|
| 422 | + if ($disabled) $resultat .= ' disabled'; |
|
| 423 | 423 | //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')'; |
| 424 | 424 | //else $labeltoshow.=' ('.$langs->trans("Private").')'; |
| 425 | - $resultat.='>'; |
|
| 426 | - $resultat.=$labeltoshow; |
|
| 427 | - $resultat.='</option>'; |
|
| 425 | + $resultat .= '>'; |
|
| 426 | + $resultat .= $labeltoshow; |
|
| 427 | + $resultat .= '</option>'; |
|
| 428 | 428 | } |
| 429 | - $out.= $resultat; |
|
| 429 | + $out .= $resultat; |
|
| 430 | 430 | } |
| 431 | 431 | } |
| 432 | 432 | $i++; |
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | if (empty($option_only)) { |
| 436 | - $out.= '</select>'; |
|
| 436 | + $out .= '</select>'; |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | print $out; |
@@ -458,17 +458,17 @@ discard block |
||
| 458 | 458 | * @param int $limitonstatus Add filters to limit length of list to opened status (for example to avoid ERR_RESPONSE_HEADERS_TOO_BIG on project/element.php page). TODO To implement |
| 459 | 459 | * @return int|string The HTML select list of element or '' if nothing or -1 if KO |
| 460 | 460 | */ |
| 461 | - function select_element($table_element, $socid=0, $morecss='', $limitonstatus=-2) |
|
| 461 | + function select_element($table_element, $socid = 0, $morecss = '', $limitonstatus = -2) |
|
| 462 | 462 | { |
| 463 | 463 | global $conf, $langs; |
| 464 | 464 | |
| 465 | - if ($table_element == 'projet_task') return ''; // Special cas of element we never link to a project (already always done) |
|
| 465 | + if ($table_element == 'projet_task') return ''; // Special cas of element we never link to a project (already always done) |
|
| 466 | 466 | |
| 467 | - $linkedtothirdparty=false; |
|
| 468 | - if (! in_array($table_element, array('don','expensereport_det','expensereport','loan','stock_mouvement','chargesociales'))) $linkedtothirdparty=true; |
|
| 467 | + $linkedtothirdparty = false; |
|
| 468 | + if (!in_array($table_element, array('don', 'expensereport_det', 'expensereport', 'loan', 'stock_mouvement', 'chargesociales'))) $linkedtothirdparty = true; |
|
| 469 | 469 | |
| 470 | - $sqlfilter=''; |
|
| 471 | - $projectkey="fk_projet"; |
|
| 470 | + $sqlfilter = ''; |
|
| 471 | + $projectkey = "fk_projet"; |
|
| 472 | 472 | //print $table_element; |
| 473 | 473 | switch ($table_element) |
| 474 | 474 | { |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | break; |
| 491 | 491 | case "actioncomm": |
| 492 | 492 | $sql = "SELECT t.id as rowid, t.label as ref"; |
| 493 | - $projectkey="fk_project"; |
|
| 493 | + $projectkey = "fk_project"; |
|
| 494 | 494 | break; |
| 495 | 495 | case "expensereport": |
| 496 | 496 | return ''; |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | break; |
| 507 | 507 | case 'stock_mouvement': |
| 508 | 508 | $sql = 'SELECT t.rowid, t.label as ref'; |
| 509 | - $projectkey='fk_origin'; |
|
| 509 | + $projectkey = 'fk_origin'; |
|
| 510 | 510 | break; |
| 511 | 511 | case "payment_various": |
| 512 | 512 | $sql = "SELECT t.rowid, t.num_payment as ref"; |
@@ -516,40 +516,40 @@ discard block |
||
| 516 | 516 | $sql = "SELECT t.rowid, t.ref"; |
| 517 | 517 | break; |
| 518 | 518 | } |
| 519 | - if ($linkedtothirdparty) $sql.=", s.nom as name"; |
|
| 520 | - $sql.= " FROM ".MAIN_DB_PREFIX.$table_element." as t"; |
|
| 521 | - if ($linkedtothirdparty) $sql.=", ".MAIN_DB_PREFIX."societe as s"; |
|
| 522 | - $sql.= " WHERE ".$projectkey." is null"; |
|
| 523 | - if (! empty($socid) && $linkedtothirdparty) |
|
| 519 | + if ($linkedtothirdparty) $sql .= ", s.nom as name"; |
|
| 520 | + $sql .= " FROM ".MAIN_DB_PREFIX.$table_element." as t"; |
|
| 521 | + if ($linkedtothirdparty) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 522 | + $sql .= " WHERE ".$projectkey." is null"; |
|
| 523 | + if (!empty($socid) && $linkedtothirdparty) |
|
| 524 | 524 | { |
| 525 | - if (is_numeric($socid)) $sql.= " AND t.fk_soc=".$socid; |
|
| 526 | - else $sql.= " AND t.fk_soc IN (".$socid.")"; |
|
| 525 | + if (is_numeric($socid)) $sql .= " AND t.fk_soc=".$socid; |
|
| 526 | + else $sql .= " AND t.fk_soc IN (".$socid.")"; |
|
| 527 | 527 | } |
| 528 | - if (! in_array($table_element, array('expensereport_det','stock_mouvement'))) $sql.= ' AND t.entity IN ('.getEntity('project').')'; |
|
| 529 | - if ($linkedtothirdparty) $sql.=" AND s.rowid = t.fk_soc"; |
|
| 530 | - if ($sqlfilter) $sql.= " AND ".$sqlfilter; |
|
| 531 | - $sql.= " ORDER BY ref DESC"; |
|
| 528 | + if (!in_array($table_element, array('expensereport_det', 'stock_mouvement'))) $sql .= ' AND t.entity IN ('.getEntity('project').')'; |
|
| 529 | + if ($linkedtothirdparty) $sql .= " AND s.rowid = t.fk_soc"; |
|
| 530 | + if ($sqlfilter) $sql .= " AND ".$sqlfilter; |
|
| 531 | + $sql .= " ORDER BY ref DESC"; |
|
| 532 | 532 | |
| 533 | 533 | dol_syslog(get_class($this).'::select_element', LOG_DEBUG); |
| 534 | - $resql=$this->db->query($sql); |
|
| 534 | + $resql = $this->db->query($sql); |
|
| 535 | 535 | if ($resql) |
| 536 | 536 | { |
| 537 | 537 | $num = $this->db->num_rows($resql); |
| 538 | 538 | $i = 0; |
| 539 | 539 | if ($num > 0) |
| 540 | 540 | { |
| 541 | - $sellist = '<select class="flat elementselect css'.$table_element.($morecss?' '.$morecss:'').'" name="elementselect">'; |
|
| 542 | - $sellist .='<option value="-1"></option>'; |
|
| 541 | + $sellist = '<select class="flat elementselect css'.$table_element.($morecss ? ' '.$morecss : '').'" name="elementselect">'; |
|
| 542 | + $sellist .= '<option value="-1"></option>'; |
|
| 543 | 543 | while ($i < $num) |
| 544 | 544 | { |
| 545 | 545 | $obj = $this->db->fetch_object($resql); |
| 546 | - $ref=$obj->ref?$obj->ref:$obj->rowid; |
|
| 547 | - if (! empty($obj->ref_supplier)) $ref.=' ('.$obj->ref_supplier.')'; |
|
| 548 | - if (! empty($obj->name)) $ref.=' - '.$obj->name; |
|
| 549 | - $sellist .='<option value="'.$obj->rowid.'">'.$ref.'</option>'; |
|
| 546 | + $ref = $obj->ref ? $obj->ref : $obj->rowid; |
|
| 547 | + if (!empty($obj->ref_supplier)) $ref .= ' ('.$obj->ref_supplier.')'; |
|
| 548 | + if (!empty($obj->name)) $ref .= ' - '.$obj->name; |
|
| 549 | + $sellist .= '<option value="'.$obj->rowid.'">'.$ref.'</option>'; |
|
| 550 | 550 | $i++; |
| 551 | 551 | } |
| 552 | - $sellist .='</select>'; |
|
| 552 | + $sellist .= '</select>'; |
|
| 553 | 553 | } |
| 554 | 554 | /*else |
| 555 | 555 | { |
@@ -564,9 +564,9 @@ discard block |
||
| 564 | 564 | else |
| 565 | 565 | { |
| 566 | 566 | dol_print_error($this->db); |
| 567 | - $this->error=$this->db->lasterror(); |
|
| 568 | - $this->errors[]=$this->db->lasterror(); |
|
| 569 | - dol_syslog(get_class($this) . "::select_element " . $this->error, LOG_ERR); |
|
| 567 | + $this->error = $this->db->lasterror(); |
|
| 568 | + $this->errors[] = $this->db->lasterror(); |
|
| 569 | + dol_syslog(get_class($this)."::select_element ".$this->error, LOG_ERR); |
|
| 570 | 570 | return -1; |
| 571 | 571 | } |
| 572 | 572 | } |
@@ -584,32 +584,32 @@ discard block |
||
| 584 | 584 | * @param string $morecss Add more css |
| 585 | 585 | * @return int|string The HTML select list of element or '' if nothing or -1 if KO |
| 586 | 586 | */ |
| 587 | - function selectOpportunityStatus($htmlname, $preselected='-1', $showempty=1, $useshortlabel=0, $showallnone=0, $showpercent=0, $morecss='') |
|
| 587 | + function selectOpportunityStatus($htmlname, $preselected = '-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '') |
|
| 588 | 588 | { |
| 589 | 589 | global $conf, $langs; |
| 590 | 590 | |
| 591 | 591 | $sql = "SELECT rowid, code, label, percent"; |
| 592 | - $sql.= " FROM ".MAIN_DB_PREFIX.'c_lead_status'; |
|
| 593 | - $sql.= " WHERE active = 1"; |
|
| 594 | - $sql.= " ORDER BY position"; |
|
| 592 | + $sql .= " FROM ".MAIN_DB_PREFIX.'c_lead_status'; |
|
| 593 | + $sql .= " WHERE active = 1"; |
|
| 594 | + $sql .= " ORDER BY position"; |
|
| 595 | 595 | |
| 596 | - $resql=$this->db->query($sql); |
|
| 596 | + $resql = $this->db->query($sql); |
|
| 597 | 597 | if ($resql) |
| 598 | 598 | { |
| 599 | 599 | $num = $this->db->num_rows($resql); |
| 600 | 600 | $i = 0; |
| 601 | 601 | if ($num > 0) |
| 602 | 602 | { |
| 603 | - $sellist = '<select class="flat oppstatus'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
|
| 604 | - if ($showempty) $sellist.= '<option value="-1"> </option>'; // Without  , strange move of screen when switching value |
|
| 605 | - if ($showallnone) $sellist.= '<option value="all"'.($preselected == 'all'?' selected="selected"':'').'>--'.$langs->trans("OnlyOpportunitiesShort").'--</option>'; |
|
| 606 | - if ($showallnone) $sellist.= '<option value="openedopp"'.($preselected == 'openedopp'?' selected="selected"':'').'>--'.$langs->trans("OpenedOpportunitiesShort").'--</option>'; |
|
| 607 | - if ($showallnone) $sellist.= '<option value="none"'.($preselected == 'none'?' selected="selected"':'').'>--'.$langs->trans("NotAnOpportunityShort").'--</option>'; |
|
| 603 | + $sellist = '<select class="flat oppstatus'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
|
| 604 | + if ($showempty) $sellist .= '<option value="-1"> </option>'; // Without  , strange move of screen when switching value |
|
| 605 | + if ($showallnone) $sellist .= '<option value="all"'.($preselected == 'all' ? ' selected="selected"' : '').'>--'.$langs->trans("OnlyOpportunitiesShort").'--</option>'; |
|
| 606 | + if ($showallnone) $sellist .= '<option value="openedopp"'.($preselected == 'openedopp' ? ' selected="selected"' : '').'>--'.$langs->trans("OpenedOpportunitiesShort").'--</option>'; |
|
| 607 | + if ($showallnone) $sellist .= '<option value="none"'.($preselected == 'none' ? ' selected="selected"' : '').'>--'.$langs->trans("NotAnOpportunityShort").'--</option>'; |
|
| 608 | 608 | while ($i < $num) |
| 609 | 609 | { |
| 610 | 610 | $obj = $this->db->fetch_object($resql); |
| 611 | 611 | |
| 612 | - $sellist .='<option value="'.$obj->rowid.'" defaultpercent="'.$obj->percent.'" elemcode="'.$obj->code.'"'; |
|
| 612 | + $sellist .= '<option value="'.$obj->rowid.'" defaultpercent="'.$obj->percent.'" elemcode="'.$obj->code.'"'; |
|
| 613 | 613 | if ($obj->rowid == $preselected) $sellist .= ' selected="selected"'; |
| 614 | 614 | $sellist .= '>'; |
| 615 | 615 | if ($useshortlabel) |
@@ -619,13 +619,13 @@ discard block |
||
| 619 | 619 | else |
| 620 | 620 | { |
| 621 | 621 | $finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label); |
| 622 | - if ($showpercent) $finallabel.= ' ('.$obj->percent.'%)'; |
|
| 622 | + if ($showpercent) $finallabel .= ' ('.$obj->percent.'%)'; |
|
| 623 | 623 | } |
| 624 | 624 | $sellist .= $finallabel; |
| 625 | - $sellist .='</option>'; |
|
| 625 | + $sellist .= '</option>'; |
|
| 626 | 626 | $i++; |
| 627 | 627 | } |
| 628 | - $sellist .='</select>'; |
|
| 628 | + $sellist .= '</select>'; |
|
| 629 | 629 | } |
| 630 | 630 | /*else |
| 631 | 631 | { |
@@ -639,9 +639,9 @@ discard block |
||
| 639 | 639 | } |
| 640 | 640 | else |
| 641 | 641 | { |
| 642 | - $this->error=$this->db->lasterror(); |
|
| 643 | - $this->errors[]=$this->db->lasterror(); |
|
| 644 | - dol_syslog(get_class($this) . "::selectOpportunityStatus " . $this->error, LOG_ERR); |
|
| 642 | + $this->error = $this->db->lasterror(); |
|
| 643 | + $this->errors[] = $this->db->lasterror(); |
|
| 644 | + dol_syslog(get_class($this)."::selectOpportunityStatus ".$this->error, LOG_ERR); |
|
| 645 | 645 | return -1; |
| 646 | 646 | } |
| 647 | 647 | } |
@@ -88,8 +88,7 @@ discard block |
||
| 88 | 88 | )); |
| 89 | 89 | |
| 90 | 90 | $out.='<input type="text" class="minwidth200'.($morecss?' '.$morecss:'').'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />'; |
| 91 | - } |
|
| 92 | - else |
|
| 91 | + } else |
|
| 93 | 92 | { |
| 94 | 93 | $out.=$this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, $discard_closed, $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid); |
| 95 | 94 | } |
@@ -97,7 +96,9 @@ discard block |
||
| 97 | 96 | { |
| 98 | 97 | if (class_exists('Form')) |
| 99 | 98 | { |
| 100 | - if (empty($form)) $form=new Form($this->db); |
|
| 99 | + if (empty($form)) { |
|
| 100 | + $form=new Form($this->db); |
|
| 101 | + } |
|
| 101 | 102 | $out.=$form->textwithpicto('', $langs->trans("ClosedProjectsAreHidden")); |
| 102 | 103 | } |
| 103 | 104 | } |
@@ -106,8 +107,9 @@ discard block |
||
| 106 | 107 | { |
| 107 | 108 | print $out; |
| 108 | 109 | return ''; |
| 110 | + } else { |
|
| 111 | + return $out; |
|
| 109 | 112 | } |
| 110 | - else return $out; |
|
| 111 | 113 | } |
| 112 | 114 | |
| 113 | 115 | /** |
@@ -136,13 +138,17 @@ discard block |
||
| 136 | 138 | |
| 137 | 139 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 138 | 140 | |
| 139 | - if (empty($htmlid)) $htmlid = $htmlname; |
|
| 141 | + if (empty($htmlid)) { |
|
| 142 | + $htmlid = $htmlname; |
|
| 143 | + } |
|
| 140 | 144 | |
| 141 | 145 | $out=''; |
| 142 | 146 | $outarray=array(); |
| 143 | 147 | |
| 144 | 148 | $hideunselectables = false; |
| 145 | - if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; |
|
| 149 | + if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) { |
|
| 150 | + $hideunselectables = true; |
|
| 151 | + } |
|
| 146 | 152 | |
| 147 | 153 | $projectsListId = false; |
| 148 | 154 | if (empty($user->rights->projet->all->lire)) |
@@ -155,17 +161,26 @@ discard block |
||
| 155 | 161 | $sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name, s.name_alias'; |
| 156 | 162 | $sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p LEFT JOIN '.MAIN_DB_PREFIX .'societe as s ON s.rowid = p.fk_soc'; |
| 157 | 163 | $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
| 158 | - if ($projectsListId !== false) $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
| 159 | - if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; |
|
| 164 | + if ($projectsListId !== false) { |
|
| 165 | + $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
| 166 | + } |
|
| 167 | + if ($socid == 0) { |
|
| 168 | + $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; |
|
| 169 | + } |
|
| 160 | 170 | if ($socid > 0) |
| 161 | 171 | { |
| 162 | - if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; |
|
| 163 | - else if ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. |
|
| 172 | + if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) { |
|
| 173 | + $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; |
|
| 174 | + } else if ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') { |
|
| 175 | + // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. |
|
| 164 | 176 | { |
| 165 | 177 | $sql.= " AND (p.fk_soc IN (".$socid.", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") OR p.fk_soc IS NULL)"; |
| 166 | 178 | } |
| 179 | + } |
|
| 180 | + } |
|
| 181 | + if (!empty($filterkey)) { |
|
| 182 | + $sql .= natural_search(array('p.title', 'p.ref'), $filterkey); |
|
| 167 | 183 | } |
| 168 | - if (!empty($filterkey)) $sql .= natural_search(array('p.title', 'p.ref'), $filterkey); |
|
| 169 | 184 | $sql.= " ORDER BY p.ref ASC"; |
| 170 | 185 | |
| 171 | 186 | $resql=$this->db->query($sql); |
@@ -197,12 +212,13 @@ discard block |
||
| 197 | 212 | if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire) |
| 198 | 213 | { |
| 199 | 214 | // Do nothing |
| 200 | - } |
|
| 201 | - else |
|
| 215 | + } else |
|
| 202 | 216 | { |
| 203 | - if ($discard_closed == 1 && $obj->fk_statut == 2 && $obj->rowid != $selected) // We discard closed except if selected |
|
| 217 | + if ($discard_closed == 1 && $obj->fk_statut == 2 && $obj->rowid != $selected) { |
|
| 218 | + // We discard closed except if selected |
|
| 204 | 219 | { |
| 205 | 220 | $i++; |
| 221 | + } |
|
| 206 | 222 | continue; |
| 207 | 223 | } |
| 208 | 224 | |
@@ -213,7 +229,9 @@ discard block |
||
| 213 | 229 | if ($obj->name) |
| 214 | 230 | { |
| 215 | 231 | $labeltoshow.=' - '.$obj->name; |
| 216 | - if ($obj->name_alias) $labeltoshow.=' ('.$obj->name_alias.')'; |
|
| 232 | + if ($obj->name_alias) { |
|
| 233 | + $labeltoshow.=' ('.$obj->name_alias.')'; |
|
| 234 | + } |
|
| 217 | 235 | } |
| 218 | 236 | |
| 219 | 237 | $disabled=0; |
@@ -221,13 +239,13 @@ discard block |
||
| 221 | 239 | { |
| 222 | 240 | $disabled=1; |
| 223 | 241 | $labeltoshow.=' - '.$langs->trans("Draft"); |
| 224 | - } |
|
| 225 | - else if ($obj->fk_statut == 2) |
|
| 242 | + } else if ($obj->fk_statut == 2) |
|
| 226 | 243 | { |
| 227 | - if ($discard_close == 2) $disabled=1; |
|
| 244 | + if ($discard_close == 2) { |
|
| 245 | + $disabled=1; |
|
| 246 | + } |
|
| 228 | 247 | $labeltoshow.=' - '.$langs->trans("Closed"); |
| 229 | - } |
|
| 230 | - else if ( empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
| 248 | + } else if ( empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
| 231 | 249 | { |
| 232 | 250 | $disabled=1; |
| 233 | 251 | $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); |
@@ -238,17 +256,17 @@ discard block |
||
| 238 | 256 | $out.= '<option value="'.$obj->rowid.'" selected'; |
| 239 | 257 | //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled |
| 240 | 258 | $out.= '>'.$labeltoshow.'</option>'; |
| 241 | - } |
|
| 242 | - else |
|
| 259 | + } else |
|
| 243 | 260 | { |
| 244 | 261 | if ($hideunselectables && $disabled && ($selected != $obj->rowid)) |
| 245 | 262 | { |
| 246 | 263 | $resultat=''; |
| 247 | - } |
|
| 248 | - else |
|
| 264 | + } else |
|
| 249 | 265 | { |
| 250 | 266 | $resultat='<option value="'.$obj->rowid.'"'; |
| 251 | - if ($disabled) $resultat.=' disabled'; |
|
| 267 | + if ($disabled) { |
|
| 268 | + $resultat.=' disabled'; |
|
| 269 | + } |
|
| 252 | 270 | //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')'; |
| 253 | 271 | //else $labeltoshow.=' ('.$langs->trans("Private").')'; |
| 254 | 272 | $resultat.='>'; |
@@ -273,18 +291,20 @@ discard block |
||
| 273 | 291 | $this->db->free($resql); |
| 274 | 292 | |
| 275 | 293 | if (!$mode) { |
| 276 | - if (empty($option_only)) $out.= '</select>'; |
|
| 294 | + if (empty($option_only)) { |
|
| 295 | + $out.= '</select>'; |
|
| 296 | + } |
|
| 277 | 297 | if (empty($nooutput)) |
| 278 | 298 | { |
| 279 | 299 | print $out; |
| 280 | 300 | return ''; |
| 301 | + } else { |
|
| 302 | + return $out; |
|
| 281 | 303 | } |
| 282 | - else return $out; |
|
| 283 | 304 | } else { |
| 284 | 305 | return $outarray; |
| 285 | 306 | } |
| 286 | - } |
|
| 287 | - else |
|
| 307 | + } else |
|
| 288 | 308 | { |
| 289 | 309 | dol_print_error($this->db); |
| 290 | 310 | return -1; |
@@ -315,7 +335,9 @@ discard block |
||
| 315 | 335 | $out=''; |
| 316 | 336 | |
| 317 | 337 | $hideunselectables = false; |
| 318 | - if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; |
|
| 338 | + if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) { |
|
| 339 | + $hideunselectables = true; |
|
| 340 | + } |
|
| 319 | 341 | |
| 320 | 342 | $projectsListId = false; |
| 321 | 343 | if (empty($user->rights->projet->all->lire)) |
@@ -332,9 +354,15 @@ discard block |
||
| 332 | 354 | $sql.= ', '.MAIN_DB_PREFIX.'projet_task as t'; |
| 333 | 355 | $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
| 334 | 356 | $sql.= " AND t.fk_projet = p.rowid"; |
| 335 | - if ($projectsListId !== false) $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
| 336 | - if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; |
|
| 337 | - if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; |
|
| 357 | + if ($projectsListId !== false) { |
|
| 358 | + $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
| 359 | + } |
|
| 360 | + if ($socid == 0) { |
|
| 361 | + $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; |
|
| 362 | + } |
|
| 363 | + if ($socid > 0) { |
|
| 364 | + $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; |
|
| 365 | + } |
|
| 338 | 366 | $sql.= " ORDER BY p.ref, t.ref ASC"; |
| 339 | 367 | |
| 340 | 368 | $resql=$this->db->query($sql); |
@@ -354,8 +382,11 @@ discard block |
||
| 354 | 382 | } |
| 355 | 383 | if (! empty($show_empty)) { |
| 356 | 384 | $out.= '<option value="0" class="optiongrey">'; |
| 357 | - if (! is_numeric($show_empty)) $out.=$show_empty; |
|
| 358 | - else $out.=' '; |
|
| 385 | + if (! is_numeric($show_empty)) { |
|
| 386 | + $out.=$show_empty; |
|
| 387 | + } else { |
|
| 388 | + $out.=' '; |
|
| 389 | + } |
|
| 359 | 390 | $out.= '</option>'; |
| 360 | 391 | } |
| 361 | 392 | $num = $this->db->num_rows($resql); |
@@ -369,8 +400,7 @@ discard block |
||
| 369 | 400 | if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($user->rights->societe->lire)) |
| 370 | 401 | { |
| 371 | 402 | // Do nothing |
| 372 | - } |
|
| 373 | - else |
|
| 403 | + } else |
|
| 374 | 404 | { |
| 375 | 405 | if ($discard_closed == 1 && $obj->fk_statut == 2) |
| 376 | 406 | { |
@@ -383,20 +413,22 @@ discard block |
||
| 383 | 413 | //else $labeltoshow.=' ('.$langs->trans("Private").')'; |
| 384 | 414 | $labeltoshow.=' '.dol_trunc($obj->title,$maxlength); |
| 385 | 415 | |
| 386 | - if ($obj->name) $labeltoshow.=' ('.$obj->name.')'; |
|
| 416 | + if ($obj->name) { |
|
| 417 | + $labeltoshow.=' ('.$obj->name.')'; |
|
| 418 | + } |
|
| 387 | 419 | |
| 388 | 420 | $disabled=0; |
| 389 | 421 | if ($obj->fk_statut == 0) |
| 390 | 422 | { |
| 391 | 423 | $disabled=1; |
| 392 | 424 | $labeltoshow.=' - '.$langs->trans("Draft"); |
| 393 | - } |
|
| 394 | - else if ($obj->fk_statut == 2) |
|
| 425 | + } else if ($obj->fk_statut == 2) |
|
| 395 | 426 | { |
| 396 | - if ($discard_closed == 2) $disabled=1; |
|
| 427 | + if ($discard_closed == 2) { |
|
| 428 | + $disabled=1; |
|
| 429 | + } |
|
| 397 | 430 | $labeltoshow.=' - '.$langs->trans("Closed"); |
| 398 | - } |
|
| 399 | - else if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
| 431 | + } else if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
| 400 | 432 | { |
| 401 | 433 | $disabled=1; |
| 402 | 434 | $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); |
@@ -409,17 +441,17 @@ discard block |
||
| 409 | 441 | $out.= '<option value="'.$obj->rowid.'" selected'; |
| 410 | 442 | //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled |
| 411 | 443 | $out.= '>'.$labeltoshow.'</option>'; |
| 412 | - } |
|
| 413 | - else |
|
| 444 | + } else |
|
| 414 | 445 | { |
| 415 | 446 | if ($hideunselectables && $disabled && ($selected != $obj->rowid)) |
| 416 | 447 | { |
| 417 | 448 | $resultat=''; |
| 418 | - } |
|
| 419 | - else |
|
| 449 | + } else |
|
| 420 | 450 | { |
| 421 | 451 | $resultat='<option value="'.$obj->rowid.'"'; |
| 422 | - if ($disabled) $resultat.=' disabled'; |
|
| 452 | + if ($disabled) { |
|
| 453 | + $resultat.=' disabled'; |
|
| 454 | + } |
|
| 423 | 455 | //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')'; |
| 424 | 456 | //else $labeltoshow.=' ('.$langs->trans("Private").')'; |
| 425 | 457 | $resultat.='>'; |
@@ -440,8 +472,7 @@ discard block |
||
| 440 | 472 | |
| 441 | 473 | $this->db->free($resql); |
| 442 | 474 | return $num; |
| 443 | - } |
|
| 444 | - else |
|
| 475 | + } else |
|
| 445 | 476 | { |
| 446 | 477 | dol_print_error($this->db); |
| 447 | 478 | return -1; |
@@ -462,10 +493,15 @@ discard block |
||
| 462 | 493 | { |
| 463 | 494 | global $conf, $langs; |
| 464 | 495 | |
| 465 | - if ($table_element == 'projet_task') return ''; // Special cas of element we never link to a project (already always done) |
|
| 496 | + if ($table_element == 'projet_task') { |
|
| 497 | + return ''; |
|
| 498 | + } |
|
| 499 | + // Special cas of element we never link to a project (already always done) |
|
| 466 | 500 | |
| 467 | 501 | $linkedtothirdparty=false; |
| 468 | - if (! in_array($table_element, array('don','expensereport_det','expensereport','loan','stock_mouvement','chargesociales'))) $linkedtothirdparty=true; |
|
| 502 | + if (! in_array($table_element, array('don','expensereport_det','expensereport','loan','stock_mouvement','chargesociales'))) { |
|
| 503 | + $linkedtothirdparty=true; |
|
| 504 | + } |
|
| 469 | 505 | |
| 470 | 506 | $sqlfilter=''; |
| 471 | 507 | $projectkey="fk_projet"; |
@@ -516,18 +552,31 @@ discard block |
||
| 516 | 552 | $sql = "SELECT t.rowid, t.ref"; |
| 517 | 553 | break; |
| 518 | 554 | } |
| 519 | - if ($linkedtothirdparty) $sql.=", s.nom as name"; |
|
| 555 | + if ($linkedtothirdparty) { |
|
| 556 | + $sql.=", s.nom as name"; |
|
| 557 | + } |
|
| 520 | 558 | $sql.= " FROM ".MAIN_DB_PREFIX.$table_element." as t"; |
| 521 | - if ($linkedtothirdparty) $sql.=", ".MAIN_DB_PREFIX."societe as s"; |
|
| 559 | + if ($linkedtothirdparty) { |
|
| 560 | + $sql.=", ".MAIN_DB_PREFIX."societe as s"; |
|
| 561 | + } |
|
| 522 | 562 | $sql.= " WHERE ".$projectkey." is null"; |
| 523 | 563 | if (! empty($socid) && $linkedtothirdparty) |
| 524 | 564 | { |
| 525 | - if (is_numeric($socid)) $sql.= " AND t.fk_soc=".$socid; |
|
| 526 | - else $sql.= " AND t.fk_soc IN (".$socid.")"; |
|
| 565 | + if (is_numeric($socid)) { |
|
| 566 | + $sql.= " AND t.fk_soc=".$socid; |
|
| 567 | + } else { |
|
| 568 | + $sql.= " AND t.fk_soc IN (".$socid.")"; |
|
| 569 | + } |
|
| 570 | + } |
|
| 571 | + if (! in_array($table_element, array('expensereport_det','stock_mouvement'))) { |
|
| 572 | + $sql.= ' AND t.entity IN ('.getEntity('project').')'; |
|
| 573 | + } |
|
| 574 | + if ($linkedtothirdparty) { |
|
| 575 | + $sql.=" AND s.rowid = t.fk_soc"; |
|
| 576 | + } |
|
| 577 | + if ($sqlfilter) { |
|
| 578 | + $sql.= " AND ".$sqlfilter; |
|
| 527 | 579 | } |
| 528 | - if (! in_array($table_element, array('expensereport_det','stock_mouvement'))) $sql.= ' AND t.entity IN ('.getEntity('project').')'; |
|
| 529 | - if ($linkedtothirdparty) $sql.=" AND s.rowid = t.fk_soc"; |
|
| 530 | - if ($sqlfilter) $sql.= " AND ".$sqlfilter; |
|
| 531 | 580 | $sql.= " ORDER BY ref DESC"; |
| 532 | 581 | |
| 533 | 582 | dol_syslog(get_class($this).'::select_element', LOG_DEBUG); |
@@ -544,8 +593,12 @@ discard block |
||
| 544 | 593 | { |
| 545 | 594 | $obj = $this->db->fetch_object($resql); |
| 546 | 595 | $ref=$obj->ref?$obj->ref:$obj->rowid; |
| 547 | - if (! empty($obj->ref_supplier)) $ref.=' ('.$obj->ref_supplier.')'; |
|
| 548 | - if (! empty($obj->name)) $ref.=' - '.$obj->name; |
|
| 596 | + if (! empty($obj->ref_supplier)) { |
|
| 597 | + $ref.=' ('.$obj->ref_supplier.')'; |
|
| 598 | + } |
|
| 599 | + if (! empty($obj->name)) { |
|
| 600 | + $ref.=' - '.$obj->name; |
|
| 601 | + } |
|
| 549 | 602 | $sellist .='<option value="'.$obj->rowid.'">'.$ref.'</option>'; |
| 550 | 603 | $i++; |
| 551 | 604 | } |
@@ -560,8 +613,7 @@ discard block |
||
| 560 | 613 | $this->db->free($resql); |
| 561 | 614 | |
| 562 | 615 | return $sellist; |
| 563 | - } |
|
| 564 | - else |
|
| 616 | + } else |
|
| 565 | 617 | { |
| 566 | 618 | dol_print_error($this->db); |
| 567 | 619 | $this->error=$this->db->lasterror(); |
@@ -601,25 +653,37 @@ discard block |
||
| 601 | 653 | if ($num > 0) |
| 602 | 654 | { |
| 603 | 655 | $sellist = '<select class="flat oppstatus'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
| 604 | - if ($showempty) $sellist.= '<option value="-1"> </option>'; // Without  , strange move of screen when switching value |
|
| 605 | - if ($showallnone) $sellist.= '<option value="all"'.($preselected == 'all'?' selected="selected"':'').'>--'.$langs->trans("OnlyOpportunitiesShort").'--</option>'; |
|
| 606 | - if ($showallnone) $sellist.= '<option value="openedopp"'.($preselected == 'openedopp'?' selected="selected"':'').'>--'.$langs->trans("OpenedOpportunitiesShort").'--</option>'; |
|
| 607 | - if ($showallnone) $sellist.= '<option value="none"'.($preselected == 'none'?' selected="selected"':'').'>--'.$langs->trans("NotAnOpportunityShort").'--</option>'; |
|
| 656 | + if ($showempty) { |
|
| 657 | + $sellist.= '<option value="-1"> </option>'; |
|
| 658 | + } |
|
| 659 | + // Without  , strange move of screen when switching value |
|
| 660 | + if ($showallnone) { |
|
| 661 | + $sellist.= '<option value="all"'.($preselected == 'all'?' selected="selected"':'').'>--'.$langs->trans("OnlyOpportunitiesShort").'--</option>'; |
|
| 662 | + } |
|
| 663 | + if ($showallnone) { |
|
| 664 | + $sellist.= '<option value="openedopp"'.($preselected == 'openedopp'?' selected="selected"':'').'>--'.$langs->trans("OpenedOpportunitiesShort").'--</option>'; |
|
| 665 | + } |
|
| 666 | + if ($showallnone) { |
|
| 667 | + $sellist.= '<option value="none"'.($preselected == 'none'?' selected="selected"':'').'>--'.$langs->trans("NotAnOpportunityShort").'--</option>'; |
|
| 668 | + } |
|
| 608 | 669 | while ($i < $num) |
| 609 | 670 | { |
| 610 | 671 | $obj = $this->db->fetch_object($resql); |
| 611 | 672 | |
| 612 | 673 | $sellist .='<option value="'.$obj->rowid.'" defaultpercent="'.$obj->percent.'" elemcode="'.$obj->code.'"'; |
| 613 | - if ($obj->rowid == $preselected) $sellist .= ' selected="selected"'; |
|
| 674 | + if ($obj->rowid == $preselected) { |
|
| 675 | + $sellist .= ' selected="selected"'; |
|
| 676 | + } |
|
| 614 | 677 | $sellist .= '>'; |
| 615 | 678 | if ($useshortlabel) |
| 616 | 679 | { |
| 617 | 680 | $finallabel = ($langs->transnoentitiesnoconv("OppStatusShort".$obj->code) != "OppStatusShort".$obj->code ? $langs->transnoentitiesnoconv("OppStatusShort".$obj->code) : $obj->label); |
| 618 | - } |
|
| 619 | - else |
|
| 681 | + } else |
|
| 620 | 682 | { |
| 621 | 683 | $finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label); |
| 622 | - if ($showpercent) $finallabel.= ' ('.$obj->percent.'%)'; |
|
| 684 | + if ($showpercent) { |
|
| 685 | + $finallabel.= ' ('.$obj->percent.'%)'; |
|
| 686 | + } |
|
| 623 | 687 | } |
| 624 | 688 | $sellist .= $finallabel; |
| 625 | 689 | $sellist .='</option>'; |
@@ -636,8 +700,7 @@ discard block |
||
| 636 | 700 | $this->db->free($resql); |
| 637 | 701 | |
| 638 | 702 | return $sellist; |
| 639 | - } |
|
| 640 | - else |
|
| 703 | + } else |
|
| 641 | 704 | { |
| 642 | 705 | $this->error=$this->db->lasterror(); |
| 643 | 706 | $this->errors[]=$this->db->lasterror(); |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | * Retourne le libelle du statut d'une charge (impaye, payee) |
| 378 | 378 | * |
| 379 | 379 | * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto |
| 380 | - * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
|
| 380 | + * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
|
| 381 | 381 | * @return string Label |
| 382 | 382 | */ |
| 383 | 383 | function getLibStatut($mode=0,$alreadypaid=-1) |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | * |
| 391 | 391 | * @param int $statut Id statut |
| 392 | 392 | * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto |
| 393 | - * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
|
| 393 | + * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
|
| 394 | 394 | * @return string Label |
| 395 | 395 | */ |
| 396 | 396 | function LibStatut($statut,$mode=0,$alreadypaid=-1) |
@@ -32,101 +32,101 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | class ChargeSociales extends CommonObject |
| 34 | 34 | { |
| 35 | - public $element='chargesociales'; |
|
| 36 | - public $table='chargesociales'; |
|
| 37 | - public $table_element='chargesociales'; |
|
| 38 | - public $picto = 'bill'; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * {@inheritdoc} |
|
| 42 | - */ |
|
| 43 | - protected $table_ref_field = 'ref'; |
|
| 44 | - |
|
| 45 | - var $date_ech; |
|
| 46 | - var $lib; |
|
| 47 | - var $type; |
|
| 48 | - var $type_libelle; |
|
| 49 | - var $amount; |
|
| 50 | - var $paye; |
|
| 51 | - var $periode; |
|
| 52 | - var $date_creation; |
|
| 53 | - var $date_modification; |
|
| 54 | - var $date_validation; |
|
| 55 | - var $fk_account; |
|
| 35 | + public $element='chargesociales'; |
|
| 36 | + public $table='chargesociales'; |
|
| 37 | + public $table_element='chargesociales'; |
|
| 38 | + public $picto = 'bill'; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * {@inheritdoc} |
|
| 42 | + */ |
|
| 43 | + protected $table_ref_field = 'ref'; |
|
| 44 | + |
|
| 45 | + var $date_ech; |
|
| 46 | + var $lib; |
|
| 47 | + var $type; |
|
| 48 | + var $type_libelle; |
|
| 49 | + var $amount; |
|
| 50 | + var $paye; |
|
| 51 | + var $periode; |
|
| 52 | + var $date_creation; |
|
| 53 | + var $date_modification; |
|
| 54 | + var $date_validation; |
|
| 55 | + var $fk_account; |
|
| 56 | 56 | var $fk_project; |
| 57 | 57 | |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Constructor |
|
| 61 | - * |
|
| 62 | - * @param DoliDB $db Database handler |
|
| 63 | - */ |
|
| 64 | - function __construct($db) |
|
| 65 | - { |
|
| 66 | - $this->db = $db; |
|
| 67 | - return 1; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Retrouve et charge une charge sociale |
|
| 72 | - * |
|
| 73 | - * @param int $id Id |
|
| 74 | - * @param string $ref Ref |
|
| 75 | - * @return int <0 KO >0 OK |
|
| 76 | - */ |
|
| 77 | - function fetch($id, $ref='') |
|
| 78 | - { |
|
| 79 | - $sql = "SELECT cs.rowid, cs.date_ech"; |
|
| 80 | - $sql.= ", cs.libelle as lib, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; |
|
| 81 | - $sql.= ", cs.fk_account, cs.fk_mode_reglement"; |
|
| 82 | - $sql.= ", c.libelle"; |
|
| 83 | - $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; |
|
| 84 | - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; |
|
| 85 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; |
|
| 86 | - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id AND p.entity IN ('.getEntity('c_paiement').')'; |
|
| 87 | - $sql.= ' WHERE cs.entity IN ('.getEntity('tax').')'; |
|
| 88 | - if ($ref) $sql.= " AND cs.rowid = ".$ref; |
|
| 89 | - else $sql.= " AND cs.rowid = ".$id; |
|
| 90 | - |
|
| 91 | - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
|
| 92 | - $resql=$this->db->query($sql); |
|
| 93 | - if ($resql) |
|
| 94 | - { |
|
| 95 | - if ($this->db->num_rows($resql)) |
|
| 96 | - { |
|
| 97 | - $obj = $this->db->fetch_object($resql); |
|
| 98 | - |
|
| 99 | - $this->id = $obj->rowid; |
|
| 100 | - $this->ref = $obj->rowid; |
|
| 101 | - $this->date_ech = $this->db->jdate($obj->date_ech); |
|
| 102 | - $this->lib = $obj->lib; |
|
| 103 | - $this->type = $obj->fk_type; |
|
| 104 | - $this->type_libelle = $obj->libelle; |
|
| 105 | - $this->fk_account = $obj->fk_account; |
|
| 106 | - $this->mode_reglement_id = $obj->fk_mode_reglement; |
|
| 107 | - $this->mode_reglement_code = $obj->mode_reglement_code; |
|
| 108 | - $this->mode_reglement = $obj->mode_reglement_libelle; |
|
| 109 | - $this->amount = $obj->amount; |
|
| 59 | + /** |
|
| 60 | + * Constructor |
|
| 61 | + * |
|
| 62 | + * @param DoliDB $db Database handler |
|
| 63 | + */ |
|
| 64 | + function __construct($db) |
|
| 65 | + { |
|
| 66 | + $this->db = $db; |
|
| 67 | + return 1; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Retrouve et charge une charge sociale |
|
| 72 | + * |
|
| 73 | + * @param int $id Id |
|
| 74 | + * @param string $ref Ref |
|
| 75 | + * @return int <0 KO >0 OK |
|
| 76 | + */ |
|
| 77 | + function fetch($id, $ref='') |
|
| 78 | + { |
|
| 79 | + $sql = "SELECT cs.rowid, cs.date_ech"; |
|
| 80 | + $sql.= ", cs.libelle as lib, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; |
|
| 81 | + $sql.= ", cs.fk_account, cs.fk_mode_reglement"; |
|
| 82 | + $sql.= ", c.libelle"; |
|
| 83 | + $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; |
|
| 84 | + $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; |
|
| 85 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; |
|
| 86 | + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id AND p.entity IN ('.getEntity('c_paiement').')'; |
|
| 87 | + $sql.= ' WHERE cs.entity IN ('.getEntity('tax').')'; |
|
| 88 | + if ($ref) $sql.= " AND cs.rowid = ".$ref; |
|
| 89 | + else $sql.= " AND cs.rowid = ".$id; |
|
| 90 | + |
|
| 91 | + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
|
| 92 | + $resql=$this->db->query($sql); |
|
| 93 | + if ($resql) |
|
| 94 | + { |
|
| 95 | + if ($this->db->num_rows($resql)) |
|
| 96 | + { |
|
| 97 | + $obj = $this->db->fetch_object($resql); |
|
| 98 | + |
|
| 99 | + $this->id = $obj->rowid; |
|
| 100 | + $this->ref = $obj->rowid; |
|
| 101 | + $this->date_ech = $this->db->jdate($obj->date_ech); |
|
| 102 | + $this->lib = $obj->lib; |
|
| 103 | + $this->type = $obj->fk_type; |
|
| 104 | + $this->type_libelle = $obj->libelle; |
|
| 105 | + $this->fk_account = $obj->fk_account; |
|
| 106 | + $this->mode_reglement_id = $obj->fk_mode_reglement; |
|
| 107 | + $this->mode_reglement_code = $obj->mode_reglement_code; |
|
| 108 | + $this->mode_reglement = $obj->mode_reglement_libelle; |
|
| 109 | + $this->amount = $obj->amount; |
|
| 110 | 110 | $this->fk_project = $obj->fk_project; |
| 111 | - $this->paye = $obj->paye; |
|
| 112 | - $this->periode = $this->db->jdate($obj->periode); |
|
| 113 | - $this->import_key = $this->import_key; |
|
| 114 | - |
|
| 115 | - $this->db->free($resql); |
|
| 116 | - |
|
| 117 | - return 1; |
|
| 118 | - } |
|
| 119 | - else |
|
| 120 | - { |
|
| 121 | - return 0; |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - else |
|
| 125 | - { |
|
| 126 | - $this->error=$this->db->lasterror(); |
|
| 127 | - return -1; |
|
| 128 | - } |
|
| 129 | - } |
|
| 111 | + $this->paye = $obj->paye; |
|
| 112 | + $this->periode = $this->db->jdate($obj->periode); |
|
| 113 | + $this->import_key = $this->import_key; |
|
| 114 | + |
|
| 115 | + $this->db->free($resql); |
|
| 116 | + |
|
| 117 | + return 1; |
|
| 118 | + } |
|
| 119 | + else |
|
| 120 | + { |
|
| 121 | + return 0; |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + else |
|
| 125 | + { |
|
| 126 | + $this->error=$this->db->lasterror(); |
|
| 127 | + return -1; |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | 132 | * Check if a social contribution can be created into database |
@@ -137,31 +137,31 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | $newamount=price2num($this->amount,'MT'); |
| 139 | 139 | |
| 140 | - // Validation parametres |
|
| 141 | - if (! $newamount > 0 || empty($this->date_ech) || empty($this->periode)) |
|
| 142 | - { |
|
| 143 | - return false; |
|
| 144 | - } |
|
| 140 | + // Validation parametres |
|
| 141 | + if (! $newamount > 0 || empty($this->date_ech) || empty($this->periode)) |
|
| 142 | + { |
|
| 143 | + return false; |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | 146 | |
| 147 | 147 | return true; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Create a social contribution into database |
|
| 152 | - * |
|
| 153 | - * @param User $user User making creation |
|
| 154 | - * @return int <0 if KO, id if OK |
|
| 155 | - */ |
|
| 156 | - function create($user) |
|
| 157 | - { |
|
| 158 | - global $conf; |
|
| 150 | + /** |
|
| 151 | + * Create a social contribution into database |
|
| 152 | + * |
|
| 153 | + * @param User $user User making creation |
|
| 154 | + * @return int <0 if KO, id if OK |
|
| 155 | + */ |
|
| 156 | + function create($user) |
|
| 157 | + { |
|
| 158 | + global $conf; |
|
| 159 | 159 | $error=0; |
| 160 | 160 | |
| 161 | - $now=dol_now(); |
|
| 161 | + $now=dol_now(); |
|
| 162 | 162 | |
| 163 | - // Nettoyage parametres |
|
| 164 | - $newamount=price2num($this->amount,'MT'); |
|
| 163 | + // Nettoyage parametres |
|
| 164 | + $newamount=price2num($this->amount,'MT'); |
|
| 165 | 165 | |
| 166 | 166 | if (!$this->check()) |
| 167 | 167 | { |
@@ -169,29 +169,29 @@ discard block |
||
| 169 | 169 | return -2; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - $this->db->begin(); |
|
| 172 | + $this->db->begin(); |
|
| 173 | 173 | |
| 174 | - $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, date_creation)"; |
|
| 175 | - $sql.= " VALUES (".$this->type; |
|
| 176 | - $sql.= ", ".($this->fk_account>0 ? $this->fk_account:'NULL'); |
|
| 177 | - $sql.= ", ".($this->mode_reglement_id>0 ? $this->mode_reglement_id:"NULL"); |
|
| 178 | - $sql.= ", '".$this->db->escape($this->lib)."'"; |
|
| 179 | - $sql.= ", '".$this->db->idate($this->date_ech)."'"; |
|
| 174 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, date_creation)"; |
|
| 175 | + $sql.= " VALUES (".$this->type; |
|
| 176 | + $sql.= ", ".($this->fk_account>0 ? $this->fk_account:'NULL'); |
|
| 177 | + $sql.= ", ".($this->mode_reglement_id>0 ? $this->mode_reglement_id:"NULL"); |
|
| 178 | + $sql.= ", '".$this->db->escape($this->lib)."'"; |
|
| 179 | + $sql.= ", '".$this->db->idate($this->date_ech)."'"; |
|
| 180 | 180 | $sql.= ", '".$this->db->idate($this->periode)."'"; |
| 181 | - $sql.= ", '".price2num($newamount)."'"; |
|
| 181 | + $sql.= ", '".price2num($newamount)."'"; |
|
| 182 | 182 | $sql.= ", ".($this->fk_project>0?$this->fk_project:'NULL'); |
| 183 | - $sql.= ", ".$conf->entity; |
|
| 184 | - $sql.= ", ".$user->id; |
|
| 185 | - $sql.= ", '".$this->db->idate($now)."'"; |
|
| 186 | - $sql.= ")"; |
|
| 187 | - |
|
| 188 | - dol_syslog(get_class($this)."::create", LOG_DEBUG); |
|
| 189 | - $resql=$this->db->query($sql); |
|
| 190 | - if ($resql) |
|
| 191 | - { |
|
| 192 | - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); |
|
| 193 | - |
|
| 194 | - //dol_syslog("ChargesSociales::create this->id=".$this->id); |
|
| 183 | + $sql.= ", ".$conf->entity; |
|
| 184 | + $sql.= ", ".$user->id; |
|
| 185 | + $sql.= ", '".$this->db->idate($now)."'"; |
|
| 186 | + $sql.= ")"; |
|
| 187 | + |
|
| 188 | + dol_syslog(get_class($this)."::create", LOG_DEBUG); |
|
| 189 | + $resql=$this->db->query($sql); |
|
| 190 | + if ($resql) |
|
| 191 | + { |
|
| 192 | + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); |
|
| 193 | + |
|
| 194 | + //dol_syslog("ChargesSociales::create this->id=".$this->id); |
|
| 195 | 195 | $result=$this->call_trigger('PAYMENTSOCIALCONTRIBUTION_CREATE',$user); |
| 196 | 196 | if ($result < 0) $error++; |
| 197 | 197 | |
@@ -203,401 +203,401 @@ discard block |
||
| 203 | 203 | $this->db->rollback(); |
| 204 | 204 | return -1*$error; |
| 205 | 205 | } |
| 206 | - } |
|
| 207 | - else |
|
| 208 | - { |
|
| 209 | - $this->error=$this->db->error(); |
|
| 210 | - $this->db->rollback(); |
|
| 211 | - return -1; |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * Delete a social contribution |
|
| 218 | - * |
|
| 219 | - * @param User $user Object user making delete |
|
| 220 | - * @return int <0 if KO, >0 if OK |
|
| 221 | - */ |
|
| 222 | - function delete($user) |
|
| 223 | - { |
|
| 224 | - $error=0; |
|
| 225 | - |
|
| 226 | - $this->db->begin(); |
|
| 227 | - |
|
| 228 | - // Get bank transaction lines for this social contributions |
|
| 229 | - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
|
| 230 | - $account=new Account($this->db); |
|
| 231 | - $lines_url=$account->get_url('',$this->id,'sc'); |
|
| 232 | - |
|
| 233 | - // Delete bank urls |
|
| 234 | - foreach ($lines_url as $line_url) |
|
| 235 | - { |
|
| 236 | - if (! $error) |
|
| 237 | - { |
|
| 238 | - $accountline=new AccountLine($this->db); |
|
| 239 | - $accountline->fetch($line_url['fk_bank']); |
|
| 240 | - $result=$accountline->delete_urls($user); |
|
| 241 | - if ($result < 0) |
|
| 242 | - { |
|
| 243 | - $error++; |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - // Delete payments |
|
| 249 | - if (! $error) |
|
| 250 | - { |
|
| 251 | - $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge WHERE fk_charge=".$this->id; |
|
| 252 | - dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
|
| 253 | - $resql=$this->db->query($sql); |
|
| 254 | - if (! $resql) |
|
| 255 | - { |
|
| 256 | - $error++; |
|
| 257 | - $this->error=$this->db->lasterror(); |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - if (! $error) |
|
| 262 | - { |
|
| 263 | - $sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales WHERE rowid=".$this->id; |
|
| 264 | - dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
|
| 265 | - $resql=$this->db->query($sql); |
|
| 266 | - if (! $resql) |
|
| 267 | - { |
|
| 268 | - $error++; |
|
| 269 | - $this->error=$this->db->lasterror(); |
|
| 270 | - } |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - if (! $error) |
|
| 274 | - { |
|
| 275 | - $this->db->commit(); |
|
| 276 | - return 1; |
|
| 277 | - } |
|
| 278 | - else |
|
| 279 | - { |
|
| 280 | - $this->db->rollback(); |
|
| 281 | - return -1; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * Met a jour une charge sociale |
|
| 289 | - * |
|
| 290 | - * @param User $user Utilisateur qui modifie |
|
| 291 | - * @return int <0 si erreur, >0 si ok |
|
| 292 | - */ |
|
| 293 | - function update($user) |
|
| 294 | - { |
|
| 295 | - $this->db->begin(); |
|
| 296 | - |
|
| 297 | - $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; |
|
| 298 | - $sql.= " SET libelle='".$this->db->escape($this->lib)."'"; |
|
| 299 | - $sql.= ", date_ech='".$this->db->idate($this->date_ech)."'"; |
|
| 300 | - $sql.= ", periode='".$this->db->idate($this->periode)."'"; |
|
| 301 | - $sql.= ", amount='".price2num($this->amount,'MT')."'"; |
|
| 206 | + } |
|
| 207 | + else |
|
| 208 | + { |
|
| 209 | + $this->error=$this->db->error(); |
|
| 210 | + $this->db->rollback(); |
|
| 211 | + return -1; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * Delete a social contribution |
|
| 218 | + * |
|
| 219 | + * @param User $user Object user making delete |
|
| 220 | + * @return int <0 if KO, >0 if OK |
|
| 221 | + */ |
|
| 222 | + function delete($user) |
|
| 223 | + { |
|
| 224 | + $error=0; |
|
| 225 | + |
|
| 226 | + $this->db->begin(); |
|
| 227 | + |
|
| 228 | + // Get bank transaction lines for this social contributions |
|
| 229 | + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
|
| 230 | + $account=new Account($this->db); |
|
| 231 | + $lines_url=$account->get_url('',$this->id,'sc'); |
|
| 232 | + |
|
| 233 | + // Delete bank urls |
|
| 234 | + foreach ($lines_url as $line_url) |
|
| 235 | + { |
|
| 236 | + if (! $error) |
|
| 237 | + { |
|
| 238 | + $accountline=new AccountLine($this->db); |
|
| 239 | + $accountline->fetch($line_url['fk_bank']); |
|
| 240 | + $result=$accountline->delete_urls($user); |
|
| 241 | + if ($result < 0) |
|
| 242 | + { |
|
| 243 | + $error++; |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + // Delete payments |
|
| 249 | + if (! $error) |
|
| 250 | + { |
|
| 251 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge WHERE fk_charge=".$this->id; |
|
| 252 | + dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
|
| 253 | + $resql=$this->db->query($sql); |
|
| 254 | + if (! $resql) |
|
| 255 | + { |
|
| 256 | + $error++; |
|
| 257 | + $this->error=$this->db->lasterror(); |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + if (! $error) |
|
| 262 | + { |
|
| 263 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales WHERE rowid=".$this->id; |
|
| 264 | + dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
|
| 265 | + $resql=$this->db->query($sql); |
|
| 266 | + if (! $resql) |
|
| 267 | + { |
|
| 268 | + $error++; |
|
| 269 | + $this->error=$this->db->lasterror(); |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + if (! $error) |
|
| 274 | + { |
|
| 275 | + $this->db->commit(); |
|
| 276 | + return 1; |
|
| 277 | + } |
|
| 278 | + else |
|
| 279 | + { |
|
| 280 | + $this->db->rollback(); |
|
| 281 | + return -1; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * Met a jour une charge sociale |
|
| 289 | + * |
|
| 290 | + * @param User $user Utilisateur qui modifie |
|
| 291 | + * @return int <0 si erreur, >0 si ok |
|
| 292 | + */ |
|
| 293 | + function update($user) |
|
| 294 | + { |
|
| 295 | + $this->db->begin(); |
|
| 296 | + |
|
| 297 | + $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; |
|
| 298 | + $sql.= " SET libelle='".$this->db->escape($this->lib)."'"; |
|
| 299 | + $sql.= ", date_ech='".$this->db->idate($this->date_ech)."'"; |
|
| 300 | + $sql.= ", periode='".$this->db->idate($this->periode)."'"; |
|
| 301 | + $sql.= ", amount='".price2num($this->amount,'MT')."'"; |
|
| 302 | 302 | $sql.= ", fk_projet='".$this->db->escape($this->fk_project)."'"; |
| 303 | - $sql.= ", fk_user_modif=".$user->id; |
|
| 304 | - $sql.= " WHERE rowid=".$this->id; |
|
| 305 | - |
|
| 306 | - dol_syslog(get_class($this)."::update", LOG_DEBUG); |
|
| 307 | - $resql=$this->db->query($sql); |
|
| 308 | - if ($resql) |
|
| 309 | - { |
|
| 310 | - $this->db->commit(); |
|
| 311 | - return 1; |
|
| 312 | - } |
|
| 313 | - else |
|
| 314 | - { |
|
| 315 | - $this->error=$this->db->error(); |
|
| 316 | - $this->db->rollback(); |
|
| 317 | - return -1; |
|
| 318 | - } |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * Calculate amount remaining to pay by year |
|
| 323 | - * |
|
| 324 | - * @param int $year Year |
|
| 325 | - * @return number |
|
| 326 | - */ |
|
| 327 | - function solde($year = 0) |
|
| 328 | - { |
|
| 329 | - global $conf; |
|
| 330 | - |
|
| 331 | - $sql = "SELECT SUM(f.amount) as amount"; |
|
| 332 | - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; |
|
| 333 | - $sql.= " WHERE f.entity = ".$conf->entity; |
|
| 334 | - $sql.= " AND paye = 0"; |
|
| 335 | - |
|
| 336 | - if ($year) { |
|
| 337 | - $sql .= " AND f.datev >= '$y-01-01' AND f.datev <= '$y-12-31' "; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - $result = $this->db->query($sql); |
|
| 341 | - if ($result) |
|
| 342 | - { |
|
| 343 | - if ($this->db->num_rows($result)) |
|
| 344 | - { |
|
| 345 | - $obj = $this->db->fetch_object($result); |
|
| 346 | - $this->db->free($result); |
|
| 347 | - return $obj->amount; |
|
| 348 | - } |
|
| 349 | - else |
|
| 350 | - { |
|
| 351 | - return 0; |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - } |
|
| 355 | - else |
|
| 356 | - { |
|
| 357 | - print $this->db->error(); |
|
| 358 | - return -1; |
|
| 359 | - } |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * Tag social contribution as payed completely |
|
| 364 | - * |
|
| 365 | - * @param User $user Object user making change |
|
| 366 | - * @return int <0 if KO, >0 if OK |
|
| 367 | - */ |
|
| 368 | - function set_paid($user) |
|
| 369 | - { |
|
| 370 | - $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; |
|
| 371 | - $sql.= " paye = 1"; |
|
| 372 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 373 | - $return = $this->db->query($sql); |
|
| 374 | - if ($return) return 1; |
|
| 375 | - else return -1; |
|
| 376 | - } |
|
| 377 | - /** |
|
| 378 | - * Remove tag payed on social contribution |
|
| 379 | - * |
|
| 380 | - * @param User $user Object user making change |
|
| 381 | - * @return int <0 if KO, >0 if OK |
|
| 382 | - */ |
|
| 383 | - function set_unpaid($user) |
|
| 384 | - { |
|
| 385 | - $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; |
|
| 386 | - $sql.= " paye = 0"; |
|
| 387 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 388 | - $return = $this->db->query($sql); |
|
| 389 | - if ($return) return 1; |
|
| 390 | - else return -1; |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * Retourne le libelle du statut d'une charge (impaye, payee) |
|
| 395 | - * |
|
| 396 | - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto |
|
| 303 | + $sql.= ", fk_user_modif=".$user->id; |
|
| 304 | + $sql.= " WHERE rowid=".$this->id; |
|
| 305 | + |
|
| 306 | + dol_syslog(get_class($this)."::update", LOG_DEBUG); |
|
| 307 | + $resql=$this->db->query($sql); |
|
| 308 | + if ($resql) |
|
| 309 | + { |
|
| 310 | + $this->db->commit(); |
|
| 311 | + return 1; |
|
| 312 | + } |
|
| 313 | + else |
|
| 314 | + { |
|
| 315 | + $this->error=$this->db->error(); |
|
| 316 | + $this->db->rollback(); |
|
| 317 | + return -1; |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * Calculate amount remaining to pay by year |
|
| 323 | + * |
|
| 324 | + * @param int $year Year |
|
| 325 | + * @return number |
|
| 326 | + */ |
|
| 327 | + function solde($year = 0) |
|
| 328 | + { |
|
| 329 | + global $conf; |
|
| 330 | + |
|
| 331 | + $sql = "SELECT SUM(f.amount) as amount"; |
|
| 332 | + $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; |
|
| 333 | + $sql.= " WHERE f.entity = ".$conf->entity; |
|
| 334 | + $sql.= " AND paye = 0"; |
|
| 335 | + |
|
| 336 | + if ($year) { |
|
| 337 | + $sql .= " AND f.datev >= '$y-01-01' AND f.datev <= '$y-12-31' "; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + $result = $this->db->query($sql); |
|
| 341 | + if ($result) |
|
| 342 | + { |
|
| 343 | + if ($this->db->num_rows($result)) |
|
| 344 | + { |
|
| 345 | + $obj = $this->db->fetch_object($result); |
|
| 346 | + $this->db->free($result); |
|
| 347 | + return $obj->amount; |
|
| 348 | + } |
|
| 349 | + else |
|
| 350 | + { |
|
| 351 | + return 0; |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + } |
|
| 355 | + else |
|
| 356 | + { |
|
| 357 | + print $this->db->error(); |
|
| 358 | + return -1; |
|
| 359 | + } |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * Tag social contribution as payed completely |
|
| 364 | + * |
|
| 365 | + * @param User $user Object user making change |
|
| 366 | + * @return int <0 if KO, >0 if OK |
|
| 367 | + */ |
|
| 368 | + function set_paid($user) |
|
| 369 | + { |
|
| 370 | + $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; |
|
| 371 | + $sql.= " paye = 1"; |
|
| 372 | + $sql.= " WHERE rowid = ".$this->id; |
|
| 373 | + $return = $this->db->query($sql); |
|
| 374 | + if ($return) return 1; |
|
| 375 | + else return -1; |
|
| 376 | + } |
|
| 377 | + /** |
|
| 378 | + * Remove tag payed on social contribution |
|
| 379 | + * |
|
| 380 | + * @param User $user Object user making change |
|
| 381 | + * @return int <0 if KO, >0 if OK |
|
| 382 | + */ |
|
| 383 | + function set_unpaid($user) |
|
| 384 | + { |
|
| 385 | + $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; |
|
| 386 | + $sql.= " paye = 0"; |
|
| 387 | + $sql.= " WHERE rowid = ".$this->id; |
|
| 388 | + $return = $this->db->query($sql); |
|
| 389 | + if ($return) return 1; |
|
| 390 | + else return -1; |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * Retourne le libelle du statut d'une charge (impaye, payee) |
|
| 395 | + * |
|
| 396 | + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto |
|
| 397 | 397 | * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
| 398 | - * @return string Label |
|
| 399 | - */ |
|
| 400 | - function getLibStatut($mode=0,$alreadypaid=-1) |
|
| 401 | - { |
|
| 402 | - return $this->LibStatut($this->paye,$mode,$alreadypaid); |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * Renvoi le libelle d'un statut donne |
|
| 407 | - * |
|
| 408 | - * @param int $statut Id statut |
|
| 409 | - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto |
|
| 398 | + * @return string Label |
|
| 399 | + */ |
|
| 400 | + function getLibStatut($mode=0,$alreadypaid=-1) |
|
| 401 | + { |
|
| 402 | + return $this->LibStatut($this->paye,$mode,$alreadypaid); |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * Renvoi le libelle d'un statut donne |
|
| 407 | + * |
|
| 408 | + * @param int $statut Id statut |
|
| 409 | + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto |
|
| 410 | 410 | * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
| 411 | - * @return string Label |
|
| 412 | - */ |
|
| 413 | - function LibStatut($statut,$mode=0,$alreadypaid=-1) |
|
| 414 | - { |
|
| 415 | - global $langs; |
|
| 416 | - $langs->load('customers'); |
|
| 417 | - $langs->load('bills'); |
|
| 418 | - |
|
| 419 | - if ($mode == 0) |
|
| 420 | - { |
|
| 421 | - if ($statut == 0) return $langs->trans("Unpaid"); |
|
| 422 | - if ($statut == 1) return $langs->trans("Paid"); |
|
| 423 | - } |
|
| 424 | - if ($mode == 1) |
|
| 425 | - { |
|
| 426 | - if ($statut == 0) return $langs->trans("Unpaid"); |
|
| 427 | - if ($statut == 1) return $langs->trans("Paid"); |
|
| 428 | - } |
|
| 429 | - if ($mode == 2) |
|
| 430 | - { |
|
| 431 | - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); |
|
| 432 | - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); |
|
| 433 | - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); |
|
| 434 | - } |
|
| 435 | - if ($mode == 3) |
|
| 436 | - { |
|
| 437 | - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 438 | - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 439 | - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); |
|
| 440 | - } |
|
| 441 | - if ($mode == 4) |
|
| 442 | - { |
|
| 443 | - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); |
|
| 444 | - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); |
|
| 445 | - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); |
|
| 446 | - } |
|
| 447 | - if ($mode == 5) |
|
| 448 | - { |
|
| 449 | - if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 450 | - if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 451 | - if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); |
|
| 452 | - } |
|
| 453 | - if ($mode == 6) |
|
| 454 | - { |
|
| 455 | - if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 456 | - if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 457 | - if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); |
|
| 458 | - } |
|
| 459 | - |
|
| 460 | - return "Error, mode/status not found"; |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - |
|
| 464 | - /** |
|
| 411 | + * @return string Label |
|
| 412 | + */ |
|
| 413 | + function LibStatut($statut,$mode=0,$alreadypaid=-1) |
|
| 414 | + { |
|
| 415 | + global $langs; |
|
| 416 | + $langs->load('customers'); |
|
| 417 | + $langs->load('bills'); |
|
| 418 | + |
|
| 419 | + if ($mode == 0) |
|
| 420 | + { |
|
| 421 | + if ($statut == 0) return $langs->trans("Unpaid"); |
|
| 422 | + if ($statut == 1) return $langs->trans("Paid"); |
|
| 423 | + } |
|
| 424 | + if ($mode == 1) |
|
| 425 | + { |
|
| 426 | + if ($statut == 0) return $langs->trans("Unpaid"); |
|
| 427 | + if ($statut == 1) return $langs->trans("Paid"); |
|
| 428 | + } |
|
| 429 | + if ($mode == 2) |
|
| 430 | + { |
|
| 431 | + if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); |
|
| 432 | + if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); |
|
| 433 | + if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); |
|
| 434 | + } |
|
| 435 | + if ($mode == 3) |
|
| 436 | + { |
|
| 437 | + if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 438 | + if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 439 | + if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); |
|
| 440 | + } |
|
| 441 | + if ($mode == 4) |
|
| 442 | + { |
|
| 443 | + if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); |
|
| 444 | + if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); |
|
| 445 | + if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); |
|
| 446 | + } |
|
| 447 | + if ($mode == 5) |
|
| 448 | + { |
|
| 449 | + if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 450 | + if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 451 | + if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); |
|
| 452 | + } |
|
| 453 | + if ($mode == 6) |
|
| 454 | + { |
|
| 455 | + if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 456 | + if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 457 | + if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); |
|
| 458 | + } |
|
| 459 | + |
|
| 460 | + return "Error, mode/status not found"; |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + |
|
| 464 | + /** |
|
| 465 | 465 | * Return a link to the object card (with optionaly the picto) |
| 466 | 466 | * |
| 467 | 467 | * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) |
| 468 | - * @param int $maxlen Max length of label |
|
| 469 | - * @param int $notooltip 1=Disable tooltip |
|
| 470 | - * @return string String with link |
|
| 471 | - */ |
|
| 472 | - function getNomUrl($withpicto=0, $maxlen=0, $notooltip=0) |
|
| 473 | - { |
|
| 474 | - global $langs; |
|
| 475 | - |
|
| 476 | - $result=''; |
|
| 477 | - |
|
| 478 | - if (empty($this->ref)) $this->ref=$this->lib; |
|
| 479 | - $label = $langs->trans("ShowSocialContribution").': '.$this->ref; |
|
| 480 | - |
|
| 481 | - $linkstart = '<a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; |
|
| 482 | - $linkend='</a>'; |
|
| 483 | - |
|
| 484 | - $result .= $linkstart; |
|
| 485 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
| 486 | - if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->ref,$maxlen):$this->ref); |
|
| 487 | - $result .= $linkend; |
|
| 488 | - |
|
| 489 | - return $result; |
|
| 490 | - } |
|
| 491 | - |
|
| 492 | - /** |
|
| 493 | - * Return amount of payments already done |
|
| 494 | - * |
|
| 495 | - * @return int Amount of payment already done, <0 if KO |
|
| 496 | - */ |
|
| 497 | - function getSommePaiement() |
|
| 498 | - { |
|
| 499 | - $table='paiementcharge'; |
|
| 500 | - $field='fk_charge'; |
|
| 501 | - |
|
| 502 | - $sql = 'SELECT sum(amount) as amount'; |
|
| 503 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table; |
|
| 504 | - $sql.= ' WHERE '.$field.' = '.$this->id; |
|
| 505 | - |
|
| 506 | - dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); |
|
| 507 | - $resql=$this->db->query($sql); |
|
| 508 | - if ($resql) |
|
| 509 | - { |
|
| 510 | - $amount=0; |
|
| 511 | - |
|
| 512 | - $obj = $this->db->fetch_object($resql); |
|
| 513 | - if ($obj) $amount=$obj->amount?$obj->amount:0; |
|
| 514 | - |
|
| 515 | - $this->db->free($resql); |
|
| 516 | - return $amount; |
|
| 517 | - } |
|
| 518 | - else |
|
| 519 | - { |
|
| 520 | - return -1; |
|
| 521 | - } |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - /** |
|
| 525 | - * Charge les informations d'ordre info dans l'objet entrepot |
|
| 526 | - * |
|
| 527 | - * @param int $id Id of social contribution |
|
| 528 | - * @return int <0 if KO, >0 if OK |
|
| 529 | - */ |
|
| 530 | - function info($id) |
|
| 531 | - { |
|
| 532 | - $sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,"; |
|
| 533 | - $sql.= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; |
|
| 468 | + * @param int $maxlen Max length of label |
|
| 469 | + * @param int $notooltip 1=Disable tooltip |
|
| 470 | + * @return string String with link |
|
| 471 | + */ |
|
| 472 | + function getNomUrl($withpicto=0, $maxlen=0, $notooltip=0) |
|
| 473 | + { |
|
| 474 | + global $langs; |
|
| 475 | + |
|
| 476 | + $result=''; |
|
| 477 | + |
|
| 478 | + if (empty($this->ref)) $this->ref=$this->lib; |
|
| 479 | + $label = $langs->trans("ShowSocialContribution").': '.$this->ref; |
|
| 480 | + |
|
| 481 | + $linkstart = '<a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; |
|
| 482 | + $linkend='</a>'; |
|
| 483 | + |
|
| 484 | + $result .= $linkstart; |
|
| 485 | + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
| 486 | + if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->ref,$maxlen):$this->ref); |
|
| 487 | + $result .= $linkend; |
|
| 488 | + |
|
| 489 | + return $result; |
|
| 490 | + } |
|
| 491 | + |
|
| 492 | + /** |
|
| 493 | + * Return amount of payments already done |
|
| 494 | + * |
|
| 495 | + * @return int Amount of payment already done, <0 if KO |
|
| 496 | + */ |
|
| 497 | + function getSommePaiement() |
|
| 498 | + { |
|
| 499 | + $table='paiementcharge'; |
|
| 500 | + $field='fk_charge'; |
|
| 501 | + |
|
| 502 | + $sql = 'SELECT sum(amount) as amount'; |
|
| 503 | + $sql.= ' FROM '.MAIN_DB_PREFIX.$table; |
|
| 504 | + $sql.= ' WHERE '.$field.' = '.$this->id; |
|
| 505 | + |
|
| 506 | + dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); |
|
| 507 | + $resql=$this->db->query($sql); |
|
| 508 | + if ($resql) |
|
| 509 | + { |
|
| 510 | + $amount=0; |
|
| 511 | + |
|
| 512 | + $obj = $this->db->fetch_object($resql); |
|
| 513 | + if ($obj) $amount=$obj->amount?$obj->amount:0; |
|
| 514 | + |
|
| 515 | + $this->db->free($resql); |
|
| 516 | + return $amount; |
|
| 517 | + } |
|
| 518 | + else |
|
| 519 | + { |
|
| 520 | + return -1; |
|
| 521 | + } |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + /** |
|
| 525 | + * Charge les informations d'ordre info dans l'objet entrepot |
|
| 526 | + * |
|
| 527 | + * @param int $id Id of social contribution |
|
| 528 | + * @return int <0 if KO, >0 if OK |
|
| 529 | + */ |
|
| 530 | + function info($id) |
|
| 531 | + { |
|
| 532 | + $sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,"; |
|
| 533 | + $sql.= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; |
|
| 534 | 534 | $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as e"; |
| 535 | - $sql.= " WHERE e.rowid = ".$id; |
|
| 536 | - |
|
| 537 | - dol_syslog(get_class($this)."::info", LOG_DEBUG); |
|
| 538 | - $result=$this->db->query($sql); |
|
| 539 | - if ($result) |
|
| 540 | - { |
|
| 541 | - if ($this->db->num_rows($result)) |
|
| 542 | - { |
|
| 543 | - $obj = $this->db->fetch_object($result); |
|
| 544 | - |
|
| 545 | - $this->id = $obj->rowid; |
|
| 546 | - |
|
| 547 | - if ($obj->fk_user_author) { |
|
| 548 | - $cuser = new User($this->db); |
|
| 549 | - $cuser->fetch($obj->fk_user_author); |
|
| 550 | - $this->user_creation = $cuser; |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - if ($obj->fk_user_modif) { |
|
| 554 | - $muser = new User($this->db); |
|
| 555 | - $muser->fetch($obj->fk_user_modif); |
|
| 556 | - $this->user_modification = $muser; |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - if ($obj->fk_user_valid) { |
|
| 560 | - $vuser = new User($this->db); |
|
| 561 | - $vuser->fetch($obj->fk_user_valid); |
|
| 562 | - $this->user_validation = $vuser; |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - $this->date_creation = $this->db->jdate($obj->datec); |
|
| 566 | - $this->date_modification = $this->db->jdate($obj->datem); |
|
| 567 | - $this->date_validation = $this->db->jdate($obj->datev); |
|
| 568 | - $this->import_key = $obj->import_key; |
|
| 569 | - } |
|
| 570 | - |
|
| 571 | - $this->db->free($result); |
|
| 572 | - |
|
| 573 | - } |
|
| 574 | - else |
|
| 575 | - { |
|
| 576 | - dol_print_error($this->db); |
|
| 577 | - } |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - /** |
|
| 581 | - * Initialise an instance with random values. |
|
| 582 | - * Used to build previews or test instances. |
|
| 583 | - * id must be 0 if object instance is a specimen. |
|
| 584 | - * |
|
| 585 | - * @return void |
|
| 586 | - */ |
|
| 587 | - function initAsSpecimen() |
|
| 588 | - { |
|
| 589 | - // Initialize parameters |
|
| 590 | - $this->id=0; |
|
| 591 | - $this->ref = 'SPECIMEN'; |
|
| 592 | - $this->specimen=1; |
|
| 593 | - $this->paye = 0; |
|
| 594 | - $this->date = time(); |
|
| 595 | - $this->date_ech=$this->date+3600*24*30; |
|
| 596 | - $this->periode=$this->date+3600*24*30; |
|
| 597 | - $this->amount=100; |
|
| 598 | - $this->lib = 0; |
|
| 599 | - $this->type = 1; |
|
| 600 | - $this->type_libelle = 'Social contribution label'; |
|
| 601 | - } |
|
| 535 | + $sql.= " WHERE e.rowid = ".$id; |
|
| 536 | + |
|
| 537 | + dol_syslog(get_class($this)."::info", LOG_DEBUG); |
|
| 538 | + $result=$this->db->query($sql); |
|
| 539 | + if ($result) |
|
| 540 | + { |
|
| 541 | + if ($this->db->num_rows($result)) |
|
| 542 | + { |
|
| 543 | + $obj = $this->db->fetch_object($result); |
|
| 544 | + |
|
| 545 | + $this->id = $obj->rowid; |
|
| 546 | + |
|
| 547 | + if ($obj->fk_user_author) { |
|
| 548 | + $cuser = new User($this->db); |
|
| 549 | + $cuser->fetch($obj->fk_user_author); |
|
| 550 | + $this->user_creation = $cuser; |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + if ($obj->fk_user_modif) { |
|
| 554 | + $muser = new User($this->db); |
|
| 555 | + $muser->fetch($obj->fk_user_modif); |
|
| 556 | + $this->user_modification = $muser; |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + if ($obj->fk_user_valid) { |
|
| 560 | + $vuser = new User($this->db); |
|
| 561 | + $vuser->fetch($obj->fk_user_valid); |
|
| 562 | + $this->user_validation = $vuser; |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + $this->date_creation = $this->db->jdate($obj->datec); |
|
| 566 | + $this->date_modification = $this->db->jdate($obj->datem); |
|
| 567 | + $this->date_validation = $this->db->jdate($obj->datev); |
|
| 568 | + $this->import_key = $obj->import_key; |
|
| 569 | + } |
|
| 570 | + |
|
| 571 | + $this->db->free($result); |
|
| 572 | + |
|
| 573 | + } |
|
| 574 | + else |
|
| 575 | + { |
|
| 576 | + dol_print_error($this->db); |
|
| 577 | + } |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + /** |
|
| 581 | + * Initialise an instance with random values. |
|
| 582 | + * Used to build previews or test instances. |
|
| 583 | + * id must be 0 if object instance is a specimen. |
|
| 584 | + * |
|
| 585 | + * @return void |
|
| 586 | + */ |
|
| 587 | + function initAsSpecimen() |
|
| 588 | + { |
|
| 589 | + // Initialize parameters |
|
| 590 | + $this->id=0; |
|
| 591 | + $this->ref = 'SPECIMEN'; |
|
| 592 | + $this->specimen=1; |
|
| 593 | + $this->paye = 0; |
|
| 594 | + $this->date = time(); |
|
| 595 | + $this->date_ech=$this->date+3600*24*30; |
|
| 596 | + $this->periode=$this->date+3600*24*30; |
|
| 597 | + $this->amount=100; |
|
| 598 | + $this->lib = 0; |
|
| 599 | + $this->type = 1; |
|
| 600 | + $this->type_libelle = 'Social contribution label'; |
|
| 601 | + } |
|
| 602 | 602 | } |
| 603 | 603 | |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | class ChargeSociales extends CommonObject |
| 34 | 34 | { |
| 35 | - public $element='chargesociales'; |
|
| 36 | - public $table='chargesociales'; |
|
| 37 | - public $table_element='chargesociales'; |
|
| 35 | + public $element = 'chargesociales'; |
|
| 36 | + public $table = 'chargesociales'; |
|
| 37 | + public $table_element = 'chargesociales'; |
|
| 38 | 38 | public $picto = 'bill'; |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -74,43 +74,43 @@ discard block |
||
| 74 | 74 | * @param string $ref Ref |
| 75 | 75 | * @return int <0 KO >0 OK |
| 76 | 76 | */ |
| 77 | - function fetch($id, $ref='') |
|
| 77 | + function fetch($id, $ref = '') |
|
| 78 | 78 | { |
| 79 | 79 | $sql = "SELECT cs.rowid, cs.date_ech"; |
| 80 | - $sql.= ", cs.libelle as lib, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; |
|
| 81 | - $sql.= ", cs.fk_account, cs.fk_mode_reglement"; |
|
| 82 | - $sql.= ", c.libelle"; |
|
| 83 | - $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; |
|
| 84 | - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; |
|
| 85 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; |
|
| 86 | - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id AND p.entity IN ('.getEntity('c_paiement').')'; |
|
| 87 | - $sql.= ' WHERE cs.entity IN ('.getEntity('tax').')'; |
|
| 88 | - if ($ref) $sql.= " AND cs.rowid = ".$ref; |
|
| 89 | - else $sql.= " AND cs.rowid = ".$id; |
|
| 80 | + $sql .= ", cs.libelle as lib, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; |
|
| 81 | + $sql .= ", cs.fk_account, cs.fk_mode_reglement"; |
|
| 82 | + $sql .= ", c.libelle"; |
|
| 83 | + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; |
|
| 84 | + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; |
|
| 85 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; |
|
| 86 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id AND p.entity IN ('.getEntity('c_paiement').')'; |
|
| 87 | + $sql .= ' WHERE cs.entity IN ('.getEntity('tax').')'; |
|
| 88 | + if ($ref) $sql .= " AND cs.rowid = ".$ref; |
|
| 89 | + else $sql .= " AND cs.rowid = ".$id; |
|
| 90 | 90 | |
| 91 | 91 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
| 92 | - $resql=$this->db->query($sql); |
|
| 92 | + $resql = $this->db->query($sql); |
|
| 93 | 93 | if ($resql) |
| 94 | 94 | { |
| 95 | 95 | if ($this->db->num_rows($resql)) |
| 96 | 96 | { |
| 97 | 97 | $obj = $this->db->fetch_object($resql); |
| 98 | 98 | |
| 99 | - $this->id = $obj->rowid; |
|
| 99 | + $this->id = $obj->rowid; |
|
| 100 | 100 | $this->ref = $obj->rowid; |
| 101 | - $this->date_ech = $this->db->jdate($obj->date_ech); |
|
| 101 | + $this->date_ech = $this->db->jdate($obj->date_ech); |
|
| 102 | 102 | $this->lib = $obj->lib; |
| 103 | - $this->type = $obj->fk_type; |
|
| 104 | - $this->type_libelle = $obj->libelle; |
|
| 105 | - $this->fk_account = $obj->fk_account; |
|
| 106 | - $this->mode_reglement_id = $obj->fk_mode_reglement; |
|
| 107 | - $this->mode_reglement_code = $obj->mode_reglement_code; |
|
| 108 | - $this->mode_reglement = $obj->mode_reglement_libelle; |
|
| 109 | - $this->amount = $obj->amount; |
|
| 110 | - $this->fk_project = $obj->fk_project; |
|
| 111 | - $this->paye = $obj->paye; |
|
| 112 | - $this->periode = $this->db->jdate($obj->periode); |
|
| 113 | - $this->import_key = $this->import_key; |
|
| 103 | + $this->type = $obj->fk_type; |
|
| 104 | + $this->type_libelle = $obj->libelle; |
|
| 105 | + $this->fk_account = $obj->fk_account; |
|
| 106 | + $this->mode_reglement_id = $obj->fk_mode_reglement; |
|
| 107 | + $this->mode_reglement_code = $obj->mode_reglement_code; |
|
| 108 | + $this->mode_reglement = $obj->mode_reglement_libelle; |
|
| 109 | + $this->amount = $obj->amount; |
|
| 110 | + $this->fk_project = $obj->fk_project; |
|
| 111 | + $this->paye = $obj->paye; |
|
| 112 | + $this->periode = $this->db->jdate($obj->periode); |
|
| 113 | + $this->import_key = $this->import_key; |
|
| 114 | 114 | |
| 115 | 115 | $this->db->free($resql); |
| 116 | 116 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | else |
| 125 | 125 | { |
| 126 | - $this->error=$this->db->lasterror(); |
|
| 126 | + $this->error = $this->db->lasterror(); |
|
| 127 | 127 | return -1; |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | function check() |
| 137 | 137 | { |
| 138 | - $newamount=price2num($this->amount,'MT'); |
|
| 138 | + $newamount = price2num($this->amount, 'MT'); |
|
| 139 | 139 | |
| 140 | 140 | // Validation parametres |
| 141 | - if (! $newamount > 0 || empty($this->date_ech) || empty($this->periode)) |
|
| 141 | + if (!$newamount > 0 || empty($this->date_ech) || empty($this->periode)) |
|
| 142 | 142 | { |
| 143 | 143 | return false; |
| 144 | 144 | } |
@@ -156,57 +156,57 @@ discard block |
||
| 156 | 156 | function create($user) |
| 157 | 157 | { |
| 158 | 158 | global $conf; |
| 159 | - $error=0; |
|
| 159 | + $error = 0; |
|
| 160 | 160 | |
| 161 | - $now=dol_now(); |
|
| 161 | + $now = dol_now(); |
|
| 162 | 162 | |
| 163 | 163 | // Nettoyage parametres |
| 164 | - $newamount=price2num($this->amount,'MT'); |
|
| 164 | + $newamount = price2num($this->amount, 'MT'); |
|
| 165 | 165 | |
| 166 | 166 | if (!$this->check()) |
| 167 | 167 | { |
| 168 | - $this->error="ErrorBadParameter"; |
|
| 168 | + $this->error = "ErrorBadParameter"; |
|
| 169 | 169 | return -2; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $this->db->begin(); |
| 173 | 173 | |
| 174 | 174 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, date_creation)"; |
| 175 | - $sql.= " VALUES (".$this->type; |
|
| 176 | - $sql.= ", ".($this->fk_account>0 ? $this->fk_account:'NULL'); |
|
| 177 | - $sql.= ", ".($this->mode_reglement_id>0 ? $this->mode_reglement_id:"NULL"); |
|
| 178 | - $sql.= ", '".$this->db->escape($this->lib)."'"; |
|
| 179 | - $sql.= ", '".$this->db->idate($this->date_ech)."'"; |
|
| 180 | - $sql.= ", '".$this->db->idate($this->periode)."'"; |
|
| 181 | - $sql.= ", '".price2num($newamount)."'"; |
|
| 182 | - $sql.= ", ".($this->fk_project>0?$this->fk_project:'NULL'); |
|
| 183 | - $sql.= ", ".$conf->entity; |
|
| 184 | - $sql.= ", ".$user->id; |
|
| 185 | - $sql.= ", '".$this->db->idate($now)."'"; |
|
| 186 | - $sql.= ")"; |
|
| 175 | + $sql .= " VALUES (".$this->type; |
|
| 176 | + $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); |
|
| 177 | + $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "NULL"); |
|
| 178 | + $sql .= ", '".$this->db->escape($this->lib)."'"; |
|
| 179 | + $sql .= ", '".$this->db->idate($this->date_ech)."'"; |
|
| 180 | + $sql .= ", '".$this->db->idate($this->periode)."'"; |
|
| 181 | + $sql .= ", '".price2num($newamount)."'"; |
|
| 182 | + $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 'NULL'); |
|
| 183 | + $sql .= ", ".$conf->entity; |
|
| 184 | + $sql .= ", ".$user->id; |
|
| 185 | + $sql .= ", '".$this->db->idate($now)."'"; |
|
| 186 | + $sql .= ")"; |
|
| 187 | 187 | |
| 188 | 188 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
| 189 | - $resql=$this->db->query($sql); |
|
| 189 | + $resql = $this->db->query($sql); |
|
| 190 | 190 | if ($resql) |
| 191 | 191 | { |
| 192 | - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); |
|
| 192 | + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); |
|
| 193 | 193 | |
| 194 | 194 | //dol_syslog("ChargesSociales::create this->id=".$this->id); |
| 195 | - $result=$this->call_trigger('PAYMENTSOCIALCONTRIBUTION_CREATE',$user); |
|
| 195 | + $result = $this->call_trigger('PAYMENTSOCIALCONTRIBUTION_CREATE', $user); |
|
| 196 | 196 | if ($result < 0) $error++; |
| 197 | 197 | |
| 198 | - if(empty($error)) { |
|
| 198 | + if (empty($error)) { |
|
| 199 | 199 | $this->db->commit(); |
| 200 | 200 | return $this->id; |
| 201 | 201 | } |
| 202 | 202 | else { |
| 203 | 203 | $this->db->rollback(); |
| 204 | - return -1*$error; |
|
| 204 | + return -1 * $error; |
|
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | else |
| 208 | 208 | { |
| 209 | - $this->error=$this->db->error(); |
|
| 209 | + $this->error = $this->db->error(); |
|
| 210 | 210 | $this->db->rollback(); |
| 211 | 211 | return -1; |
| 212 | 212 | } |
@@ -221,23 +221,23 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | function delete($user) |
| 223 | 223 | { |
| 224 | - $error=0; |
|
| 224 | + $error = 0; |
|
| 225 | 225 | |
| 226 | 226 | $this->db->begin(); |
| 227 | 227 | |
| 228 | 228 | // Get bank transaction lines for this social contributions |
| 229 | 229 | include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
| 230 | - $account=new Account($this->db); |
|
| 231 | - $lines_url=$account->get_url('',$this->id,'sc'); |
|
| 230 | + $account = new Account($this->db); |
|
| 231 | + $lines_url = $account->get_url('', $this->id, 'sc'); |
|
| 232 | 232 | |
| 233 | 233 | // Delete bank urls |
| 234 | 234 | foreach ($lines_url as $line_url) |
| 235 | 235 | { |
| 236 | - if (! $error) |
|
| 236 | + if (!$error) |
|
| 237 | 237 | { |
| 238 | - $accountline=new AccountLine($this->db); |
|
| 238 | + $accountline = new AccountLine($this->db); |
|
| 239 | 239 | $accountline->fetch($line_url['fk_bank']); |
| 240 | - $result=$accountline->delete_urls($user); |
|
| 240 | + $result = $accountline->delete_urls($user); |
|
| 241 | 241 | if ($result < 0) |
| 242 | 242 | { |
| 243 | 243 | $error++; |
@@ -246,31 +246,31 @@ discard block |
||
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | // Delete payments |
| 249 | - if (! $error) |
|
| 249 | + if (!$error) |
|
| 250 | 250 | { |
| 251 | 251 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge WHERE fk_charge=".$this->id; |
| 252 | 252 | dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
| 253 | - $resql=$this->db->query($sql); |
|
| 254 | - if (! $resql) |
|
| 253 | + $resql = $this->db->query($sql); |
|
| 254 | + if (!$resql) |
|
| 255 | 255 | { |
| 256 | 256 | $error++; |
| 257 | - $this->error=$this->db->lasterror(); |
|
| 257 | + $this->error = $this->db->lasterror(); |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - if (! $error) |
|
| 261 | + if (!$error) |
|
| 262 | 262 | { |
| 263 | 263 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales WHERE rowid=".$this->id; |
| 264 | 264 | dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
| 265 | - $resql=$this->db->query($sql); |
|
| 266 | - if (! $resql) |
|
| 265 | + $resql = $this->db->query($sql); |
|
| 266 | + if (!$resql) |
|
| 267 | 267 | { |
| 268 | 268 | $error++; |
| 269 | - $this->error=$this->db->lasterror(); |
|
| 269 | + $this->error = $this->db->lasterror(); |
|
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if (! $error) |
|
| 273 | + if (!$error) |
|
| 274 | 274 | { |
| 275 | 275 | $this->db->commit(); |
| 276 | 276 | return 1; |
@@ -295,16 +295,16 @@ discard block |
||
| 295 | 295 | $this->db->begin(); |
| 296 | 296 | |
| 297 | 297 | $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; |
| 298 | - $sql.= " SET libelle='".$this->db->escape($this->lib)."'"; |
|
| 299 | - $sql.= ", date_ech='".$this->db->idate($this->date_ech)."'"; |
|
| 300 | - $sql.= ", periode='".$this->db->idate($this->periode)."'"; |
|
| 301 | - $sql.= ", amount='".price2num($this->amount,'MT')."'"; |
|
| 302 | - $sql.= ", fk_projet='".$this->db->escape($this->fk_project)."'"; |
|
| 303 | - $sql.= ", fk_user_modif=".$user->id; |
|
| 304 | - $sql.= " WHERE rowid=".$this->id; |
|
| 298 | + $sql .= " SET libelle='".$this->db->escape($this->lib)."'"; |
|
| 299 | + $sql .= ", date_ech='".$this->db->idate($this->date_ech)."'"; |
|
| 300 | + $sql .= ", periode='".$this->db->idate($this->periode)."'"; |
|
| 301 | + $sql .= ", amount='".price2num($this->amount, 'MT')."'"; |
|
| 302 | + $sql .= ", fk_projet='".$this->db->escape($this->fk_project)."'"; |
|
| 303 | + $sql .= ", fk_user_modif=".$user->id; |
|
| 304 | + $sql .= " WHERE rowid=".$this->id; |
|
| 305 | 305 | |
| 306 | 306 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
| 307 | - $resql=$this->db->query($sql); |
|
| 307 | + $resql = $this->db->query($sql); |
|
| 308 | 308 | if ($resql) |
| 309 | 309 | { |
| 310 | 310 | $this->db->commit(); |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | else |
| 314 | 314 | { |
| 315 | - $this->error=$this->db->error(); |
|
| 315 | + $this->error = $this->db->error(); |
|
| 316 | 316 | $this->db->rollback(); |
| 317 | 317 | return -1; |
| 318 | 318 | } |
@@ -329,9 +329,9 @@ discard block |
||
| 329 | 329 | global $conf; |
| 330 | 330 | |
| 331 | 331 | $sql = "SELECT SUM(f.amount) as amount"; |
| 332 | - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; |
|
| 333 | - $sql.= " WHERE f.entity = ".$conf->entity; |
|
| 334 | - $sql.= " AND paye = 0"; |
|
| 332 | + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; |
|
| 333 | + $sql .= " WHERE f.entity = ".$conf->entity; |
|
| 334 | + $sql .= " AND paye = 0"; |
|
| 335 | 335 | |
| 336 | 336 | if ($year) { |
| 337 | 337 | $sql .= " AND f.datev >= '$y-01-01' AND f.datev <= '$y-12-31' "; |
@@ -368,8 +368,8 @@ discard block |
||
| 368 | 368 | function set_paid($user) |
| 369 | 369 | { |
| 370 | 370 | $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; |
| 371 | - $sql.= " paye = 1"; |
|
| 372 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 371 | + $sql .= " paye = 1"; |
|
| 372 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 373 | 373 | $return = $this->db->query($sql); |
| 374 | 374 | if ($return) return 1; |
| 375 | 375 | else return -1; |
@@ -383,8 +383,8 @@ discard block |
||
| 383 | 383 | function set_unpaid($user) |
| 384 | 384 | { |
| 385 | 385 | $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; |
| 386 | - $sql.= " paye = 0"; |
|
| 387 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 386 | + $sql .= " paye = 0"; |
|
| 387 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 388 | 388 | $return = $this->db->query($sql); |
| 389 | 389 | if ($return) return 1; |
| 390 | 390 | else return -1; |
@@ -397,9 +397,9 @@ discard block |
||
| 397 | 397 | * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
| 398 | 398 | * @return string Label |
| 399 | 399 | */ |
| 400 | - function getLibStatut($mode=0,$alreadypaid=-1) |
|
| 400 | + function getLibStatut($mode = 0, $alreadypaid = -1) |
|
| 401 | 401 | { |
| 402 | - return $this->LibStatut($this->paye,$mode,$alreadypaid); |
|
| 402 | + return $this->LibStatut($this->paye, $mode, $alreadypaid); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | /** |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
| 411 | 411 | * @return string Label |
| 412 | 412 | */ |
| 413 | - function LibStatut($statut,$mode=0,$alreadypaid=-1) |
|
| 413 | + function LibStatut($statut, $mode = 0, $alreadypaid = -1) |
|
| 414 | 414 | { |
| 415 | 415 | global $langs; |
| 416 | 416 | $langs->load('customers'); |
@@ -418,43 +418,43 @@ discard block |
||
| 418 | 418 | |
| 419 | 419 | if ($mode == 0) |
| 420 | 420 | { |
| 421 | - if ($statut == 0) return $langs->trans("Unpaid"); |
|
| 422 | - if ($statut == 1) return $langs->trans("Paid"); |
|
| 421 | + if ($statut == 0) return $langs->trans("Unpaid"); |
|
| 422 | + if ($statut == 1) return $langs->trans("Paid"); |
|
| 423 | 423 | } |
| 424 | 424 | if ($mode == 1) |
| 425 | 425 | { |
| 426 | - if ($statut == 0) return $langs->trans("Unpaid"); |
|
| 427 | - if ($statut == 1) return $langs->trans("Paid"); |
|
| 426 | + if ($statut == 0) return $langs->trans("Unpaid"); |
|
| 427 | + if ($statut == 1) return $langs->trans("Paid"); |
|
| 428 | 428 | } |
| 429 | 429 | if ($mode == 2) |
| 430 | 430 | { |
| 431 | - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); |
|
| 432 | - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); |
|
| 433 | - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); |
|
| 431 | + if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); |
|
| 432 | + if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); |
|
| 433 | + if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); |
|
| 434 | 434 | } |
| 435 | 435 | if ($mode == 3) |
| 436 | 436 | { |
| 437 | - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 438 | - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 439 | - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); |
|
| 437 | + if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 438 | + if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 439 | + if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); |
|
| 440 | 440 | } |
| 441 | 441 | if ($mode == 4) |
| 442 | 442 | { |
| 443 | - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); |
|
| 444 | - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); |
|
| 445 | - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); |
|
| 443 | + if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); |
|
| 444 | + if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); |
|
| 445 | + if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); |
|
| 446 | 446 | } |
| 447 | 447 | if ($mode == 5) |
| 448 | 448 | { |
| 449 | - if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 450 | - if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 451 | - if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); |
|
| 449 | + if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 450 | + if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 451 | + if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); |
|
| 452 | 452 | } |
| 453 | 453 | if ($mode == 6) |
| 454 | 454 | { |
| 455 | - if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 456 | - if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 457 | - if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); |
|
| 455 | + if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 456 | + if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 457 | + if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | return "Error, mode/status not found"; |
@@ -469,21 +469,21 @@ discard block |
||
| 469 | 469 | * @param int $notooltip 1=Disable tooltip |
| 470 | 470 | * @return string String with link |
| 471 | 471 | */ |
| 472 | - function getNomUrl($withpicto=0, $maxlen=0, $notooltip=0) |
|
| 472 | + function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) |
|
| 473 | 473 | { |
| 474 | 474 | global $langs; |
| 475 | 475 | |
| 476 | - $result=''; |
|
| 476 | + $result = ''; |
|
| 477 | 477 | |
| 478 | - if (empty($this->ref)) $this->ref=$this->lib; |
|
| 478 | + if (empty($this->ref)) $this->ref = $this->lib; |
|
| 479 | 479 | $label = $langs->trans("ShowSocialContribution").': '.$this->ref; |
| 480 | 480 | |
| 481 | 481 | $linkstart = '<a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; |
| 482 | - $linkend='</a>'; |
|
| 482 | + $linkend = '</a>'; |
|
| 483 | 483 | |
| 484 | 484 | $result .= $linkstart; |
| 485 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
| 486 | - if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->ref,$maxlen):$this->ref); |
|
| 485 | + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
| 486 | + if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref); |
|
| 487 | 487 | $result .= $linkend; |
| 488 | 488 | |
| 489 | 489 | return $result; |
@@ -496,21 +496,21 @@ discard block |
||
| 496 | 496 | */ |
| 497 | 497 | function getSommePaiement() |
| 498 | 498 | { |
| 499 | - $table='paiementcharge'; |
|
| 500 | - $field='fk_charge'; |
|
| 499 | + $table = 'paiementcharge'; |
|
| 500 | + $field = 'fk_charge'; |
|
| 501 | 501 | |
| 502 | 502 | $sql = 'SELECT sum(amount) as amount'; |
| 503 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table; |
|
| 504 | - $sql.= ' WHERE '.$field.' = '.$this->id; |
|
| 503 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; |
|
| 504 | + $sql .= ' WHERE '.$field.' = '.$this->id; |
|
| 505 | 505 | |
| 506 | 506 | dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); |
| 507 | - $resql=$this->db->query($sql); |
|
| 507 | + $resql = $this->db->query($sql); |
|
| 508 | 508 | if ($resql) |
| 509 | 509 | { |
| 510 | - $amount=0; |
|
| 510 | + $amount = 0; |
|
| 511 | 511 | |
| 512 | 512 | $obj = $this->db->fetch_object($resql); |
| 513 | - if ($obj) $amount=$obj->amount?$obj->amount:0; |
|
| 513 | + if ($obj) $amount = $obj->amount ? $obj->amount : 0; |
|
| 514 | 514 | |
| 515 | 515 | $this->db->free($resql); |
| 516 | 516 | return $amount; |
@@ -530,12 +530,12 @@ discard block |
||
| 530 | 530 | function info($id) |
| 531 | 531 | { |
| 532 | 532 | $sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,"; |
| 533 | - $sql.= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; |
|
| 534 | - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as e"; |
|
| 535 | - $sql.= " WHERE e.rowid = ".$id; |
|
| 533 | + $sql .= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; |
|
| 534 | + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as e"; |
|
| 535 | + $sql .= " WHERE e.rowid = ".$id; |
|
| 536 | 536 | |
| 537 | 537 | dol_syslog(get_class($this)."::info", LOG_DEBUG); |
| 538 | - $result=$this->db->query($sql); |
|
| 538 | + $result = $this->db->query($sql); |
|
| 539 | 539 | if ($result) |
| 540 | 540 | { |
| 541 | 541 | if ($this->db->num_rows($result)) |
@@ -587,14 +587,14 @@ discard block |
||
| 587 | 587 | function initAsSpecimen() |
| 588 | 588 | { |
| 589 | 589 | // Initialize parameters |
| 590 | - $this->id=0; |
|
| 590 | + $this->id = 0; |
|
| 591 | 591 | $this->ref = 'SPECIMEN'; |
| 592 | - $this->specimen=1; |
|
| 592 | + $this->specimen = 1; |
|
| 593 | 593 | $this->paye = 0; |
| 594 | 594 | $this->date = time(); |
| 595 | - $this->date_ech=$this->date+3600*24*30; |
|
| 596 | - $this->periode=$this->date+3600*24*30; |
|
| 597 | - $this->amount=100; |
|
| 595 | + $this->date_ech = $this->date + 3600 * 24 * 30; |
|
| 596 | + $this->periode = $this->date + 3600 * 24 * 30; |
|
| 597 | + $this->amount = 100; |
|
| 598 | 598 | $this->lib = 0; |
| 599 | 599 | $this->type = 1; |
| 600 | 600 | $this->type_libelle = 'Social contribution label'; |
@@ -85,8 +85,11 @@ discard block |
||
| 85 | 85 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; |
| 86 | 86 | $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id AND p.entity IN ('.getEntity('c_paiement').')'; |
| 87 | 87 | $sql.= ' WHERE cs.entity IN ('.getEntity('tax').')'; |
| 88 | - if ($ref) $sql.= " AND cs.rowid = ".$ref; |
|
| 89 | - else $sql.= " AND cs.rowid = ".$id; |
|
| 88 | + if ($ref) { |
|
| 89 | + $sql.= " AND cs.rowid = ".$ref; |
|
| 90 | + } else { |
|
| 91 | + $sql.= " AND cs.rowid = ".$id; |
|
| 92 | + } |
|
| 90 | 93 | |
| 91 | 94 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
| 92 | 95 | $resql=$this->db->query($sql); |
@@ -115,13 +118,11 @@ discard block |
||
| 115 | 118 | $this->db->free($resql); |
| 116 | 119 | |
| 117 | 120 | return 1; |
| 118 | - } |
|
| 119 | - else |
|
| 121 | + } else |
|
| 120 | 122 | { |
| 121 | 123 | return 0; |
| 122 | 124 | } |
| 123 | - } |
|
| 124 | - else |
|
| 125 | + } else |
|
| 125 | 126 | { |
| 126 | 127 | $this->error=$this->db->lasterror(); |
| 127 | 128 | return -1; |
@@ -193,18 +194,18 @@ discard block |
||
| 193 | 194 | |
| 194 | 195 | //dol_syslog("ChargesSociales::create this->id=".$this->id); |
| 195 | 196 | $result=$this->call_trigger('PAYMENTSOCIALCONTRIBUTION_CREATE',$user); |
| 196 | - if ($result < 0) $error++; |
|
| 197 | + if ($result < 0) { |
|
| 198 | + $error++; |
|
| 199 | + } |
|
| 197 | 200 | |
| 198 | 201 | if(empty($error)) { |
| 199 | 202 | $this->db->commit(); |
| 200 | 203 | return $this->id; |
| 201 | - } |
|
| 202 | - else { |
|
| 204 | + } else { |
|
| 203 | 205 | $this->db->rollback(); |
| 204 | 206 | return -1*$error; |
| 205 | 207 | } |
| 206 | - } |
|
| 207 | - else |
|
| 208 | + } else |
|
| 208 | 209 | { |
| 209 | 210 | $this->error=$this->db->error(); |
| 210 | 211 | $this->db->rollback(); |
@@ -274,8 +275,7 @@ discard block |
||
| 274 | 275 | { |
| 275 | 276 | $this->db->commit(); |
| 276 | 277 | return 1; |
| 277 | - } |
|
| 278 | - else |
|
| 278 | + } else |
|
| 279 | 279 | { |
| 280 | 280 | $this->db->rollback(); |
| 281 | 281 | return -1; |
@@ -309,8 +309,7 @@ discard block |
||
| 309 | 309 | { |
| 310 | 310 | $this->db->commit(); |
| 311 | 311 | return 1; |
| 312 | - } |
|
| 313 | - else |
|
| 312 | + } else |
|
| 314 | 313 | { |
| 315 | 314 | $this->error=$this->db->error(); |
| 316 | 315 | $this->db->rollback(); |
@@ -345,14 +344,12 @@ discard block |
||
| 345 | 344 | $obj = $this->db->fetch_object($result); |
| 346 | 345 | $this->db->free($result); |
| 347 | 346 | return $obj->amount; |
| 348 | - } |
|
| 349 | - else |
|
| 347 | + } else |
|
| 350 | 348 | { |
| 351 | 349 | return 0; |
| 352 | 350 | } |
| 353 | 351 | |
| 354 | - } |
|
| 355 | - else |
|
| 352 | + } else |
|
| 356 | 353 | { |
| 357 | 354 | print $this->db->error(); |
| 358 | 355 | return -1; |
@@ -371,8 +368,11 @@ discard block |
||
| 371 | 368 | $sql.= " paye = 1"; |
| 372 | 369 | $sql.= " WHERE rowid = ".$this->id; |
| 373 | 370 | $return = $this->db->query($sql); |
| 374 | - if ($return) return 1; |
|
| 375 | - else return -1; |
|
| 371 | + if ($return) { |
|
| 372 | + return 1; |
|
| 373 | + } else { |
|
| 374 | + return -1; |
|
| 375 | + } |
|
| 376 | 376 | } |
| 377 | 377 | /** |
| 378 | 378 | * Remove tag payed on social contribution |
@@ -386,8 +386,11 @@ discard block |
||
| 386 | 386 | $sql.= " paye = 0"; |
| 387 | 387 | $sql.= " WHERE rowid = ".$this->id; |
| 388 | 388 | $return = $this->db->query($sql); |
| 389 | - if ($return) return 1; |
|
| 390 | - else return -1; |
|
| 389 | + if ($return) { |
|
| 390 | + return 1; |
|
| 391 | + } else { |
|
| 392 | + return -1; |
|
| 393 | + } |
|
| 391 | 394 | } |
| 392 | 395 | |
| 393 | 396 | /** |
@@ -418,43 +421,81 @@ discard block |
||
| 418 | 421 | |
| 419 | 422 | if ($mode == 0) |
| 420 | 423 | { |
| 421 | - if ($statut == 0) return $langs->trans("Unpaid"); |
|
| 422 | - if ($statut == 1) return $langs->trans("Paid"); |
|
| 424 | + if ($statut == 0) { |
|
| 425 | + return $langs->trans("Unpaid"); |
|
| 426 | + } |
|
| 427 | + if ($statut == 1) { |
|
| 428 | + return $langs->trans("Paid"); |
|
| 429 | + } |
|
| 423 | 430 | } |
| 424 | 431 | if ($mode == 1) |
| 425 | 432 | { |
| 426 | - if ($statut == 0) return $langs->trans("Unpaid"); |
|
| 427 | - if ($statut == 1) return $langs->trans("Paid"); |
|
| 433 | + if ($statut == 0) { |
|
| 434 | + return $langs->trans("Unpaid"); |
|
| 435 | + } |
|
| 436 | + if ($statut == 1) { |
|
| 437 | + return $langs->trans("Paid"); |
|
| 438 | + } |
|
| 428 | 439 | } |
| 429 | 440 | if ($mode == 2) |
| 430 | 441 | { |
| 431 | - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); |
|
| 432 | - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); |
|
| 433 | - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); |
|
| 442 | + if ($statut == 0 && $alreadypaid <= 0) { |
|
| 443 | + return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); |
|
| 444 | + } |
|
| 445 | + if ($statut == 0 && $alreadypaid > 0) { |
|
| 446 | + return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); |
|
| 447 | + } |
|
| 448 | + if ($statut == 1) { |
|
| 449 | + return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); |
|
| 450 | + } |
|
| 434 | 451 | } |
| 435 | 452 | if ($mode == 3) |
| 436 | 453 | { |
| 437 | - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 438 | - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 439 | - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); |
|
| 454 | + if ($statut == 0 && $alreadypaid <= 0) { |
|
| 455 | + return img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 456 | + } |
|
| 457 | + if ($statut == 0 && $alreadypaid > 0) { |
|
| 458 | + return img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 459 | + } |
|
| 460 | + if ($statut == 1) { |
|
| 461 | + return img_picto($langs->trans("Paid"), 'statut6'); |
|
| 462 | + } |
|
| 440 | 463 | } |
| 441 | 464 | if ($mode == 4) |
| 442 | 465 | { |
| 443 | - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); |
|
| 444 | - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); |
|
| 445 | - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); |
|
| 466 | + if ($statut == 0 && $alreadypaid <= 0) { |
|
| 467 | + return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); |
|
| 468 | + } |
|
| 469 | + if ($statut == 0 && $alreadypaid > 0) { |
|
| 470 | + return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); |
|
| 471 | + } |
|
| 472 | + if ($statut == 1) { |
|
| 473 | + return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); |
|
| 474 | + } |
|
| 446 | 475 | } |
| 447 | 476 | if ($mode == 5) |
| 448 | 477 | { |
| 449 | - if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 450 | - if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 451 | - if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); |
|
| 478 | + if ($statut == 0 && $alreadypaid <= 0) { |
|
| 479 | + return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 480 | + } |
|
| 481 | + if ($statut == 0 && $alreadypaid > 0) { |
|
| 482 | + return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 483 | + } |
|
| 484 | + if ($statut == 1) { |
|
| 485 | + return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); |
|
| 486 | + } |
|
| 452 | 487 | } |
| 453 | 488 | if ($mode == 6) |
| 454 | 489 | { |
| 455 | - if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 456 | - if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 457 | - if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); |
|
| 490 | + if ($statut == 0 && $alreadypaid <= 0) { |
|
| 491 | + return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); |
|
| 492 | + } |
|
| 493 | + if ($statut == 0 && $alreadypaid > 0) { |
|
| 494 | + return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); |
|
| 495 | + } |
|
| 496 | + if ($statut == 1) { |
|
| 497 | + return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); |
|
| 498 | + } |
|
| 458 | 499 | } |
| 459 | 500 | |
| 460 | 501 | return "Error, mode/status not found"; |
@@ -475,15 +516,21 @@ discard block |
||
| 475 | 516 | |
| 476 | 517 | $result=''; |
| 477 | 518 | |
| 478 | - if (empty($this->ref)) $this->ref=$this->lib; |
|
| 519 | + if (empty($this->ref)) { |
|
| 520 | + $this->ref=$this->lib; |
|
| 521 | + } |
|
| 479 | 522 | $label = $langs->trans("ShowSocialContribution").': '.$this->ref; |
| 480 | 523 | |
| 481 | 524 | $linkstart = '<a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; |
| 482 | 525 | $linkend='</a>'; |
| 483 | 526 | |
| 484 | 527 | $result .= $linkstart; |
| 485 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
| 486 | - if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->ref,$maxlen):$this->ref); |
|
| 528 | + if ($withpicto) { |
|
| 529 | + $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
| 530 | + } |
|
| 531 | + if ($withpicto != 2) { |
|
| 532 | + $result.= ($maxlen?dol_trunc($this->ref,$maxlen):$this->ref); |
|
| 533 | + } |
|
| 487 | 534 | $result .= $linkend; |
| 488 | 535 | |
| 489 | 536 | return $result; |
@@ -510,12 +557,13 @@ discard block |
||
| 510 | 557 | $amount=0; |
| 511 | 558 | |
| 512 | 559 | $obj = $this->db->fetch_object($resql); |
| 513 | - if ($obj) $amount=$obj->amount?$obj->amount:0; |
|
| 560 | + if ($obj) { |
|
| 561 | + $amount=$obj->amount?$obj->amount:0; |
|
| 562 | + } |
|
| 514 | 563 | |
| 515 | 564 | $this->db->free($resql); |
| 516 | 565 | return $amount; |
| 517 | - } |
|
| 518 | - else |
|
| 566 | + } else |
|
| 519 | 567 | { |
| 520 | 568 | return -1; |
| 521 | 569 | } |
@@ -570,8 +618,7 @@ discard block |
||
| 570 | 618 | |
| 571 | 619 | $this->db->free($result); |
| 572 | 620 | |
| 573 | - } |
|
| 574 | - else |
|
| 621 | + } else |
|
| 575 | 622 | { |
| 576 | 623 | dol_print_error($this->db); |
| 577 | 624 | } |