@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | class Facture extends CommonInvoice |
| 50 | 50 | { |
| 51 | - public $element='facture'; |
|
| 52 | - public $table_element='facture'; |
|
| 51 | + public $element = 'facture'; |
|
| 52 | + public $table_element = 'facture'; |
|
| 53 | 53 | public $table_element_line = 'facturedet'; |
| 54 | 54 | public $fk_element = 'fk_facture'; |
| 55 | - public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 56 | - public $picto='bill'; |
|
| 55 | + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 56 | + public $picto = 'bill'; |
|
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * {@inheritdoc} |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | public $author; |
| 66 | 66 | public $fk_user_author; |
| 67 | 67 | public $fk_user_valid; |
| 68 | - public $date; // Date invoice |
|
| 69 | - public $date_creation; // Creation date |
|
| 70 | - public $date_validation; // Validation date |
|
| 68 | + public $date; // Date invoice |
|
| 69 | + public $date_creation; // Creation date |
|
| 70 | + public $date_validation; // Validation date |
|
| 71 | 71 | public $datem; |
| 72 | 72 | public $ref_client; |
| 73 | 73 | public $ref_int; |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | //var $amount; |
| 78 | 78 | public $remise_absolue; |
| 79 | 79 | public $remise_percent; |
| 80 | - public $total_ht=0; |
|
| 81 | - public $total_tva=0; |
|
| 82 | - public $total_localtax1=0; |
|
| 83 | - public $total_localtax2=0; |
|
| 84 | - public $total_ttc=0; |
|
| 80 | + public $total_ht = 0; |
|
| 81 | + public $total_tva = 0; |
|
| 82 | + public $total_localtax1 = 0; |
|
| 83 | + public $total_localtax2 = 0; |
|
| 84 | + public $total_ttc = 0; |
|
| 85 | 85 | public $revenuestamp; |
| 86 | 86 | |
| 87 | 87 | //! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon |
@@ -93,21 +93,21 @@ discard block |
||
| 93 | 93 | public $paye; |
| 94 | 94 | //! id of source invoice if replacement invoice or credit note |
| 95 | 95 | public $fk_facture_source; |
| 96 | - public $linked_objects=array(); |
|
| 96 | + public $linked_objects = array(); |
|
| 97 | 97 | public $date_lim_reglement; |
| 98 | - public $cond_reglement_code; // Code in llx_c_paiement |
|
| 99 | - public $mode_reglement_code; // Code in llx_c_paiement |
|
| 100 | - public $fk_bank; // Field to store bank id to use when payment mode is withdraw |
|
| 98 | + public $cond_reglement_code; // Code in llx_c_paiement |
|
| 99 | + public $mode_reglement_code; // Code in llx_c_paiement |
|
| 100 | + public $fk_bank; // Field to store bank id to use when payment mode is withdraw |
|
| 101 | 101 | /** |
| 102 | 102 | * @deprecated |
| 103 | 103 | */ |
| 104 | - public $products=array(); |
|
| 104 | + public $products = array(); |
|
| 105 | 105 | /** |
| 106 | 106 | * @var FactureLigne[] |
| 107 | 107 | */ |
| 108 | - public $lines=array(); |
|
| 108 | + public $lines = array(); |
|
| 109 | 109 | public $line; |
| 110 | - public $extraparams=array(); |
|
| 110 | + public $extraparams = array(); |
|
| 111 | 111 | public $specimen; |
| 112 | 112 | |
| 113 | 113 | public $fac_rec; |
@@ -138,12 +138,12 @@ discard block |
||
| 138 | 138 | /** |
| 139 | 139 | * @var array Table of previous situations |
| 140 | 140 | */ |
| 141 | - public $tab_previous_situation_invoice=array(); |
|
| 141 | + public $tab_previous_situation_invoice = array(); |
|
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * @var array Table of next situations |
| 145 | 145 | */ |
| 146 | - public $tab_next_situation_invoice=array(); |
|
| 146 | + public $tab_next_situation_invoice = array(); |
|
| 147 | 147 | |
| 148 | 148 | public $oldcopy; |
| 149 | 149 | |
@@ -230,24 +230,24 @@ discard block |
||
| 230 | 230 | * @param int $forceduedate 1=Do not recalculate due date from payment condition but force it with value |
| 231 | 231 | * @return int <0 if KO, >0 if OK |
| 232 | 232 | */ |
| 233 | - function create($user,$notrigger=0,$forceduedate=0) |
|
| 233 | + function create($user, $notrigger = 0, $forceduedate = 0) |
|
| 234 | 234 | { |
| 235 | - global $langs,$conf,$mysoc,$hookmanager; |
|
| 236 | - $error=0; |
|
| 235 | + global $langs, $conf, $mysoc, $hookmanager; |
|
| 236 | + $error = 0; |
|
| 237 | 237 | |
| 238 | 238 | // Clean parameters |
| 239 | 239 | if (empty($this->type)) $this->type = self::TYPE_STANDARD; |
| 240 | - $this->ref_client=trim($this->ref_client); |
|
| 241 | - $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated |
|
| 242 | - $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note_private)); |
|
| 243 | - $this->note_public=trim($this->note_public); |
|
| 244 | - if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; |
|
| 245 | - if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; |
|
| 240 | + $this->ref_client = trim($this->ref_client); |
|
| 241 | + $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated |
|
| 242 | + $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note_private)); |
|
| 243 | + $this->note_public = trim($this->note_public); |
|
| 244 | + if (!$this->cond_reglement_id) $this->cond_reglement_id = 0; |
|
| 245 | + if (!$this->mode_reglement_id) $this->mode_reglement_id = 0; |
|
| 246 | 246 | $this->brouillon = 1; |
| 247 | 247 | if (empty($this->entity)) $this->entity = $conf->entity; |
| 248 | 248 | |
| 249 | 249 | // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) |
| 250 | - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); |
|
| 250 | + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); |
|
| 251 | 251 | else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); |
| 252 | 252 | if (empty($this->fk_multicurrency)) |
| 253 | 253 | { |
@@ -261,20 +261,20 @@ discard block |
||
| 261 | 261 | // Check parameters |
| 262 | 262 | if (empty($this->date) || empty($user->id)) |
| 263 | 263 | { |
| 264 | - $this->error="ErrorBadParameter"; |
|
| 264 | + $this->error = "ErrorBadParameter"; |
|
| 265 | 265 | dol_syslog(get_class($this)."::create Try to create an invoice with an empty parameter (user, date, ...)", LOG_ERR); |
| 266 | 266 | return -3; |
| 267 | 267 | } |
| 268 | 268 | $soc = new Societe($this->db); |
| 269 | - $result=$soc->fetch($this->socid); |
|
| 269 | + $result = $soc->fetch($this->socid); |
|
| 270 | 270 | if ($result < 0) |
| 271 | 271 | { |
| 272 | - $this->error="Failed to fetch company: ".$soc->error; |
|
| 272 | + $this->error = "Failed to fetch company: ".$soc->error; |
|
| 273 | 273 | dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); |
| 274 | 274 | return -2; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - $now=dol_now(); |
|
| 277 | + $now = dol_now(); |
|
| 278 | 278 | |
| 279 | 279 | $this->db->begin(); |
| 280 | 280 | |
@@ -285,18 +285,18 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
| 287 | 287 | $_facrec = new FactureRec($this->db); |
| 288 | - $result=$_facrec->fetch($this->fac_rec); |
|
| 289 | - $result=$_facrec->fetchObjectLinked(); // This load $_facrec->linkedObjectsIds |
|
| 288 | + $result = $_facrec->fetch($this->fac_rec); |
|
| 289 | + $result = $_facrec->fetchObjectLinked(); // This load $_facrec->linkedObjectsIds |
|
| 290 | 290 | |
| 291 | 291 | $originaldatewhen = $_facrec->date_when; |
| 292 | 292 | |
| 293 | - $this->socid = $_facrec->socid; // Invoice created on same thirdparty than template |
|
| 293 | + $this->socid = $_facrec->socid; // Invoice created on same thirdparty than template |
|
| 294 | 294 | $this->entity = $_facrec->entity; // Invoice created in same entity than template |
| 295 | 295 | |
| 296 | 296 | // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI |
| 297 | - $this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project; |
|
| 298 | - $this->note_public = GETPOST('note_public','none') ? GETPOST('note_public','none') : $_facrec->note_public; |
|
| 299 | - $this->note_private = GETPOST('note_private','none') ? GETPOST('note_private','none') : $_facrec->note_private; |
|
| 297 | + $this->fk_project = GETPOST('projectid', 'int') > 0 ? GETPOST('projectid', 'int') : $_facrec->fk_project; |
|
| 298 | + $this->note_public = GETPOST('note_public', 'none') ? GETPOST('note_public', 'none') : $_facrec->note_public; |
|
| 299 | + $this->note_private = GETPOST('note_private', 'none') ? GETPOST('note_private', 'none') : $_facrec->note_private; |
|
| 300 | 300 | $this->modelpdf = GETPOST('model') ? GETPOST('model') : $_facrec->modelpdf; |
| 301 | 301 | $this->cond_reglement_id = GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $_facrec->cond_reglement_id; |
| 302 | 302 | $this->mode_reglement_id = GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id; |
@@ -309,20 +309,20 @@ discard block |
||
| 309 | 309 | // Fields always coming from template |
| 310 | 310 | $this->remise_absolue = $_facrec->remise_absolue; |
| 311 | 311 | $this->remise_percent = $_facrec->remise_percent; |
| 312 | - $this->fk_incoterms = $_facrec->fk_incoterms; |
|
| 313 | - $this->location_incoterms= $_facrec->location_incoterms; |
|
| 312 | + $this->fk_incoterms = $_facrec->fk_incoterms; |
|
| 313 | + $this->location_incoterms = $_facrec->location_incoterms; |
|
| 314 | 314 | |
| 315 | 315 | // Clean parameters |
| 316 | - if (! $this->type) $this->type = self::TYPE_STANDARD; |
|
| 317 | - $this->ref_client=trim($this->ref_client); |
|
| 318 | - $this->note_public=trim($this->note_public); |
|
| 319 | - $this->note_private=trim($this->note_private); |
|
| 320 | - $this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); |
|
| 316 | + if (!$this->type) $this->type = self::TYPE_STANDARD; |
|
| 317 | + $this->ref_client = trim($this->ref_client); |
|
| 318 | + $this->note_public = trim($this->note_public); |
|
| 319 | + $this->note_private = trim($this->note_private); |
|
| 320 | + $this->note_private = dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); |
|
| 321 | 321 | |
| 322 | - $this->array_options=$_facrec->array_options; |
|
| 322 | + $this->array_options = $_facrec->array_options; |
|
| 323 | 323 | |
| 324 | 324 | //if (! $this->remise) $this->remise = 0; |
| 325 | - if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; |
|
| 325 | + if (!$this->mode_reglement_id) $this->mode_reglement_id = 0; |
|
| 326 | 326 | $this->brouillon = 1; |
| 327 | 327 | |
| 328 | 328 | $this->linked_objects = $_facrec->linkedObjectsIds; |
@@ -334,26 +334,26 @@ discard block |
||
| 334 | 334 | { |
| 335 | 335 | dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); |
| 336 | 336 | if (empty($_facrec->date_when)) $_facrec->date_when = $now; |
| 337 | - $next_date = $_facrec->getNextDate(); // Calculate next date |
|
| 337 | + $next_date = $_facrec->getNextDate(); // Calculate next date |
|
| 338 | 338 | $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date', '', $user, ''); |
| 339 | 339 | //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. |
| 340 | - $result = $_facrec->setNextDate($next_date,1); |
|
| 340 | + $result = $_facrec->setNextDate($next_date, 1); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | // Define lang of customer |
| 344 | 344 | $outputlangs = $langs; |
| 345 | - $newlang=''; |
|
| 345 | + $newlang = ''; |
|
| 346 | 346 | |
| 347 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) $newlang=$this->thirdparty->default_lang; // for proposal, order, invoice, ... |
|
| 348 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) $newlang=$this->default_lang; // for thirdparty |
|
| 349 | - if (! empty($newlang)) |
|
| 347 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) $newlang = $this->thirdparty->default_lang; // for proposal, order, invoice, ... |
|
| 348 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) $newlang = $this->default_lang; // for thirdparty |
|
| 349 | + if (!empty($newlang)) |
|
| 350 | 350 | { |
| 351 | - $outputlangs = new Translate("",$conf); |
|
| 351 | + $outputlangs = new Translate("", $conf); |
|
| 352 | 352 | $outputlangs->setDefaultLang($newlang); |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) |
| 356 | - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $this); |
|
| 356 | + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $this); |
|
| 357 | 357 | $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%m'); |
| 358 | 358 | $substitutionarray['__INVOICE_MONTH__'] = dol_print_date($this->date, '%m'); |
| 359 | 359 | $substitutionarray['__INVOICE_NEXT_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%m'); |
@@ -369,105 +369,105 @@ discard block |
||
| 369 | 369 | |
| 370 | 370 | //var_dump($substitutionarray);exit; |
| 371 | 371 | |
| 372 | - $substitutionisok=true; |
|
| 372 | + $substitutionisok = true; |
|
| 373 | 373 | complete_substitutions_array($substitutionarray, $outputlangs); |
| 374 | 374 | |
| 375 | - $this->note_public=make_substitutions($this->note_public,$substitutionarray); |
|
| 376 | - $this->note_private=make_substitutions($this->note_private,$substitutionarray); |
|
| 375 | + $this->note_public = make_substitutions($this->note_public, $substitutionarray); |
|
| 376 | + $this->note_private = make_substitutions($this->note_private, $substitutionarray); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | // Define due date if not already defined |
| 380 | - $datelim=(empty($forceduedate)?$this->calculate_date_lim_reglement():$forceduedate); |
|
| 380 | + $datelim = (empty($forceduedate) ? $this->calculate_date_lim_reglement() : $forceduedate); |
|
| 381 | 381 | |
| 382 | 382 | // Insert into database |
| 383 | 383 | $socid = $this->socid; |
| 384 | 384 | |
| 385 | 385 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture ("; |
| 386 | - $sql.= " facnumber"; |
|
| 387 | - $sql.= ", entity"; |
|
| 388 | - $sql.= ", ref_ext"; |
|
| 389 | - $sql.= ", type"; |
|
| 390 | - $sql.= ", fk_soc"; |
|
| 391 | - $sql.= ", datec"; |
|
| 392 | - $sql.= ", remise_absolue"; |
|
| 393 | - $sql.= ", remise_percent"; |
|
| 394 | - $sql.= ", datef"; |
|
| 395 | - $sql.= ", date_pointoftax"; |
|
| 396 | - $sql.= ", note_private"; |
|
| 397 | - $sql.= ", note_public"; |
|
| 398 | - $sql.= ", ref_client, ref_int"; |
|
| 399 | - $sql.= ", fk_account"; |
|
| 400 | - $sql.= ", fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; |
|
| 401 | - $sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; |
|
| 402 | - $sql.= ", situation_cycle_ref, situation_counter, situation_final"; |
|
| 403 | - $sql.= ", fk_incoterms, location_incoterms"; |
|
| 404 | - $sql.= ", fk_multicurrency"; |
|
| 405 | - $sql.= ", multicurrency_code"; |
|
| 406 | - $sql.= ", multicurrency_tx"; |
|
| 407 | - $sql.= ")"; |
|
| 408 | - $sql.= " VALUES ("; |
|
| 409 | - $sql.= "'(PROV)'"; |
|
| 410 | - $sql.= ", ".$this->entity; |
|
| 411 | - $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null"); |
|
| 412 | - $sql.= ", '".$this->db->escape($this->type)."'"; |
|
| 413 | - $sql.= ", '".$socid."'"; |
|
| 414 | - $sql.= ", '".$this->db->idate($now)."'"; |
|
| 415 | - $sql.= ", ".($this->remise_absolue>0?$this->remise_absolue:'NULL'); |
|
| 416 | - $sql.= ", ".($this->remise_percent>0?$this->remise_percent:'NULL'); |
|
| 417 | - $sql.= ", '".$this->db->idate($this->date)."'"; |
|
| 418 | - $sql.= ", ".(strval($this->date_pointoftax)!='' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null'); |
|
| 419 | - $sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); |
|
| 420 | - $sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); |
|
| 421 | - $sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); |
|
| 422 | - $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); |
|
| 423 | - $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); |
|
| 424 | - $sql.= ", ".($this->fk_fac_rec_source?"'".$this->db->escape($this->fk_fac_rec_source)."'":"null"); |
|
| 425 | - $sql.= ", ".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null"); |
|
| 426 | - $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); |
|
| 427 | - $sql.= ", ".($this->fk_project?$this->fk_project:"null"); |
|
| 428 | - $sql.= ", ".$this->cond_reglement_id; |
|
| 429 | - $sql.= ", ".$this->mode_reglement_id; |
|
| 430 | - $sql.= ", '".$this->db->idate($datelim)."', '".$this->db->escape($this->modelpdf)."'"; |
|
| 431 | - $sql.= ", ".($this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null"); |
|
| 432 | - $sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null"); |
|
| 433 | - $sql.= ", ".($this->situation_final?$this->situation_final:0); |
|
| 434 | - $sql.= ", ".(int) $this->fk_incoterms; |
|
| 435 | - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; |
|
| 436 | - $sql.= ", ".(int) $this->fk_multicurrency; |
|
| 437 | - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; |
|
| 438 | - $sql.= ", ".(double) $this->multicurrency_tx; |
|
| 439 | - $sql.=")"; |
|
| 440 | - |
|
| 441 | - $resql=$this->db->query($sql); |
|
| 386 | + $sql .= " facnumber"; |
|
| 387 | + $sql .= ", entity"; |
|
| 388 | + $sql .= ", ref_ext"; |
|
| 389 | + $sql .= ", type"; |
|
| 390 | + $sql .= ", fk_soc"; |
|
| 391 | + $sql .= ", datec"; |
|
| 392 | + $sql .= ", remise_absolue"; |
|
| 393 | + $sql .= ", remise_percent"; |
|
| 394 | + $sql .= ", datef"; |
|
| 395 | + $sql .= ", date_pointoftax"; |
|
| 396 | + $sql .= ", note_private"; |
|
| 397 | + $sql .= ", note_public"; |
|
| 398 | + $sql .= ", ref_client, ref_int"; |
|
| 399 | + $sql .= ", fk_account"; |
|
| 400 | + $sql .= ", fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; |
|
| 401 | + $sql .= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; |
|
| 402 | + $sql .= ", situation_cycle_ref, situation_counter, situation_final"; |
|
| 403 | + $sql .= ", fk_incoterms, location_incoterms"; |
|
| 404 | + $sql .= ", fk_multicurrency"; |
|
| 405 | + $sql .= ", multicurrency_code"; |
|
| 406 | + $sql .= ", multicurrency_tx"; |
|
| 407 | + $sql .= ")"; |
|
| 408 | + $sql .= " VALUES ("; |
|
| 409 | + $sql .= "'(PROV)'"; |
|
| 410 | + $sql .= ", ".$this->entity; |
|
| 411 | + $sql .= ", ".($this->ref_ext ? "'".$this->db->escape($this->ref_ext)."'" : "null"); |
|
| 412 | + $sql .= ", '".$this->db->escape($this->type)."'"; |
|
| 413 | + $sql .= ", '".$socid."'"; |
|
| 414 | + $sql .= ", '".$this->db->idate($now)."'"; |
|
| 415 | + $sql .= ", ".($this->remise_absolue > 0 ? $this->remise_absolue : 'NULL'); |
|
| 416 | + $sql .= ", ".($this->remise_percent > 0 ? $this->remise_percent : 'NULL'); |
|
| 417 | + $sql .= ", '".$this->db->idate($this->date)."'"; |
|
| 418 | + $sql .= ", ".(strval($this->date_pointoftax) != '' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null'); |
|
| 419 | + $sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); |
|
| 420 | + $sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); |
|
| 421 | + $sql .= ", ".($this->ref_client ? "'".$this->db->escape($this->ref_client)."'" : "null"); |
|
| 422 | + $sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null"); |
|
| 423 | + $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); |
|
| 424 | + $sql .= ", ".($this->fk_fac_rec_source ? "'".$this->db->escape($this->fk_fac_rec_source)."'" : "null"); |
|
| 425 | + $sql .= ", ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'" : "null"); |
|
| 426 | + $sql .= ", ".($user->id > 0 ? "'".$user->id."'" : "null"); |
|
| 427 | + $sql .= ", ".($this->fk_project ? $this->fk_project : "null"); |
|
| 428 | + $sql .= ", ".$this->cond_reglement_id; |
|
| 429 | + $sql .= ", ".$this->mode_reglement_id; |
|
| 430 | + $sql .= ", '".$this->db->idate($datelim)."', '".$this->db->escape($this->modelpdf)."'"; |
|
| 431 | + $sql .= ", ".($this->situation_cycle_ref ? "'".$this->db->escape($this->situation_cycle_ref)."'" : "null"); |
|
| 432 | + $sql .= ", ".($this->situation_counter ? "'".$this->db->escape($this->situation_counter)."'" : "null"); |
|
| 433 | + $sql .= ", ".($this->situation_final ? $this->situation_final : 0); |
|
| 434 | + $sql .= ", ".(int) $this->fk_incoterms; |
|
| 435 | + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; |
|
| 436 | + $sql .= ", ".(int) $this->fk_multicurrency; |
|
| 437 | + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; |
|
| 438 | + $sql .= ", ".(double) $this->multicurrency_tx; |
|
| 439 | + $sql .= ")"; |
|
| 440 | + |
|
| 441 | + $resql = $this->db->query($sql); |
|
| 442 | 442 | if ($resql) |
| 443 | 443 | { |
| 444 | 444 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture'); |
| 445 | 445 | |
| 446 | 446 | // Update ref with new one |
| 447 | - $this->ref='(PROV'.$this->id.')'; |
|
| 447 | + $this->ref = '(PROV'.$this->id.')'; |
|
| 448 | 448 | $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET facnumber='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; |
| 449 | 449 | |
| 450 | - $resql=$this->db->query($sql); |
|
| 451 | - if (! $resql) $error++; |
|
| 450 | + $resql = $this->db->query($sql); |
|
| 451 | + if (!$resql) $error++; |
|
| 452 | 452 | |
| 453 | - if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects |
|
| 453 | + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects |
|
| 454 | 454 | { |
| 455 | - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds |
|
| 455 | + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | // Add object linked |
| 459 | - if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) |
|
| 459 | + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) |
|
| 460 | 460 | { |
| 461 | - foreach($this->linked_objects as $origin => $tmp_origin_id) |
|
| 461 | + foreach ($this->linked_objects as $origin => $tmp_origin_id) |
|
| 462 | 462 | { |
| 463 | 463 | if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) |
| 464 | 464 | { |
| 465 | - foreach($tmp_origin_id as $origin_id) |
|
| 465 | + foreach ($tmp_origin_id as $origin_id) |
|
| 466 | 466 | { |
| 467 | 467 | $ret = $this->add_object_linked($origin, $origin_id); |
| 468 | - if (! $ret) |
|
| 468 | + if (!$ret) |
|
| 469 | 469 | { |
| 470 | - $this->error=$this->db->lasterror(); |
|
| 470 | + $this->error = $this->db->lasterror(); |
|
| 471 | 471 | $error++; |
| 472 | 472 | } |
| 473 | 473 | } |
@@ -476,22 +476,22 @@ discard block |
||
| 476 | 476 | { |
| 477 | 477 | $origin_id = $tmp_origin_id; |
| 478 | 478 | $ret = $this->add_object_linked($origin, $origin_id); |
| 479 | - if (! $ret) |
|
| 479 | + if (!$ret) |
|
| 480 | 480 | { |
| 481 | - $this->error=$this->db->lasterror(); |
|
| 481 | + $this->error = $this->db->lasterror(); |
|
| 482 | 482 | $error++; |
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object |
|
| 488 | + if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object |
|
| 489 | 489 | { |
| 490 | 490 | $originforcontact = $this->origin; |
| 491 | 491 | $originidforcontact = $this->origin_id; |
| 492 | 492 | if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order |
| 493 | 493 | { |
| 494 | - require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; |
|
| 494 | + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; |
|
| 495 | 495 | $exp = new Expedition($this->db); |
| 496 | 496 | $exp->fetch($this->origin_id); |
| 497 | 497 | $exp->fetchObjectLinked(); |
@@ -508,15 +508,15 @@ discard block |
||
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
| 511 | - $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; |
|
| 511 | + $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; |
|
| 512 | 512 | |
| 513 | 513 | $resqlcontact = $this->db->query($sqlcontact); |
| 514 | 514 | if ($resqlcontact) |
| 515 | 515 | { |
| 516 | - while($objcontact = $this->db->fetch_object($resqlcontact)) |
|
| 516 | + while ($objcontact = $this->db->fetch_object($resqlcontact)) |
|
| 517 | 517 | { |
| 518 | 518 | //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; |
| 519 | - $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object |
|
| 519 | + $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object |
|
| 520 | 520 | } |
| 521 | 521 | } |
| 522 | 522 | else dol_print_error($resqlcontact); |
@@ -532,8 +532,8 @@ discard block |
||
| 532 | 532 | dol_syslog("There is ".count($this->lines)." lines that are invoice lines objects"); |
| 533 | 533 | foreach ($this->lines as $i => $val) |
| 534 | 534 | { |
| 535 | - $newinvoiceline=$this->lines[$i]; |
|
| 536 | - $newinvoiceline->fk_facture=$this->id; |
|
| 535 | + $newinvoiceline = $this->lines[$i]; |
|
| 536 | + $newinvoiceline->fk_facture = $this->id; |
|
| 537 | 537 | |
| 538 | 538 | // TODO This seems not used. Here we put origin 'facture' but after, we put an id of object ! |
| 539 | 539 | $newinvoiceline->origin = $this->element; |
@@ -546,8 +546,8 @@ discard block |
||
| 546 | 546 | $fk_parent_line = 0; |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | - $newinvoiceline->fk_parent_line=$fk_parent_line; |
|
| 550 | - $result=$newinvoiceline->insert(); |
|
| 549 | + $newinvoiceline->fk_parent_line = $fk_parent_line; |
|
| 550 | + $result = $newinvoiceline->insert(); |
|
| 551 | 551 | |
| 552 | 552 | // Defined the new fk_parent_line |
| 553 | 553 | if ($result > 0 && $newinvoiceline->product_type == 9) { |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | } |
| 557 | 557 | if ($result < 0) |
| 558 | 558 | { |
| 559 | - $this->error=$newinvoiceline->error; |
|
| 559 | + $this->error = $newinvoiceline->error; |
|
| 560 | 560 | $error++; |
| 561 | 561 | break; |
| 562 | 562 | } |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | |
| 575 | 575 | // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array |
| 576 | 576 | //if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object. |
| 577 | - if (! is_object($line)) $line = (object) $line; |
|
| 577 | + if (!is_object($line)) $line = (object) $line; |
|
| 578 | 578 | |
| 579 | 579 | if ($result >= 0) |
| 580 | 580 | { |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | |
| 586 | 586 | // Complete vat rate with code |
| 587 | 587 | $vatrate = $line->tva_tx; |
| 588 | - if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; |
|
| 588 | + if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; |
|
| 589 | 589 | |
| 590 | 590 | $result = $this->addline( |
| 591 | 591 | $line->desc, |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | ); |
| 621 | 621 | if ($result < 0) |
| 622 | 622 | { |
| 623 | - $this->error=$this->db->lasterror(); |
|
| 623 | + $this->error = $this->db->lasterror(); |
|
| 624 | 624 | dol_print_error($this->db); |
| 625 | 625 | $this->db->rollback(); |
| 626 | 626 | return -1; |
@@ -637,20 +637,20 @@ discard block |
||
| 637 | 637 | /* |
| 638 | 638 | * Insert lines of predefined invoices |
| 639 | 639 | */ |
| 640 | - if (! $error && $this->fac_rec > 0) |
|
| 640 | + if (!$error && $this->fac_rec > 0) |
|
| 641 | 641 | { |
| 642 | 642 | foreach ($_facrec->lines as $i => $val) |
| 643 | 643 | { |
| 644 | 644 | if ($_facrec->lines[$i]->fk_product) |
| 645 | 645 | { |
| 646 | 646 | $prod = new Product($this->db); |
| 647 | - $res=$prod->fetch($_facrec->lines[$i]->fk_product); |
|
| 647 | + $res = $prod->fetch($_facrec->lines[$i]->fk_product); |
|
| 648 | 648 | } |
| 649 | - $tva_tx = get_default_tva($mysoc,$soc,$prod->id); |
|
| 650 | - $tva_npr = get_default_npr($mysoc,$soc,$prod->id); |
|
| 651 | - if (empty($tva_tx)) $tva_npr=0; |
|
| 652 | - $localtax1_tx=get_localtax($tva_tx,1,$soc,$mysoc,$tva_npr); |
|
| 653 | - $localtax2_tx=get_localtax($tva_tx,2,$soc,$mysoc,$tva_npr); |
|
| 649 | + $tva_tx = get_default_tva($mysoc, $soc, $prod->id); |
|
| 650 | + $tva_npr = get_default_npr($mysoc, $soc, $prod->id); |
|
| 651 | + if (empty($tva_tx)) $tva_npr = 0; |
|
| 652 | + $localtax1_tx = get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr); |
|
| 653 | + $localtax2_tx = get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr); |
|
| 654 | 654 | |
| 655 | 655 | $result_insert = $this->addline( |
| 656 | 656 | $_facrec->lines[$i]->desc, |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | $localtax2_tx, |
| 662 | 662 | $_facrec->lines[$i]->fk_product, |
| 663 | 663 | $_facrec->lines[$i]->remise_percent, |
| 664 | - '','',0,$tva_npr,'','HT',0, |
|
| 664 | + '', '', 0, $tva_npr, '', 'HT', 0, |
|
| 665 | 665 | $_facrec->lines[$i]->product_type, |
| 666 | 666 | $_facrec->lines[$i]->rang, |
| 667 | 667 | $_facrec->lines[$i]->special_code, |
@@ -671,29 +671,29 @@ discard block |
||
| 671 | 671 | null, |
| 672 | 672 | 0, |
| 673 | 673 | $_facrec->lines[$i]->label, |
| 674 | - empty($_facrec->lines[$i]->array_options)?null:$_facrec->lines[$i]->array_options, |
|
| 674 | + empty($_facrec->lines[$i]->array_options) ?null:$_facrec->lines[$i]->array_options, |
|
| 675 | 675 | $_facrec->lines[$i]->situation_percent, |
| 676 | 676 | '', |
| 677 | 677 | $_facrec->lines[$i]->fk_unit, |
| 678 | 678 | $_facrec->lines[$i]->pu_ht_devise |
| 679 | 679 | ); |
| 680 | 680 | |
| 681 | - if ( $result_insert < 0) |
|
| 681 | + if ($result_insert < 0) |
|
| 682 | 682 | { |
| 683 | 683 | $error++; |
| 684 | - $this->error=$this->db->error(); |
|
| 684 | + $this->error = $this->db->error(); |
|
| 685 | 685 | break; |
| 686 | 686 | } |
| 687 | 687 | } |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | - if (! $error) |
|
| 690 | + if (!$error) |
|
| 691 | 691 | { |
| 692 | 692 | |
| 693 | - $result=$this->update_price(1); |
|
| 693 | + $result = $this->update_price(1); |
|
| 694 | 694 | if ($result > 0) |
| 695 | 695 | { |
| 696 | - $action='create'; |
|
| 696 | + $action = 'create'; |
|
| 697 | 697 | |
| 698 | 698 | // Actions on extra fields (by external module or standard code) |
| 699 | 699 | // TODO le hook fait double emploi avec le trigger !! |
@@ -705,9 +705,9 @@ discard block |
||
| 705 | 705 | { |
| 706 | 706 | if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
| 707 | 707 | {*/ |
| 708 | - if (! $error) |
|
| 708 | + if (!$error) |
|
| 709 | 709 | { |
| 710 | - $result=$this->insertExtraFields(); |
|
| 710 | + $result = $this->insertExtraFields(); |
|
| 711 | 711 | if ($result < 0) $error++; |
| 712 | 712 | } |
| 713 | 713 | /*} |
@@ -715,11 +715,11 @@ discard block |
||
| 715 | 715 | else if ($reshook < 0) $error++;*/ |
| 716 | 716 | |
| 717 | 717 | // Call trigger |
| 718 | - $result=$this->call_trigger('BILL_CREATE',$user); |
|
| 718 | + $result = $this->call_trigger('BILL_CREATE', $user); |
|
| 719 | 719 | if ($result < 0) $error++; |
| 720 | 720 | // End call triggers |
| 721 | 721 | |
| 722 | - if (! $error) |
|
| 722 | + if (!$error) |
|
| 723 | 723 | { |
| 724 | 724 | $this->db->commit(); |
| 725 | 725 | return $this->id; |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | } |
| 733 | 733 | else |
| 734 | 734 | { |
| 735 | - $this->error=$langs->trans('FailedToUpdatePrice'); |
|
| 735 | + $this->error = $langs->trans('FailedToUpdatePrice'); |
|
| 736 | 736 | $this->db->rollback(); |
| 737 | 737 | return -3; |
| 738 | 738 | } |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | } |
| 747 | 747 | else |
| 748 | 748 | { |
| 749 | - $this->error=$this->db->error(); |
|
| 749 | + $this->error = $this->db->error(); |
|
| 750 | 750 | $this->db->rollback(); |
| 751 | 751 | return -1; |
| 752 | 752 | } |
@@ -760,20 +760,20 @@ discard block |
||
| 760 | 760 | * @param int $invertdetail Reverse sign of amounts for lines |
| 761 | 761 | * @return int <0 if KO, >0 if OK |
| 762 | 762 | */ |
| 763 | - function createFromCurrent(User $user, $invertdetail=0) |
|
| 763 | + function createFromCurrent(User $user, $invertdetail = 0) |
|
| 764 | 764 | { |
| 765 | 765 | global $conf; |
| 766 | 766 | |
| 767 | 767 | // Charge facture source |
| 768 | - $facture=new Facture($this->db); |
|
| 768 | + $facture = new Facture($this->db); |
|
| 769 | 769 | |
| 770 | 770 | $this->fetch_optionals(); |
| 771 | - if(!empty($this->array_options)){ |
|
| 771 | + if (!empty($this->array_options)) { |
|
| 772 | 772 | $facture->array_options = $this->array_options; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | - foreach($this->lines as &$line){ |
|
| 776 | - $line->fetch_optionals();//fetch extrafields |
|
| 775 | + foreach ($this->lines as &$line) { |
|
| 776 | + $line->fetch_optionals(); //fetch extrafields |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | $facture->fk_facture_source = $this->fk_facture_source; |
@@ -794,14 +794,14 @@ discard block |
||
| 794 | 794 | $facture->origin = $this->origin; |
| 795 | 795 | $facture->origin_id = $this->origin_id; |
| 796 | 796 | |
| 797 | - $facture->lines = $this->lines; // Tableau des lignes de factures |
|
| 798 | - $facture->products = $this->lines; // Tant que products encore utilise |
|
| 797 | + $facture->lines = $this->lines; // Tableau des lignes de factures |
|
| 798 | + $facture->products = $this->lines; // Tant que products encore utilise |
|
| 799 | 799 | $facture->situation_counter = $this->situation_counter; |
| 800 | - $facture->situation_cycle_ref=$this->situation_cycle_ref; |
|
| 801 | - $facture->situation_final = $this->situation_final; |
|
| 800 | + $facture->situation_cycle_ref = $this->situation_cycle_ref; |
|
| 801 | + $facture->situation_final = $this->situation_final; |
|
| 802 | 802 | |
| 803 | 803 | // Loop on each line of new invoice |
| 804 | - foreach($facture->lines as $i => $tmpline) |
|
| 804 | + foreach ($facture->lines as $i => $tmpline) |
|
| 805 | 805 | { |
| 806 | 806 | $facture->lines[$i]->fk_prev_id = $this->lines[$i]->rowid; |
| 807 | 807 | if ($invertdetail) |
@@ -820,8 +820,8 @@ discard block |
||
| 820 | 820 | $facid = $facture->create($user); |
| 821 | 821 | if ($facid <= 0) |
| 822 | 822 | { |
| 823 | - $this->error=$facture->error; |
|
| 824 | - $this->errors=$facture->errors; |
|
| 823 | + $this->error = $facture->error; |
|
| 824 | + $this->errors = $facture->errors; |
|
| 825 | 825 | } |
| 826 | 826 | elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) |
| 827 | 827 | { |
@@ -848,18 +848,18 @@ discard block |
||
| 848 | 848 | * @param int $socid Id of thirdparty |
| 849 | 849 | * @return int New id of clone |
| 850 | 850 | */ |
| 851 | - function createFromClone($socid=0) |
|
| 851 | + function createFromClone($socid = 0) |
|
| 852 | 852 | { |
| 853 | - global $user,$hookmanager; |
|
| 853 | + global $user, $hookmanager; |
|
| 854 | 854 | |
| 855 | - $error=0; |
|
| 855 | + $error = 0; |
|
| 856 | 856 | |
| 857 | 857 | $this->context['createfromclone'] = 'createfromclone'; |
| 858 | 858 | |
| 859 | 859 | $this->db->begin(); |
| 860 | 860 | |
| 861 | 861 | // get extrafields so they will be clone |
| 862 | - foreach($this->lines as $line) |
|
| 862 | + foreach ($this->lines as $line) |
|
| 863 | 863 | $line->fetch_optionals($line->rowid); |
| 864 | 864 | |
| 865 | 865 | // Load source object |
@@ -868,27 +868,27 @@ discard block |
||
| 868 | 868 | |
| 869 | 869 | |
| 870 | 870 | // Change socid if needed |
| 871 | - if (! empty($socid) && $socid != $this->socid) |
|
| 871 | + if (!empty($socid) && $socid != $this->socid) |
|
| 872 | 872 | { |
| 873 | 873 | $objsoc = new Societe($this->db); |
| 874 | 874 | |
| 875 | - if ($objsoc->fetch($socid)>0) |
|
| 875 | + if ($objsoc->fetch($socid) > 0) |
|
| 876 | 876 | { |
| 877 | - $this->socid = $objsoc->id; |
|
| 878 | - $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); |
|
| 879 | - $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); |
|
| 880 | - $this->fk_project = ''; |
|
| 881 | - $this->fk_delivery_address = ''; |
|
| 877 | + $this->socid = $objsoc->id; |
|
| 878 | + $this->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); |
|
| 879 | + $this->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); |
|
| 880 | + $this->fk_project = ''; |
|
| 881 | + $this->fk_delivery_address = ''; |
|
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | // TODO Change product price if multi-prices |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - $this->id=0; |
|
| 888 | - $this->statut= self::STATUS_DRAFT; |
|
| 887 | + $this->id = 0; |
|
| 888 | + $this->statut = self::STATUS_DRAFT; |
|
| 889 | 889 | |
| 890 | 890 | // Clear fields |
| 891 | - $this->date = dol_now(); // Date of invoice is set to current date when cloning. // TODO Best is to ask date into confirm box |
|
| 891 | + $this->date = dol_now(); // Date of invoice is set to current date when cloning. // TODO Best is to ask date into confirm box |
|
| 892 | 892 | $this->user_author = $user->id; |
| 893 | 893 | $this->user_valid = ''; |
| 894 | 894 | $this->fk_facture_source = 0; |
@@ -897,20 +897,20 @@ discard block |
||
| 897 | 897 | $this->ref_client = ''; |
| 898 | 898 | $this->close_code = ''; |
| 899 | 899 | $this->close_note = ''; |
| 900 | - $this->products = $this->lines; // Tant que products encore utilise |
|
| 900 | + $this->products = $this->lines; // Tant que products encore utilise |
|
| 901 | 901 | |
| 902 | 902 | // Loop on each line of new invoice |
| 903 | - foreach($this->lines as $i => $line) |
|
| 903 | + foreach ($this->lines as $i => $line) |
|
| 904 | 904 | { |
| 905 | 905 | if (($this->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts |
| 906 | 906 | { |
| 907 | 907 | unset($this->lines[$i]); |
| 908 | - unset($this->products[$i]); // Tant que products encore utilise |
|
| 908 | + unset($this->products[$i]); // Tant que products encore utilise |
|
| 909 | 909 | } |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | // Create clone |
| 913 | - $result=$this->create($user); |
|
| 913 | + $result = $this->create($user); |
|
| 914 | 914 | if ($result < 0) $error++; |
| 915 | 915 | else { |
| 916 | 916 | // copy internal contacts |
@@ -925,19 +925,19 @@ discard block |
||
| 925 | 925 | } |
| 926 | 926 | } |
| 927 | 927 | |
| 928 | - if (! $error) |
|
| 928 | + if (!$error) |
|
| 929 | 929 | { |
| 930 | 930 | // Hook of thirdparty module |
| 931 | 931 | if (is_object($hookmanager)) |
| 932 | 932 | { |
| 933 | - $parameters=array('objFrom'=>$objFrom); |
|
| 934 | - $action=''; |
|
| 935 | - $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
| 933 | + $parameters = array('objFrom'=>$objFrom); |
|
| 934 | + $action = ''; |
|
| 935 | + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 936 | 936 | if ($reshook < 0) $error++; |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | // Call trigger |
| 940 | - $result=$this->call_trigger('BILL_CLONE',$user); |
|
| 940 | + $result = $this->call_trigger('BILL_CLONE', $user); |
|
| 941 | 941 | if ($result < 0) $error++; |
| 942 | 942 | // End call triggers |
| 943 | 943 | } |
@@ -945,7 +945,7 @@ discard block |
||
| 945 | 945 | unset($this->context['createfromclone']); |
| 946 | 946 | |
| 947 | 947 | // End |
| 948 | - if (! $error) |
|
| 948 | + if (!$error) |
|
| 949 | 949 | { |
| 950 | 950 | $this->db->commit(); |
| 951 | 951 | return $this->id; |
@@ -968,18 +968,18 @@ discard block |
||
| 968 | 968 | { |
| 969 | 969 | global $hookmanager; |
| 970 | 970 | |
| 971 | - $error=0; |
|
| 971 | + $error = 0; |
|
| 972 | 972 | |
| 973 | 973 | // Closed order |
| 974 | 974 | $this->date = dol_now(); |
| 975 | 975 | $this->source = 0; |
| 976 | 976 | |
| 977 | - $num=count($object->lines); |
|
| 977 | + $num = count($object->lines); |
|
| 978 | 978 | for ($i = 0; $i < $num; $i++) |
| 979 | 979 | { |
| 980 | 980 | $line = new FactureLigne($this->db); |
| 981 | 981 | |
| 982 | - $line->libelle = $object->lines[$i]->libelle; |
|
| 982 | + $line->libelle = $object->lines[$i]->libelle; |
|
| 983 | 983 | $line->label = $object->lines[$i]->label; |
| 984 | 984 | $line->desc = $object->lines[$i]->desc; |
| 985 | 985 | $line->subprice = $object->lines[$i]->subprice; |
@@ -988,30 +988,30 @@ discard block |
||
| 988 | 988 | $line->total_localtax1 = $object->lines[$i]->total_localtax1; |
| 989 | 989 | $line->total_localtax2 = $object->lines[$i]->total_localtax2; |
| 990 | 990 | $line->total_ttc = $object->lines[$i]->total_ttc; |
| 991 | - $line->vat_src_code = $object->lines[$i]->vat_src_code; |
|
| 992 | - $line->tva_tx = $object->lines[$i]->tva_tx; |
|
| 991 | + $line->vat_src_code = $object->lines[$i]->vat_src_code; |
|
| 992 | + $line->tva_tx = $object->lines[$i]->tva_tx; |
|
| 993 | 993 | $line->localtax1_tx = $object->lines[$i]->localtax1_tx; |
| 994 | 994 | $line->localtax2_tx = $object->lines[$i]->localtax2_tx; |
| 995 | - $line->qty = $object->lines[$i]->qty; |
|
| 996 | - $line->fk_remise_except = $object->lines[$i]->fk_remise_except; |
|
| 997 | - $line->remise_percent = $object->lines[$i]->remise_percent; |
|
| 998 | - $line->fk_product = $object->lines[$i]->fk_product; |
|
| 999 | - $line->info_bits = $object->lines[$i]->info_bits; |
|
| 995 | + $line->qty = $object->lines[$i]->qty; |
|
| 996 | + $line->fk_remise_except = $object->lines[$i]->fk_remise_except; |
|
| 997 | + $line->remise_percent = $object->lines[$i]->remise_percent; |
|
| 998 | + $line->fk_product = $object->lines[$i]->fk_product; |
|
| 999 | + $line->info_bits = $object->lines[$i]->info_bits; |
|
| 1000 | 1000 | $line->product_type = $object->lines[$i]->product_type; |
| 1001 | - $line->rang = $object->lines[$i]->rang; |
|
| 1001 | + $line->rang = $object->lines[$i]->rang; |
|
| 1002 | 1002 | $line->special_code = $object->lines[$i]->special_code; |
| 1003 | - $line->fk_parent_line = $object->lines[$i]->fk_parent_line; |
|
| 1004 | - $line->fk_unit = $object->lines[$i]->fk_unit; |
|
| 1005 | - $line->date_start = $object->lines[$i]->date_start; |
|
| 1006 | - $line->date_end = $object->lines[$i]->date_end; |
|
| 1003 | + $line->fk_parent_line = $object->lines[$i]->fk_parent_line; |
|
| 1004 | + $line->fk_unit = $object->lines[$i]->fk_unit; |
|
| 1005 | + $line->date_start = $object->lines[$i]->date_start; |
|
| 1006 | + $line->date_end = $object->lines[$i]->date_end; |
|
| 1007 | 1007 | |
| 1008 | - $line->fk_fournprice = $object->lines[$i]->fk_fournprice; |
|
| 1008 | + $line->fk_fournprice = $object->lines[$i]->fk_fournprice; |
|
| 1009 | 1009 | $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); |
| 1010 | 1010 | $line->pa_ht = $marginInfos[0]; |
| 1011 | 1011 | |
| 1012 | 1012 | // get extrafields from original line |
| 1013 | 1013 | $object->lines[$i]->fetch_optionals($object->lines[$i]->rowid); |
| 1014 | - foreach($object->lines[$i]->array_options as $options_key => $value) |
|
| 1014 | + foreach ($object->lines[$i]->array_options as $options_key => $value) |
|
| 1015 | 1015 | $line->array_options[$options_key] = $value; |
| 1016 | 1016 | |
| 1017 | 1017 | $this->lines[$i] = $line; |
@@ -1030,17 +1030,17 @@ discard block |
||
| 1030 | 1030 | $this->note_private = $object->note_private; |
| 1031 | 1031 | $this->note_public = $object->note_public; |
| 1032 | 1032 | |
| 1033 | - $this->origin = $object->element; |
|
| 1034 | - $this->origin_id = $object->id; |
|
| 1033 | + $this->origin = $object->element; |
|
| 1034 | + $this->origin_id = $object->id; |
|
| 1035 | 1035 | |
| 1036 | 1036 | // get extrafields from original line |
| 1037 | 1037 | $object->fetch_optionals($object->id); |
| 1038 | - foreach($object->array_options as $options_key => $value) |
|
| 1038 | + foreach ($object->array_options as $options_key => $value) |
|
| 1039 | 1039 | $this->array_options[$options_key] = $value; |
| 1040 | 1040 | |
| 1041 | 1041 | // Possibility to add external linked objects with hooks |
| 1042 | 1042 | $this->linked_objects[$this->origin] = $this->origin_id; |
| 1043 | - if (! empty($object->other_linked_objects) && is_array($object->other_linked_objects)) |
|
| 1043 | + if (!empty($object->other_linked_objects) && is_array($object->other_linked_objects)) |
|
| 1044 | 1044 | { |
| 1045 | 1045 | $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); |
| 1046 | 1046 | } |
@@ -1052,12 +1052,12 @@ discard block |
||
| 1052 | 1052 | // Actions hooked (by external module) |
| 1053 | 1053 | $hookmanager->initHooks(array('invoicedao')); |
| 1054 | 1054 | |
| 1055 | - $parameters=array('objFrom'=>$object); |
|
| 1056 | - $action=''; |
|
| 1057 | - $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
| 1055 | + $parameters = array('objFrom'=>$object); |
|
| 1056 | + $action = ''; |
|
| 1057 | + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 1058 | 1058 | if ($reshook < 0) $error++; |
| 1059 | 1059 | |
| 1060 | - if (! $error) |
|
| 1060 | + if (!$error) |
|
| 1061 | 1061 | { |
| 1062 | 1062 | return 1; |
| 1063 | 1063 | } |
@@ -1072,21 +1072,21 @@ discard block |
||
| 1072 | 1072 | * @param int $withpicto Add download picto into link |
| 1073 | 1073 | * @return string HTML link to file |
| 1074 | 1074 | */ |
| 1075 | - function getDirectExternalLink($withpicto=0) |
|
| 1075 | + function getDirectExternalLink($withpicto = 0) |
|
| 1076 | 1076 | { |
| 1077 | 1077 | global $dolibarr_main_url_root; |
| 1078 | 1078 | |
| 1079 | 1079 | // Define $urlwithroot |
| 1080 | - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
| 1081 | - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
| 1080 | + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); |
|
| 1081 | + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
| 1082 | 1082 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
| 1083 | 1083 | |
| 1084 | 1084 | // TODO Read into ecmfile table to get entry and hash exists (PS: If not found, add it) |
| 1085 | 1085 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
| 1086 | - $ecmfile=new EcmFiles($this->db); |
|
| 1086 | + $ecmfile = new EcmFiles($this->db); |
|
| 1087 | 1087 | //$result = $ecmfile->get(); |
| 1088 | 1088 | |
| 1089 | - $hashp='todo'; |
|
| 1089 | + $hashp = 'todo'; |
|
| 1090 | 1090 | return '<a href="'.$urlwithroot.'/document.php?modulepart=invoice&hashp='.$hashp.'" target="_download" rel="noindex, nofollow">'.$this->ref.'</a>'; |
| 1091 | 1091 | } |
| 1092 | 1092 | |
@@ -1103,13 +1103,13 @@ discard block |
||
| 1103 | 1103 | * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
| 1104 | 1104 | * @return string String with URL |
| 1105 | 1105 | */ |
| 1106 | - function getNomUrl($withpicto=0, $option='', $max=0, $short=0, $moretitle='', $notooltip=0, $addlinktonotes=0, $save_lastsearch_value=-1) |
|
| 1106 | + function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1) |
|
| 1107 | 1107 | { |
| 1108 | 1108 | global $langs, $conf, $user, $form; |
| 1109 | 1109 | |
| 1110 | - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
| 1110 | + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips |
|
| 1111 | 1111 | |
| 1112 | - $result=''; |
|
| 1112 | + $result = ''; |
|
| 1113 | 1113 | |
| 1114 | 1114 | if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id; |
| 1115 | 1115 | else $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id; |
@@ -1119,72 +1119,72 @@ discard block |
||
| 1119 | 1119 | if ($option !== 'nolink') |
| 1120 | 1120 | { |
| 1121 | 1121 | // Add param to save lastsearch_values or not |
| 1122 | - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
| 1123 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 1124 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 1122 | + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
|
| 1123 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; |
|
| 1124 | + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; |
|
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | - $picto='bill'; |
|
| 1128 | - if ($this->type == self::TYPE_REPLACEMENT) $picto.='r'; // Replacement invoice |
|
| 1129 | - if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note |
|
| 1130 | - if ($this->type == self::TYPE_DEPOSIT) $picto.='d'; // Deposit invoice |
|
| 1131 | - $label=''; |
|
| 1127 | + $picto = 'bill'; |
|
| 1128 | + if ($this->type == self::TYPE_REPLACEMENT) $picto .= 'r'; // Replacement invoice |
|
| 1129 | + if ($this->type == self::TYPE_CREDIT_NOTE) $picto .= 'a'; // Credit note |
|
| 1130 | + if ($this->type == self::TYPE_DEPOSIT) $picto .= 'd'; // Deposit invoice |
|
| 1131 | + $label = ''; |
|
| 1132 | 1132 | |
| 1133 | 1133 | if ($user->rights->facture->lire) { |
| 1134 | - $label = '<u>' . $langs->trans("ShowInvoice") . '</u>'; |
|
| 1135 | - if (! empty($this->ref)) |
|
| 1136 | - $label .= '<br><b>'.$langs->trans('Ref') . ':</b> ' . $this->ref; |
|
| 1137 | - if (! empty($this->ref_client)) |
|
| 1138 | - $label .= '<br><b>' . $langs->trans('RefCustomer') . ':</b> ' . $this->ref_client; |
|
| 1139 | - if (! empty($this->total_ht)) |
|
| 1140 | - $label.= '<br><b>' . $langs->trans('AmountHT') . ':</b> ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1141 | - if (! empty($this->total_tva)) |
|
| 1142 | - $label.= '<br><b>' . $langs->trans('VAT') . ':</b> ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1143 | - if (! empty($this->total_tva)) |
|
| 1144 | - $label.= '<br><b>' . $langs->trans('LT1') . ':</b> ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1145 | - if (! empty($this->total_tva)) |
|
| 1146 | - $label.= '<br><b>' . $langs->trans('LT2') . ':</b> ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1147 | - if (! empty($this->total_ttc)) |
|
| 1148 | - $label.= '<br><b>' . $langs->trans('AmountTTC') . ':</b> ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1149 | - if ($this->type == self::TYPE_REPLACEMENT) $label=$langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref; |
|
| 1150 | - if ($this->type == self::TYPE_CREDIT_NOTE) $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref; |
|
| 1151 | - if ($this->type == self::TYPE_DEPOSIT) $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref; |
|
| 1152 | - if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref; |
|
| 1153 | - if ($moretitle) $label.=' - '.$moretitle; |
|
| 1134 | + $label = '<u>'.$langs->trans("ShowInvoice").'</u>'; |
|
| 1135 | + if (!empty($this->ref)) |
|
| 1136 | + $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref; |
|
| 1137 | + if (!empty($this->ref_client)) |
|
| 1138 | + $label .= '<br><b>'.$langs->trans('RefCustomer').':</b> '.$this->ref_client; |
|
| 1139 | + if (!empty($this->total_ht)) |
|
| 1140 | + $label .= '<br><b>'.$langs->trans('AmountHT').':</b> '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1141 | + if (!empty($this->total_tva)) |
|
| 1142 | + $label .= '<br><b>'.$langs->trans('VAT').':</b> '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1143 | + if (!empty($this->total_tva)) |
|
| 1144 | + $label .= '<br><b>'.$langs->trans('LT1').':</b> '.price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1145 | + if (!empty($this->total_tva)) |
|
| 1146 | + $label .= '<br><b>'.$langs->trans('LT2').':</b> '.price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1147 | + if (!empty($this->total_ttc)) |
|
| 1148 | + $label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1149 | + if ($this->type == self::TYPE_REPLACEMENT) $label = $langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref; |
|
| 1150 | + if ($this->type == self::TYPE_CREDIT_NOTE) $label = $langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref; |
|
| 1151 | + if ($this->type == self::TYPE_DEPOSIT) $label = $langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref; |
|
| 1152 | + if ($this->type == self::TYPE_SITUATION) $label = $langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref; |
|
| 1153 | + if ($moretitle) $label .= ' - '.$moretitle; |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | - $linkclose=''; |
|
| 1156 | + $linkclose = ''; |
|
| 1157 | 1157 | if (empty($notooltip) && $user->rights->facture->lire) |
| 1158 | 1158 | { |
| 1159 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 1159 | + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 1160 | 1160 | { |
| 1161 | - $label=$langs->trans("ShowInvoice"); |
|
| 1162 | - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1161 | + $label = $langs->trans("ShowInvoice"); |
|
| 1162 | + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1163 | 1163 | } |
| 1164 | - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1165 | - $linkclose.=' class="classfortooltip"'; |
|
| 1164 | + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1165 | + $linkclose .= ' class="classfortooltip"'; |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | - $linkstart='<a href="'.$url.'"'; |
|
| 1169 | - $linkstart.=$linkclose.'>'; |
|
| 1170 | - $linkend='</a>'; |
|
| 1168 | + $linkstart = '<a href="'.$url.'"'; |
|
| 1169 | + $linkstart .= $linkclose.'>'; |
|
| 1170 | + $linkend = '</a>'; |
|
| 1171 | 1171 | |
| 1172 | 1172 | $result .= $linkstart; |
| 1173 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
| 1174 | - if ($withpicto != 2) $result.= ($max?dol_trunc($this->ref,$max):$this->ref); |
|
| 1173 | + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
| 1174 | + if ($withpicto != 2) $result .= ($max ?dol_trunc($this->ref, $max) : $this->ref); |
|
| 1175 | 1175 | $result .= $linkend; |
| 1176 | 1176 | |
| 1177 | 1177 | if ($addlinktonotes) |
| 1178 | 1178 | { |
| 1179 | - $txttoshow=($user->societe_id>0?$this->note_public:$this->note_private); |
|
| 1179 | + $txttoshow = ($user->societe_id > 0 ? $this->note_public : $this->note_private); |
|
| 1180 | 1180 | if ($txttoshow) |
| 1181 | 1181 | { |
| 1182 | - $notetoshow=$langs->trans("ViewPrivateNote").':<br>'.dol_string_nohtmltag($txttoshow,1); |
|
| 1183 | - $result.=' <span class="note inline-block">'; |
|
| 1184 | - $result.='<a href="'.DOL_URL_ROOT.'/compta/facture/note.php?id='.$this->id.'" class="classfortooltip" title="'.dol_escape_htmltag($notetoshow).'">'.img_picto('','object_generic').'</a>'; |
|
| 1182 | + $notetoshow = $langs->trans("ViewPrivateNote").':<br>'.dol_string_nohtmltag($txttoshow, 1); |
|
| 1183 | + $result .= ' <span class="note inline-block">'; |
|
| 1184 | + $result .= '<a href="'.DOL_URL_ROOT.'/compta/facture/note.php?id='.$this->id.'" class="classfortooltip" title="'.dol_escape_htmltag($notetoshow).'">'.img_picto('', 'object_generic').'</a>'; |
|
| 1185 | 1185 | //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); |
| 1186 | 1186 | //$result.='</a>'; |
| 1187 | - $result.='</span>'; |
|
| 1187 | + $result .= '</span>'; |
|
| 1188 | 1188 | } |
| 1189 | 1189 | } |
| 1190 | 1190 | |
@@ -1201,39 +1201,39 @@ discard block |
||
| 1201 | 1201 | * @param bool $fetch_situation Fetch the previous and next situation in $tab_previous_situation_invoice and $tab_next_situation_invoice |
| 1202 | 1202 | * @return int >0 if OK, <0 if KO, 0 if not found |
| 1203 | 1203 | */ |
| 1204 | - function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $fetch_situation=false) |
|
| 1204 | + function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $fetch_situation = false) |
|
| 1205 | 1205 | { |
| 1206 | 1206 | global $conf; |
| 1207 | 1207 | |
| 1208 | 1208 | if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; |
| 1209 | 1209 | |
| 1210 | 1210 | $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; |
| 1211 | - $sql.= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; |
|
| 1212 | - $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; |
|
| 1213 | - $sql.= ', f.datef as df, f.date_pointoftax'; |
|
| 1214 | - $sql.= ', f.date_lim_reglement as dlr'; |
|
| 1215 | - $sql.= ', f.datec as datec'; |
|
| 1216 | - $sql.= ', f.date_valid as datev'; |
|
| 1217 | - $sql.= ', f.tms as datem'; |
|
| 1218 | - $sql.= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf, f.last_main_doc'; |
|
| 1219 | - $sql.= ', f.fk_facture_source'; |
|
| 1220 | - $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams'; |
|
| 1221 | - $sql.= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; |
|
| 1222 | - $sql.= ', f.fk_account'; |
|
| 1223 | - $sql.= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; |
|
| 1224 | - $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; |
|
| 1225 | - $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; |
|
| 1226 | - $sql.= ', f.fk_incoterms, f.location_incoterms'; |
|
| 1227 | - $sql.= ", i.libelle as libelle_incoterms"; |
|
| 1228 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; |
|
| 1229 | - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid AND c.entity IN (' . getEntity('c_payment_term').')'; |
|
| 1230 | - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id AND p.entity IN ('.getEntity('c_paiement').')'; |
|
| 1231 | - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; |
|
| 1232 | - $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; |
|
| 1233 | - if ($rowid) $sql.= " AND f.rowid=".$rowid; |
|
| 1234 | - if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'"; |
|
| 1235 | - if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; |
|
| 1236 | - if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; |
|
| 1211 | + $sql .= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; |
|
| 1212 | + $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; |
|
| 1213 | + $sql .= ', f.datef as df, f.date_pointoftax'; |
|
| 1214 | + $sql .= ', f.date_lim_reglement as dlr'; |
|
| 1215 | + $sql .= ', f.datec as datec'; |
|
| 1216 | + $sql .= ', f.date_valid as datev'; |
|
| 1217 | + $sql .= ', f.tms as datem'; |
|
| 1218 | + $sql .= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf, f.last_main_doc'; |
|
| 1219 | + $sql .= ', f.fk_facture_source'; |
|
| 1220 | + $sql .= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams'; |
|
| 1221 | + $sql .= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; |
|
| 1222 | + $sql .= ', f.fk_account'; |
|
| 1223 | + $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; |
|
| 1224 | + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; |
|
| 1225 | + $sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; |
|
| 1226 | + $sql .= ', f.fk_incoterms, f.location_incoterms'; |
|
| 1227 | + $sql .= ", i.libelle as libelle_incoterms"; |
|
| 1228 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f'; |
|
| 1229 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid AND c.entity IN ('.getEntity('c_payment_term').')'; |
|
| 1230 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id AND p.entity IN ('.getEntity('c_paiement').')'; |
|
| 1231 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; |
|
| 1232 | + $sql .= ' WHERE f.entity IN ('.getEntity('facture').')'; |
|
| 1233 | + if ($rowid) $sql .= " AND f.rowid=".$rowid; |
|
| 1234 | + if ($ref) $sql .= " AND f.facnumber='".$this->db->escape($ref)."'"; |
|
| 1235 | + if ($ref_ext) $sql .= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; |
|
| 1236 | + if ($ref_int) $sql .= " AND f.ref_int='".$this->db->escape($ref_int)."'"; |
|
| 1237 | 1237 | |
| 1238 | 1238 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
| 1239 | 1239 | $result = $this->db->query($sql); |
@@ -1243,17 +1243,17 @@ discard block |
||
| 1243 | 1243 | { |
| 1244 | 1244 | $obj = $this->db->fetch_object($result); |
| 1245 | 1245 | |
| 1246 | - $this->id = $obj->rowid; |
|
| 1247 | - $this->ref = $obj->facnumber; |
|
| 1248 | - $this->ref_client = $obj->ref_client; |
|
| 1246 | + $this->id = $obj->rowid; |
|
| 1247 | + $this->ref = $obj->facnumber; |
|
| 1248 | + $this->ref_client = $obj->ref_client; |
|
| 1249 | 1249 | $this->ref_ext = $obj->ref_ext; |
| 1250 | 1250 | $this->ref_int = $obj->ref_int; |
| 1251 | 1251 | $this->type = $obj->type; |
| 1252 | 1252 | $this->date = $this->db->jdate($obj->df); |
| 1253 | 1253 | $this->date_pointoftax = $this->db->jdate($obj->date_pointoftax); |
| 1254 | - $this->date_creation = $this->db->jdate($obj->datec); |
|
| 1254 | + $this->date_creation = $this->db->jdate($obj->datec); |
|
| 1255 | 1255 | $this->date_validation = $this->db->jdate($obj->datev); |
| 1256 | - $this->datem = $this->db->jdate($obj->datem); |
|
| 1256 | + $this->datem = $this->db->jdate($obj->datem); |
|
| 1257 | 1257 | $this->remise_percent = $obj->remise_percent; |
| 1258 | 1258 | $this->remise_absolue = $obj->remise_absolue; |
| 1259 | 1259 | $this->total_ht = $obj->total; |
@@ -1261,34 +1261,34 @@ discard block |
||
| 1261 | 1261 | $this->total_localtax1 = $obj->localtax1; |
| 1262 | 1262 | $this->total_localtax2 = $obj->localtax2; |
| 1263 | 1263 | $this->total_ttc = $obj->total_ttc; |
| 1264 | - $this->revenuestamp = $obj->revenuestamp; |
|
| 1264 | + $this->revenuestamp = $obj->revenuestamp; |
|
| 1265 | 1265 | $this->paye = $obj->paye; |
| 1266 | 1266 | $this->close_code = $obj->close_code; |
| 1267 | 1267 | $this->close_note = $obj->close_note; |
| 1268 | 1268 | $this->socid = $obj->fk_soc; |
| 1269 | - $this->statut = $obj->fk_statut; |
|
| 1270 | - $this->date_lim_reglement = $this->db->jdate($obj->dlr); |
|
| 1269 | + $this->statut = $obj->fk_statut; |
|
| 1270 | + $this->date_lim_reglement = $this->db->jdate($obj->dlr); |
|
| 1271 | 1271 | $this->mode_reglement_id = $obj->fk_mode_reglement; |
| 1272 | 1272 | $this->mode_reglement_code = $obj->mode_reglement_code; |
| 1273 | 1273 | $this->mode_reglement = $obj->mode_reglement_libelle; |
| 1274 | 1274 | $this->cond_reglement_id = $obj->fk_cond_reglement; |
| 1275 | 1275 | $this->cond_reglement_code = $obj->cond_reglement_code; |
| 1276 | 1276 | $this->cond_reglement = $obj->cond_reglement_libelle; |
| 1277 | - $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; |
|
| 1278 | - $this->fk_account = ($obj->fk_account>0)?$obj->fk_account:null; |
|
| 1279 | - $this->fk_project = $obj->fk_projet; |
|
| 1280 | - $this->fk_facture_source = $obj->fk_facture_source; |
|
| 1281 | - $this->note = $obj->note_private; // deprecated |
|
| 1282 | - $this->note_private = $obj->note_private; |
|
| 1277 | + $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; |
|
| 1278 | + $this->fk_account = ($obj->fk_account > 0) ? $obj->fk_account : null; |
|
| 1279 | + $this->fk_project = $obj->fk_projet; |
|
| 1280 | + $this->fk_facture_source = $obj->fk_facture_source; |
|
| 1281 | + $this->note = $obj->note_private; // deprecated |
|
| 1282 | + $this->note_private = $obj->note_private; |
|
| 1283 | 1283 | $this->note_public = $obj->note_public; |
| 1284 | 1284 | $this->user_author = $obj->fk_user_author; |
| 1285 | - $this->user_valid = $obj->fk_user_valid; |
|
| 1286 | - $this->modelpdf = $obj->model_pdf; |
|
| 1287 | - $this->last_main_doc = $obj->last_main_doc; |
|
| 1285 | + $this->user_valid = $obj->fk_user_valid; |
|
| 1286 | + $this->modelpdf = $obj->model_pdf; |
|
| 1287 | + $this->last_main_doc = $obj->last_main_doc; |
|
| 1288 | 1288 | $this->situation_cycle_ref = $obj->situation_cycle_ref; |
| 1289 | 1289 | $this->situation_counter = $obj->situation_counter; |
| 1290 | 1290 | $this->situation_final = $obj->situation_final; |
| 1291 | - $this->extraparams = (array) json_decode($obj->extraparams, true); |
|
| 1291 | + $this->extraparams = (array) json_decode($obj->extraparams, true); |
|
| 1292 | 1292 | |
| 1293 | 1293 | //Incoterms |
| 1294 | 1294 | $this->fk_incoterms = $obj->fk_incoterms; |
@@ -1297,9 +1297,9 @@ discard block |
||
| 1297 | 1297 | |
| 1298 | 1298 | // Multicurrency |
| 1299 | 1299 | $this->fk_multicurrency = $obj->fk_multicurrency; |
| 1300 | - $this->multicurrency_code = $obj->multicurrency_code; |
|
| 1300 | + $this->multicurrency_code = $obj->multicurrency_code; |
|
| 1301 | 1301 | $this->multicurrency_tx = $obj->multicurrency_tx; |
| 1302 | - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; |
|
| 1302 | + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; |
|
| 1303 | 1303 | $this->multicurrency_total_tva = $obj->multicurrency_total_tva; |
| 1304 | 1304 | $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; |
| 1305 | 1305 | |
@@ -1313,34 +1313,34 @@ discard block |
||
| 1313 | 1313 | // Retrieve all extrafield for invoice |
| 1314 | 1314 | // fetch optionals attributes and labels |
| 1315 | 1315 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
| 1316 | - $extrafields=new ExtraFields($this->db); |
|
| 1317 | - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); |
|
| 1318 | - $this->fetch_optionals($this->id,$extralabels); |
|
| 1316 | + $extrafields = new ExtraFields($this->db); |
|
| 1317 | + $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); |
|
| 1318 | + $this->fetch_optionals($this->id, $extralabels); |
|
| 1319 | 1319 | |
| 1320 | 1320 | /* |
| 1321 | 1321 | * Lines |
| 1322 | 1322 | */ |
| 1323 | 1323 | |
| 1324 | - $this->lines = array(); |
|
| 1324 | + $this->lines = array(); |
|
| 1325 | 1325 | |
| 1326 | - $result=$this->fetch_lines(); |
|
| 1326 | + $result = $this->fetch_lines(); |
|
| 1327 | 1327 | if ($result < 0) |
| 1328 | 1328 | { |
| 1329 | - $this->error=$this->db->error(); |
|
| 1329 | + $this->error = $this->db->error(); |
|
| 1330 | 1330 | return -3; |
| 1331 | 1331 | } |
| 1332 | 1332 | return 1; |
| 1333 | 1333 | } |
| 1334 | 1334 | else |
| 1335 | 1335 | { |
| 1336 | - $this->error='Bill with id '.$rowid.' or ref '.$ref.' not found'; |
|
| 1336 | + $this->error = 'Bill with id '.$rowid.' or ref '.$ref.' not found'; |
|
| 1337 | 1337 | dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); |
| 1338 | 1338 | return 0; |
| 1339 | 1339 | } |
| 1340 | 1340 | } |
| 1341 | 1341 | else |
| 1342 | 1342 | { |
| 1343 | - $this->error=$this->db->error(); |
|
| 1343 | + $this->error = $this->db->error(); |
|
| 1344 | 1344 | return -1; |
| 1345 | 1345 | } |
| 1346 | 1346 | } |
@@ -1353,21 +1353,21 @@ discard block |
||
| 1353 | 1353 | */ |
| 1354 | 1354 | function fetch_lines() |
| 1355 | 1355 | { |
| 1356 | - $this->lines=array(); |
|
| 1356 | + $this->lines = array(); |
|
| 1357 | 1357 | |
| 1358 | 1358 | $sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; |
| 1359 | - $sql.= ' l.situation_percent, l.fk_prev_id,'; |
|
| 1360 | - $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; |
|
| 1361 | - $sql.= ' l.rang, l.special_code,'; |
|
| 1362 | - $sql.= ' l.date_start as date_start, l.date_end as date_end,'; |
|
| 1363 | - $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; |
|
| 1364 | - $sql.= ' l.fk_unit,'; |
|
| 1365 | - $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; |
|
| 1366 | - $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; |
|
| 1367 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; |
|
| 1368 | - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; |
|
| 1369 | - $sql.= ' WHERE l.fk_facture = '.$this->id; |
|
| 1370 | - $sql.= ' ORDER BY l.rang, l.rowid'; |
|
| 1359 | + $sql .= ' l.situation_percent, l.fk_prev_id,'; |
|
| 1360 | + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; |
|
| 1361 | + $sql .= ' l.rang, l.special_code,'; |
|
| 1362 | + $sql .= ' l.date_start as date_start, l.date_end as date_end,'; |
|
| 1363 | + $sql .= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; |
|
| 1364 | + $sql .= ' l.fk_unit,'; |
|
| 1365 | + $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; |
|
| 1366 | + $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; |
|
| 1367 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; |
|
| 1368 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; |
|
| 1369 | + $sql .= ' WHERE l.fk_facture = '.$this->id; |
|
| 1370 | + $sql .= ' ORDER BY l.rang, l.rowid'; |
|
| 1371 | 1371 | |
| 1372 | 1372 | dol_syslog(get_class($this).'::fetch_lines', LOG_DEBUG); |
| 1373 | 1373 | $result = $this->db->query($sql); |
@@ -1381,22 +1381,22 @@ discard block |
||
| 1381 | 1381 | $line = new FactureLigne($this->db); |
| 1382 | 1382 | |
| 1383 | 1383 | $line->id = $objp->rowid; |
| 1384 | - $line->rowid = $objp->rowid; // deprecated |
|
| 1384 | + $line->rowid = $objp->rowid; // deprecated |
|
| 1385 | 1385 | $line->fk_facture = $objp->fk_facture; |
| 1386 | - $line->label = $objp->custom_label; // deprecated |
|
| 1387 | - $line->desc = $objp->description; // Description line |
|
| 1388 | - $line->description = $objp->description; // Description line |
|
| 1389 | - $line->product_type = $objp->product_type; // Type of line |
|
| 1390 | - $line->ref = $objp->product_ref; // Ref product |
|
| 1391 | - $line->product_ref = $objp->product_ref; // Ref product |
|
| 1392 | - $line->libelle = $objp->product_label; // TODO deprecated |
|
| 1393 | - $line->product_label = $objp->product_label; // Label product |
|
| 1394 | - $line->product_desc = $objp->product_desc; // Description product |
|
| 1395 | - $line->fk_product_type = $objp->fk_product_type; // Type of product |
|
| 1386 | + $line->label = $objp->custom_label; // deprecated |
|
| 1387 | + $line->desc = $objp->description; // Description line |
|
| 1388 | + $line->description = $objp->description; // Description line |
|
| 1389 | + $line->product_type = $objp->product_type; // Type of line |
|
| 1390 | + $line->ref = $objp->product_ref; // Ref product |
|
| 1391 | + $line->product_ref = $objp->product_ref; // Ref product |
|
| 1392 | + $line->libelle = $objp->product_label; // TODO deprecated |
|
| 1393 | + $line->product_label = $objp->product_label; // Label product |
|
| 1394 | + $line->product_desc = $objp->product_desc; // Description product |
|
| 1395 | + $line->fk_product_type = $objp->fk_product_type; // Type of product |
|
| 1396 | 1396 | $line->qty = $objp->qty; |
| 1397 | 1397 | $line->subprice = $objp->subprice; |
| 1398 | 1398 | |
| 1399 | - $line->vat_src_code = $objp->vat_src_code; |
|
| 1399 | + $line->vat_src_code = $objp->vat_src_code; |
|
| 1400 | 1400 | $line->tva_tx = $objp->tva_tx; |
| 1401 | 1401 | $line->localtax1_tx = $objp->localtax1_tx; |
| 1402 | 1402 | $line->localtax2_tx = $objp->localtax2_tx; |
@@ -1416,21 +1416,21 @@ discard block |
||
| 1416 | 1416 | $line->total_localtax2 = $objp->total_localtax2; |
| 1417 | 1417 | $line->total_ttc = $objp->total_ttc; |
| 1418 | 1418 | $line->code_ventilation = $objp->fk_code_ventilation; |
| 1419 | - $line->fk_fournprice = $objp->fk_fournprice; |
|
| 1420 | - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); |
|
| 1421 | - $line->pa_ht = $marginInfos[0]; |
|
| 1419 | + $line->fk_fournprice = $objp->fk_fournprice; |
|
| 1420 | + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); |
|
| 1421 | + $line->pa_ht = $marginInfos[0]; |
|
| 1422 | 1422 | $line->marge_tx = $marginInfos[1]; |
| 1423 | 1423 | $line->marque_tx = $marginInfos[2]; |
| 1424 | - $line->rang = $objp->rang; |
|
| 1425 | - $line->special_code = $objp->special_code; |
|
| 1426 | - $line->fk_parent_line = $objp->fk_parent_line; |
|
| 1427 | - $line->situation_percent= $objp->situation_percent; |
|
| 1424 | + $line->rang = $objp->rang; |
|
| 1425 | + $line->special_code = $objp->special_code; |
|
| 1426 | + $line->fk_parent_line = $objp->fk_parent_line; |
|
| 1427 | + $line->situation_percent = $objp->situation_percent; |
|
| 1428 | 1428 | $line->fk_prev_id = $objp->fk_prev_id; |
| 1429 | - $line->fk_unit = $objp->fk_unit; |
|
| 1429 | + $line->fk_unit = $objp->fk_unit; |
|
| 1430 | 1430 | |
| 1431 | 1431 | // Multicurrency |
| 1432 | - $line->fk_multicurrency = $objp->fk_multicurrency; |
|
| 1433 | - $line->multicurrency_code = $objp->multicurrency_code; |
|
| 1432 | + $line->fk_multicurrency = $objp->fk_multicurrency; |
|
| 1433 | + $line->multicurrency_code = $objp->multicurrency_code; |
|
| 1434 | 1434 | $line->multicurrency_subprice = $objp->multicurrency_subprice; |
| 1435 | 1435 | $line->multicurrency_total_ht = $objp->multicurrency_total_ht; |
| 1436 | 1436 | $line->multicurrency_total_tva = $objp->multicurrency_total_tva; |
@@ -1447,7 +1447,7 @@ discard block |
||
| 1447 | 1447 | } |
| 1448 | 1448 | else |
| 1449 | 1449 | { |
| 1450 | - $this->error=$this->db->error(); |
|
| 1450 | + $this->error = $this->db->error(); |
|
| 1451 | 1451 | return -3; |
| 1452 | 1452 | } |
| 1453 | 1453 | } |
@@ -1490,22 +1490,22 @@ discard block |
||
| 1490 | 1490 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
| 1491 | 1491 | * @return int <0 if KO, >0 if OK |
| 1492 | 1492 | */ |
| 1493 | - function update($user=null, $notrigger=0) |
|
| 1493 | + function update($user = null, $notrigger = 0) |
|
| 1494 | 1494 | { |
| 1495 | - $error=0; |
|
| 1495 | + $error = 0; |
|
| 1496 | 1496 | |
| 1497 | 1497 | // Clean parameters |
| 1498 | - if (empty($this->type)) $this->type= self::TYPE_STANDARD; |
|
| 1499 | - if (isset($this->facnumber)) $this->facnumber=trim($this->ref); |
|
| 1500 | - if (isset($this->ref_client)) $this->ref_client=trim($this->ref_client); |
|
| 1501 | - if (isset($this->increment)) $this->increment=trim($this->increment); |
|
| 1502 | - if (isset($this->close_code)) $this->close_code=trim($this->close_code); |
|
| 1503 | - if (isset($this->close_note)) $this->close_note=trim($this->close_note); |
|
| 1504 | - if (isset($this->note) || isset($this->note_private)) $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated |
|
| 1505 | - if (isset($this->note) || isset($this->note_private)) $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note)); |
|
| 1506 | - if (isset($this->note_public)) $this->note_public=trim($this->note_public); |
|
| 1507 | - if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); |
|
| 1508 | - if (isset($this->import_key)) $this->import_key=trim($this->import_key); |
|
| 1498 | + if (empty($this->type)) $this->type = self::TYPE_STANDARD; |
|
| 1499 | + if (isset($this->facnumber)) $this->facnumber = trim($this->ref); |
|
| 1500 | + if (isset($this->ref_client)) $this->ref_client = trim($this->ref_client); |
|
| 1501 | + if (isset($this->increment)) $this->increment = trim($this->increment); |
|
| 1502 | + if (isset($this->close_code)) $this->close_code = trim($this->close_code); |
|
| 1503 | + if (isset($this->close_note)) $this->close_note = trim($this->close_note); |
|
| 1504 | + if (isset($this->note) || isset($this->note_private)) $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated |
|
| 1505 | + if (isset($this->note) || isset($this->note_private)) $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note)); |
|
| 1506 | + if (isset($this->note_public)) $this->note_public = trim($this->note_public); |
|
| 1507 | + if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); |
|
| 1508 | + if (isset($this->import_key)) $this->import_key = trim($this->import_key); |
|
| 1509 | 1509 | if (empty($this->situation_cycle_ref)) { |
| 1510 | 1510 | $this->situation_cycle_ref = 'null'; |
| 1511 | 1511 | } |
@@ -1524,58 +1524,58 @@ discard block |
||
| 1524 | 1524 | // Update request |
| 1525 | 1525 | $sql = "UPDATE ".MAIN_DB_PREFIX."facture SET"; |
| 1526 | 1526 | |
| 1527 | - $sql.= " facnumber=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; |
|
| 1528 | - $sql.= " type=".(isset($this->type)?$this->type:"null").","; |
|
| 1529 | - $sql.= " ref_client=".(isset($this->ref_client)?"'".$this->db->escape($this->ref_client)."'":"null").","; |
|
| 1530 | - $sql.= " increment=".(isset($this->increment)?"'".$this->db->escape($this->increment)."'":"null").","; |
|
| 1531 | - $sql.= " fk_soc=".(isset($this->socid)?$this->socid:"null").","; |
|
| 1532 | - $sql.= " datec=".(strval($this->date_creation)!='' ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; |
|
| 1533 | - $sql.= " datef=".(strval($this->date)!='' ? "'".$this->db->idate($this->date)."'" : 'null').","; |
|
| 1534 | - $sql.= " date_pointoftax=".(strval($this->date_pointoftax)!='' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null').","; |
|
| 1535 | - $sql.= " date_valid=".(strval($this->date_validation)!='' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; |
|
| 1536 | - $sql.= " paye=".(isset($this->paye)?$this->paye:"null").","; |
|
| 1537 | - $sql.= " remise_percent=".(isset($this->remise_percent)?$this->remise_percent:"null").","; |
|
| 1538 | - $sql.= " remise_absolue=".(isset($this->remise_absolue)?$this->remise_absolue:"null").","; |
|
| 1539 | - $sql.= " close_code=".(isset($this->close_code)?"'".$this->db->escape($this->close_code)."'":"null").","; |
|
| 1540 | - $sql.= " close_note=".(isset($this->close_note)?"'".$this->db->escape($this->close_note)."'":"null").","; |
|
| 1541 | - $sql.= " tva=".(isset($this->total_tva)?$this->total_tva:"null").","; |
|
| 1542 | - $sql.= " localtax1=".(isset($this->total_localtax1)?$this->total_localtax1:"null").","; |
|
| 1543 | - $sql.= " localtax2=".(isset($this->total_localtax2)?$this->total_localtax2:"null").","; |
|
| 1544 | - $sql.= " total=".(isset($this->total_ht)?$this->total_ht:"null").","; |
|
| 1545 | - $sql.= " total_ttc=".(isset($this->total_ttc)?$this->total_ttc:"null").","; |
|
| 1546 | - $sql.= " revenuestamp=".((isset($this->revenuestamp) && $this->revenuestamp != '')?$this->revenuestamp:"null").","; |
|
| 1547 | - $sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").","; |
|
| 1548 | - $sql.= " fk_user_author=".(isset($this->user_author)?$this->user_author:"null").","; |
|
| 1549 | - $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->fk_user_valid:"null").","; |
|
| 1550 | - $sql.= " fk_facture_source=".(isset($this->fk_facture_source)?$this->fk_facture_source:"null").","; |
|
| 1551 | - $sql.= " fk_projet=".(isset($this->fk_project)?$this->fk_project:"null").","; |
|
| 1552 | - $sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null").","; |
|
| 1553 | - $sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->mode_reglement_id:"null").","; |
|
| 1554 | - $sql.= " date_lim_reglement=".(strval($this->date_lim_reglement)!='' ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'null').","; |
|
| 1555 | - $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; |
|
| 1556 | - $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; |
|
| 1557 | - $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; |
|
| 1558 | - $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
| 1559 | - $sql.= ", situation_cycle_ref=".$this->situation_cycle_ref; |
|
| 1560 | - $sql.= ", situation_counter=".$this->situation_counter; |
|
| 1561 | - $sql.= ", situation_final=".$this->situation_final; |
|
| 1562 | - |
|
| 1563 | - $sql.= " WHERE rowid=".$this->id; |
|
| 1527 | + $sql .= " facnumber=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; |
|
| 1528 | + $sql .= " type=".(isset($this->type) ? $this->type : "null").","; |
|
| 1529 | + $sql .= " ref_client=".(isset($this->ref_client) ? "'".$this->db->escape($this->ref_client)."'" : "null").","; |
|
| 1530 | + $sql .= " increment=".(isset($this->increment) ? "'".$this->db->escape($this->increment)."'" : "null").","; |
|
| 1531 | + $sql .= " fk_soc=".(isset($this->socid) ? $this->socid : "null").","; |
|
| 1532 | + $sql .= " datec=".(strval($this->date_creation) != '' ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; |
|
| 1533 | + $sql .= " datef=".(strval($this->date) != '' ? "'".$this->db->idate($this->date)."'" : 'null').","; |
|
| 1534 | + $sql .= " date_pointoftax=".(strval($this->date_pointoftax) != '' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null').","; |
|
| 1535 | + $sql .= " date_valid=".(strval($this->date_validation) != '' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; |
|
| 1536 | + $sql .= " paye=".(isset($this->paye) ? $this->paye : "null").","; |
|
| 1537 | + $sql .= " remise_percent=".(isset($this->remise_percent) ? $this->remise_percent : "null").","; |
|
| 1538 | + $sql .= " remise_absolue=".(isset($this->remise_absolue) ? $this->remise_absolue : "null").","; |
|
| 1539 | + $sql .= " close_code=".(isset($this->close_code) ? "'".$this->db->escape($this->close_code)."'" : "null").","; |
|
| 1540 | + $sql .= " close_note=".(isset($this->close_note) ? "'".$this->db->escape($this->close_note)."'" : "null").","; |
|
| 1541 | + $sql .= " tva=".(isset($this->total_tva) ? $this->total_tva : "null").","; |
|
| 1542 | + $sql .= " localtax1=".(isset($this->total_localtax1) ? $this->total_localtax1 : "null").","; |
|
| 1543 | + $sql .= " localtax2=".(isset($this->total_localtax2) ? $this->total_localtax2 : "null").","; |
|
| 1544 | + $sql .= " total=".(isset($this->total_ht) ? $this->total_ht : "null").","; |
|
| 1545 | + $sql .= " total_ttc=".(isset($this->total_ttc) ? $this->total_ttc : "null").","; |
|
| 1546 | + $sql .= " revenuestamp=".((isset($this->revenuestamp) && $this->revenuestamp != '') ? $this->revenuestamp : "null").","; |
|
| 1547 | + $sql .= " fk_statut=".(isset($this->statut) ? $this->statut : "null").","; |
|
| 1548 | + $sql .= " fk_user_author=".(isset($this->user_author) ? $this->user_author : "null").","; |
|
| 1549 | + $sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? $this->fk_user_valid : "null").","; |
|
| 1550 | + $sql .= " fk_facture_source=".(isset($this->fk_facture_source) ? $this->fk_facture_source : "null").","; |
|
| 1551 | + $sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").","; |
|
| 1552 | + $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").","; |
|
| 1553 | + $sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->mode_reglement_id : "null").","; |
|
| 1554 | + $sql .= " date_lim_reglement=".(strval($this->date_lim_reglement) != '' ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'null').","; |
|
| 1555 | + $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; |
|
| 1556 | + $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; |
|
| 1557 | + $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; |
|
| 1558 | + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); |
|
| 1559 | + $sql .= ", situation_cycle_ref=".$this->situation_cycle_ref; |
|
| 1560 | + $sql .= ", situation_counter=".$this->situation_counter; |
|
| 1561 | + $sql .= ", situation_final=".$this->situation_final; |
|
| 1562 | + |
|
| 1563 | + $sql .= " WHERE rowid=".$this->id; |
|
| 1564 | 1564 | |
| 1565 | 1565 | $this->db->begin(); |
| 1566 | 1566 | |
| 1567 | 1567 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
| 1568 | 1568 | $resql = $this->db->query($sql); |
| 1569 | - if (! $resql) { |
|
| 1570 | - $error++; $this->errors[]="Error ".$this->db->lasterror(); |
|
| 1569 | + if (!$resql) { |
|
| 1570 | + $error++; $this->errors[] = "Error ".$this->db->lasterror(); |
|
| 1571 | 1571 | } |
| 1572 | 1572 | |
| 1573 | - if (! $error) |
|
| 1573 | + if (!$error) |
|
| 1574 | 1574 | { |
| 1575 | - if (! $notrigger) |
|
| 1575 | + if (!$notrigger) |
|
| 1576 | 1576 | { |
| 1577 | 1577 | // Call trigger |
| 1578 | - $result=$this->call_trigger('BILL_MODIFY',$user); |
|
| 1578 | + $result = $this->call_trigger('BILL_MODIFY', $user); |
|
| 1579 | 1579 | if ($result < 0) $error++; |
| 1580 | 1580 | // End call triggers |
| 1581 | 1581 | } |
@@ -1584,13 +1584,13 @@ discard block |
||
| 1584 | 1584 | // Commit or rollback |
| 1585 | 1585 | if ($error) |
| 1586 | 1586 | { |
| 1587 | - foreach($this->errors as $errmsg) |
|
| 1587 | + foreach ($this->errors as $errmsg) |
|
| 1588 | 1588 | { |
| 1589 | 1589 | dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
| 1590 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 1590 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 1591 | 1591 | } |
| 1592 | 1592 | $this->db->rollback(); |
| 1593 | - return -1*$error; |
|
| 1593 | + return -1 * $error; |
|
| 1594 | 1594 | } |
| 1595 | 1595 | else |
| 1596 | 1596 | { |
@@ -1615,40 +1615,40 @@ discard block |
||
| 1615 | 1615 | |
| 1616 | 1616 | $this->db->begin(); |
| 1617 | 1617 | |
| 1618 | - $remise=new DiscountAbsolute($this->db); |
|
| 1619 | - $result=$remise->fetch($idremise); |
|
| 1618 | + $remise = new DiscountAbsolute($this->db); |
|
| 1619 | + $result = $remise->fetch($idremise); |
|
| 1620 | 1620 | |
| 1621 | 1621 | if ($result > 0) |
| 1622 | 1622 | { |
| 1623 | 1623 | if ($remise->fk_facture) // Protection against multiple submission |
| 1624 | 1624 | { |
| 1625 | - $this->error=$langs->trans("ErrorDiscountAlreadyUsed"); |
|
| 1625 | + $this->error = $langs->trans("ErrorDiscountAlreadyUsed"); |
|
| 1626 | 1626 | $this->db->rollback(); |
| 1627 | 1627 | return -5; |
| 1628 | 1628 | } |
| 1629 | 1629 | |
| 1630 | - $facligne=new FactureLigne($this->db); |
|
| 1631 | - $facligne->fk_facture=$this->id; |
|
| 1632 | - $facligne->fk_remise_except=$remise->id; |
|
| 1633 | - $facligne->desc=$remise->description; // Description ligne |
|
| 1634 | - $facligne->vat_src_code=$remise->vat_src_code; |
|
| 1635 | - $facligne->tva_tx=$remise->tva_tx; |
|
| 1630 | + $facligne = new FactureLigne($this->db); |
|
| 1631 | + $facligne->fk_facture = $this->id; |
|
| 1632 | + $facligne->fk_remise_except = $remise->id; |
|
| 1633 | + $facligne->desc = $remise->description; // Description ligne |
|
| 1634 | + $facligne->vat_src_code = $remise->vat_src_code; |
|
| 1635 | + $facligne->tva_tx = $remise->tva_tx; |
|
| 1636 | 1636 | $facligne->subprice = -$remise->amount_ht; |
| 1637 | - $facligne->fk_product=0; // Id produit predefini |
|
| 1638 | - $facligne->qty=1; |
|
| 1639 | - $facligne->remise_percent=0; |
|
| 1640 | - $facligne->rang=-1; |
|
| 1641 | - $facligne->info_bits=2; |
|
| 1637 | + $facligne->fk_product = 0; // Id produit predefini |
|
| 1638 | + $facligne->qty = 1; |
|
| 1639 | + $facligne->remise_percent = 0; |
|
| 1640 | + $facligne->rang = -1; |
|
| 1641 | + $facligne->info_bits = 2; |
|
| 1642 | 1642 | |
| 1643 | 1643 | // Get buy/cost price of invoice that is source of discount |
| 1644 | 1644 | if ($remise->fk_facture_source > 0) |
| 1645 | 1645 | { |
| 1646 | - $srcinvoice=new Facture($this->db); |
|
| 1646 | + $srcinvoice = new Facture($this->db); |
|
| 1647 | 1647 | $srcinvoice->fetch($remise->fk_facture_source); |
| 1648 | - $totalcostpriceofinvoice=0; |
|
| 1649 | - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject |
|
| 1650 | - $formmargin=new FormMargin($this->db); |
|
| 1651 | - $arraytmp=$formmargin->getMarginInfosArray($srcinvoice, false); |
|
| 1648 | + $totalcostpriceofinvoice = 0; |
|
| 1649 | + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject |
|
| 1650 | + $formmargin = new FormMargin($this->db); |
|
| 1651 | + $arraytmp = $formmargin->getMarginInfosArray($srcinvoice, false); |
|
| 1652 | 1652 | $facligne->pa_ht = $arraytmp['pa_total']; |
| 1653 | 1653 | } |
| 1654 | 1654 | |
@@ -1661,17 +1661,17 @@ discard block |
||
| 1661 | 1661 | $facligne->multicurrency_total_tva = -$remise->multicurrency_total_tva; |
| 1662 | 1662 | $facligne->multicurrency_total_ttc = -$remise->multicurrency_total_ttc; |
| 1663 | 1663 | |
| 1664 | - $lineid=$facligne->insert(); |
|
| 1664 | + $lineid = $facligne->insert(); |
|
| 1665 | 1665 | if ($lineid > 0) |
| 1666 | 1666 | { |
| 1667 | - $result=$this->update_price(1); |
|
| 1667 | + $result = $this->update_price(1); |
|
| 1668 | 1668 | if ($result > 0) |
| 1669 | 1669 | { |
| 1670 | 1670 | // Create link between discount and invoice line |
| 1671 | - $result=$remise->link_to_invoice($lineid,0); |
|
| 1671 | + $result = $remise->link_to_invoice($lineid, 0); |
|
| 1672 | 1672 | if ($result < 0) |
| 1673 | 1673 | { |
| 1674 | - $this->error=$remise->error; |
|
| 1674 | + $this->error = $remise->error; |
|
| 1675 | 1675 | $this->db->rollback(); |
| 1676 | 1676 | return -4; |
| 1677 | 1677 | } |
@@ -1681,14 +1681,14 @@ discard block |
||
| 1681 | 1681 | } |
| 1682 | 1682 | else |
| 1683 | 1683 | { |
| 1684 | - $this->error=$facligne->error; |
|
| 1684 | + $this->error = $facligne->error; |
|
| 1685 | 1685 | $this->db->rollback(); |
| 1686 | 1686 | return -1; |
| 1687 | 1687 | } |
| 1688 | 1688 | } |
| 1689 | 1689 | else |
| 1690 | 1690 | { |
| 1691 | - $this->error=$facligne->error; |
|
| 1691 | + $this->error = $facligne->error; |
|
| 1692 | 1692 | $this->db->rollback(); |
| 1693 | 1693 | return -2; |
| 1694 | 1694 | } |
@@ -1707,11 +1707,11 @@ discard block |
||
| 1707 | 1707 | * @param int $notrigger 1=Does not execute triggers, 0= execute triggers |
| 1708 | 1708 | * @return int <0 if KO, >0 if OK |
| 1709 | 1709 | */ |
| 1710 | - function set_ref_client($ref_client, $notrigger=0) |
|
| 1710 | + function set_ref_client($ref_client, $notrigger = 0) |
|
| 1711 | 1711 | { |
| 1712 | 1712 | global $user; |
| 1713 | 1713 | |
| 1714 | - $error=0; |
|
| 1714 | + $error = 0; |
|
| 1715 | 1715 | |
| 1716 | 1716 | $this->db->begin(); |
| 1717 | 1717 | |
@@ -1723,27 +1723,27 @@ discard block |
||
| 1723 | 1723 | $sql .= ' WHERE rowid = '.$this->id; |
| 1724 | 1724 | |
| 1725 | 1725 | dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG); |
| 1726 | - $resql=$this->db->query($sql); |
|
| 1726 | + $resql = $this->db->query($sql); |
|
| 1727 | 1727 | if (!$resql) |
| 1728 | 1728 | { |
| 1729 | - $this->errors[]=$this->db->error(); |
|
| 1729 | + $this->errors[] = $this->db->error(); |
|
| 1730 | 1730 | $error++; |
| 1731 | 1731 | } |
| 1732 | 1732 | |
| 1733 | - if (! $error) |
|
| 1733 | + if (!$error) |
|
| 1734 | 1734 | { |
| 1735 | 1735 | $this->ref_client = $ref_client; |
| 1736 | 1736 | } |
| 1737 | 1737 | |
| 1738 | - if (! $notrigger && empty($error)) |
|
| 1738 | + if (!$notrigger && empty($error)) |
|
| 1739 | 1739 | { |
| 1740 | 1740 | // Call trigger |
| 1741 | - $result=$this->call_trigger('BILL_MODIFY',$user); |
|
| 1741 | + $result = $this->call_trigger('BILL_MODIFY', $user); |
|
| 1742 | 1742 | if ($result < 0) $error++; |
| 1743 | 1743 | // End call triggers |
| 1744 | 1744 | } |
| 1745 | 1745 | |
| 1746 | - if (! $error) |
|
| 1746 | + if (!$error) |
|
| 1747 | 1747 | { |
| 1748 | 1748 | |
| 1749 | 1749 | $this->ref_client = $ref_client; |
@@ -1753,13 +1753,13 @@ discard block |
||
| 1753 | 1753 | } |
| 1754 | 1754 | else |
| 1755 | 1755 | { |
| 1756 | - foreach($this->errors as $errmsg) |
|
| 1756 | + foreach ($this->errors as $errmsg) |
|
| 1757 | 1757 | { |
| 1758 | 1758 | dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); |
| 1759 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 1759 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 1760 | 1760 | } |
| 1761 | 1761 | $this->db->rollback(); |
| 1762 | - return -1*$error; |
|
| 1762 | + return -1 * $error; |
|
| 1763 | 1763 | } |
| 1764 | 1764 | } |
| 1765 | 1765 | |
@@ -1771,12 +1771,12 @@ discard block |
||
| 1771 | 1771 | * @param int $idwarehouse Id warehouse to use for stock change. |
| 1772 | 1772 | * @return int <0 if KO, 0=Refused, >0 if OK |
| 1773 | 1773 | */ |
| 1774 | - function delete($user, $notrigger=0, $idwarehouse=-1) |
|
| 1774 | + function delete($user, $notrigger = 0, $idwarehouse = -1) |
|
| 1775 | 1775 | { |
| 1776 | - global $langs,$conf; |
|
| 1776 | + global $langs, $conf; |
|
| 1777 | 1777 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 1778 | 1778 | |
| 1779 | - $rowid=$this->id; |
|
| 1779 | + $rowid = $this->id; |
|
| 1780 | 1780 | |
| 1781 | 1781 | dol_syslog(get_class($this)."::delete rowid=".$rowid.", ref=".$this->ref.", thirdparty=".$this->thirdparty->name, LOG_DEBUG); |
| 1782 | 1782 | |
@@ -1785,21 +1785,21 @@ discard block |
||
| 1785 | 1785 | |
| 1786 | 1786 | if ($test <= 0) return 0; |
| 1787 | 1787 | |
| 1788 | - $error=0; |
|
| 1788 | + $error = 0; |
|
| 1789 | 1789 | |
| 1790 | 1790 | $this->db->begin(); |
| 1791 | 1791 | |
| 1792 | - if (! $error && ! $notrigger) |
|
| 1792 | + if (!$error && !$notrigger) |
|
| 1793 | 1793 | { |
| 1794 | 1794 | // Call trigger |
| 1795 | - $result=$this->call_trigger('BILL_DELETE',$user); |
|
| 1795 | + $result = $this->call_trigger('BILL_DELETE', $user); |
|
| 1796 | 1796 | if ($result < 0) $error++; |
| 1797 | 1797 | // End call triggers |
| 1798 | 1798 | } |
| 1799 | 1799 | |
| 1800 | 1800 | // Removed extrafields |
| 1801 | - if (! $error) { |
|
| 1802 | - $result=$this->deleteExtraFields(); |
|
| 1801 | + if (!$error) { |
|
| 1802 | + $result = $this->deleteExtraFields(); |
|
| 1803 | 1803 | if ($result < 0) |
| 1804 | 1804 | { |
| 1805 | 1805 | $error++; |
@@ -1807,52 +1807,52 @@ discard block |
||
| 1807 | 1807 | } |
| 1808 | 1808 | } |
| 1809 | 1809 | |
| 1810 | - if (! $error) |
|
| 1810 | + if (!$error) |
|
| 1811 | 1811 | { |
| 1812 | 1812 | // Delete linked object |
| 1813 | 1813 | $res = $this->deleteObjectLinked(); |
| 1814 | 1814 | if ($res < 0) $error++; |
| 1815 | 1815 | } |
| 1816 | 1816 | |
| 1817 | - if (! $error) |
|
| 1817 | + if (!$error) |
|
| 1818 | 1818 | { |
| 1819 | 1819 | // If invoice was converted into a discount not yet consumed, we remove discount |
| 1820 | 1820 | $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except'; |
| 1821 | - $sql.= ' WHERE fk_facture_source = '.$rowid; |
|
| 1822 | - $sql.= ' AND fk_facture_line IS NULL'; |
|
| 1823 | - $resql=$this->db->query($sql); |
|
| 1821 | + $sql .= ' WHERE fk_facture_source = '.$rowid; |
|
| 1822 | + $sql .= ' AND fk_facture_line IS NULL'; |
|
| 1823 | + $resql = $this->db->query($sql); |
|
| 1824 | 1824 | |
| 1825 | 1825 | // If invoice has consumned discounts |
| 1826 | 1826 | $this->fetch_lines(); |
| 1827 | - $list_rowid_det=array(); |
|
| 1828 | - foreach($this->lines as $key => $invoiceline) |
|
| 1827 | + $list_rowid_det = array(); |
|
| 1828 | + foreach ($this->lines as $key => $invoiceline) |
|
| 1829 | 1829 | { |
| 1830 | - $list_rowid_det[]=$invoiceline->rowid; |
|
| 1830 | + $list_rowid_det[] = $invoiceline->rowid; |
|
| 1831 | 1831 | } |
| 1832 | 1832 | |
| 1833 | 1833 | // Consumned discounts are freed |
| 1834 | 1834 | if (count($list_rowid_det)) |
| 1835 | 1835 | { |
| 1836 | 1836 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; |
| 1837 | - $sql.= ' SET fk_facture = NULL, fk_facture_line = NULL'; |
|
| 1838 | - $sql.= ' WHERE fk_facture_line IN ('.join(',',$list_rowid_det).')'; |
|
| 1837 | + $sql .= ' SET fk_facture = NULL, fk_facture_line = NULL'; |
|
| 1838 | + $sql .= ' WHERE fk_facture_line IN ('.join(',', $list_rowid_det).')'; |
|
| 1839 | 1839 | |
| 1840 | 1840 | dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
| 1841 | - if (! $this->db->query($sql)) |
|
| 1841 | + if (!$this->db->query($sql)) |
|
| 1842 | 1842 | { |
| 1843 | - $this->error=$this->db->error()." sql=".$sql; |
|
| 1843 | + $this->error = $this->db->error()." sql=".$sql; |
|
| 1844 | 1844 | $this->db->rollback(); |
| 1845 | 1845 | return -5; |
| 1846 | 1846 | } |
| 1847 | 1847 | } |
| 1848 | 1848 | |
| 1849 | 1849 | // If we decrement stock on invoice validation, we increment |
| 1850 | - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse!=-1) |
|
| 1850 | + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse != -1) |
|
| 1851 | 1851 | { |
| 1852 | 1852 | require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; |
| 1853 | 1853 | $langs->load("agenda"); |
| 1854 | 1854 | |
| 1855 | - $num=count($this->lines); |
|
| 1855 | + $num = count($this->lines); |
|
| 1856 | 1856 | for ($i = 0; $i < $num; $i++) |
| 1857 | 1857 | { |
| 1858 | 1858 | if ($this->lines[$i]->fk_product > 0) |
@@ -1860,8 +1860,8 @@ discard block |
||
| 1860 | 1860 | $mouvP = new MouvementStock($this->db); |
| 1861 | 1861 | $mouvP->origin = &$this; |
| 1862 | 1862 | // We decrease stock for product |
| 1863 | - if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); |
|
| 1864 | - else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value |
|
| 1863 | + if ($this->type == self::TYPE_CREDIT_NOTE) $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); |
|
| 1864 | + else $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value |
|
| 1865 | 1865 | } |
| 1866 | 1866 | } |
| 1867 | 1867 | } |
@@ -1878,31 +1878,31 @@ discard block |
||
| 1878 | 1878 | |
| 1879 | 1879 | dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
| 1880 | 1880 | |
| 1881 | - $resql=$this->db->query($sql); |
|
| 1881 | + $resql = $this->db->query($sql); |
|
| 1882 | 1882 | if ($resql) |
| 1883 | 1883 | { |
| 1884 | 1884 | // On efface le repertoire de pdf provisoire |
| 1885 | 1885 | $ref = dol_sanitizeFileName($this->ref); |
| 1886 | 1886 | if ($conf->facture->dir_output && !empty($this->ref)) |
| 1887 | 1887 | { |
| 1888 | - $dir = $conf->facture->dir_output . "/" . $ref; |
|
| 1889 | - $file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf"; |
|
| 1888 | + $dir = $conf->facture->dir_output."/".$ref; |
|
| 1889 | + $file = $conf->facture->dir_output."/".$ref."/".$ref.".pdf"; |
|
| 1890 | 1890 | if (file_exists($file)) // We must delete all files before deleting directory |
| 1891 | 1891 | { |
| 1892 | - $ret=dol_delete_preview($this); |
|
| 1892 | + $ret = dol_delete_preview($this); |
|
| 1893 | 1893 | |
| 1894 | - if (! dol_delete_file($file,0,0,0,$this)) // For triggers |
|
| 1894 | + if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers |
|
| 1895 | 1895 | { |
| 1896 | - $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); |
|
| 1896 | + $this->error = $langs->trans("ErrorCanNotDeleteFile", $file); |
|
| 1897 | 1897 | $this->db->rollback(); |
| 1898 | 1898 | return 0; |
| 1899 | 1899 | } |
| 1900 | 1900 | } |
| 1901 | 1901 | if (file_exists($dir)) |
| 1902 | 1902 | { |
| 1903 | - if (! dol_delete_dir_recursive($dir)) // For remove dir and meta |
|
| 1903 | + if (!dol_delete_dir_recursive($dir)) // For remove dir and meta |
|
| 1904 | 1904 | { |
| 1905 | - $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); |
|
| 1905 | + $this->error = $langs->trans("ErrorCanNotDeleteDir", $dir); |
|
| 1906 | 1906 | $this->db->rollback(); |
| 1907 | 1907 | return 0; |
| 1908 | 1908 | } |
@@ -1914,14 +1914,14 @@ discard block |
||
| 1914 | 1914 | } |
| 1915 | 1915 | else |
| 1916 | 1916 | { |
| 1917 | - $this->error=$this->db->lasterror()." sql=".$sql; |
|
| 1917 | + $this->error = $this->db->lasterror()." sql=".$sql; |
|
| 1918 | 1918 | $this->db->rollback(); |
| 1919 | 1919 | return -6; |
| 1920 | 1920 | } |
| 1921 | 1921 | } |
| 1922 | 1922 | else |
| 1923 | 1923 | { |
| 1924 | - $this->error=$this->db->lasterror()." sql=".$sql; |
|
| 1924 | + $this->error = $this->db->lasterror()." sql=".$sql; |
|
| 1925 | 1925 | $this->db->rollback(); |
| 1926 | 1926 | return -4; |
| 1927 | 1927 | } |
@@ -1942,9 +1942,9 @@ discard block |
||
| 1942 | 1942 | * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple) |
| 1943 | 1943 | * @return int <0 if KO, >0 if OK |
| 1944 | 1944 | */ |
| 1945 | - function set_paid($user, $close_code='', $close_note='') |
|
| 1945 | + function set_paid($user, $close_code = '', $close_note = '') |
|
| 1946 | 1946 | { |
| 1947 | - $error=0; |
|
| 1947 | + $error = 0; |
|
| 1948 | 1948 | |
| 1949 | 1949 | if ($this->paye != 1) |
| 1950 | 1950 | { |
@@ -1952,28 +1952,28 @@ discard block |
||
| 1952 | 1952 | |
| 1953 | 1953 | dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG); |
| 1954 | 1954 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; |
| 1955 | - $sql.= ' fk_statut='.self::STATUS_CLOSED; |
|
| 1956 | - if (! $close_code) $sql.= ', paye=1'; |
|
| 1957 | - if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; |
|
| 1958 | - if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; |
|
| 1959 | - $sql.= ' WHERE rowid = '.$this->id; |
|
| 1955 | + $sql .= ' fk_statut='.self::STATUS_CLOSED; |
|
| 1956 | + if (!$close_code) $sql .= ', paye=1'; |
|
| 1957 | + if ($close_code) $sql .= ", close_code='".$this->db->escape($close_code)."'"; |
|
| 1958 | + if ($close_note) $sql .= ", close_note='".$this->db->escape($close_note)."'"; |
|
| 1959 | + $sql .= ' WHERE rowid = '.$this->id; |
|
| 1960 | 1960 | |
| 1961 | 1961 | dol_syslog(get_class($this)."::set_paid", LOG_DEBUG); |
| 1962 | 1962 | $resql = $this->db->query($sql); |
| 1963 | 1963 | if ($resql) |
| 1964 | 1964 | { |
| 1965 | 1965 | // Call trigger |
| 1966 | - $result=$this->call_trigger('BILL_PAYED',$user); |
|
| 1966 | + $result = $this->call_trigger('BILL_PAYED', $user); |
|
| 1967 | 1967 | if ($result < 0) $error++; |
| 1968 | 1968 | // End call triggers |
| 1969 | 1969 | } |
| 1970 | 1970 | else |
| 1971 | 1971 | { |
| 1972 | 1972 | $error++; |
| 1973 | - $this->error=$this->db->lasterror(); |
|
| 1973 | + $this->error = $this->db->lasterror(); |
|
| 1974 | 1974 | } |
| 1975 | 1975 | |
| 1976 | - if (! $error) |
|
| 1976 | + if (!$error) |
|
| 1977 | 1977 | { |
| 1978 | 1978 | $this->db->commit(); |
| 1979 | 1979 | return 1; |
@@ -2001,31 +2001,31 @@ discard block |
||
| 2001 | 2001 | */ |
| 2002 | 2002 | function set_unpaid($user) |
| 2003 | 2003 | { |
| 2004 | - $error=0; |
|
| 2004 | + $error = 0; |
|
| 2005 | 2005 | |
| 2006 | 2006 | $this->db->begin(); |
| 2007 | 2007 | |
| 2008 | 2008 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; |
| 2009 | - $sql.= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null'; |
|
| 2010 | - $sql.= ' WHERE rowid = '.$this->id; |
|
| 2009 | + $sql .= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null'; |
|
| 2010 | + $sql .= ' WHERE rowid = '.$this->id; |
|
| 2011 | 2011 | |
| 2012 | 2012 | dol_syslog(get_class($this)."::set_unpaid", LOG_DEBUG); |
| 2013 | 2013 | $resql = $this->db->query($sql); |
| 2014 | 2014 | if ($resql) |
| 2015 | 2015 | { |
| 2016 | 2016 | // Call trigger |
| 2017 | - $result=$this->call_trigger('BILL_UNPAYED',$user); |
|
| 2017 | + $result = $this->call_trigger('BILL_UNPAYED', $user); |
|
| 2018 | 2018 | if ($result < 0) $error++; |
| 2019 | 2019 | // End call triggers |
| 2020 | 2020 | } |
| 2021 | 2021 | else |
| 2022 | 2022 | { |
| 2023 | 2023 | $error++; |
| 2024 | - $this->error=$this->db->error(); |
|
| 2024 | + $this->error = $this->db->error(); |
|
| 2025 | 2025 | dol_print_error($this->db); |
| 2026 | 2026 | } |
| 2027 | 2027 | |
| 2028 | - if (! $error) |
|
| 2028 | + if (!$error) |
|
| 2029 | 2029 | { |
| 2030 | 2030 | $this->db->commit(); |
| 2031 | 2031 | return 1; |
@@ -2048,7 +2048,7 @@ discard block |
||
| 2048 | 2048 | * @param string $close_note Comment |
| 2049 | 2049 | * @return int <0 if KO, >0 if OK |
| 2050 | 2050 | */ |
| 2051 | - function set_canceled($user,$close_code='',$close_note='') |
|
| 2051 | + function set_canceled($user, $close_code = '', $close_note = '') |
|
| 2052 | 2052 | { |
| 2053 | 2053 | |
| 2054 | 2054 | dol_syslog(get_class($this)."::set_canceled rowid=".$this->id, LOG_DEBUG); |
@@ -2056,10 +2056,10 @@ discard block |
||
| 2056 | 2056 | $this->db->begin(); |
| 2057 | 2057 | |
| 2058 | 2058 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; |
| 2059 | - $sql.= ' fk_statut='.self::STATUS_ABANDONED; |
|
| 2060 | - if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; |
|
| 2061 | - if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; |
|
| 2062 | - $sql.= ' WHERE rowid = '.$this->id; |
|
| 2059 | + $sql .= ' fk_statut='.self::STATUS_ABANDONED; |
|
| 2060 | + if ($close_code) $sql .= ", close_code='".$this->db->escape($close_code)."'"; |
|
| 2061 | + if ($close_note) $sql .= ", close_note='".$this->db->escape($close_note)."'"; |
|
| 2062 | + $sql .= ' WHERE rowid = '.$this->id; |
|
| 2063 | 2063 | |
| 2064 | 2064 | $resql = $this->db->query($sql); |
| 2065 | 2065 | if ($resql) |
@@ -2067,14 +2067,14 @@ discard block |
||
| 2067 | 2067 | // On desaffecte de la facture les remises liees |
| 2068 | 2068 | // car elles n'ont pas ete utilisees vu que la facture est abandonnee. |
| 2069 | 2069 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; |
| 2070 | - $sql.= ' SET fk_facture = NULL'; |
|
| 2071 | - $sql.= ' WHERE fk_facture = '.$this->id; |
|
| 2070 | + $sql .= ' SET fk_facture = NULL'; |
|
| 2071 | + $sql .= ' WHERE fk_facture = '.$this->id; |
|
| 2072 | 2072 | |
| 2073 | - $resql=$this->db->query($sql); |
|
| 2073 | + $resql = $this->db->query($sql); |
|
| 2074 | 2074 | if ($resql) |
| 2075 | 2075 | { |
| 2076 | 2076 | // Call trigger |
| 2077 | - $result=$this->call_trigger('BILL_CANCEL',$user); |
|
| 2077 | + $result = $this->call_trigger('BILL_CANCEL', $user); |
|
| 2078 | 2078 | if ($result < 0) |
| 2079 | 2079 | { |
| 2080 | 2080 | $this->db->rollback(); |
@@ -2087,14 +2087,14 @@ discard block |
||
| 2087 | 2087 | } |
| 2088 | 2088 | else |
| 2089 | 2089 | { |
| 2090 | - $this->error=$this->db->error()." sql=".$sql; |
|
| 2090 | + $this->error = $this->db->error()." sql=".$sql; |
|
| 2091 | 2091 | $this->db->rollback(); |
| 2092 | 2092 | return -1; |
| 2093 | 2093 | } |
| 2094 | 2094 | } |
| 2095 | 2095 | else |
| 2096 | 2096 | { |
| 2097 | - $this->error=$this->db->error()." sql=".$sql; |
|
| 2097 | + $this->error = $this->db->error()." sql=".$sql; |
|
| 2098 | 2098 | $this->db->rollback(); |
| 2099 | 2099 | return -2; |
| 2100 | 2100 | } |
@@ -2110,14 +2110,14 @@ discard block |
||
| 2110 | 2110 | * @param int $notrigger 1=Does not execute triggers, 0= execute triggers |
| 2111 | 2111 | * @return int <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK |
| 2112 | 2112 | */ |
| 2113 | - function validate($user, $force_number='', $idwarehouse=0, $notrigger=0) |
|
| 2113 | + function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0) |
|
| 2114 | 2114 | { |
| 2115 | - global $conf,$langs; |
|
| 2115 | + global $conf, $langs; |
|
| 2116 | 2116 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 2117 | 2117 | |
| 2118 | - $now=dol_now(); |
|
| 2118 | + $now = dol_now(); |
|
| 2119 | 2119 | |
| 2120 | - $error=0; |
|
| 2120 | + $error = 0; |
|
| 2121 | 2121 | dol_syslog(get_class($this).'::validate user='.$user->id.', force_number='.$force_number.', idwarehouse='.$idwarehouse); |
| 2122 | 2122 | |
| 2123 | 2123 | // Force to have object complete for checks |
@@ -2125,7 +2125,7 @@ discard block |
||
| 2125 | 2125 | $this->fetch_lines(); |
| 2126 | 2126 | |
| 2127 | 2127 | // Check parameters |
| 2128 | - if (! $this->brouillon) |
|
| 2128 | + if (!$this->brouillon) |
|
| 2129 | 2129 | { |
| 2130 | 2130 | dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING); |
| 2131 | 2131 | return 0; |
@@ -2133,13 +2133,13 @@ discard block |
||
| 2133 | 2133 | if (count($this->lines) <= 0) |
| 2134 | 2134 | { |
| 2135 | 2135 | $langs->load("errors"); |
| 2136 | - $this->error=$langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); |
|
| 2136 | + $this->error = $langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); |
|
| 2137 | 2137 | return -1; |
| 2138 | 2138 | } |
| 2139 | 2139 | if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->creer)) |
| 2140 | - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) |
|
| 2140 | + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) |
|
| 2141 | 2141 | { |
| 2142 | - $this->error='Permission denied'; |
|
| 2142 | + $this->error = 'Permission denied'; |
|
| 2143 | 2143 | dol_syslog(get_class($this)."::validate ".$this->error.' MAIN_USE_ADVANCED_PERMS='.$conf->global->MAIN_USE_ADVANCED_PERMS, LOG_ERR); |
| 2144 | 2144 | return -1; |
| 2145 | 2145 | } |
@@ -2152,36 +2152,36 @@ discard block |
||
| 2152 | 2152 | // Controle que facture source connue |
| 2153 | 2153 | if ($this->fk_facture_source <= 0) |
| 2154 | 2154 | { |
| 2155 | - $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("InvoiceReplacement")); |
|
| 2155 | + $this->error = $langs->trans("ErrorFieldRequired", $langs->trans("InvoiceReplacement")); |
|
| 2156 | 2156 | $this->db->rollback(); |
| 2157 | 2157 | return -10; |
| 2158 | 2158 | } |
| 2159 | 2159 | |
| 2160 | 2160 | // Charge la facture source a remplacer |
| 2161 | - $facreplaced=new Facture($this->db); |
|
| 2162 | - $result=$facreplaced->fetch($this->fk_facture_source); |
|
| 2161 | + $facreplaced = new Facture($this->db); |
|
| 2162 | + $result = $facreplaced->fetch($this->fk_facture_source); |
|
| 2163 | 2163 | if ($result <= 0) |
| 2164 | 2164 | { |
| 2165 | - $this->error=$langs->trans("ErrorBadInvoice"); |
|
| 2165 | + $this->error = $langs->trans("ErrorBadInvoice"); |
|
| 2166 | 2166 | $this->db->rollback(); |
| 2167 | 2167 | return -11; |
| 2168 | 2168 | } |
| 2169 | 2169 | |
| 2170 | 2170 | // Controle que facture source non deja remplacee par une autre |
| 2171 | - $idreplacement=$facreplaced->getIdReplacingInvoice('validated'); |
|
| 2171 | + $idreplacement = $facreplaced->getIdReplacingInvoice('validated'); |
|
| 2172 | 2172 | if ($idreplacement && $idreplacement != $this->id) |
| 2173 | 2173 | { |
| 2174 | - $facreplacement=new Facture($this->db); |
|
| 2174 | + $facreplacement = new Facture($this->db); |
|
| 2175 | 2175 | $facreplacement->fetch($idreplacement); |
| 2176 | - $this->error=$langs->trans("ErrorInvoiceAlreadyReplaced",$facreplaced->ref,$facreplacement->ref); |
|
| 2176 | + $this->error = $langs->trans("ErrorInvoiceAlreadyReplaced", $facreplaced->ref, $facreplacement->ref); |
|
| 2177 | 2177 | $this->db->rollback(); |
| 2178 | 2178 | return -12; |
| 2179 | 2179 | } |
| 2180 | 2180 | |
| 2181 | - $result=$facreplaced->set_canceled($user,'replaced',''); |
|
| 2181 | + $result = $facreplaced->set_canceled($user, 'replaced', ''); |
|
| 2182 | 2182 | if ($result < 0) |
| 2183 | 2183 | { |
| 2184 | - $this->error=$facreplaced->error; |
|
| 2184 | + $this->error = $facreplaced->error; |
|
| 2185 | 2185 | $this->db->rollback(); |
| 2186 | 2186 | return -13; |
| 2187 | 2187 | } |
@@ -2194,10 +2194,10 @@ discard block |
||
| 2194 | 2194 | } |
| 2195 | 2195 | else if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life |
| 2196 | 2196 | { |
| 2197 | - if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date |
|
| 2197 | + if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date |
|
| 2198 | 2198 | { |
| 2199 | - $this->date=dol_now(); |
|
| 2200 | - $this->date_lim_reglement=$this->calculate_date_lim_reglement(); |
|
| 2199 | + $this->date = dol_now(); |
|
| 2200 | + $this->date_lim_reglement = $this->calculate_date_lim_reglement(); |
|
| 2201 | 2201 | } |
| 2202 | 2202 | $num = $this->getNextNumRef($this->thirdparty); |
| 2203 | 2203 | } |
@@ -2213,41 +2213,41 @@ discard block |
||
| 2213 | 2213 | |
| 2214 | 2214 | // Validate |
| 2215 | 2215 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; |
| 2216 | - $sql.= " SET facnumber='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; |
|
| 2217 | - if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date |
|
| 2216 | + $sql .= " SET facnumber='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; |
|
| 2217 | + if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date |
|
| 2218 | 2218 | { |
| 2219 | - $sql.= ", datef='".$this->db->idate($this->date)."'"; |
|
| 2220 | - $sql.= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'"; |
|
| 2219 | + $sql .= ", datef='".$this->db->idate($this->date)."'"; |
|
| 2220 | + $sql .= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'"; |
|
| 2221 | 2221 | } |
| 2222 | - $sql.= ' WHERE rowid = '.$this->id; |
|
| 2222 | + $sql .= ' WHERE rowid = '.$this->id; |
|
| 2223 | 2223 | |
| 2224 | 2224 | dol_syslog(get_class($this)."::validate", LOG_DEBUG); |
| 2225 | - $resql=$this->db->query($sql); |
|
| 2226 | - if (! $resql) |
|
| 2225 | + $resql = $this->db->query($sql); |
|
| 2226 | + if (!$resql) |
|
| 2227 | 2227 | { |
| 2228 | 2228 | dol_print_error($this->db); |
| 2229 | 2229 | $error++; |
| 2230 | 2230 | } |
| 2231 | 2231 | |
| 2232 | 2232 | // On verifie si la facture etait une provisoire |
| 2233 | - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) |
|
| 2233 | + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref))) |
|
| 2234 | 2234 | { |
| 2235 | 2235 | // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne |
| 2236 | 2236 | } |
| 2237 | 2237 | |
| 2238 | - if (! $error) |
|
| 2238 | + if (!$error) |
|
| 2239 | 2239 | { |
| 2240 | 2240 | // Define third party as a customer |
| 2241 | - $result=$this->thirdparty->set_as_client(); |
|
| 2241 | + $result = $this->thirdparty->set_as_client(); |
|
| 2242 | 2242 | |
| 2243 | 2243 | // Si active on decremente le produit principal et ses composants a la validation de facture |
| 2244 | - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) |
|
| 2244 | + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) |
|
| 2245 | 2245 | { |
| 2246 | 2246 | require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; |
| 2247 | 2247 | $langs->load("agenda"); |
| 2248 | 2248 | |
| 2249 | 2249 | // Loop on each line |
| 2250 | - $cpt=count($this->lines); |
|
| 2250 | + $cpt = count($this->lines); |
|
| 2251 | 2251 | for ($i = 0; $i < $cpt; $i++) |
| 2252 | 2252 | { |
| 2253 | 2253 | if ($this->lines[$i]->fk_product > 0) |
@@ -2255,8 +2255,8 @@ discard block |
||
| 2255 | 2255 | $mouvP = new MouvementStock($this->db); |
| 2256 | 2256 | $mouvP->origin = &$this; |
| 2257 | 2257 | // We decrease stock for product |
| 2258 | - if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr",$num)); |
|
| 2259 | - else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); |
|
| 2258 | + if ($this->type == self::TYPE_CREDIT_NOTE) $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num)); |
|
| 2259 | + else $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num)); |
|
| 2260 | 2260 | if ($result < 0) { |
| 2261 | 2261 | $error++; |
| 2262 | 2262 | } |
@@ -2266,15 +2266,15 @@ discard block |
||
| 2266 | 2266 | } |
| 2267 | 2267 | |
| 2268 | 2268 | // Trigger calls |
| 2269 | - if (! $error && ! $notrigger) |
|
| 2269 | + if (!$error && !$notrigger) |
|
| 2270 | 2270 | { |
| 2271 | 2271 | // Call trigger |
| 2272 | - $result=$this->call_trigger('BILL_VALIDATE',$user); |
|
| 2272 | + $result = $this->call_trigger('BILL_VALIDATE', $user); |
|
| 2273 | 2273 | if ($result < 0) $error++; |
| 2274 | 2274 | // End call triggers |
| 2275 | 2275 | } |
| 2276 | 2276 | |
| 2277 | - if (! $error) |
|
| 2277 | + if (!$error) |
|
| 2278 | 2278 | { |
| 2279 | 2279 | $this->oldref = $this->ref; |
| 2280 | 2280 | |
@@ -2295,13 +2295,13 @@ discard block |
||
| 2295 | 2295 | { |
| 2296 | 2296 | dol_syslog("Rename ok"); |
| 2297 | 2297 | // Rename docs starting with $oldref with $newref |
| 2298 | - $listoffiles=dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); |
|
| 2299 | - foreach($listoffiles as $fileentry) |
|
| 2298 | + $listoffiles = dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); |
|
| 2299 | + foreach ($listoffiles as $fileentry) |
|
| 2300 | 2300 | { |
| 2301 | - $dirsource=$fileentry['name']; |
|
| 2302 | - $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource); |
|
| 2303 | - $dirsource=$fileentry['path'].'/'.$dirsource; |
|
| 2304 | - $dirdest=$fileentry['path'].'/'.$dirdest; |
|
| 2301 | + $dirsource = $fileentry['name']; |
|
| 2302 | + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); |
|
| 2303 | + $dirsource = $fileentry['path'].'/'.$dirsource; |
|
| 2304 | + $dirdest = $fileentry['path'].'/'.$dirdest; |
|
| 2305 | 2305 | @rename($dirsource, $dirdest); |
| 2306 | 2306 | } |
| 2307 | 2307 | } |
@@ -2309,22 +2309,22 @@ discard block |
||
| 2309 | 2309 | } |
| 2310 | 2310 | } |
| 2311 | 2311 | |
| 2312 | - if (! $error && !$this->is_last_in_cycle()) |
|
| 2312 | + if (!$error && !$this->is_last_in_cycle()) |
|
| 2313 | 2313 | { |
| 2314 | - if (! $this->updatePriceNextInvoice($langs)) |
|
| 2314 | + if (!$this->updatePriceNextInvoice($langs)) |
|
| 2315 | 2315 | { |
| 2316 | 2316 | $error++; |
| 2317 | 2317 | } |
| 2318 | 2318 | } |
| 2319 | 2319 | |
| 2320 | 2320 | // Set new ref and define current statut |
| 2321 | - if (! $error) |
|
| 2321 | + if (!$error) |
|
| 2322 | 2322 | { |
| 2323 | 2323 | $this->ref = $num; |
| 2324 | - $this->facnumber=$num; |
|
| 2325 | - $this->statut= self::STATUS_VALIDATED; |
|
| 2326 | - $this->brouillon=0; |
|
| 2327 | - $this->date_validation=$now; |
|
| 2324 | + $this->facnumber = $num; |
|
| 2325 | + $this->statut = self::STATUS_VALIDATED; |
|
| 2326 | + $this->brouillon = 0; |
|
| 2327 | + $this->date_validation = $now; |
|
| 2328 | 2328 | $i = 0; |
| 2329 | 2329 | |
| 2330 | 2330 | if (!empty($conf->global->INVOICE_USE_SITUATION)) |
@@ -2346,7 +2346,7 @@ discard block |
||
| 2346 | 2346 | $error++; |
| 2347 | 2347 | } |
| 2348 | 2348 | |
| 2349 | - if (! $error) |
|
| 2349 | + if (!$error) |
|
| 2350 | 2350 | { |
| 2351 | 2351 | $this->db->commit(); |
| 2352 | 2352 | return 1; |
@@ -2404,11 +2404,11 @@ discard block |
||
| 2404 | 2404 | * @param int $idwarehouse Id warehouse to use for stock change. |
| 2405 | 2405 | * @return int <0 if KO, >0 if OK |
| 2406 | 2406 | */ |
| 2407 | - function set_draft($user,$idwarehouse=-1) |
|
| 2407 | + function set_draft($user, $idwarehouse = -1) |
|
| 2408 | 2408 | { |
| 2409 | - global $conf,$langs; |
|
| 2409 | + global $conf, $langs; |
|
| 2410 | 2410 | |
| 2411 | - $error=0; |
|
| 2411 | + $error = 0; |
|
| 2412 | 2412 | |
| 2413 | 2413 | if ($this->statut == self::STATUS_DRAFT) |
| 2414 | 2414 | { |
@@ -2419,20 +2419,20 @@ discard block |
||
| 2419 | 2419 | $this->db->begin(); |
| 2420 | 2420 | |
| 2421 | 2421 | $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; |
| 2422 | - $sql.= " SET fk_statut = ".self::STATUS_DRAFT; |
|
| 2423 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 2422 | + $sql .= " SET fk_statut = ".self::STATUS_DRAFT; |
|
| 2423 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 2424 | 2424 | |
| 2425 | 2425 | dol_syslog(get_class($this)."::set_draft", LOG_DEBUG); |
| 2426 | - $result=$this->db->query($sql); |
|
| 2426 | + $result = $this->db->query($sql); |
|
| 2427 | 2427 | if ($result) |
| 2428 | 2428 | { |
| 2429 | 2429 | // Si on decremente le produit principal et ses composants a la validation de facture, on réincrement |
| 2430 | - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) |
|
| 2430 | + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) |
|
| 2431 | 2431 | { |
| 2432 | 2432 | require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; |
| 2433 | 2433 | $langs->load("agenda"); |
| 2434 | 2434 | |
| 2435 | - $num=count($this->lines); |
|
| 2435 | + $num = count($this->lines); |
|
| 2436 | 2436 | for ($i = 0; $i < $num; $i++) |
| 2437 | 2437 | { |
| 2438 | 2438 | if ($this->lines[$i]->fk_product > 0) |
@@ -2440,24 +2440,24 @@ discard block |
||
| 2440 | 2440 | $mouvP = new MouvementStock($this->db); |
| 2441 | 2441 | $mouvP->origin = &$this; |
| 2442 | 2442 | // We decrease stock for product |
| 2443 | - if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); |
|
| 2444 | - else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value |
|
| 2443 | + if ($this->type == self::TYPE_CREDIT_NOTE) $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); |
|
| 2444 | + else $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value |
|
| 2445 | 2445 | } |
| 2446 | 2446 | } |
| 2447 | 2447 | } |
| 2448 | 2448 | |
| 2449 | 2449 | if ($error == 0) |
| 2450 | 2450 | { |
| 2451 | - $old_statut=$this->statut; |
|
| 2451 | + $old_statut = $this->statut; |
|
| 2452 | 2452 | $this->brouillon = 1; |
| 2453 | 2453 | $this->statut = self::STATUS_DRAFT; |
| 2454 | 2454 | // Call trigger |
| 2455 | - $result=$this->call_trigger('BILL_UNVALIDATE',$user); |
|
| 2455 | + $result = $this->call_trigger('BILL_UNVALIDATE', $user); |
|
| 2456 | 2456 | if ($result < 0) |
| 2457 | 2457 | { |
| 2458 | 2458 | $error++; |
| 2459 | - $this->statut=$old_statut; |
|
| 2460 | - $this->brouillon=0; |
|
| 2459 | + $this->statut = $old_statut; |
|
| 2460 | + $this->brouillon = 0; |
|
| 2461 | 2461 | } |
| 2462 | 2462 | // End call triggers |
| 2463 | 2463 | } else { |
@@ -2478,7 +2478,7 @@ discard block |
||
| 2478 | 2478 | } |
| 2479 | 2479 | else |
| 2480 | 2480 | { |
| 2481 | - $this->error=$this->db->error(); |
|
| 2481 | + $this->error = $this->db->error(); |
|
| 2482 | 2482 | $this->db->rollback(); |
| 2483 | 2483 | return -1; |
| 2484 | 2484 | } |
@@ -2523,11 +2523,11 @@ discard block |
||
| 2523 | 2523 | * @param double $pu_ht_devise Unit price in currency |
| 2524 | 2524 | * @return int <0 if KO, Id of line if OK |
| 2525 | 2525 | */ |
| 2526 | - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id='', $fk_unit = null, $pu_ht_devise = 0) |
|
| 2526 | + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = 0, $fk_remise_except = '', $price_base_type = 'HT', $pu_ttc = 0, $type = self::TYPE_STANDARD, $rang = -1, $special_code = 0, $origin = '', $origin_id = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $situation_percent = 100, $fk_prev_id = '', $fk_unit = null, $pu_ht_devise = 0) |
|
| 2527 | 2527 | { |
| 2528 | 2528 | // Deprecation warning |
| 2529 | 2529 | if ($label) { |
| 2530 | - dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); |
|
| 2530 | + dol_syslog(__METHOD__.": using line label is deprecated", LOG_WARNING); |
|
| 2531 | 2531 | } |
| 2532 | 2532 | |
| 2533 | 2533 | global $mysoc, $conf, $langs; |
@@ -2536,63 +2536,63 @@ discard block |
||
| 2536 | 2536 | include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; |
| 2537 | 2537 | |
| 2538 | 2538 | // Clean parameters |
| 2539 | - if (empty($remise_percent)) $remise_percent=0; |
|
| 2540 | - if (empty($qty)) $qty=0; |
|
| 2541 | - if (empty($info_bits)) $info_bits=0; |
|
| 2542 | - if (empty($rang)) $rang=0; |
|
| 2543 | - if (empty($ventil)) $ventil=0; |
|
| 2544 | - if (empty($txtva)) $txtva=0; |
|
| 2545 | - if (empty($txlocaltax1)) $txlocaltax1=0; |
|
| 2546 | - if (empty($txlocaltax2)) $txlocaltax2=0; |
|
| 2547 | - if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; |
|
| 2539 | + if (empty($remise_percent)) $remise_percent = 0; |
|
| 2540 | + if (empty($qty)) $qty = 0; |
|
| 2541 | + if (empty($info_bits)) $info_bits = 0; |
|
| 2542 | + if (empty($rang)) $rang = 0; |
|
| 2543 | + if (empty($ventil)) $ventil = 0; |
|
| 2544 | + if (empty($txtva)) $txtva = 0; |
|
| 2545 | + if (empty($txlocaltax1)) $txlocaltax1 = 0; |
|
| 2546 | + if (empty($txlocaltax2)) $txlocaltax2 = 0; |
|
| 2547 | + if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; |
|
| 2548 | 2548 | if (empty($fk_prev_id)) $fk_prev_id = 'null'; |
| 2549 | - if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; |
|
| 2549 | + if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; |
|
| 2550 | 2550 | |
| 2551 | - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); |
|
| 2551 | + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); |
|
| 2552 | 2552 | |
| 2553 | 2553 | // Clean vat code |
| 2554 | - $vat_src_code=''; |
|
| 2554 | + $vat_src_code = ''; |
|
| 2555 | 2555 | if (preg_match('/\((.*)\)/', $txtva, $reg)) |
| 2556 | 2556 | { |
| 2557 | 2557 | $vat_src_code = $reg[1]; |
| 2558 | - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. |
|
| 2558 | + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. |
|
| 2559 | 2559 | } |
| 2560 | 2560 | |
| 2561 | - $remise_percent=price2num($remise_percent); |
|
| 2562 | - $qty=price2num($qty); |
|
| 2563 | - $pu_ht=price2num($pu_ht); |
|
| 2564 | - $pu_ttc=price2num($pu_ttc); |
|
| 2565 | - $pa_ht=price2num($pa_ht); |
|
| 2566 | - $txtva=price2num($txtva); |
|
| 2567 | - $txlocaltax1=price2num($txlocaltax1); |
|
| 2568 | - $txlocaltax2=price2num($txlocaltax2); |
|
| 2561 | + $remise_percent = price2num($remise_percent); |
|
| 2562 | + $qty = price2num($qty); |
|
| 2563 | + $pu_ht = price2num($pu_ht); |
|
| 2564 | + $pu_ttc = price2num($pu_ttc); |
|
| 2565 | + $pa_ht = price2num($pa_ht); |
|
| 2566 | + $txtva = price2num($txtva); |
|
| 2567 | + $txlocaltax1 = price2num($txlocaltax1); |
|
| 2568 | + $txlocaltax2 = price2num($txlocaltax2); |
|
| 2569 | 2569 | |
| 2570 | - if ($price_base_type=='HT') |
|
| 2570 | + if ($price_base_type == 'HT') |
|
| 2571 | 2571 | { |
| 2572 | - $pu=$pu_ht; |
|
| 2572 | + $pu = $pu_ht; |
|
| 2573 | 2573 | } |
| 2574 | 2574 | else |
| 2575 | 2575 | { |
| 2576 | - $pu=$pu_ttc; |
|
| 2576 | + $pu = $pu_ttc; |
|
| 2577 | 2577 | } |
| 2578 | 2578 | |
| 2579 | 2579 | // Check parameters |
| 2580 | 2580 | if ($type < 0) return -1; |
| 2581 | 2581 | |
| 2582 | - if (! empty($this->brouillon)) |
|
| 2582 | + if (!empty($this->brouillon)) |
|
| 2583 | 2583 | { |
| 2584 | 2584 | $this->db->begin(); |
| 2585 | 2585 | |
| 2586 | - $product_type=$type; |
|
| 2586 | + $product_type = $type; |
|
| 2587 | 2587 | if (!empty($fk_product)) |
| 2588 | 2588 | { |
| 2589 | - $product=new Product($this->db); |
|
| 2590 | - $result=$product->fetch($fk_product); |
|
| 2591 | - $product_type=$product->type; |
|
| 2589 | + $product = new Product($this->db); |
|
| 2590 | + $result = $product->fetch($fk_product); |
|
| 2591 | + $product_type = $product->type; |
|
| 2592 | 2592 | |
| 2593 | - if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { |
|
| 2593 | + if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { |
|
| 2594 | 2594 | $langs->load("errors"); |
| 2595 | - $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); |
|
| 2595 | + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); |
|
| 2596 | 2596 | $this->db->rollback(); |
| 2597 | 2597 | return -3; |
| 2598 | 2598 | } |
@@ -2613,7 +2613,7 @@ discard block |
||
| 2613 | 2613 | $pu_ht = $tabprice[3]; |
| 2614 | 2614 | |
| 2615 | 2615 | // MultiCurrency |
| 2616 | - $multicurrency_total_ht = $tabprice[16]; |
|
| 2616 | + $multicurrency_total_ht = $tabprice[16]; |
|
| 2617 | 2617 | $multicurrency_total_tva = $tabprice[17]; |
| 2618 | 2618 | $multicurrency_total_ttc = $tabprice[18]; |
| 2619 | 2619 | $pu_ht_devise = $tabprice[19]; |
@@ -2627,72 +2627,72 @@ discard block |
||
| 2627 | 2627 | } |
| 2628 | 2628 | |
| 2629 | 2629 | // Insert line |
| 2630 | - $this->line=new FactureLigne($this->db); |
|
| 2630 | + $this->line = new FactureLigne($this->db); |
|
| 2631 | 2631 | |
| 2632 | 2632 | $this->line->context = $this->context; |
| 2633 | 2633 | |
| 2634 | - $this->line->fk_facture=$this->id; |
|
| 2635 | - $this->line->label=$label; // deprecated |
|
| 2636 | - $this->line->desc=$desc; |
|
| 2634 | + $this->line->fk_facture = $this->id; |
|
| 2635 | + $this->line->label = $label; // deprecated |
|
| 2636 | + $this->line->desc = $desc; |
|
| 2637 | 2637 | |
| 2638 | - $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative |
|
| 2639 | - $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise |
|
| 2638 | + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative |
|
| 2639 | + $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise |
|
| 2640 | 2640 | |
| 2641 | - $this->line->vat_src_code=$vat_src_code; |
|
| 2642 | - $this->line->tva_tx=$txtva; |
|
| 2643 | - $this->line->localtax1_tx=$txlocaltax1; |
|
| 2644 | - $this->line->localtax2_tx=$txlocaltax2; |
|
| 2641 | + $this->line->vat_src_code = $vat_src_code; |
|
| 2642 | + $this->line->tva_tx = $txtva; |
|
| 2643 | + $this->line->localtax1_tx = $txlocaltax1; |
|
| 2644 | + $this->line->localtax2_tx = $txlocaltax2; |
|
| 2645 | 2645 | $this->line->localtax1_type = $localtaxes_type[0]; |
| 2646 | 2646 | $this->line->localtax2_type = $localtaxes_type[2]; |
| 2647 | 2647 | |
| 2648 | - $this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative |
|
| 2649 | - $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); // For credit note and if qty is negative, total is negative |
|
| 2650 | - $this->line->total_tva= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); // For credit note and if qty is negative, total is negative |
|
| 2651 | - $this->line->total_localtax1=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax1):$total_localtax1); // For credit note and if qty is negative, total is negative |
|
| 2652 | - $this->line->total_localtax2=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax2):$total_localtax2); // For credit note and if qty is negative, total is negative |
|
| 2653 | - |
|
| 2654 | - $this->line->fk_product=$fk_product; |
|
| 2655 | - $this->line->product_type=$product_type; |
|
| 2656 | - $this->line->remise_percent=$remise_percent; |
|
| 2657 | - $this->line->date_start=$date_start; |
|
| 2658 | - $this->line->date_end=$date_end; |
|
| 2659 | - $this->line->ventil=$ventil; |
|
| 2660 | - $this->line->rang=$rangtouse; |
|
| 2661 | - $this->line->info_bits=$info_bits; |
|
| 2662 | - $this->line->fk_remise_except=$fk_remise_except; |
|
| 2663 | - |
|
| 2664 | - $this->line->special_code=$special_code; |
|
| 2665 | - $this->line->fk_parent_line=$fk_parent_line; |
|
| 2666 | - $this->line->origin=$origin; |
|
| 2667 | - $this->line->origin_id=$origin_id; |
|
| 2648 | + $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative |
|
| 2649 | + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative |
|
| 2650 | + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva); // For credit note and if qty is negative, total is negative |
|
| 2651 | + $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax1) : $total_localtax1); // For credit note and if qty is negative, total is negative |
|
| 2652 | + $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax2) : $total_localtax2); // For credit note and if qty is negative, total is negative |
|
| 2653 | + |
|
| 2654 | + $this->line->fk_product = $fk_product; |
|
| 2655 | + $this->line->product_type = $product_type; |
|
| 2656 | + $this->line->remise_percent = $remise_percent; |
|
| 2657 | + $this->line->date_start = $date_start; |
|
| 2658 | + $this->line->date_end = $date_end; |
|
| 2659 | + $this->line->ventil = $ventil; |
|
| 2660 | + $this->line->rang = $rangtouse; |
|
| 2661 | + $this->line->info_bits = $info_bits; |
|
| 2662 | + $this->line->fk_remise_except = $fk_remise_except; |
|
| 2663 | + |
|
| 2664 | + $this->line->special_code = $special_code; |
|
| 2665 | + $this->line->fk_parent_line = $fk_parent_line; |
|
| 2666 | + $this->line->origin = $origin; |
|
| 2667 | + $this->line->origin_id = $origin_id; |
|
| 2668 | 2668 | $this->line->situation_percent = $situation_percent; |
| 2669 | 2669 | $this->line->fk_prev_id = $fk_prev_id; |
| 2670 | - $this->line->fk_unit=$fk_unit; |
|
| 2670 | + $this->line->fk_unit = $fk_unit; |
|
| 2671 | 2671 | |
| 2672 | 2672 | // infos marge |
| 2673 | 2673 | $this->line->fk_fournprice = $fk_fournprice; |
| 2674 | 2674 | $this->line->pa_ht = $pa_ht; |
| 2675 | 2675 | |
| 2676 | 2676 | // Multicurrency |
| 2677 | - $this->line->fk_multicurrency = $this->fk_multicurrency; |
|
| 2678 | - $this->line->multicurrency_code = $this->multicurrency_code; |
|
| 2677 | + $this->line->fk_multicurrency = $this->fk_multicurrency; |
|
| 2678 | + $this->line->multicurrency_code = $this->multicurrency_code; |
|
| 2679 | 2679 | $this->line->multicurrency_subprice = $pu_ht_devise; |
| 2680 | 2680 | $this->line->multicurrency_total_ht = $multicurrency_total_ht; |
| 2681 | 2681 | $this->line->multicurrency_total_tva = $multicurrency_total_tva; |
| 2682 | 2682 | $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; |
| 2683 | 2683 | |
| 2684 | - if (is_array($array_options) && count($array_options)>0) { |
|
| 2685 | - $this->line->array_options=$array_options; |
|
| 2684 | + if (is_array($array_options) && count($array_options) > 0) { |
|
| 2685 | + $this->line->array_options = $array_options; |
|
| 2686 | 2686 | } |
| 2687 | 2687 | |
| 2688 | - $result=$this->line->insert(); |
|
| 2688 | + $result = $this->line->insert(); |
|
| 2689 | 2689 | if ($result > 0) |
| 2690 | 2690 | { |
| 2691 | 2691 | // Reorder if child line |
| 2692 | - if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); |
|
| 2692 | + if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); |
|
| 2693 | 2693 | |
| 2694 | 2694 | // Mise a jour informations denormalisees au niveau de la facture meme |
| 2695 | - $result=$this->update_price(1,'auto',0,$mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. |
|
| 2695 | + $result = $this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. |
|
| 2696 | 2696 | if ($result > 0) |
| 2697 | 2697 | { |
| 2698 | 2698 | $this->db->commit(); |
@@ -2700,14 +2700,14 @@ discard block |
||
| 2700 | 2700 | } |
| 2701 | 2701 | else |
| 2702 | 2702 | { |
| 2703 | - $this->error=$this->db->error(); |
|
| 2703 | + $this->error = $this->db->error(); |
|
| 2704 | 2704 | $this->db->rollback(); |
| 2705 | 2705 | return -1; |
| 2706 | 2706 | } |
| 2707 | 2707 | } |
| 2708 | 2708 | else |
| 2709 | 2709 | { |
| 2710 | - $this->error=$this->line->error; |
|
| 2710 | + $this->error = $this->line->error; |
|
| 2711 | 2711 | $this->db->rollback(); |
| 2712 | 2712 | return -2; |
| 2713 | 2713 | } |
@@ -2748,17 +2748,17 @@ discard block |
||
| 2748 | 2748 | * @param int $notrigger disable line update trigger |
| 2749 | 2749 | * @return int < 0 if KO, > 0 if OK |
| 2750 | 2750 | */ |
| 2751 | - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=100, $fk_unit = null, $pu_ht_devise = 0, $notrigger=0) |
|
| 2751 | + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) |
|
| 2752 | 2752 | { |
| 2753 | - global $conf,$user; |
|
| 2753 | + global $conf, $user; |
|
| 2754 | 2754 | // Deprecation warning |
| 2755 | 2755 | if ($label) { |
| 2756 | - dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); |
|
| 2756 | + dol_syslog(__METHOD__.": using line label is deprecated", LOG_WARNING); |
|
| 2757 | 2757 | } |
| 2758 | 2758 | |
| 2759 | 2759 | include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; |
| 2760 | 2760 | |
| 2761 | - global $mysoc,$langs; |
|
| 2761 | + global $mysoc, $langs; |
|
| 2762 | 2762 | |
| 2763 | 2763 | dol_syslog(get_class($this)."::updateline rowid=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, date_start=$date_start, date_end=$date_end, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, type=$type, fk_parent_line=$fk_parent_line pa_ht=$pa_ht, special_code=$special_code, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); |
| 2764 | 2764 | |
@@ -2768,7 +2768,7 @@ discard block |
||
| 2768 | 2768 | { |
| 2769 | 2769 | if (!$this->checkProgressLine($rowid, $situation_percent)) |
| 2770 | 2770 | { |
| 2771 | - if (!$this->error) $this->error=$langs->trans('invoiceLineProgressError'); |
|
| 2771 | + if (!$this->error) $this->error = $langs->trans('invoiceLineProgressError'); |
|
| 2772 | 2772 | return -3; |
| 2773 | 2773 | } |
| 2774 | 2774 | } |
@@ -2776,12 +2776,12 @@ discard block |
||
| 2776 | 2776 | $this->db->begin(); |
| 2777 | 2777 | |
| 2778 | 2778 | // Clean parameters |
| 2779 | - if (empty($qty)) $qty=0; |
|
| 2780 | - if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; |
|
| 2781 | - if (empty($special_code) || $special_code == 3) $special_code=0; |
|
| 2782 | - if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; |
|
| 2779 | + if (empty($qty)) $qty = 0; |
|
| 2780 | + if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; |
|
| 2781 | + if (empty($special_code) || $special_code == 3) $special_code = 0; |
|
| 2782 | + if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; |
|
| 2783 | 2783 | |
| 2784 | - $remise_percent = price2num($remise_percent); |
|
| 2784 | + $remise_percent = price2num($remise_percent); |
|
| 2785 | 2785 | $qty = price2num($qty); |
| 2786 | 2786 | $pu = price2num($pu); |
| 2787 | 2787 | $pa_ht = price2num($pa_ht); |
@@ -2796,29 +2796,29 @@ discard block |
||
| 2796 | 2796 | // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker |
| 2797 | 2797 | // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. |
| 2798 | 2798 | |
| 2799 | - $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc); |
|
| 2799 | + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); |
|
| 2800 | 2800 | |
| 2801 | 2801 | // Clean vat code |
| 2802 | - $vat_src_code=''; |
|
| 2802 | + $vat_src_code = ''; |
|
| 2803 | 2803 | if (preg_match('/\((.*)\)/', $txtva, $reg)) |
| 2804 | 2804 | { |
| 2805 | 2805 | $vat_src_code = $reg[1]; |
| 2806 | - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. |
|
| 2806 | + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. |
|
| 2807 | 2807 | } |
| 2808 | 2808 | |
| 2809 | - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); |
|
| 2809 | + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); |
|
| 2810 | 2810 | |
| 2811 | 2811 | $total_ht = $tabprice[0]; |
| 2812 | 2812 | $total_tva = $tabprice[1]; |
| 2813 | 2813 | $total_ttc = $tabprice[2]; |
| 2814 | - $total_localtax1=$tabprice[9]; |
|
| 2815 | - $total_localtax2=$tabprice[10]; |
|
| 2814 | + $total_localtax1 = $tabprice[9]; |
|
| 2815 | + $total_localtax2 = $tabprice[10]; |
|
| 2816 | 2816 | $pu_ht = $tabprice[3]; |
| 2817 | 2817 | $pu_tva = $tabprice[4]; |
| 2818 | 2818 | $pu_ttc = $tabprice[5]; |
| 2819 | 2819 | |
| 2820 | 2820 | // MultiCurrency |
| 2821 | - $multicurrency_total_ht = $tabprice[16]; |
|
| 2821 | + $multicurrency_total_ht = $tabprice[16]; |
|
| 2822 | 2822 | $multicurrency_total_tva = $tabprice[17]; |
| 2823 | 2823 | $multicurrency_total_ttc = $tabprice[18]; |
| 2824 | 2824 | $pu_ht_devise = $tabprice[19]; |
@@ -2828,10 +2828,10 @@ discard block |
||
| 2828 | 2828 | $remise = 0; |
| 2829 | 2829 | if ($remise_percent > 0) |
| 2830 | 2830 | { |
| 2831 | - $remise = round(($pu * $remise_percent / 100),2); |
|
| 2831 | + $remise = round(($pu * $remise_percent / 100), 2); |
|
| 2832 | 2832 | $price = ($pu - $remise); |
| 2833 | 2833 | } |
| 2834 | - $price = price2num($price); |
|
| 2834 | + $price = price2num($price); |
|
| 2835 | 2835 | |
| 2836 | 2836 | //Fetch current line from the database and then clone the object and set it in $oldline property |
| 2837 | 2837 | $line = new FactureLigne($this->db); |
@@ -2839,13 +2839,13 @@ discard block |
||
| 2839 | 2839 | |
| 2840 | 2840 | if (!empty($line->fk_product)) |
| 2841 | 2841 | { |
| 2842 | - $product=new Product($this->db); |
|
| 2843 | - $result=$product->fetch($line->fk_product); |
|
| 2844 | - $product_type=$product->type; |
|
| 2842 | + $product = new Product($this->db); |
|
| 2843 | + $result = $product->fetch($line->fk_product); |
|
| 2844 | + $product_type = $product->type; |
|
| 2845 | 2845 | |
| 2846 | - if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { |
|
| 2846 | + if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { |
|
| 2847 | 2847 | $langs->load("errors"); |
| 2848 | - $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); |
|
| 2848 | + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); |
|
| 2849 | 2849 | $this->db->rollback(); |
| 2850 | 2850 | return -3; |
| 2851 | 2851 | } |
@@ -2858,7 +2858,7 @@ discard block |
||
| 2858 | 2858 | $this->line->context = $this->context; |
| 2859 | 2859 | |
| 2860 | 2860 | // Reorder if fk_parent_line change |
| 2861 | - if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) |
|
| 2861 | + if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) |
|
| 2862 | 2862 | { |
| 2863 | 2863 | $rangmax = $this->line_max($fk_parent_line); |
| 2864 | 2864 | $this->line->rang = $rangmax + 1; |
@@ -2866,32 +2866,32 @@ discard block |
||
| 2866 | 2866 | |
| 2867 | 2867 | $this->line->rowid = $rowid; |
| 2868 | 2868 | $this->line->label = $label; |
| 2869 | - $this->line->desc = $desc; |
|
| 2870 | - $this->line->qty = ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative |
|
| 2869 | + $this->line->desc = $desc; |
|
| 2870 | + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative |
|
| 2871 | 2871 | |
| 2872 | - $this->line->vat_src_code = $vat_src_code; |
|
| 2873 | - $this->line->tva_tx = $txtva; |
|
| 2872 | + $this->line->vat_src_code = $vat_src_code; |
|
| 2873 | + $this->line->tva_tx = $txtva; |
|
| 2874 | 2874 | $this->line->localtax1_tx = $txlocaltax1; |
| 2875 | 2875 | $this->line->localtax2_tx = $txlocaltax2; |
| 2876 | 2876 | $this->line->localtax1_type = $localtaxes_type[0]; |
| 2877 | 2877 | $this->line->localtax2_type = $localtaxes_type[2]; |
| 2878 | 2878 | |
| 2879 | 2879 | $this->line->remise_percent = $remise_percent; |
| 2880 | - $this->line->subprice = ($this->type==2?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise |
|
| 2881 | - $this->line->date_start = $date_start; |
|
| 2880 | + $this->line->subprice = ($this->type == 2 ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise |
|
| 2881 | + $this->line->date_start = $date_start; |
|
| 2882 | 2882 | $this->line->date_end = $date_end; |
| 2883 | - $this->line->total_ht = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative |
|
| 2884 | - $this->line->total_tva = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); |
|
| 2883 | + $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative |
|
| 2884 | + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva); |
|
| 2885 | 2885 | $this->line->total_localtax1 = $total_localtax1; |
| 2886 | 2886 | $this->line->total_localtax2 = $total_localtax2; |
| 2887 | - $this->line->total_ttc = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); |
|
| 2887 | + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); |
|
| 2888 | 2888 | $this->line->info_bits = $info_bits; |
| 2889 | 2889 | $this->line->special_code = $special_code; |
| 2890 | 2890 | $this->line->product_type = $type; |
| 2891 | - $this->line->fk_parent_line = $fk_parent_line; |
|
| 2892 | - $this->line->skip_update_total = $skip_update_total; |
|
| 2893 | - $this->line->situation_percent = $situation_percent; |
|
| 2894 | - $this->line->fk_unit = $fk_unit; |
|
| 2891 | + $this->line->fk_parent_line = $fk_parent_line; |
|
| 2892 | + $this->line->skip_update_total = $skip_update_total; |
|
| 2893 | + $this->line->situation_percent = $situation_percent; |
|
| 2894 | + $this->line->fk_unit = $fk_unit; |
|
| 2895 | 2895 | |
| 2896 | 2896 | $this->line->fk_fournprice = $fk_fournprice; |
| 2897 | 2897 | $this->line->pa_ht = $pa_ht; |
@@ -2902,15 +2902,15 @@ discard block |
||
| 2902 | 2902 | $this->line->multicurrency_total_tva = $multicurrency_total_tva; |
| 2903 | 2903 | $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; |
| 2904 | 2904 | |
| 2905 | - if (is_array($array_options) && count($array_options)>0) { |
|
| 2906 | - $this->line->array_options=$array_options; |
|
| 2905 | + if (is_array($array_options) && count($array_options) > 0) { |
|
| 2906 | + $this->line->array_options = $array_options; |
|
| 2907 | 2907 | } |
| 2908 | 2908 | |
| 2909 | - $result=$this->line->update($user, $notrigger); |
|
| 2909 | + $result = $this->line->update($user, $notrigger); |
|
| 2910 | 2910 | if ($result > 0) |
| 2911 | 2911 | { |
| 2912 | 2912 | // Reorder if child line |
| 2913 | - if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); |
|
| 2913 | + if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); |
|
| 2914 | 2914 | |
| 2915 | 2915 | // Mise a jour info denormalisees au niveau facture |
| 2916 | 2916 | $this->update_price(1); |
@@ -2919,14 +2919,14 @@ discard block |
||
| 2919 | 2919 | } |
| 2920 | 2920 | else |
| 2921 | 2921 | { |
| 2922 | - $this->error=$this->line->error; |
|
| 2922 | + $this->error = $this->line->error; |
|
| 2923 | 2923 | $this->db->rollback(); |
| 2924 | 2924 | return -1; |
| 2925 | 2925 | } |
| 2926 | 2926 | } |
| 2927 | 2927 | else |
| 2928 | 2928 | { |
| 2929 | - $this->error="Invoice statut makes operation forbidden"; |
|
| 2929 | + $this->error = "Invoice statut makes operation forbidden"; |
|
| 2930 | 2930 | return -2; |
| 2931 | 2931 | } |
| 2932 | 2932 | } |
@@ -2946,9 +2946,9 @@ discard block |
||
| 2946 | 2946 | AND f.fk_statut <> 0'; |
| 2947 | 2947 | |
| 2948 | 2948 | $result = $this->db->query($sql); |
| 2949 | - if (! $result) |
|
| 2949 | + if (!$result) |
|
| 2950 | 2950 | { |
| 2951 | - $this->error=$this->db->error(); |
|
| 2951 | + $this->error = $this->db->error(); |
|
| 2952 | 2952 | return false; |
| 2953 | 2953 | } |
| 2954 | 2954 | |
@@ -2967,9 +2967,9 @@ discard block |
||
| 2967 | 2967 | */ |
| 2968 | 2968 | function update_percent($line, $percent) |
| 2969 | 2969 | { |
| 2970 | - global $mysoc,$user; |
|
| 2970 | + global $mysoc, $user; |
|
| 2971 | 2971 | |
| 2972 | - include_once(DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'); |
|
| 2972 | + include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'); |
|
| 2973 | 2973 | |
| 2974 | 2974 | // Cap percentages to 100 |
| 2975 | 2975 | if ($percent > 100) $percent = 100; |
@@ -2997,9 +2997,9 @@ discard block |
||
| 2997 | 2997 | |
| 2998 | 2998 | dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG); |
| 2999 | 2999 | |
| 3000 | - if (! $this->brouillon) |
|
| 3000 | + if (!$this->brouillon) |
|
| 3001 | 3001 | { |
| 3002 | - $this->error='ErrorBadStatus'; |
|
| 3002 | + $this->error = 'ErrorBadStatus'; |
|
| 3003 | 3003 | return -1; |
| 3004 | 3004 | } |
| 3005 | 3005 | |
@@ -3007,29 +3007,29 @@ discard block |
||
| 3007 | 3007 | |
| 3008 | 3008 | // Libere remise liee a ligne de facture |
| 3009 | 3009 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; |
| 3010 | - $sql.= ' SET fk_facture_line = NULL'; |
|
| 3011 | - $sql.= ' WHERE fk_facture_line = '.$rowid; |
|
| 3010 | + $sql .= ' SET fk_facture_line = NULL'; |
|
| 3011 | + $sql .= ' WHERE fk_facture_line = '.$rowid; |
|
| 3012 | 3012 | |
| 3013 | 3013 | dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); |
| 3014 | 3014 | $result = $this->db->query($sql); |
| 3015 | - if (! $result) |
|
| 3015 | + if (!$result) |
|
| 3016 | 3016 | { |
| 3017 | - $this->error=$this->db->error(); |
|
| 3017 | + $this->error = $this->db->error(); |
|
| 3018 | 3018 | $this->db->rollback(); |
| 3019 | 3019 | return -1; |
| 3020 | 3020 | } |
| 3021 | 3021 | |
| 3022 | - $line=new FactureLigne($this->db); |
|
| 3022 | + $line = new FactureLigne($this->db); |
|
| 3023 | 3023 | |
| 3024 | 3024 | $line->context = $this->context; |
| 3025 | 3025 | |
| 3026 | 3026 | // For triggers |
| 3027 | 3027 | $result = $line->fetch($rowid); |
| 3028 | - if (! ($result > 0)) dol_print_error($db, $line->error, $line->errors); |
|
| 3028 | + if (!($result > 0)) dol_print_error($db, $line->error, $line->errors); |
|
| 3029 | 3029 | |
| 3030 | 3030 | if ($line->delete($user) > 0) |
| 3031 | 3031 | { |
| 3032 | - $result=$this->update_price(1); |
|
| 3032 | + $result = $this->update_price(1); |
|
| 3033 | 3033 | |
| 3034 | 3034 | if ($result > 0) |
| 3035 | 3035 | { |
@@ -3039,14 +3039,14 @@ discard block |
||
| 3039 | 3039 | else |
| 3040 | 3040 | { |
| 3041 | 3041 | $this->db->rollback(); |
| 3042 | - $this->error=$this->db->lasterror(); |
|
| 3042 | + $this->error = $this->db->lasterror(); |
|
| 3043 | 3043 | return -1; |
| 3044 | 3044 | } |
| 3045 | 3045 | } |
| 3046 | 3046 | else |
| 3047 | 3047 | { |
| 3048 | 3048 | $this->db->rollback(); |
| 3049 | - $this->error=$line->error; |
|
| 3049 | + $this->error = $line->error; |
|
| 3050 | 3050 | return -1; |
| 3051 | 3051 | } |
| 3052 | 3052 | } |
@@ -3059,41 +3059,41 @@ discard block |
||
| 3059 | 3059 | * @param int $notrigger 1=Does not execute triggers, 0= execute triggers |
| 3060 | 3060 | * @return int <0 if ko, >0 if ok |
| 3061 | 3061 | */ |
| 3062 | - function set_remise($user, $remise, $notrigger=0) |
|
| 3062 | + function set_remise($user, $remise, $notrigger = 0) |
|
| 3063 | 3063 | { |
| 3064 | 3064 | // Clean parameters |
| 3065 | - if (empty($remise)) $remise=0; |
|
| 3065 | + if (empty($remise)) $remise = 0; |
|
| 3066 | 3066 | |
| 3067 | 3067 | if ($user->rights->facture->creer) |
| 3068 | 3068 | { |
| 3069 | - $remise=price2num($remise); |
|
| 3069 | + $remise = price2num($remise); |
|
| 3070 | 3070 | |
| 3071 | - $error=0; |
|
| 3071 | + $error = 0; |
|
| 3072 | 3072 | |
| 3073 | 3073 | $this->db->begin(); |
| 3074 | 3074 | |
| 3075 | 3075 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; |
| 3076 | - $sql.= ' SET remise_percent = '.$remise; |
|
| 3077 | - $sql.= ' WHERE rowid = '.$this->id; |
|
| 3078 | - $sql.= ' AND fk_statut = '.self::STATUS_DRAFT; |
|
| 3076 | + $sql .= ' SET remise_percent = '.$remise; |
|
| 3077 | + $sql .= ' WHERE rowid = '.$this->id; |
|
| 3078 | + $sql .= ' AND fk_statut = '.self::STATUS_DRAFT; |
|
| 3079 | 3079 | |
| 3080 | 3080 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 3081 | - $resql=$this->db->query($sql); |
|
| 3081 | + $resql = $this->db->query($sql); |
|
| 3082 | 3082 | if (!$resql) |
| 3083 | 3083 | { |
| 3084 | - $this->errors[]=$this->db->error(); |
|
| 3084 | + $this->errors[] = $this->db->error(); |
|
| 3085 | 3085 | $error++; |
| 3086 | 3086 | } |
| 3087 | 3087 | |
| 3088 | - if (! $notrigger && empty($error)) |
|
| 3088 | + if (!$notrigger && empty($error)) |
|
| 3089 | 3089 | { |
| 3090 | 3090 | // Call trigger |
| 3091 | - $result=$this->call_trigger('BILL_MODIFY',$user); |
|
| 3091 | + $result = $this->call_trigger('BILL_MODIFY', $user); |
|
| 3092 | 3092 | if ($result < 0) $error++; |
| 3093 | 3093 | // End call triggers |
| 3094 | 3094 | } |
| 3095 | 3095 | |
| 3096 | - if (! $error) |
|
| 3096 | + if (!$error) |
|
| 3097 | 3097 | { |
| 3098 | 3098 | $this->remise_percent = $remise; |
| 3099 | 3099 | $this->update_price(1); |
@@ -3103,13 +3103,13 @@ discard block |
||
| 3103 | 3103 | } |
| 3104 | 3104 | else |
| 3105 | 3105 | { |
| 3106 | - foreach($this->errors as $errmsg) |
|
| 3106 | + foreach ($this->errors as $errmsg) |
|
| 3107 | 3107 | { |
| 3108 | 3108 | dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); |
| 3109 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 3109 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 3110 | 3110 | } |
| 3111 | 3111 | $this->db->rollback(); |
| 3112 | - return -1*$error; |
|
| 3112 | + return -1 * $error; |
|
| 3113 | 3113 | } |
| 3114 | 3114 | } |
| 3115 | 3115 | } |
@@ -3123,60 +3123,60 @@ discard block |
||
| 3123 | 3123 | * @param int $notrigger 1=Does not execute triggers, 0= execute triggers |
| 3124 | 3124 | * @return int <0 if KO, >0 if OK |
| 3125 | 3125 | */ |
| 3126 | - function set_remise_absolue($user, $remise, $notrigger=0) |
|
| 3126 | + function set_remise_absolue($user, $remise, $notrigger = 0) |
|
| 3127 | 3127 | { |
| 3128 | - if (empty($remise)) $remise=0; |
|
| 3128 | + if (empty($remise)) $remise = 0; |
|
| 3129 | 3129 | |
| 3130 | 3130 | if ($user->rights->facture->creer) |
| 3131 | 3131 | { |
| 3132 | - $error=0; |
|
| 3132 | + $error = 0; |
|
| 3133 | 3133 | |
| 3134 | 3134 | $this->db->begin(); |
| 3135 | 3135 | |
| 3136 | - $remise=price2num($remise); |
|
| 3136 | + $remise = price2num($remise); |
|
| 3137 | 3137 | |
| 3138 | 3138 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; |
| 3139 | - $sql.= ' SET remise_absolue = '.$remise; |
|
| 3140 | - $sql.= ' WHERE rowid = '.$this->id; |
|
| 3141 | - $sql.= ' AND fk_statut = '.self::STATUS_DRAFT; |
|
| 3139 | + $sql .= ' SET remise_absolue = '.$remise; |
|
| 3140 | + $sql .= ' WHERE rowid = '.$this->id; |
|
| 3141 | + $sql .= ' AND fk_statut = '.self::STATUS_DRAFT; |
|
| 3142 | 3142 | |
| 3143 | 3143 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 3144 | - $resql=$this->db->query($sql); |
|
| 3144 | + $resql = $this->db->query($sql); |
|
| 3145 | 3145 | if (!$resql) |
| 3146 | 3146 | { |
| 3147 | - $this->errors[]=$this->db->error(); |
|
| 3147 | + $this->errors[] = $this->db->error(); |
|
| 3148 | 3148 | $error++; |
| 3149 | 3149 | } |
| 3150 | 3150 | |
| 3151 | - if (! $error) |
|
| 3151 | + if (!$error) |
|
| 3152 | 3152 | { |
| 3153 | - $this->oldcopy= clone $this; |
|
| 3153 | + $this->oldcopy = clone $this; |
|
| 3154 | 3154 | $this->remise_absolue = $remise; |
| 3155 | 3155 | $this->update_price(1); |
| 3156 | 3156 | } |
| 3157 | 3157 | |
| 3158 | - if (! $notrigger && empty($error)) |
|
| 3158 | + if (!$notrigger && empty($error)) |
|
| 3159 | 3159 | { |
| 3160 | 3160 | // Call trigger |
| 3161 | - $result=$this->call_trigger('BILL_MODIFY',$user); |
|
| 3161 | + $result = $this->call_trigger('BILL_MODIFY', $user); |
|
| 3162 | 3162 | if ($result < 0) $error++; |
| 3163 | 3163 | // End call triggers |
| 3164 | 3164 | } |
| 3165 | 3165 | |
| 3166 | - if (! $error) |
|
| 3166 | + if (!$error) |
|
| 3167 | 3167 | { |
| 3168 | 3168 | $this->db->commit(); |
| 3169 | 3169 | return 1; |
| 3170 | 3170 | } |
| 3171 | 3171 | else |
| 3172 | 3172 | { |
| 3173 | - foreach($this->errors as $errmsg) |
|
| 3173 | + foreach ($this->errors as $errmsg) |
|
| 3174 | 3174 | { |
| 3175 | 3175 | dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); |
| 3176 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 3176 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 3177 | 3177 | } |
| 3178 | 3178 | $this->db->rollback(); |
| 3179 | - return -1*$error; |
|
| 3179 | + return -1 * $error; |
|
| 3180 | 3180 | } |
| 3181 | 3181 | } |
| 3182 | 3182 | } |
@@ -3187,43 +3187,43 @@ discard block |
||
| 3187 | 3187 | * @param string $filtertype 1 to filter on type of payment == 'PRE' |
| 3188 | 3188 | * @return array Array with list of payments |
| 3189 | 3189 | */ |
| 3190 | - function getListOfPayments($filtertype='') |
|
| 3190 | + function getListOfPayments($filtertype = '') |
|
| 3191 | 3191 | { |
| 3192 | - $retarray=array(); |
|
| 3192 | + $retarray = array(); |
|
| 3193 | 3193 | |
| 3194 | - $table='paiement_facture'; |
|
| 3195 | - $table2='paiement'; |
|
| 3196 | - $field='fk_facture'; |
|
| 3197 | - $field2='fk_paiement'; |
|
| 3198 | - $sharedentity='facture'; |
|
| 3194 | + $table = 'paiement_facture'; |
|
| 3195 | + $table2 = 'paiement'; |
|
| 3196 | + $field = 'fk_facture'; |
|
| 3197 | + $field2 = 'fk_paiement'; |
|
| 3198 | + $sharedentity = 'facture'; |
|
| 3199 | 3199 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
| 3200 | 3200 | { |
| 3201 | - $table='paiementfourn_facturefourn'; |
|
| 3202 | - $table2='paiementfourn'; |
|
| 3203 | - $field='fk_facturefourn'; |
|
| 3204 | - $field2='fk_paiementfourn'; |
|
| 3205 | - $sharedentity='facture_fourn'; |
|
| 3201 | + $table = 'paiementfourn_facturefourn'; |
|
| 3202 | + $table2 = 'paiementfourn'; |
|
| 3203 | + $field = 'fk_facturefourn'; |
|
| 3204 | + $field2 = 'fk_paiementfourn'; |
|
| 3205 | + $sharedentity = 'facture_fourn'; |
|
| 3206 | 3206 | } |
| 3207 | 3207 | |
| 3208 | 3208 | $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'; |
| 3209 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
| 3210 | - $sql.= ' WHERE pf.'.$field.' = '.$this->id; |
|
| 3209 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
| 3210 | + $sql .= ' WHERE pf.'.$field.' = '.$this->id; |
|
| 3211 | 3211 | //$sql.= ' WHERE pf.'.$field.' = 1'; |
| 3212 | - $sql.= ' AND pf.'.$field2.' = p.rowid'; |
|
| 3213 | - $sql.= ' AND p.fk_paiement = t.id'; |
|
| 3214 | - $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; |
|
| 3215 | - if ($filtertype) $sql.=" AND t.code='PRE'"; |
|
| 3212 | + $sql .= ' AND pf.'.$field2.' = p.rowid'; |
|
| 3213 | + $sql .= ' AND p.fk_paiement = t.id'; |
|
| 3214 | + $sql .= ' AND p.entity IN ('.getEntity($sharedentity).')'; |
|
| 3215 | + if ($filtertype) $sql .= " AND t.code='PRE'"; |
|
| 3216 | 3216 | |
| 3217 | 3217 | dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); |
| 3218 | - $resql=$this->db->query($sql); |
|
| 3218 | + $resql = $this->db->query($sql); |
|
| 3219 | 3219 | if ($resql) |
| 3220 | 3220 | { |
| 3221 | 3221 | $num = $this->db->num_rows($resql); |
| 3222 | - $i=0; |
|
| 3222 | + $i = 0; |
|
| 3223 | 3223 | while ($i < $num) |
| 3224 | 3224 | { |
| 3225 | 3225 | $obj = $this->db->fetch_object($resql); |
| 3226 | - $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
| 3226 | + $retarray[] = array('amount'=>$obj->amount, 'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
| 3227 | 3227 | $i++; |
| 3228 | 3228 | } |
| 3229 | 3229 | $this->db->free($resql); |
@@ -3231,7 +3231,7 @@ discard block |
||
| 3231 | 3231 | } |
| 3232 | 3232 | else |
| 3233 | 3233 | { |
| 3234 | - $this->error=$this->db->lasterror(); |
|
| 3234 | + $this->error = $this->db->lasterror(); |
|
| 3235 | 3235 | dol_print_error($this->db); |
| 3236 | 3236 | return array(); |
| 3237 | 3237 | } |
@@ -3246,21 +3246,21 @@ discard block |
||
| 3246 | 3246 | * @param string $mode 'next' for next value or 'last' for last value |
| 3247 | 3247 | * @return string free ref or last ref |
| 3248 | 3248 | */ |
| 3249 | - function getNextNumRef($soc,$mode='next') |
|
| 3249 | + function getNextNumRef($soc, $mode = 'next') |
|
| 3250 | 3250 | { |
| 3251 | 3251 | global $conf, $langs; |
| 3252 | 3252 | $langs->load("bills"); |
| 3253 | 3253 | |
| 3254 | 3254 | // Clean parameters (if not defined or using deprecated value) |
| 3255 | - if (empty($conf->global->FACTURE_ADDON)) $conf->global->FACTURE_ADDON='mod_facture_terre'; |
|
| 3256 | - else if ($conf->global->FACTURE_ADDON=='terre') $conf->global->FACTURE_ADDON='mod_facture_terre'; |
|
| 3257 | - else if ($conf->global->FACTURE_ADDON=='mercure') $conf->global->FACTURE_ADDON='mod_facture_mercure'; |
|
| 3255 | + if (empty($conf->global->FACTURE_ADDON)) $conf->global->FACTURE_ADDON = 'mod_facture_terre'; |
|
| 3256 | + else if ($conf->global->FACTURE_ADDON == 'terre') $conf->global->FACTURE_ADDON = 'mod_facture_terre'; |
|
| 3257 | + else if ($conf->global->FACTURE_ADDON == 'mercure') $conf->global->FACTURE_ADDON = 'mod_facture_mercure'; |
|
| 3258 | 3258 | |
| 3259 | - if (! empty($conf->global->FACTURE_ADDON)) |
|
| 3259 | + if (!empty($conf->global->FACTURE_ADDON)) |
|
| 3260 | 3260 | { |
| 3261 | 3261 | dol_syslog("Call getNextNumRef with FACTURE_ADDON = ".$conf->global->FACTURE_ADDON.", thirdparty=".$soc->nom.", type=".$soc->typent_code, LOG_DEBUG); |
| 3262 | 3262 | |
| 3263 | - $mybool=false; |
|
| 3263 | + $mybool = false; |
|
| 3264 | 3264 | |
| 3265 | 3265 | $file = $conf->global->FACTURE_ADDON.".php"; |
| 3266 | 3266 | $classname = $conf->global->FACTURE_ADDON; |
@@ -3275,16 +3275,16 @@ discard block |
||
| 3275 | 3275 | // Load file with numbering class (if found) |
| 3276 | 3276 | if (is_file($dir.$file) && is_readable($dir.$file)) |
| 3277 | 3277 | { |
| 3278 | - $mybool |= include_once $dir . $file; |
|
| 3278 | + $mybool |= include_once $dir.$file; |
|
| 3279 | 3279 | } |
| 3280 | 3280 | } |
| 3281 | 3281 | |
| 3282 | 3282 | // For compatibility |
| 3283 | - if (! $mybool) |
|
| 3283 | + if (!$mybool) |
|
| 3284 | 3284 | { |
| 3285 | 3285 | $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; |
| 3286 | 3286 | $classname = "mod_facture_".$conf->global->FACTURE_ADDON; |
| 3287 | - $classname = preg_replace('/\-.*$/','',$classname); |
|
| 3287 | + $classname = preg_replace('/\-.*$/', '', $classname); |
|
| 3288 | 3288 | // Include file with class |
| 3289 | 3289 | foreach ($conf->file->dol_document_root as $dirroot) |
| 3290 | 3290 | { |
@@ -3292,27 +3292,27 @@ discard block |
||
| 3292 | 3292 | |
| 3293 | 3293 | // Load file with numbering class (if found) |
| 3294 | 3294 | if (is_file($dir.$file) && is_readable($dir.$file)) { |
| 3295 | - $mybool |= include_once $dir . $file; |
|
| 3295 | + $mybool |= include_once $dir.$file; |
|
| 3296 | 3296 | } |
| 3297 | 3297 | } |
| 3298 | 3298 | } |
| 3299 | 3299 | |
| 3300 | - if (! $mybool) |
|
| 3300 | + if (!$mybool) |
|
| 3301 | 3301 | { |
| 3302 | - dol_print_error('',"Failed to include file ".$file); |
|
| 3302 | + dol_print_error('', "Failed to include file ".$file); |
|
| 3303 | 3303 | return ''; |
| 3304 | 3304 | } |
| 3305 | 3305 | |
| 3306 | 3306 | $obj = new $classname(); |
| 3307 | 3307 | $numref = ""; |
| 3308 | - $numref = $obj->getNextValue($soc,$this,$mode); |
|
| 3308 | + $numref = $obj->getNextValue($soc, $this, $mode); |
|
| 3309 | 3309 | |
| 3310 | 3310 | /** |
| 3311 | 3311 | * $numref can be empty in case we ask for the last value because if there is no invoice created with the |
| 3312 | 3312 | * set up mask. |
| 3313 | 3313 | */ |
| 3314 | 3314 | if ($mode != 'last' && !$numref) { |
| 3315 | - $this->error=$obj->error; |
|
| 3315 | + $this->error = $obj->error; |
|
| 3316 | 3316 | //dol_print_error($this->db,"Facture::getNextNumRef ".$obj->error); |
| 3317 | 3317 | return ""; |
| 3318 | 3318 | } |
@@ -3336,11 +3336,11 @@ discard block |
||
| 3336 | 3336 | function info($id) |
| 3337 | 3337 | { |
| 3338 | 3338 | $sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,'; |
| 3339 | - $sql.= ' fk_user_author, fk_user_valid'; |
|
| 3340 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as c'; |
|
| 3341 | - $sql.= ' WHERE c.rowid = '.$id; |
|
| 3339 | + $sql .= ' fk_user_author, fk_user_valid'; |
|
| 3340 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as c'; |
|
| 3341 | + $sql .= ' WHERE c.rowid = '.$id; |
|
| 3342 | 3342 | |
| 3343 | - $result=$this->db->query($sql); |
|
| 3343 | + $result = $this->db->query($sql); |
|
| 3344 | 3344 | if ($result) |
| 3345 | 3345 | { |
| 3346 | 3346 | if ($this->db->num_rows($result)) |
@@ -3351,7 +3351,7 @@ discard block |
||
| 3351 | 3351 | { |
| 3352 | 3352 | $cuser = new User($this->db); |
| 3353 | 3353 | $cuser->fetch($obj->fk_user_author); |
| 3354 | - $this->user_creation = $cuser; |
|
| 3354 | + $this->user_creation = $cuser; |
|
| 3355 | 3355 | } |
| 3356 | 3356 | if ($obj->fk_user_valid) |
| 3357 | 3357 | { |
@@ -3361,7 +3361,7 @@ discard block |
||
| 3361 | 3361 | } |
| 3362 | 3362 | $this->date_creation = $this->db->jdate($obj->datec); |
| 3363 | 3363 | $this->date_modification = $this->db->jdate($obj->datem); |
| 3364 | - $this->date_validation = $this->db->jdate($obj->datev); // Should be in log table |
|
| 3364 | + $this->date_validation = $this->db->jdate($obj->datev); // Should be in log table |
|
| 3365 | 3365 | } |
| 3366 | 3366 | $this->db->free($result); |
| 3367 | 3367 | } |
@@ -3385,30 +3385,30 @@ discard block |
||
| 3385 | 3385 | * @param string $sortorder Sort order |
| 3386 | 3386 | * @return int -1 if KO, array with result if OK |
| 3387 | 3387 | */ |
| 3388 | - function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $offset=0, $sortfield='f.datef,f.rowid', $sortorder='DESC') |
|
| 3388 | + function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') |
|
| 3389 | 3389 | { |
| 3390 | - global $conf,$user; |
|
| 3390 | + global $conf, $user; |
|
| 3391 | 3391 | |
| 3392 | 3392 | $ga = array(); |
| 3393 | 3393 | |
| 3394 | 3394 | $sql = "SELECT s.rowid, s.nom as name, s.client,"; |
| 3395 | - $sql.= " f.rowid as fid, f.facnumber as ref, f.datef as df"; |
|
| 3396 | - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; |
|
| 3397 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; |
|
| 3398 | - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 3399 | - $sql.= " WHERE f.entity = ".$conf->entity; |
|
| 3400 | - $sql.= " AND f.fk_soc = s.rowid"; |
|
| 3401 | - if (! $user->rights->societe->client->voir && ! $socid) //restriction |
|
| 3395 | + $sql .= " f.rowid as fid, f.facnumber as ref, f.datef as df"; |
|
| 3396 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; |
|
| 3397 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; |
|
| 3398 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 3399 | + $sql .= " WHERE f.entity = ".$conf->entity; |
|
| 3400 | + $sql .= " AND f.fk_soc = s.rowid"; |
|
| 3401 | + if (!$user->rights->societe->client->voir && !$socid) //restriction |
|
| 3402 | 3402 | { |
| 3403 | - $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 3403 | + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 3404 | 3404 | } |
| 3405 | - if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
| 3406 | - if ($draft) $sql.= " AND f.fk_statut = ".self::STATUS_DRAFT; |
|
| 3407 | - if (is_object($excluser)) $sql.= " AND f.fk_user_author <> ".$excluser->id; |
|
| 3408 | - $sql.= $this->db->order($sortfield,$sortorder); |
|
| 3409 | - $sql.= $this->db->plimit($limit,$offset); |
|
| 3405 | + if ($socid) $sql .= " AND s.rowid = ".$socid; |
|
| 3406 | + if ($draft) $sql .= " AND f.fk_statut = ".self::STATUS_DRAFT; |
|
| 3407 | + if (is_object($excluser)) $sql .= " AND f.fk_user_author <> ".$excluser->id; |
|
| 3408 | + $sql .= $this->db->order($sortfield, $sortorder); |
|
| 3409 | + $sql .= $this->db->plimit($limit, $offset); |
|
| 3410 | 3410 | |
| 3411 | - $result=$this->db->query($sql); |
|
| 3411 | + $result = $this->db->query($sql); |
|
| 3412 | 3412 | if ($result) |
| 3413 | 3413 | { |
| 3414 | 3414 | $numc = $this->db->num_rows($result); |
@@ -3429,7 +3429,7 @@ discard block |
||
| 3429 | 3429 | } |
| 3430 | 3430 | else |
| 3431 | 3431 | { |
| 3432 | - $ga[$i]['id'] = $obj->fid; |
|
| 3432 | + $ga[$i]['id'] = $obj->fid; |
|
| 3433 | 3433 | $ga[$i]['ref'] = $obj->ref; |
| 3434 | 3434 | $ga[$i]['name'] = $obj->name; |
| 3435 | 3435 | } |
@@ -3454,32 +3454,32 @@ discard block |
||
| 3454 | 3454 | * @param int $socid Id thirdparty |
| 3455 | 3455 | * @return array Array of invoices ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1) |
| 3456 | 3456 | */ |
| 3457 | - function list_replacable_invoices($socid=0) |
|
| 3457 | + function list_replacable_invoices($socid = 0) |
|
| 3458 | 3458 | { |
| 3459 | 3459 | global $conf; |
| 3460 | 3460 | |
| 3461 | 3461 | $return = array(); |
| 3462 | 3462 | |
| 3463 | 3463 | $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut,"; |
| 3464 | - $sql.= " ff.rowid as rowidnext"; |
|
| 3465 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; |
|
| 3466 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; |
|
| 3467 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source"; |
|
| 3468 | - $sql.= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; |
|
| 3469 | - $sql.= " AND f.entity = ".$conf->entity; |
|
| 3470 | - $sql.= " AND f.paye = 0"; // Pas classee payee completement |
|
| 3471 | - $sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait |
|
| 3472 | - $sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement |
|
| 3473 | - if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; |
|
| 3474 | - $sql.= " ORDER BY f.facnumber"; |
|
| 3464 | + $sql .= " ff.rowid as rowidnext"; |
|
| 3465 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; |
|
| 3466 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; |
|
| 3467 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source"; |
|
| 3468 | + $sql .= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; |
|
| 3469 | + $sql .= " AND f.entity = ".$conf->entity; |
|
| 3470 | + $sql .= " AND f.paye = 0"; // Pas classee payee completement |
|
| 3471 | + $sql .= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait |
|
| 3472 | + $sql .= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement |
|
| 3473 | + if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; |
|
| 3474 | + $sql .= " ORDER BY f.facnumber"; |
|
| 3475 | 3475 | |
| 3476 | 3476 | dol_syslog(get_class($this)."::list_replacable_invoices", LOG_DEBUG); |
| 3477 | - $resql=$this->db->query($sql); |
|
| 3477 | + $resql = $this->db->query($sql); |
|
| 3478 | 3478 | if ($resql) |
| 3479 | 3479 | { |
| 3480 | - while ($obj=$this->db->fetch_object($resql)) |
|
| 3480 | + while ($obj = $this->db->fetch_object($resql)) |
|
| 3481 | 3481 | { |
| 3482 | - $return[$obj->rowid]=array( 'id' => $obj->rowid, |
|
| 3482 | + $return[$obj->rowid] = array('id' => $obj->rowid, |
|
| 3483 | 3483 | 'ref' => $obj->facnumber, |
| 3484 | 3484 | 'status' => $obj->fk_statut); |
| 3485 | 3485 | } |
@@ -3488,7 +3488,7 @@ discard block |
||
| 3488 | 3488 | } |
| 3489 | 3489 | else |
| 3490 | 3490 | { |
| 3491 | - $this->error=$this->db->error(); |
|
| 3491 | + $this->error = $this->db->error(); |
|
| 3492 | 3492 | return -1; |
| 3493 | 3493 | } |
| 3494 | 3494 | } |
@@ -3502,40 +3502,40 @@ discard block |
||
| 3502 | 3502 | * @param int $socid Id thirdparty |
| 3503 | 3503 | * @return array Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) |
| 3504 | 3504 | */ |
| 3505 | - function list_qualified_avoir_invoices($socid=0) |
|
| 3505 | + function list_qualified_avoir_invoices($socid = 0) |
|
| 3506 | 3506 | { |
| 3507 | 3507 | global $conf; |
| 3508 | 3508 | |
| 3509 | 3509 | $return = array(); |
| 3510 | 3510 | |
| 3511 | 3511 | $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, f.type, f.paye, pf.fk_paiement"; |
| 3512 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; |
|
| 3513 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; |
|
| 3514 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")"; |
|
| 3515 | - $sql.= " WHERE f.entity = ".$conf->entity; |
|
| 3516 | - $sql.= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; |
|
| 3512 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; |
|
| 3513 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; |
|
| 3514 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")"; |
|
| 3515 | + $sql .= " WHERE f.entity = ".$conf->entity; |
|
| 3516 | + $sql .= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; |
|
| 3517 | 3517 | // $sql.= " WHERE f.fk_statut >= 1"; |
| 3518 | 3518 | // $sql.= " AND (f.paye = 1"; // Classee payee completement |
| 3519 | 3519 | // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement |
| 3520 | - $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement |
|
| 3521 | - $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir |
|
| 3522 | - if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; |
|
| 3523 | - $sql.= " ORDER BY f.facnumber"; |
|
| 3520 | + $sql .= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement |
|
| 3521 | + $sql .= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir |
|
| 3522 | + if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; |
|
| 3523 | + $sql .= " ORDER BY f.facnumber"; |
|
| 3524 | 3524 | |
| 3525 | 3525 | dol_syslog(get_class($this)."::list_qualified_avoir_invoices", LOG_DEBUG); |
| 3526 | - $resql=$this->db->query($sql); |
|
| 3526 | + $resql = $this->db->query($sql); |
|
| 3527 | 3527 | if ($resql) |
| 3528 | 3528 | { |
| 3529 | - while ($obj=$this->db->fetch_object($resql)) |
|
| 3529 | + while ($obj = $this->db->fetch_object($resql)) |
|
| 3530 | 3530 | { |
| 3531 | - $qualified=0; |
|
| 3532 | - if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified=1; |
|
| 3533 | - if ($obj->fk_statut == self::STATUS_CLOSED) $qualified=1; |
|
| 3531 | + $qualified = 0; |
|
| 3532 | + if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified = 1; |
|
| 3533 | + if ($obj->fk_statut == self::STATUS_CLOSED) $qualified = 1; |
|
| 3534 | 3534 | if ($qualified) |
| 3535 | 3535 | { |
| 3536 | 3536 | //$ref=$obj->facnumber; |
| 3537 | - $paymentornot=($obj->fk_paiement?1:0); |
|
| 3538 | - $return[$obj->rowid]=array('ref'=>$obj->facnumber,'status'=>$obj->fk_statut,'type'=>$obj->type,'paye'=>$obj->paye,'paymentornot'=>$paymentornot); |
|
| 3537 | + $paymentornot = ($obj->fk_paiement ? 1 : 0); |
|
| 3538 | + $return[$obj->rowid] = array('ref'=>$obj->facnumber, 'status'=>$obj->fk_statut, 'type'=>$obj->type, 'paye'=>$obj->paye, 'paymentornot'=>$paymentornot); |
|
| 3539 | 3539 | } |
| 3540 | 3540 | } |
| 3541 | 3541 | |
@@ -3543,7 +3543,7 @@ discard block |
||
| 3543 | 3543 | } |
| 3544 | 3544 | else |
| 3545 | 3545 | { |
| 3546 | - $this->error=$this->db->error(); |
|
| 3546 | + $this->error = $this->db->error(); |
|
| 3547 | 3547 | return -1; |
| 3548 | 3548 | } |
| 3549 | 3549 | } |
@@ -3557,34 +3557,34 @@ discard block |
||
| 3557 | 3557 | * @param float $amount Amount we request direct debit for |
| 3558 | 3558 | * @return int <0 if KO, >0 if OK |
| 3559 | 3559 | */ |
| 3560 | - function demande_prelevement($fuser, $amount=0) |
|
| 3560 | + function demande_prelevement($fuser, $amount = 0) |
|
| 3561 | 3561 | { |
| 3562 | 3562 | |
| 3563 | - $error=0; |
|
| 3563 | + $error = 0; |
|
| 3564 | 3564 | |
| 3565 | 3565 | dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); |
| 3566 | 3566 | |
| 3567 | 3567 | if ($this->statut > self::STATUS_DRAFT && $this->paye == 0) |
| 3568 | 3568 | { |
| 3569 | - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; |
|
| 3569 | + require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; |
|
| 3570 | 3570 | $bac = new CompanyBankAccount($this->db); |
| 3571 | - $bac->fetch(0,$this->socid); |
|
| 3571 | + $bac->fetch(0, $this->socid); |
|
| 3572 | 3572 | |
| 3573 | 3573 | $sql = 'SELECT count(*)'; |
| 3574 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; |
|
| 3575 | - $sql.= ' WHERE fk_facture = '.$this->id; |
|
| 3576 | - $sql.= ' AND traite = 0'; |
|
| 3574 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; |
|
| 3575 | + $sql .= ' WHERE fk_facture = '.$this->id; |
|
| 3576 | + $sql .= ' AND traite = 0'; |
|
| 3577 | 3577 | |
| 3578 | 3578 | dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); |
| 3579 | - $resql=$this->db->query($sql); |
|
| 3579 | + $resql = $this->db->query($sql); |
|
| 3580 | 3580 | if ($resql) |
| 3581 | 3581 | { |
| 3582 | 3582 | $row = $this->db->fetch_row($resql); |
| 3583 | 3583 | if ($row[0] == 0) |
| 3584 | 3584 | { |
| 3585 | - $now=dol_now(); |
|
| 3585 | + $now = dol_now(); |
|
| 3586 | 3586 | |
| 3587 | - $totalpaye = $this->getSommePaiement(); |
|
| 3587 | + $totalpaye = $this->getSommePaiement(); |
|
| 3588 | 3588 | $totalcreditnotes = $this->getSumCreditNotesUsed(); |
| 3589 | 3589 | $totaldeposits = $this->getSumDepositsUsed(); |
| 3590 | 3590 | //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; |
@@ -3593,7 +3593,7 @@ discard block |
||
| 3593 | 3593 | // For example print 239.2 - 229.3 - 9.9; does not return 0. |
| 3594 | 3594 | //$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); |
| 3595 | 3595 | //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); |
| 3596 | - if (empty($amount)) $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT'); |
|
| 3596 | + if (empty($amount)) $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); |
|
| 3597 | 3597 | |
| 3598 | 3598 | if (is_numeric($amount) && $amount != 0) |
| 3599 | 3599 | { |
@@ -3609,28 +3609,28 @@ discard block |
||
| 3609 | 3609 | $sql .= ",'".$bac->cle_rib."')"; |
| 3610 | 3610 | |
| 3611 | 3611 | dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); |
| 3612 | - $resql=$this->db->query($sql); |
|
| 3613 | - if (! $resql) |
|
| 3612 | + $resql = $this->db->query($sql); |
|
| 3613 | + if (!$resql) |
|
| 3614 | 3614 | { |
| 3615 | - $this->error=$this->db->lasterror(); |
|
| 3615 | + $this->error = $this->db->lasterror(); |
|
| 3616 | 3616 | dol_syslog(get_class($this).'::demandeprelevement Erreur'); |
| 3617 | 3617 | $error++; |
| 3618 | 3618 | } |
| 3619 | 3619 | } |
| 3620 | 3620 | else |
| 3621 | 3621 | { |
| 3622 | - $this->error='WithdrawRequestErrorNilAmount'; |
|
| 3622 | + $this->error = 'WithdrawRequestErrorNilAmount'; |
|
| 3623 | 3623 | dol_syslog(get_class($this).'::demandeprelevement WithdrawRequestErrorNilAmount'); |
| 3624 | 3624 | $error++; |
| 3625 | 3625 | } |
| 3626 | 3626 | |
| 3627 | - if (! $error) |
|
| 3627 | + if (!$error) |
|
| 3628 | 3628 | { |
| 3629 | 3629 | // Force payment mode of invoice to withdraw |
| 3630 | 3630 | $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1); |
| 3631 | 3631 | if ($payment_mode_id > 0) |
| 3632 | 3632 | { |
| 3633 | - $result=$this->setPaymentMethods($payment_mode_id); |
|
| 3633 | + $result = $this->setPaymentMethods($payment_mode_id); |
|
| 3634 | 3634 | } |
| 3635 | 3635 | } |
| 3636 | 3636 | |
@@ -3639,21 +3639,21 @@ discard block |
||
| 3639 | 3639 | } |
| 3640 | 3640 | else |
| 3641 | 3641 | { |
| 3642 | - $this->error="A request already exists"; |
|
| 3642 | + $this->error = "A request already exists"; |
|
| 3643 | 3643 | dol_syslog(get_class($this).'::demandeprelevement Impossible de creer une demande, demande deja en cours'); |
| 3644 | 3644 | return 0; |
| 3645 | 3645 | } |
| 3646 | 3646 | } |
| 3647 | 3647 | else |
| 3648 | 3648 | { |
| 3649 | - $this->error=$this->db->error(); |
|
| 3649 | + $this->error = $this->db->error(); |
|
| 3650 | 3650 | dol_syslog(get_class($this).'::demandeprelevement Erreur -2'); |
| 3651 | 3651 | return -2; |
| 3652 | 3652 | } |
| 3653 | 3653 | } |
| 3654 | 3654 | else |
| 3655 | 3655 | { |
| 3656 | - $this->error="Status of invoice does not allow this"; |
|
| 3656 | + $this->error = "Status of invoice does not allow this"; |
|
| 3657 | 3657 | dol_syslog(get_class($this)."::demandeprelevement ".$this->error." $this->statut, $this->paye, $this->mode_reglement_id"); |
| 3658 | 3658 | return -3; |
| 3659 | 3659 | } |
@@ -3671,13 +3671,13 @@ discard block |
||
| 3671 | 3671 | $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; |
| 3672 | 3672 | $sql .= ' WHERE rowid = '.$did; |
| 3673 | 3673 | $sql .= ' AND traite = 0'; |
| 3674 | - if ( $this->db->query($sql) ) |
|
| 3674 | + if ($this->db->query($sql)) |
|
| 3675 | 3675 | { |
| 3676 | 3676 | return 0; |
| 3677 | 3677 | } |
| 3678 | 3678 | else |
| 3679 | 3679 | { |
| 3680 | - $this->error=$this->db->lasterror(); |
|
| 3680 | + $this->error = $this->db->lasterror(); |
|
| 3681 | 3681 | dol_syslog(get_class($this).'::demande_prelevement_delete Error '.$this->error); |
| 3682 | 3682 | return -1; |
| 3683 | 3683 | } |
@@ -3697,33 +3697,33 @@ discard block |
||
| 3697 | 3697 | $clause = " WHERE"; |
| 3698 | 3698 | |
| 3699 | 3699 | $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut"; |
| 3700 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; |
|
| 3700 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; |
|
| 3701 | 3701 | if (!$user->rights->societe->client->voir && !$user->societe_id) |
| 3702 | 3702 | { |
| 3703 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; |
|
| 3704 | - $sql.= " WHERE sc.fk_user = " .$user->id; |
|
| 3703 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; |
|
| 3704 | + $sql .= " WHERE sc.fk_user = ".$user->id; |
|
| 3705 | 3705 | $clause = " AND"; |
| 3706 | 3706 | } |
| 3707 | - $sql.= $clause." f.paye=0"; |
|
| 3708 | - $sql.= " AND f.entity = ".$conf->entity; |
|
| 3709 | - $sql.= " AND f.fk_statut = ".self::STATUS_VALIDATED; |
|
| 3710 | - if ($user->societe_id) $sql.= " AND f.fk_soc = ".$user->societe_id; |
|
| 3707 | + $sql .= $clause." f.paye=0"; |
|
| 3708 | + $sql .= " AND f.entity = ".$conf->entity; |
|
| 3709 | + $sql .= " AND f.fk_statut = ".self::STATUS_VALIDATED; |
|
| 3710 | + if ($user->societe_id) $sql .= " AND f.fk_soc = ".$user->societe_id; |
|
| 3711 | 3711 | |
| 3712 | - $resql=$this->db->query($sql); |
|
| 3712 | + $resql = $this->db->query($sql); |
|
| 3713 | 3713 | if ($resql) |
| 3714 | 3714 | { |
| 3715 | 3715 | $langs->load("bills"); |
| 3716 | - $now=dol_now(); |
|
| 3716 | + $now = dol_now(); |
|
| 3717 | 3717 | |
| 3718 | 3718 | $response = new WorkboardResponse(); |
| 3719 | - $response->warning_delay=$conf->facture->client->warning_delay/60/60/24; |
|
| 3720 | - $response->label=$langs->trans("CustomerBillsUnpaid"); |
|
| 3721 | - $response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=customers_bills'; |
|
| 3722 | - $response->img=img_object('',"bill"); |
|
| 3719 | + $response->warning_delay = $conf->facture->client->warning_delay / 60 / 60 / 24; |
|
| 3720 | + $response->label = $langs->trans("CustomerBillsUnpaid"); |
|
| 3721 | + $response->url = DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=customers_bills'; |
|
| 3722 | + $response->img = img_object('', "bill"); |
|
| 3723 | 3723 | |
| 3724 | 3724 | $generic_facture = new Facture($this->db); |
| 3725 | 3725 | |
| 3726 | - while ($obj=$this->db->fetch_object($resql)) |
|
| 3726 | + while ($obj = $this->db->fetch_object($resql)) |
|
| 3727 | 3727 | { |
| 3728 | 3728 | $generic_facture->date_lim_reglement = $this->db->jdate($obj->datefin); |
| 3729 | 3729 | $generic_facture->statut = $obj->fk_statut; |
@@ -3740,7 +3740,7 @@ discard block |
||
| 3740 | 3740 | else |
| 3741 | 3741 | { |
| 3742 | 3742 | dol_print_error($this->db); |
| 3743 | - $this->error=$this->db->error(); |
|
| 3743 | + $this->error = $this->db->error(); |
|
| 3744 | 3744 | return -1; |
| 3745 | 3745 | } |
| 3746 | 3746 | } |
@@ -3755,7 +3755,7 @@ discard block |
||
| 3755 | 3755 | */ |
| 3756 | 3756 | function getIdBillingContact() |
| 3757 | 3757 | { |
| 3758 | - return $this->getIdContact('external','BILLING'); |
|
| 3758 | + return $this->getIdContact('external', 'BILLING'); |
|
| 3759 | 3759 | } |
| 3760 | 3760 | |
| 3761 | 3761 | /** |
@@ -3765,7 +3765,7 @@ discard block |
||
| 3765 | 3765 | */ |
| 3766 | 3766 | function getIdShippingContact() |
| 3767 | 3767 | { |
| 3768 | - return $this->getIdContact('external','SHIPPING'); |
|
| 3768 | + return $this->getIdContact('external', 'SHIPPING'); |
|
| 3769 | 3769 | } |
| 3770 | 3770 | |
| 3771 | 3771 | |
@@ -3777,20 +3777,20 @@ discard block |
||
| 3777 | 3777 | * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines |
| 3778 | 3778 | * @return void |
| 3779 | 3779 | */ |
| 3780 | - function initAsSpecimen($option='') |
|
| 3780 | + function initAsSpecimen($option = '') |
|
| 3781 | 3781 | { |
| 3782 | 3782 | global $langs; |
| 3783 | 3783 | |
| 3784 | - $now=dol_now(); |
|
| 3785 | - $arraynow=dol_getdate($now); |
|
| 3786 | - $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); |
|
| 3784 | + $now = dol_now(); |
|
| 3785 | + $arraynow = dol_getdate($now); |
|
| 3786 | + $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); |
|
| 3787 | 3787 | |
| 3788 | 3788 | // Load array of products prodids |
| 3789 | 3789 | $num_prods = 0; |
| 3790 | 3790 | $prodids = array(); |
| 3791 | 3791 | $sql = "SELECT rowid"; |
| 3792 | - $sql.= " FROM ".MAIN_DB_PREFIX."product"; |
|
| 3793 | - $sql.= " WHERE entity IN (".getEntity('product').")"; |
|
| 3792 | + $sql .= " FROM ".MAIN_DB_PREFIX."product"; |
|
| 3793 | + $sql .= " WHERE entity IN (".getEntity('product').")"; |
|
| 3794 | 3794 | $resql = $this->db->query($sql); |
| 3795 | 3795 | if ($resql) |
| 3796 | 3796 | { |
@@ -3805,26 +3805,26 @@ discard block |
||
| 3805 | 3805 | } |
| 3806 | 3806 | //Avoid php warning Warning: mt_rand(): max(0) is smaller than min(1) when no product exists |
| 3807 | 3807 | if (empty($num_prods)) { |
| 3808 | - $num_prods=1; |
|
| 3808 | + $num_prods = 1; |
|
| 3809 | 3809 | } |
| 3810 | 3810 | |
| 3811 | 3811 | // Initialize parameters |
| 3812 | - $this->id=0; |
|
| 3812 | + $this->id = 0; |
|
| 3813 | 3813 | $this->ref = 'SPECIMEN'; |
| 3814 | - $this->specimen=1; |
|
| 3814 | + $this->specimen = 1; |
|
| 3815 | 3815 | $this->socid = 1; |
| 3816 | 3816 | $this->date = $nownotime; |
| 3817 | - $this->date_lim_reglement = $nownotime + 3600 * 24 *30; |
|
| 3817 | + $this->date_lim_reglement = $nownotime + 3600 * 24 * 30; |
|
| 3818 | 3818 | $this->cond_reglement_id = 1; |
| 3819 | 3819 | $this->cond_reglement_code = 'RECEP'; |
| 3820 | - $this->date_lim_reglement=$this->calculate_date_lim_reglement(); |
|
| 3821 | - $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR |
|
| 3822 | - $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR |
|
| 3823 | - $this->note_public='This is a comment (public)'; |
|
| 3824 | - $this->note_private='This is a comment (private)'; |
|
| 3825 | - $this->note='This is a comment (private)'; |
|
| 3826 | - $this->fk_incoterms=0; |
|
| 3827 | - $this->location_incoterms=''; |
|
| 3820 | + $this->date_lim_reglement = $this->calculate_date_lim_reglement(); |
|
| 3821 | + $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR |
|
| 3822 | + $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR |
|
| 3823 | + $this->note_public = 'This is a comment (public)'; |
|
| 3824 | + $this->note_private = 'This is a comment (private)'; |
|
| 3825 | + $this->note = 'This is a comment (private)'; |
|
| 3826 | + $this->fk_incoterms = 0; |
|
| 3827 | + $this->location_incoterms = ''; |
|
| 3828 | 3828 | |
| 3829 | 3829 | if (empty($option) || $option != 'nolines') |
| 3830 | 3830 | { |
@@ -3833,63 +3833,63 @@ discard block |
||
| 3833 | 3833 | $xnbp = 0; |
| 3834 | 3834 | while ($xnbp < $nbp) |
| 3835 | 3835 | { |
| 3836 | - $line=new FactureLigne($this->db); |
|
| 3837 | - $line->desc=$langs->trans("Description")." ".$xnbp; |
|
| 3838 | - $line->qty=1; |
|
| 3839 | - $line->subprice=100; |
|
| 3840 | - $line->tva_tx=19.6; |
|
| 3841 | - $line->localtax1_tx=0; |
|
| 3842 | - $line->localtax2_tx=0; |
|
| 3843 | - $line->remise_percent=0; |
|
| 3836 | + $line = new FactureLigne($this->db); |
|
| 3837 | + $line->desc = $langs->trans("Description")." ".$xnbp; |
|
| 3838 | + $line->qty = 1; |
|
| 3839 | + $line->subprice = 100; |
|
| 3840 | + $line->tva_tx = 19.6; |
|
| 3841 | + $line->localtax1_tx = 0; |
|
| 3842 | + $line->localtax2_tx = 0; |
|
| 3843 | + $line->remise_percent = 0; |
|
| 3844 | 3844 | if ($xnbp == 1) // Qty is negative (product line) |
| 3845 | 3845 | { |
| 3846 | 3846 | $prodid = mt_rand(1, $num_prods); |
| 3847 | - $line->fk_product=$prodids[$prodid]; |
|
| 3848 | - $line->qty=-1; |
|
| 3849 | - $line->total_ht=-100; |
|
| 3850 | - $line->total_ttc=-119.6; |
|
| 3851 | - $line->total_tva=-19.6; |
|
| 3852 | - $line->multicurrency_total_ht=-200; |
|
| 3853 | - $line->multicurrency_total_ttc=-239.2; |
|
| 3854 | - $line->multicurrency_total_tva=-39.2; |
|
| 3847 | + $line->fk_product = $prodids[$prodid]; |
|
| 3848 | + $line->qty = -1; |
|
| 3849 | + $line->total_ht = -100; |
|
| 3850 | + $line->total_ttc = -119.6; |
|
| 3851 | + $line->total_tva = -19.6; |
|
| 3852 | + $line->multicurrency_total_ht = -200; |
|
| 3853 | + $line->multicurrency_total_ttc = -239.2; |
|
| 3854 | + $line->multicurrency_total_tva = -39.2; |
|
| 3855 | 3855 | } |
| 3856 | 3856 | else if ($xnbp == 2) // UP is negative (free line) |
| 3857 | 3857 | { |
| 3858 | - $line->subprice=-100; |
|
| 3859 | - $line->total_ht=-100; |
|
| 3860 | - $line->total_ttc=-119.6; |
|
| 3861 | - $line->total_tva=-19.6; |
|
| 3862 | - $line->remise_percent=0; |
|
| 3863 | - $line->multicurrency_total_ht=-200; |
|
| 3864 | - $line->multicurrency_total_ttc=-239.2; |
|
| 3865 | - $line->multicurrency_total_tva=-39.2; |
|
| 3858 | + $line->subprice = -100; |
|
| 3859 | + $line->total_ht = -100; |
|
| 3860 | + $line->total_ttc = -119.6; |
|
| 3861 | + $line->total_tva = -19.6; |
|
| 3862 | + $line->remise_percent = 0; |
|
| 3863 | + $line->multicurrency_total_ht = -200; |
|
| 3864 | + $line->multicurrency_total_ttc = -239.2; |
|
| 3865 | + $line->multicurrency_total_tva = -39.2; |
|
| 3866 | 3866 | } |
| 3867 | 3867 | else if ($xnbp == 3) // Discount is 50% (product line) |
| 3868 | 3868 | { |
| 3869 | 3869 | $prodid = mt_rand(1, $num_prods); |
| 3870 | - $line->fk_product=$prodids[$prodid]; |
|
| 3871 | - $line->total_ht=50; |
|
| 3872 | - $line->total_ttc=59.8; |
|
| 3873 | - $line->total_tva=9.8; |
|
| 3874 | - $line->multicurrency_total_ht=100; |
|
| 3875 | - $line->multicurrency_total_ttc=119.6; |
|
| 3876 | - $line->multicurrency_total_tva=19.6; |
|
| 3877 | - $line->remise_percent=50; |
|
| 3870 | + $line->fk_product = $prodids[$prodid]; |
|
| 3871 | + $line->total_ht = 50; |
|
| 3872 | + $line->total_ttc = 59.8; |
|
| 3873 | + $line->total_tva = 9.8; |
|
| 3874 | + $line->multicurrency_total_ht = 100; |
|
| 3875 | + $line->multicurrency_total_ttc = 119.6; |
|
| 3876 | + $line->multicurrency_total_tva = 19.6; |
|
| 3877 | + $line->remise_percent = 50; |
|
| 3878 | 3878 | } |
| 3879 | 3879 | else // (product line) |
| 3880 | 3880 | { |
| 3881 | 3881 | $prodid = mt_rand(1, $num_prods); |
| 3882 | - $line->fk_product=$prodids[$prodid]; |
|
| 3883 | - $line->total_ht=100; |
|
| 3884 | - $line->total_ttc=119.6; |
|
| 3885 | - $line->total_tva=19.6; |
|
| 3886 | - $line->multicurrency_total_ht=200; |
|
| 3887 | - $line->multicurrency_total_ttc=239.2; |
|
| 3888 | - $line->multicurrency_total_tva=39.2; |
|
| 3889 | - $line->remise_percent=0; |
|
| 3882 | + $line->fk_product = $prodids[$prodid]; |
|
| 3883 | + $line->total_ht = 100; |
|
| 3884 | + $line->total_ttc = 119.6; |
|
| 3885 | + $line->total_tva = 19.6; |
|
| 3886 | + $line->multicurrency_total_ht = 200; |
|
| 3887 | + $line->multicurrency_total_ttc = 239.2; |
|
| 3888 | + $line->multicurrency_total_tva = 39.2; |
|
| 3889 | + $line->remise_percent = 0; |
|
| 3890 | 3890 | } |
| 3891 | 3891 | |
| 3892 | - $this->lines[$xnbp]=$line; |
|
| 3892 | + $this->lines[$xnbp] = $line; |
|
| 3893 | 3893 | |
| 3894 | 3894 | |
| 3895 | 3895 | $this->total_ht += $line->total_ht; |
@@ -3905,24 +3905,24 @@ discard block |
||
| 3905 | 3905 | $this->revenuestamp = 0; |
| 3906 | 3906 | |
| 3907 | 3907 | // Add a line "offered" |
| 3908 | - $line=new FactureLigne($this->db); |
|
| 3909 | - $line->desc=$langs->trans("Description")." (offered line)"; |
|
| 3910 | - $line->qty=1; |
|
| 3911 | - $line->subprice=100; |
|
| 3912 | - $line->tva_tx=19.6; |
|
| 3913 | - $line->localtax1_tx=0; |
|
| 3914 | - $line->localtax2_tx=0; |
|
| 3915 | - $line->remise_percent=100; |
|
| 3916 | - $line->total_ht=0; |
|
| 3917 | - $line->total_ttc=0; // 90 * 1.196 |
|
| 3918 | - $line->total_tva=0; |
|
| 3919 | - $line->multicurrency_total_ht=0; |
|
| 3920 | - $line->multicurrency_total_ttc=0; |
|
| 3921 | - $line->multicurrency_total_tva=0; |
|
| 3908 | + $line = new FactureLigne($this->db); |
|
| 3909 | + $line->desc = $langs->trans("Description")." (offered line)"; |
|
| 3910 | + $line->qty = 1; |
|
| 3911 | + $line->subprice = 100; |
|
| 3912 | + $line->tva_tx = 19.6; |
|
| 3913 | + $line->localtax1_tx = 0; |
|
| 3914 | + $line->localtax2_tx = 0; |
|
| 3915 | + $line->remise_percent = 100; |
|
| 3916 | + $line->total_ht = 0; |
|
| 3917 | + $line->total_ttc = 0; // 90 * 1.196 |
|
| 3918 | + $line->total_tva = 0; |
|
| 3919 | + $line->multicurrency_total_ht = 0; |
|
| 3920 | + $line->multicurrency_total_ttc = 0; |
|
| 3921 | + $line->multicurrency_total_tva = 0; |
|
| 3922 | 3922 | $prodid = mt_rand(1, $num_prods); |
| 3923 | - $line->fk_product=$prodids[$prodid]; |
|
| 3923 | + $line->fk_product = $prodids[$prodid]; |
|
| 3924 | 3924 | |
| 3925 | - $this->lines[$xnbp]=$line; |
|
| 3925 | + $this->lines[$xnbp] = $line; |
|
| 3926 | 3926 | $xnbp++; |
| 3927 | 3927 | } |
| 3928 | 3928 | } |
@@ -3936,27 +3936,27 @@ discard block |
||
| 3936 | 3936 | { |
| 3937 | 3937 | global $conf, $user; |
| 3938 | 3938 | |
| 3939 | - $this->nb=array(); |
|
| 3939 | + $this->nb = array(); |
|
| 3940 | 3940 | |
| 3941 | 3941 | $clause = "WHERE"; |
| 3942 | 3942 | |
| 3943 | 3943 | $sql = "SELECT count(f.rowid) as nb"; |
| 3944 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; |
|
| 3945 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; |
|
| 3944 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; |
|
| 3945 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; |
|
| 3946 | 3946 | if (!$user->rights->societe->client->voir && !$user->societe_id) |
| 3947 | 3947 | { |
| 3948 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; |
|
| 3949 | - $sql.= " WHERE sc.fk_user = " .$user->id; |
|
| 3948 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; |
|
| 3949 | + $sql .= " WHERE sc.fk_user = ".$user->id; |
|
| 3950 | 3950 | $clause = "AND"; |
| 3951 | 3951 | } |
| 3952 | - $sql.= " ".$clause." f.entity = ".$conf->entity; |
|
| 3952 | + $sql .= " ".$clause." f.entity = ".$conf->entity; |
|
| 3953 | 3953 | |
| 3954 | - $resql=$this->db->query($sql); |
|
| 3954 | + $resql = $this->db->query($sql); |
|
| 3955 | 3955 | if ($resql) |
| 3956 | 3956 | { |
| 3957 | - while ($obj=$this->db->fetch_object($resql)) |
|
| 3957 | + while ($obj = $this->db->fetch_object($resql)) |
|
| 3958 | 3958 | { |
| 3959 | - $this->nb["invoices"]=$obj->nb; |
|
| 3959 | + $this->nb["invoices"] = $obj->nb; |
|
| 3960 | 3960 | } |
| 3961 | 3961 | $this->db->free($resql); |
| 3962 | 3962 | return 1; |
@@ -3964,7 +3964,7 @@ discard block |
||
| 3964 | 3964 | else |
| 3965 | 3965 | { |
| 3966 | 3966 | dol_print_error($this->db); |
| 3967 | - $this->error=$this->db->error(); |
|
| 3967 | + $this->error = $this->db->error(); |
|
| 3968 | 3968 | return -1; |
| 3969 | 3969 | } |
| 3970 | 3970 | } |
@@ -3989,19 +3989,19 @@ discard block |
||
| 3989 | 3989 | * @param int $hideref Hide ref |
| 3990 | 3990 | * @return int <0 if KO, >0 if OK |
| 3991 | 3991 | */ |
| 3992 | - public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) |
|
| 3992 | + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
| 3993 | 3993 | { |
| 3994 | - global $conf,$langs; |
|
| 3994 | + global $conf, $langs; |
|
| 3995 | 3995 | |
| 3996 | 3996 | $langs->load("bills"); |
| 3997 | 3997 | |
| 3998 | - if (! dol_strlen($modele)) { |
|
| 3998 | + if (!dol_strlen($modele)) { |
|
| 3999 | 3999 | |
| 4000 | 4000 | $modele = 'crabe'; |
| 4001 | 4001 | |
| 4002 | 4002 | if ($this->modelpdf) { |
| 4003 | 4003 | $modele = $this->modelpdf; |
| 4004 | - } elseif (! empty($conf->global->FACTURE_ADDON_PDF)) { |
|
| 4004 | + } elseif (!empty($conf->global->FACTURE_ADDON_PDF)) { |
|
| 4005 | 4005 | $modele = $conf->global->FACTURE_ADDON_PDF; |
| 4006 | 4006 | } |
| 4007 | 4007 | } |
@@ -4018,8 +4018,8 @@ discard block |
||
| 4018 | 4018 | */ |
| 4019 | 4019 | function newCycle() |
| 4020 | 4020 | { |
| 4021 | - $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f'; |
|
| 4022 | - $sql.= " WHERE f.entity in (".getEntity('facture', 0).")"; |
|
| 4021 | + $sql = 'SELECT max(situation_cycle_ref) FROM '.MAIN_DB_PREFIX.'facture as f'; |
|
| 4022 | + $sql .= " WHERE f.entity in (".getEntity('facture', 0).")"; |
|
| 4023 | 4023 | $resql = $this->db->query($sql); |
| 4024 | 4024 | if ($resql) { |
| 4025 | 4025 | if ($resql->num_rows > 0) |
@@ -4034,7 +4034,7 @@ discard block |
||
| 4034 | 4034 | return $ref; |
| 4035 | 4035 | } else { |
| 4036 | 4036 | $this->error = $this->db->lasterror(); |
| 4037 | - dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); |
|
| 4037 | + dol_syslog("Error sql=".$sql.", error=".$this->error, LOG_ERR); |
|
| 4038 | 4038 | return -1; |
| 4039 | 4039 | } |
| 4040 | 4040 | } |
@@ -4058,10 +4058,10 @@ discard block |
||
| 4058 | 4058 | { |
| 4059 | 4059 | global $conf; |
| 4060 | 4060 | |
| 4061 | - $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture'; |
|
| 4062 | - $sql .= ' where situation_cycle_ref = ' . $this->situation_cycle_ref; |
|
| 4063 | - $sql .= ' and situation_counter < ' . $this->situation_counter; |
|
| 4064 | - $sql .= ' AND entity = '. ($this->entity > 0 ? $this->entity : $conf->entity); |
|
| 4061 | + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture'; |
|
| 4062 | + $sql .= ' where situation_cycle_ref = '.$this->situation_cycle_ref; |
|
| 4063 | + $sql .= ' and situation_counter < '.$this->situation_counter; |
|
| 4064 | + $sql .= ' AND entity = '.($this->entity > 0 ? $this->entity : $conf->entity); |
|
| 4065 | 4065 | $resql = $this->db->query($sql); |
| 4066 | 4066 | $res = array(); |
| 4067 | 4067 | if ($resql && $resql->num_rows > 0) { |
@@ -4073,7 +4073,7 @@ discard block |
||
| 4073 | 4073 | } |
| 4074 | 4074 | } else { |
| 4075 | 4075 | $this->error = $this->db->error(); |
| 4076 | - dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); |
|
| 4076 | + dol_syslog("Error sql=".$sql.", error=".$this->error, LOG_ERR); |
|
| 4077 | 4077 | return -1; |
| 4078 | 4078 | } |
| 4079 | 4079 | |
@@ -4087,45 +4087,45 @@ discard block |
||
| 4087 | 4087 | * @param int $notrigger 1=Does not execute triggers, 0= execute triggers |
| 4088 | 4088 | * @return int <0 if KO, >0 if OK |
| 4089 | 4089 | */ |
| 4090 | - function setFinal(User $user, $notrigger=0) |
|
| 4090 | + function setFinal(User $user, $notrigger = 0) |
|
| 4091 | 4091 | { |
| 4092 | - $error=0; |
|
| 4092 | + $error = 0; |
|
| 4093 | 4093 | |
| 4094 | 4094 | $this->db->begin(); |
| 4095 | 4095 | |
| 4096 | 4096 | $this->situation_final = 1; |
| 4097 | - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id; |
|
| 4097 | + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET situation_final = '.$this->situation_final.' where rowid = '.$this->id; |
|
| 4098 | 4098 | |
| 4099 | 4099 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 4100 | - $resql=$this->db->query($sql); |
|
| 4100 | + $resql = $this->db->query($sql); |
|
| 4101 | 4101 | if (!$resql) |
| 4102 | 4102 | { |
| 4103 | - $this->errors[]=$this->db->error(); |
|
| 4103 | + $this->errors[] = $this->db->error(); |
|
| 4104 | 4104 | $error++; |
| 4105 | 4105 | } |
| 4106 | 4106 | |
| 4107 | - if (! $notrigger && empty($error)) |
|
| 4107 | + if (!$notrigger && empty($error)) |
|
| 4108 | 4108 | { |
| 4109 | 4109 | // Call trigger |
| 4110 | - $result=$this->call_trigger('BILL_MODIFY',$user); |
|
| 4110 | + $result = $this->call_trigger('BILL_MODIFY', $user); |
|
| 4111 | 4111 | if ($result < 0) $error++; |
| 4112 | 4112 | // End call triggers |
| 4113 | 4113 | } |
| 4114 | 4114 | |
| 4115 | - if (! $error) |
|
| 4115 | + if (!$error) |
|
| 4116 | 4116 | { |
| 4117 | 4117 | $this->db->commit(); |
| 4118 | 4118 | return 1; |
| 4119 | 4119 | } |
| 4120 | 4120 | else |
| 4121 | 4121 | { |
| 4122 | - foreach($this->errors as $errmsg) |
|
| 4122 | + foreach ($this->errors as $errmsg) |
|
| 4123 | 4123 | { |
| 4124 | 4124 | dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); |
| 4125 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 4125 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 4126 | 4126 | } |
| 4127 | 4127 | $this->db->rollback(); |
| 4128 | - return -1*$error; |
|
| 4128 | + return -1 * $error; |
|
| 4129 | 4129 | } |
| 4130 | 4130 | } |
| 4131 | 4131 | |
@@ -4141,7 +4141,7 @@ discard block |
||
| 4141 | 4141 | |
| 4142 | 4142 | if (!empty($this->situation_cycle_ref)) { |
| 4143 | 4143 | // No point in testing anything if we're not inside a cycle |
| 4144 | - $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref . ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity); |
|
| 4144 | + $sql = 'SELECT max(situation_counter) FROM '.MAIN_DB_PREFIX.'facture WHERE situation_cycle_ref = '.$this->situation_cycle_ref.' AND entity = '.($this->entity > 0 ? $this->entity : $conf->entity); |
|
| 4145 | 4145 | $resql = $this->db->query($sql); |
| 4146 | 4146 | |
| 4147 | 4147 | if ($resql && $resql->num_rows > 0) { |
@@ -4150,7 +4150,7 @@ discard block |
||
| 4150 | 4150 | return ($last == $this->situation_counter); |
| 4151 | 4151 | } else { |
| 4152 | 4152 | $this->error = $this->db->lasterror(); |
| 4153 | - dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); |
|
| 4153 | + dol_syslog(get_class($this)."::select Error ".$this->error, LOG_ERR); |
|
| 4154 | 4154 | return false; |
| 4155 | 4155 | } |
| 4156 | 4156 | } else { |
@@ -4199,8 +4199,8 @@ discard block |
||
| 4199 | 4199 | */ |
| 4200 | 4200 | class FactureLigne extends CommonInvoiceLine |
| 4201 | 4201 | { |
| 4202 | - public $element='facturedet'; |
|
| 4203 | - public $table_element='facturedet'; |
|
| 4202 | + public $element = 'facturedet'; |
|
| 4203 | + public $table_element = 'facturedet'; |
|
| 4204 | 4204 | |
| 4205 | 4205 | var $oldline; |
| 4206 | 4206 | |
@@ -4216,9 +4216,9 @@ discard block |
||
| 4216 | 4216 | //! Description ligne |
| 4217 | 4217 | var $desc; |
| 4218 | 4218 | |
| 4219 | - var $localtax1_type; // Local tax 1 type |
|
| 4220 | - var $localtax2_type; // Local tax 2 type |
|
| 4221 | - var $fk_remise_except; // Link to line into llx_remise_except |
|
| 4219 | + var $localtax1_type; // Local tax 1 type |
|
| 4220 | + var $localtax2_type; // Local tax 2 type |
|
| 4221 | + var $fk_remise_except; // Link to line into llx_remise_except |
|
| 4222 | 4222 | var $rang = 0; |
| 4223 | 4223 | |
| 4224 | 4224 | var $fk_fournprice; |
@@ -4226,7 +4226,7 @@ discard block |
||
| 4226 | 4226 | var $marge_tx; |
| 4227 | 4227 | var $marque_tx; |
| 4228 | 4228 | |
| 4229 | - var $special_code; // Liste d'options non cumulabels: |
|
| 4229 | + var $special_code; // Liste d'options non cumulabels: |
|
| 4230 | 4230 | // 1: frais de port |
| 4231 | 4231 | // 2: ecotaxe |
| 4232 | 4232 | // 3: ?? |
@@ -4248,15 +4248,15 @@ discard block |
||
| 4248 | 4248 | * @deprecated |
| 4249 | 4249 | * @see product_ref |
| 4250 | 4250 | */ |
| 4251 | - var $ref; // Product ref (deprecated) |
|
| 4252 | - var $product_ref; // Product ref |
|
| 4251 | + var $ref; // Product ref (deprecated) |
|
| 4252 | + var $product_ref; // Product ref |
|
| 4253 | 4253 | /** |
| 4254 | 4254 | * @deprecated |
| 4255 | 4255 | * @see product_label |
| 4256 | 4256 | */ |
| 4257 | - var $libelle; // Product label (deprecated) |
|
| 4258 | - var $product_label; // Product label |
|
| 4259 | - var $product_desc; // Description produit |
|
| 4257 | + var $libelle; // Product label (deprecated) |
|
| 4258 | + var $product_label; // Product label |
|
| 4259 | + var $product_desc; // Description produit |
|
| 4260 | 4260 | |
| 4261 | 4261 | var $skip_update_total; // Skip update price total for special lines |
| 4262 | 4262 | |
@@ -4287,20 +4287,20 @@ discard block |
||
| 4287 | 4287 | function fetch($rowid) |
| 4288 | 4288 | { |
| 4289 | 4289 | $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; |
| 4290 | - $sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; |
|
| 4291 | - $sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; |
|
| 4292 | - $sql.= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; |
|
| 4293 | - $sql.= ' fd.fk_code_ventilation,'; |
|
| 4294 | - $sql.= ' fd.fk_unit, fd.fk_user_author, fd.fk_user_modif,'; |
|
| 4295 | - $sql.= ' fd.situation_percent, fd.fk_prev_id,'; |
|
| 4296 | - $sql.= ' fd.multicurrency_subprice,'; |
|
| 4297 | - $sql.= ' fd.multicurrency_total_ht,'; |
|
| 4298 | - $sql.= ' fd.multicurrency_total_tva,'; |
|
| 4299 | - $sql.= ' fd.multicurrency_total_ttc,'; |
|
| 4300 | - $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; |
|
| 4301 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd'; |
|
| 4302 | - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid'; |
|
| 4303 | - $sql.= ' WHERE fd.rowid = '.$rowid; |
|
| 4290 | + $sql .= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; |
|
| 4291 | + $sql .= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; |
|
| 4292 | + $sql .= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; |
|
| 4293 | + $sql .= ' fd.fk_code_ventilation,'; |
|
| 4294 | + $sql .= ' fd.fk_unit, fd.fk_user_author, fd.fk_user_modif,'; |
|
| 4295 | + $sql .= ' fd.situation_percent, fd.fk_prev_id,'; |
|
| 4296 | + $sql .= ' fd.multicurrency_subprice,'; |
|
| 4297 | + $sql .= ' fd.multicurrency_total_ht,'; |
|
| 4298 | + $sql .= ' fd.multicurrency_total_tva,'; |
|
| 4299 | + $sql .= ' fd.multicurrency_total_ttc,'; |
|
| 4300 | + $sql .= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; |
|
| 4301 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd'; |
|
| 4302 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid'; |
|
| 4303 | + $sql .= ' WHERE fd.rowid = '.$rowid; |
|
| 4304 | 4304 | |
| 4305 | 4305 | $result = $this->db->query($sql); |
| 4306 | 4306 | if ($result) |
@@ -4308,54 +4308,54 @@ discard block |
||
| 4308 | 4308 | $objp = $this->db->fetch_object($result); |
| 4309 | 4309 | |
| 4310 | 4310 | $this->rowid = $objp->rowid; |
| 4311 | - $this->fk_facture = $objp->fk_facture; |
|
| 4312 | - $this->fk_parent_line = $objp->fk_parent_line; |
|
| 4311 | + $this->fk_facture = $objp->fk_facture; |
|
| 4312 | + $this->fk_parent_line = $objp->fk_parent_line; |
|
| 4313 | 4313 | $this->label = $objp->custom_label; |
| 4314 | 4314 | $this->desc = $objp->description; |
| 4315 | - $this->qty = $objp->qty; |
|
| 4316 | - $this->subprice = $objp->subprice; |
|
| 4317 | - $this->vat_src_code = $objp->vat_src_code; |
|
| 4318 | - $this->tva_tx = $objp->tva_tx; |
|
| 4315 | + $this->qty = $objp->qty; |
|
| 4316 | + $this->subprice = $objp->subprice; |
|
| 4317 | + $this->vat_src_code = $objp->vat_src_code; |
|
| 4318 | + $this->tva_tx = $objp->tva_tx; |
|
| 4319 | 4319 | $this->localtax1_tx = $objp->localtax1_tx; |
| 4320 | 4320 | $this->localtax2_tx = $objp->localtax2_tx; |
| 4321 | - $this->remise_percent = $objp->remise_percent; |
|
| 4322 | - $this->fk_remise_except = $objp->fk_remise_except; |
|
| 4321 | + $this->remise_percent = $objp->remise_percent; |
|
| 4322 | + $this->fk_remise_except = $objp->fk_remise_except; |
|
| 4323 | 4323 | $this->fk_product = $objp->fk_product; |
| 4324 | - $this->product_type = $objp->product_type; |
|
| 4324 | + $this->product_type = $objp->product_type; |
|
| 4325 | 4325 | $this->date_start = $this->db->jdate($objp->date_start); |
| 4326 | 4326 | $this->date_end = $this->db->jdate($objp->date_end); |
| 4327 | 4327 | $this->info_bits = $objp->info_bits; |
| 4328 | - $this->tva_npr = ($objp->info_bits & 1 == 1) ? 1 : 0; |
|
| 4329 | - $this->special_code = $objp->special_code; |
|
| 4328 | + $this->tva_npr = ($objp->info_bits & 1 == 1) ? 1 : 0; |
|
| 4329 | + $this->special_code = $objp->special_code; |
|
| 4330 | 4330 | $this->total_ht = $objp->total_ht; |
| 4331 | 4331 | $this->total_tva = $objp->total_tva; |
| 4332 | 4332 | $this->total_localtax1 = $objp->total_localtax1; |
| 4333 | 4333 | $this->total_localtax2 = $objp->total_localtax2; |
| 4334 | 4334 | $this->total_ttc = $objp->total_ttc; |
| 4335 | - $this->fk_code_ventilation = $objp->fk_code_ventilation; |
|
| 4335 | + $this->fk_code_ventilation = $objp->fk_code_ventilation; |
|
| 4336 | 4336 | $this->rang = $objp->rang; |
| 4337 | - $this->fk_fournprice = $objp->fk_fournprice; |
|
| 4337 | + $this->fk_fournprice = $objp->fk_fournprice; |
|
| 4338 | 4338 | $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); |
| 4339 | 4339 | $this->pa_ht = $marginInfos[0]; |
| 4340 | 4340 | $this->marge_tx = $marginInfos[1]; |
| 4341 | 4341 | $this->marque_tx = $marginInfos[2]; |
| 4342 | 4342 | |
| 4343 | - $this->ref = $objp->product_ref; // deprecated |
|
| 4344 | - $this->product_ref = $objp->product_ref; |
|
| 4345 | - $this->libelle = $objp->product_libelle; // deprecated |
|
| 4343 | + $this->ref = $objp->product_ref; // deprecated |
|
| 4344 | + $this->product_ref = $objp->product_ref; |
|
| 4345 | + $this->libelle = $objp->product_libelle; // deprecated |
|
| 4346 | 4346 | $this->product_label = $objp->product_libelle; |
| 4347 | 4347 | $this->product_desc = $objp->product_desc; |
| 4348 | 4348 | $this->fk_unit = $objp->fk_unit; |
| 4349 | 4349 | $this->fk_user_modif = $objp->fk_user_modif; |
| 4350 | - $this->fk_user_author = $objp->fk_user_author; |
|
| 4350 | + $this->fk_user_author = $objp->fk_user_author; |
|
| 4351 | 4351 | |
| 4352 | 4352 | $this->situation_percent = $objp->situation_percent; |
| 4353 | 4353 | $this->fk_prev_id = $objp->fk_prev_id; |
| 4354 | 4354 | |
| 4355 | 4355 | $this->multicurrency_subprice = $objp->multicurrency_subprice; |
| 4356 | 4356 | $this->multicurrency_total_ht = $objp->multicurrency_total_ht; |
| 4357 | - $this->multicurrency_total_tva= $objp->multicurrency_total_tva; |
|
| 4358 | - $this->multicurrency_total_ttc= $objp->multicurrency_total_ttc; |
|
| 4357 | + $this->multicurrency_total_tva = $objp->multicurrency_total_tva; |
|
| 4358 | + $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; |
|
| 4359 | 4359 | |
| 4360 | 4360 | $this->db->free($result); |
| 4361 | 4361 | |
@@ -4375,39 +4375,39 @@ discard block |
||
| 4375 | 4375 | * @param int $noerrorifdiscountalreadylinked 1=Do not make error if lines is linked to a discount and discount already linked to another |
| 4376 | 4376 | * @return int <0 if KO, >0 if OK |
| 4377 | 4377 | */ |
| 4378 | - function insert($notrigger=0, $noerrorifdiscountalreadylinked=0) |
|
| 4378 | + function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0) |
|
| 4379 | 4379 | { |
| 4380 | - global $langs,$user,$conf; |
|
| 4380 | + global $langs, $user, $conf; |
|
| 4381 | 4381 | |
| 4382 | - $error=0; |
|
| 4382 | + $error = 0; |
|
| 4383 | 4383 | |
| 4384 | 4384 | $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. |
| 4385 | 4385 | |
| 4386 | 4386 | dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG); |
| 4387 | 4387 | |
| 4388 | 4388 | // Clean parameters |
| 4389 | - $this->desc=trim($this->desc); |
|
| 4390 | - if (empty($this->tva_tx)) $this->tva_tx=0; |
|
| 4391 | - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; |
|
| 4392 | - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; |
|
| 4393 | - if (empty($this->localtax1_type)) $this->localtax1_type=0; |
|
| 4394 | - if (empty($this->localtax2_type)) $this->localtax2_type=0; |
|
| 4395 | - if (empty($this->total_localtax1)) $this->total_localtax1=0; |
|
| 4396 | - if (empty($this->total_localtax2)) $this->total_localtax2=0; |
|
| 4397 | - if (empty($this->rang)) $this->rang=0; |
|
| 4398 | - if (empty($this->remise_percent)) $this->remise_percent=0; |
|
| 4399 | - if (empty($this->info_bits)) $this->info_bits=0; |
|
| 4400 | - if (empty($this->subprice)) $this->subprice=0; |
|
| 4401 | - if (empty($this->special_code)) $this->special_code=0; |
|
| 4402 | - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; |
|
| 4389 | + $this->desc = trim($this->desc); |
|
| 4390 | + if (empty($this->tva_tx)) $this->tva_tx = 0; |
|
| 4391 | + if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; |
|
| 4392 | + if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; |
|
| 4393 | + if (empty($this->localtax1_type)) $this->localtax1_type = 0; |
|
| 4394 | + if (empty($this->localtax2_type)) $this->localtax2_type = 0; |
|
| 4395 | + if (empty($this->total_localtax1)) $this->total_localtax1 = 0; |
|
| 4396 | + if (empty($this->total_localtax2)) $this->total_localtax2 = 0; |
|
| 4397 | + if (empty($this->rang)) $this->rang = 0; |
|
| 4398 | + if (empty($this->remise_percent)) $this->remise_percent = 0; |
|
| 4399 | + if (empty($this->info_bits)) $this->info_bits = 0; |
|
| 4400 | + if (empty($this->subprice)) $this->subprice = 0; |
|
| 4401 | + if (empty($this->special_code)) $this->special_code = 0; |
|
| 4402 | + if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; |
|
| 4403 | 4403 | if (empty($this->fk_prev_id)) $this->fk_prev_id = 'null'; |
| 4404 | - if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; |
|
| 4404 | + if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; |
|
| 4405 | 4405 | |
| 4406 | - if (empty($this->pa_ht)) $this->pa_ht=0; |
|
| 4407 | - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; |
|
| 4408 | - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; |
|
| 4409 | - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; |
|
| 4410 | - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; |
|
| 4406 | + if (empty($this->pa_ht)) $this->pa_ht = 0; |
|
| 4407 | + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; |
|
| 4408 | + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; |
|
| 4409 | + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; |
|
| 4410 | + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; |
|
| 4411 | 4411 | |
| 4412 | 4412 | // if buy price not defined, define buyprice as configured in margin admin |
| 4413 | 4413 | if ($this->pa_ht == 0 && $pa_ht_isemptystring) |
@@ -4425,16 +4425,16 @@ discard block |
||
| 4425 | 4425 | // Check parameters |
| 4426 | 4426 | if ($this->product_type < 0) |
| 4427 | 4427 | { |
| 4428 | - $this->error='ErrorProductTypeMustBe0orMore'; |
|
| 4428 | + $this->error = 'ErrorProductTypeMustBe0orMore'; |
|
| 4429 | 4429 | return -1; |
| 4430 | 4430 | } |
| 4431 | - if (! empty($this->fk_product)) |
|
| 4431 | + if (!empty($this->fk_product)) |
|
| 4432 | 4432 | { |
| 4433 | 4433 | // Check product exists |
| 4434 | - $result=Product::isExistingObject('product', $this->fk_product); |
|
| 4434 | + $result = Product::isExistingObject('product', $this->fk_product); |
|
| 4435 | 4435 | if ($result <= 0) |
| 4436 | 4436 | { |
| 4437 | - $this->error='ErrorProductIdDoesNotExists'; |
|
| 4437 | + $this->error = 'ErrorProductIdDoesNotExists'; |
|
| 4438 | 4438 | return -1; |
| 4439 | 4439 | } |
| 4440 | 4440 | } |
@@ -4443,68 +4443,68 @@ discard block |
||
| 4443 | 4443 | |
| 4444 | 4444 | // Insertion dans base de la ligne |
| 4445 | 4445 | $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet'; |
| 4446 | - $sql.= ' (fk_facture, fk_parent_line, label, description, qty,'; |
|
| 4447 | - $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; |
|
| 4448 | - $sql.= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; |
|
| 4449 | - $sql.= ' date_start, date_end, fk_code_ventilation, '; |
|
| 4450 | - $sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; |
|
| 4451 | - $sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; |
|
| 4452 | - $sql.= ' situation_percent, fk_prev_id,'; |
|
| 4453 | - $sql.= ' fk_unit, fk_user_author, fk_user_modif,'; |
|
| 4454 | - $sql.= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; |
|
| 4455 | - $sql.= ')'; |
|
| 4456 | - $sql.= " VALUES (".$this->fk_facture.","; |
|
| 4457 | - $sql.= " ".($this->fk_parent_line>0 ? $this->fk_parent_line:"null").","; |
|
| 4458 | - $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; |
|
| 4459 | - $sql.= " '".$this->db->escape($this->desc)."',"; |
|
| 4460 | - $sql.= " ".price2num($this->qty).","; |
|
| 4461 | - $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").","; |
|
| 4462 | - $sql.= " ".price2num($this->tva_tx).","; |
|
| 4463 | - $sql.= " ".price2num($this->localtax1_tx).","; |
|
| 4464 | - $sql.= " ".price2num($this->localtax2_tx).","; |
|
| 4465 | - $sql.= " '".$this->db->escape($this->localtax1_type)."',"; |
|
| 4466 | - $sql.= " '".$this->db->escape($this->localtax2_type)."',"; |
|
| 4467 | - $sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").','; |
|
| 4468 | - $sql.= " ".$this->product_type.","; |
|
| 4469 | - $sql.= " ".price2num($this->remise_percent).","; |
|
| 4470 | - $sql.= " ".price2num($this->subprice).","; |
|
| 4471 | - $sql.= ' '.(! empty($this->fk_remise_except)?$this->fk_remise_except:"null").','; |
|
| 4472 | - $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").","; |
|
| 4473 | - $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").","; |
|
| 4474 | - $sql.= ' '.$this->fk_code_ventilation.','; |
|
| 4475 | - $sql.= ' '.$this->rang.','; |
|
| 4476 | - $sql.= ' '.$this->special_code.','; |
|
| 4477 | - $sql.= ' '.(! empty($this->fk_fournprice)?$this->fk_fournprice:"null").','; |
|
| 4478 | - $sql.= ' '.price2num($this->pa_ht).','; |
|
| 4479 | - $sql.= " '".$this->db->escape($this->info_bits)."',"; |
|
| 4480 | - $sql.= " ".price2num($this->total_ht).","; |
|
| 4481 | - $sql.= " ".price2num($this->total_tva).","; |
|
| 4482 | - $sql.= " ".price2num($this->total_ttc).","; |
|
| 4483 | - $sql.= " ".price2num($this->total_localtax1).","; |
|
| 4484 | - $sql.= " ".price2num($this->total_localtax2); |
|
| 4485 | - $sql.= ", " . $this->situation_percent; |
|
| 4486 | - $sql.= ", " . $this->fk_prev_id; |
|
| 4487 | - $sql.= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); |
|
| 4488 | - $sql.= ", ".$user->id; |
|
| 4489 | - $sql.= ", ".$user->id; |
|
| 4490 | - $sql.= ", ".(int) $this->fk_multicurrency; |
|
| 4491 | - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; |
|
| 4492 | - $sql.= ", ".price2num($this->multicurrency_subprice); |
|
| 4493 | - $sql.= ", ".price2num($this->multicurrency_total_ht); |
|
| 4494 | - $sql.= ", ".price2num($this->multicurrency_total_tva); |
|
| 4495 | - $sql.= ", ".price2num($this->multicurrency_total_ttc); |
|
| 4496 | - $sql.= ')'; |
|
| 4446 | + $sql .= ' (fk_facture, fk_parent_line, label, description, qty,'; |
|
| 4447 | + $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; |
|
| 4448 | + $sql .= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; |
|
| 4449 | + $sql .= ' date_start, date_end, fk_code_ventilation, '; |
|
| 4450 | + $sql .= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; |
|
| 4451 | + $sql .= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; |
|
| 4452 | + $sql .= ' situation_percent, fk_prev_id,'; |
|
| 4453 | + $sql .= ' fk_unit, fk_user_author, fk_user_modif,'; |
|
| 4454 | + $sql .= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; |
|
| 4455 | + $sql .= ')'; |
|
| 4456 | + $sql .= " VALUES (".$this->fk_facture.","; |
|
| 4457 | + $sql .= " ".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null").","; |
|
| 4458 | + $sql .= " ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; |
|
| 4459 | + $sql .= " '".$this->db->escape($this->desc)."',"; |
|
| 4460 | + $sql .= " ".price2num($this->qty).","; |
|
| 4461 | + $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").","; |
|
| 4462 | + $sql .= " ".price2num($this->tva_tx).","; |
|
| 4463 | + $sql .= " ".price2num($this->localtax1_tx).","; |
|
| 4464 | + $sql .= " ".price2num($this->localtax2_tx).","; |
|
| 4465 | + $sql .= " '".$this->db->escape($this->localtax1_type)."',"; |
|
| 4466 | + $sql .= " '".$this->db->escape($this->localtax2_type)."',"; |
|
| 4467 | + $sql .= ' '.(!empty($this->fk_product) ? $this->fk_product : "null").','; |
|
| 4468 | + $sql .= " ".$this->product_type.","; |
|
| 4469 | + $sql .= " ".price2num($this->remise_percent).","; |
|
| 4470 | + $sql .= " ".price2num($this->subprice).","; |
|
| 4471 | + $sql .= ' '.(!empty($this->fk_remise_except) ? $this->fk_remise_except : "null").','; |
|
| 4472 | + $sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").","; |
|
| 4473 | + $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").","; |
|
| 4474 | + $sql .= ' '.$this->fk_code_ventilation.','; |
|
| 4475 | + $sql .= ' '.$this->rang.','; |
|
| 4476 | + $sql .= ' '.$this->special_code.','; |
|
| 4477 | + $sql .= ' '.(!empty($this->fk_fournprice) ? $this->fk_fournprice : "null").','; |
|
| 4478 | + $sql .= ' '.price2num($this->pa_ht).','; |
|
| 4479 | + $sql .= " '".$this->db->escape($this->info_bits)."',"; |
|
| 4480 | + $sql .= " ".price2num($this->total_ht).","; |
|
| 4481 | + $sql .= " ".price2num($this->total_tva).","; |
|
| 4482 | + $sql .= " ".price2num($this->total_ttc).","; |
|
| 4483 | + $sql .= " ".price2num($this->total_localtax1).","; |
|
| 4484 | + $sql .= " ".price2num($this->total_localtax2); |
|
| 4485 | + $sql .= ", ".$this->situation_percent; |
|
| 4486 | + $sql .= ", ".$this->fk_prev_id; |
|
| 4487 | + $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); |
|
| 4488 | + $sql .= ", ".$user->id; |
|
| 4489 | + $sql .= ", ".$user->id; |
|
| 4490 | + $sql .= ", ".(int) $this->fk_multicurrency; |
|
| 4491 | + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; |
|
| 4492 | + $sql .= ", ".price2num($this->multicurrency_subprice); |
|
| 4493 | + $sql .= ", ".price2num($this->multicurrency_total_ht); |
|
| 4494 | + $sql .= ", ".price2num($this->multicurrency_total_tva); |
|
| 4495 | + $sql .= ", ".price2num($this->multicurrency_total_ttc); |
|
| 4496 | + $sql .= ')'; |
|
| 4497 | 4497 | |
| 4498 | 4498 | dol_syslog(get_class($this)."::insert", LOG_DEBUG); |
| 4499 | - $resql=$this->db->query($sql); |
|
| 4499 | + $resql = $this->db->query($sql); |
|
| 4500 | 4500 | if ($resql) |
| 4501 | 4501 | { |
| 4502 | - $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); |
|
| 4502 | + $this->rowid = $this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); |
|
| 4503 | 4503 | |
| 4504 | 4504 | if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
| 4505 | 4505 | { |
| 4506 | - $this->id=$this->rowid; |
|
| 4507 | - $result=$this->insertExtraFields(); |
|
| 4506 | + $this->id = $this->rowid; |
|
| 4507 | + $result = $this->insertExtraFields(); |
|
| 4508 | 4508 | if ($result < 0) |
| 4509 | 4509 | { |
| 4510 | 4510 | $error++; |
@@ -4515,8 +4515,8 @@ discard block |
||
| 4515 | 4515 | // ce qui la flague comme "consommee". |
| 4516 | 4516 | if ($this->fk_remise_except) |
| 4517 | 4517 | { |
| 4518 | - $discount=new DiscountAbsolute($this->db); |
|
| 4519 | - $result=$discount->fetch($this->fk_remise_except); |
|
| 4518 | + $discount = new DiscountAbsolute($this->db); |
|
| 4519 | + $result = $discount->fetch($this->fk_remise_except); |
|
| 4520 | 4520 | if ($result >= 0) |
| 4521 | 4521 | { |
| 4522 | 4522 | // Check if discount was found |
@@ -4527,7 +4527,7 @@ discard block |
||
| 4527 | 4527 | { |
| 4528 | 4528 | if (empty($noerrorifdiscountalreadylinked)) |
| 4529 | 4529 | { |
| 4530 | - $this->error=$langs->trans("ErrorDiscountAlreadyUsed",$discount->id); |
|
| 4530 | + $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id); |
|
| 4531 | 4531 | dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); |
| 4532 | 4532 | $this->db->rollback(); |
| 4533 | 4533 | return -3; |
@@ -4535,10 +4535,10 @@ discard block |
||
| 4535 | 4535 | } |
| 4536 | 4536 | else |
| 4537 | 4537 | { |
| 4538 | - $result=$discount->link_to_invoice($this->rowid,0); |
|
| 4538 | + $result = $discount->link_to_invoice($this->rowid, 0); |
|
| 4539 | 4539 | if ($result < 0) |
| 4540 | 4540 | { |
| 4541 | - $this->error=$discount->error; |
|
| 4541 | + $this->error = $discount->error; |
|
| 4542 | 4542 | dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); |
| 4543 | 4543 | $this->db->rollback(); |
| 4544 | 4544 | return -3; |
@@ -4547,7 +4547,7 @@ discard block |
||
| 4547 | 4547 | } |
| 4548 | 4548 | else |
| 4549 | 4549 | { |
| 4550 | - $this->error=$langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded"); |
|
| 4550 | + $this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded"); |
|
| 4551 | 4551 | dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); |
| 4552 | 4552 | $this->db->rollback(); |
| 4553 | 4553 | return -3; |
@@ -4555,17 +4555,17 @@ discard block |
||
| 4555 | 4555 | } |
| 4556 | 4556 | else |
| 4557 | 4557 | { |
| 4558 | - $this->error=$discount->error; |
|
| 4558 | + $this->error = $discount->error; |
|
| 4559 | 4559 | dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); |
| 4560 | 4560 | $this->db->rollback(); |
| 4561 | 4561 | return -3; |
| 4562 | 4562 | } |
| 4563 | 4563 | } |
| 4564 | 4564 | |
| 4565 | - if (! $notrigger) |
|
| 4565 | + if (!$notrigger) |
|
| 4566 | 4566 | { |
| 4567 | 4567 | // Call trigger |
| 4568 | - $result=$this->call_trigger('LINEBILL_INSERT',$user); |
|
| 4568 | + $result = $this->call_trigger('LINEBILL_INSERT', $user); |
|
| 4569 | 4569 | if ($result < 0) |
| 4570 | 4570 | { |
| 4571 | 4571 | $this->db->rollback(); |
@@ -4580,7 +4580,7 @@ discard block |
||
| 4580 | 4580 | } |
| 4581 | 4581 | else |
| 4582 | 4582 | { |
| 4583 | - $this->error=$this->db->error(); |
|
| 4583 | + $this->error = $this->db->error(); |
|
| 4584 | 4584 | $this->db->rollback(); |
| 4585 | 4585 | return -2; |
| 4586 | 4586 | } |
@@ -4593,35 +4593,35 @@ discard block |
||
| 4593 | 4593 | * @param int $notrigger Disable triggers |
| 4594 | 4594 | * @return int <0 if KO, >0 if OK |
| 4595 | 4595 | */ |
| 4596 | - function update($user='',$notrigger=0) |
|
| 4596 | + function update($user = '', $notrigger = 0) |
|
| 4597 | 4597 | { |
| 4598 | - global $user,$conf; |
|
| 4598 | + global $user, $conf; |
|
| 4599 | 4599 | |
| 4600 | - $error=0; |
|
| 4600 | + $error = 0; |
|
| 4601 | 4601 | |
| 4602 | 4602 | $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. |
| 4603 | 4603 | |
| 4604 | 4604 | // Clean parameters |
| 4605 | - $this->desc=trim($this->desc); |
|
| 4606 | - if (empty($this->tva_tx)) $this->tva_tx=0; |
|
| 4607 | - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; |
|
| 4608 | - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; |
|
| 4609 | - if (empty($this->localtax1_type)) $this->localtax1_type=0; |
|
| 4610 | - if (empty($this->localtax2_type)) $this->localtax2_type=0; |
|
| 4611 | - if (empty($this->total_localtax1)) $this->total_localtax1=0; |
|
| 4612 | - if (empty($this->total_localtax2)) $this->total_localtax2=0; |
|
| 4613 | - if (empty($this->remise_percent)) $this->remise_percent=0; |
|
| 4614 | - if (empty($this->info_bits)) $this->info_bits=0; |
|
| 4615 | - if (empty($this->special_code)) $this->special_code=0; |
|
| 4616 | - if (empty($this->product_type)) $this->product_type=0; |
|
| 4617 | - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; |
|
| 4618 | - if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; |
|
| 4619 | - if (empty($this->pa_ht)) $this->pa_ht=0; |
|
| 4620 | - |
|
| 4621 | - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; |
|
| 4622 | - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; |
|
| 4623 | - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; |
|
| 4624 | - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; |
|
| 4605 | + $this->desc = trim($this->desc); |
|
| 4606 | + if (empty($this->tva_tx)) $this->tva_tx = 0; |
|
| 4607 | + if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; |
|
| 4608 | + if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; |
|
| 4609 | + if (empty($this->localtax1_type)) $this->localtax1_type = 0; |
|
| 4610 | + if (empty($this->localtax2_type)) $this->localtax2_type = 0; |
|
| 4611 | + if (empty($this->total_localtax1)) $this->total_localtax1 = 0; |
|
| 4612 | + if (empty($this->total_localtax2)) $this->total_localtax2 = 0; |
|
| 4613 | + if (empty($this->remise_percent)) $this->remise_percent = 0; |
|
| 4614 | + if (empty($this->info_bits)) $this->info_bits = 0; |
|
| 4615 | + if (empty($this->special_code)) $this->special_code = 0; |
|
| 4616 | + if (empty($this->product_type)) $this->product_type = 0; |
|
| 4617 | + if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; |
|
| 4618 | + if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; |
|
| 4619 | + if (empty($this->pa_ht)) $this->pa_ht = 0; |
|
| 4620 | + |
|
| 4621 | + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; |
|
| 4622 | + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; |
|
| 4623 | + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; |
|
| 4624 | + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; |
|
| 4625 | 4625 | |
| 4626 | 4626 | // Check parameters |
| 4627 | 4627 | if ($this->product_type < 0) return -1; |
@@ -4643,66 +4643,66 @@ discard block |
||
| 4643 | 4643 | |
| 4644 | 4644 | // Mise a jour ligne en base |
| 4645 | 4645 | $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; |
| 4646 | - $sql.= " description='".$this->db->escape($this->desc)."'"; |
|
| 4647 | - $sql.= ", label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); |
|
| 4648 | - $sql.= ", subprice=".price2num($this->subprice).""; |
|
| 4649 | - $sql.= ", remise_percent=".price2num($this->remise_percent).""; |
|
| 4650 | - if ($this->fk_remise_except) $sql.= ", fk_remise_except=".$this->fk_remise_except; |
|
| 4651 | - else $sql.= ", fk_remise_except=null"; |
|
| 4652 | - $sql.= ", vat_src_code = '".(empty($this->vat_src_code)?'':$this->db->escape($this->vat_src_code))."'"; |
|
| 4653 | - $sql.= ", tva_tx=".price2num($this->tva_tx).""; |
|
| 4654 | - $sql.= ", localtax1_tx=".price2num($this->localtax1_tx).""; |
|
| 4655 | - $sql.= ", localtax2_tx=".price2num($this->localtax2_tx).""; |
|
| 4656 | - $sql.= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; |
|
| 4657 | - $sql.= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; |
|
| 4658 | - $sql.= ", qty=".price2num($this->qty); |
|
| 4659 | - $sql.= ", date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null"); |
|
| 4660 | - $sql.= ", date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null"); |
|
| 4661 | - $sql.= ", product_type=".$this->product_type; |
|
| 4662 | - $sql.= ", info_bits='".$this->db->escape($this->info_bits)."'"; |
|
| 4663 | - $sql.= ", special_code='".$this->db->escape($this->special_code)."'"; |
|
| 4646 | + $sql .= " description='".$this->db->escape($this->desc)."'"; |
|
| 4647 | + $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); |
|
| 4648 | + $sql .= ", subprice=".price2num($this->subprice).""; |
|
| 4649 | + $sql .= ", remise_percent=".price2num($this->remise_percent).""; |
|
| 4650 | + if ($this->fk_remise_except) $sql .= ", fk_remise_except=".$this->fk_remise_except; |
|
| 4651 | + else $sql .= ", fk_remise_except=null"; |
|
| 4652 | + $sql .= ", vat_src_code = '".(empty($this->vat_src_code) ? '' : $this->db->escape($this->vat_src_code))."'"; |
|
| 4653 | + $sql .= ", tva_tx=".price2num($this->tva_tx).""; |
|
| 4654 | + $sql .= ", localtax1_tx=".price2num($this->localtax1_tx).""; |
|
| 4655 | + $sql .= ", localtax2_tx=".price2num($this->localtax2_tx).""; |
|
| 4656 | + $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; |
|
| 4657 | + $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; |
|
| 4658 | + $sql .= ", qty=".price2num($this->qty); |
|
| 4659 | + $sql .= ", date_start=".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null"); |
|
| 4660 | + $sql .= ", date_end=".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null"); |
|
| 4661 | + $sql .= ", product_type=".$this->product_type; |
|
| 4662 | + $sql .= ", info_bits='".$this->db->escape($this->info_bits)."'"; |
|
| 4663 | + $sql .= ", special_code='".$this->db->escape($this->special_code)."'"; |
|
| 4664 | 4664 | if (empty($this->skip_update_total)) |
| 4665 | 4665 | { |
| 4666 | - $sql.= ", total_ht=".price2num($this->total_ht).""; |
|
| 4667 | - $sql.= ", total_tva=".price2num($this->total_tva).""; |
|
| 4668 | - $sql.= ", total_ttc=".price2num($this->total_ttc).""; |
|
| 4669 | - $sql.= ", total_localtax1=".price2num($this->total_localtax1).""; |
|
| 4670 | - $sql.= ", total_localtax2=".price2num($this->total_localtax2).""; |
|
| 4666 | + $sql .= ", total_ht=".price2num($this->total_ht).""; |
|
| 4667 | + $sql .= ", total_tva=".price2num($this->total_tva).""; |
|
| 4668 | + $sql .= ", total_ttc=".price2num($this->total_ttc).""; |
|
| 4669 | + $sql .= ", total_localtax1=".price2num($this->total_localtax1).""; |
|
| 4670 | + $sql .= ", total_localtax2=".price2num($this->total_localtax2).""; |
|
| 4671 | 4671 | } |
| 4672 | - $sql.= ", fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); |
|
| 4673 | - $sql.= ", buy_price_ht='".price2num($this->pa_ht)."'"; |
|
| 4674 | - $sql.= ", fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); |
|
| 4675 | - if (! empty($this->rang)) $sql.= ", rang=".$this->rang; |
|
| 4676 | - $sql.= ", situation_percent=" . $this->situation_percent; |
|
| 4677 | - $sql.= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); |
|
| 4678 | - $sql.= ", fk_user_modif =".$user->id; |
|
| 4672 | + $sql .= ", fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null"); |
|
| 4673 | + $sql .= ", buy_price_ht='".price2num($this->pa_ht)."'"; |
|
| 4674 | + $sql .= ", fk_parent_line=".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); |
|
| 4675 | + if (!empty($this->rang)) $sql .= ", rang=".$this->rang; |
|
| 4676 | + $sql .= ", situation_percent=".$this->situation_percent; |
|
| 4677 | + $sql .= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); |
|
| 4678 | + $sql .= ", fk_user_modif =".$user->id; |
|
| 4679 | 4679 | |
| 4680 | 4680 | // Multicurrency |
| 4681 | - $sql.= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; |
|
| 4682 | - $sql.= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; |
|
| 4683 | - $sql.= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; |
|
| 4684 | - $sql.= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; |
|
| 4681 | + $sql .= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; |
|
| 4682 | + $sql .= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; |
|
| 4683 | + $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; |
|
| 4684 | + $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; |
|
| 4685 | 4685 | |
| 4686 | - $sql.= " WHERE rowid = ".$this->rowid; |
|
| 4686 | + $sql .= " WHERE rowid = ".$this->rowid; |
|
| 4687 | 4687 | |
| 4688 | 4688 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
| 4689 | - $resql=$this->db->query($sql); |
|
| 4689 | + $resql = $this->db->query($sql); |
|
| 4690 | 4690 | if ($resql) |
| 4691 | 4691 | { |
| 4692 | 4692 | if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
| 4693 | 4693 | { |
| 4694 | - $this->id=$this->rowid; |
|
| 4695 | - $result=$this->insertExtraFields(); |
|
| 4694 | + $this->id = $this->rowid; |
|
| 4695 | + $result = $this->insertExtraFields(); |
|
| 4696 | 4696 | if ($result < 0) |
| 4697 | 4697 | { |
| 4698 | 4698 | $error++; |
| 4699 | 4699 | } |
| 4700 | 4700 | } |
| 4701 | 4701 | |
| 4702 | - if (! $notrigger) |
|
| 4702 | + if (!$notrigger) |
|
| 4703 | 4703 | { |
| 4704 | 4704 | // Call trigger |
| 4705 | - $result=$this->call_trigger('LINEBILL_UPDATE',$user); |
|
| 4705 | + $result = $this->call_trigger('LINEBILL_UPDATE', $user); |
|
| 4706 | 4706 | if ($result < 0) |
| 4707 | 4707 | { |
| 4708 | 4708 | $this->db->rollback(); |
@@ -4715,7 +4715,7 @@ discard block |
||
| 4715 | 4715 | } |
| 4716 | 4716 | else |
| 4717 | 4717 | { |
| 4718 | - $this->error=$this->db->error(); |
|
| 4718 | + $this->error = $this->db->error(); |
|
| 4719 | 4719 | $this->db->rollback(); |
| 4720 | 4720 | return -2; |
| 4721 | 4721 | } |
@@ -4734,7 +4734,7 @@ discard block |
||
| 4734 | 4734 | $this->db->begin(); |
| 4735 | 4735 | |
| 4736 | 4736 | // Call trigger |
| 4737 | - $result=$this->call_trigger('LINEBILL_DELETE',$user); |
|
| 4737 | + $result = $this->call_trigger('LINEBILL_DELETE', $user); |
|
| 4738 | 4738 | if ($result < 0) |
| 4739 | 4739 | { |
| 4740 | 4740 | $this->db->rollback(); |
@@ -4745,14 +4745,14 @@ discard block |
||
| 4745 | 4745 | |
| 4746 | 4746 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".$this->rowid; |
| 4747 | 4747 | dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
| 4748 | - if ($this->db->query($sql) ) |
|
| 4748 | + if ($this->db->query($sql)) |
|
| 4749 | 4749 | { |
| 4750 | 4750 | $this->db->commit(); |
| 4751 | 4751 | return 1; |
| 4752 | 4752 | } |
| 4753 | 4753 | else |
| 4754 | 4754 | { |
| 4755 | - $this->error=$this->db->error()." sql=".$sql; |
|
| 4755 | + $this->error = $this->db->error()." sql=".$sql; |
|
| 4756 | 4756 | $this->db->rollback(); |
| 4757 | 4757 | return -1; |
| 4758 | 4758 | } |
@@ -4769,21 +4769,21 @@ discard block |
||
| 4769 | 4769 | dol_syslog(get_class($this)."::update_total", LOG_DEBUG); |
| 4770 | 4770 | |
| 4771 | 4771 | // Clean parameters |
| 4772 | - if (empty($this->total_localtax1)) $this->total_localtax1=0; |
|
| 4773 | - if (empty($this->total_localtax2)) $this->total_localtax2=0; |
|
| 4772 | + if (empty($this->total_localtax1)) $this->total_localtax1 = 0; |
|
| 4773 | + if (empty($this->total_localtax2)) $this->total_localtax2 = 0; |
|
| 4774 | 4774 | |
| 4775 | 4775 | // Mise a jour ligne en base |
| 4776 | 4776 | $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; |
| 4777 | - $sql.= " total_ht=".price2num($this->total_ht).""; |
|
| 4778 | - $sql.= ",total_tva=".price2num($this->total_tva).""; |
|
| 4779 | - $sql.= ",total_localtax1=".price2num($this->total_localtax1).""; |
|
| 4780 | - $sql.= ",total_localtax2=".price2num($this->total_localtax2).""; |
|
| 4781 | - $sql.= ",total_ttc=".price2num($this->total_ttc).""; |
|
| 4782 | - $sql.= " WHERE rowid = ".$this->rowid; |
|
| 4777 | + $sql .= " total_ht=".price2num($this->total_ht).""; |
|
| 4778 | + $sql .= ",total_tva=".price2num($this->total_tva).""; |
|
| 4779 | + $sql .= ",total_localtax1=".price2num($this->total_localtax1).""; |
|
| 4780 | + $sql .= ",total_localtax2=".price2num($this->total_localtax2).""; |
|
| 4781 | + $sql .= ",total_ttc=".price2num($this->total_ttc).""; |
|
| 4782 | + $sql .= " WHERE rowid = ".$this->rowid; |
|
| 4783 | 4783 | |
| 4784 | 4784 | dol_syslog(get_class($this)."::update_total", LOG_DEBUG); |
| 4785 | 4785 | |
| 4786 | - $resql=$this->db->query($sql); |
|
| 4786 | + $resql = $this->db->query($sql); |
|
| 4787 | 4787 | if ($resql) |
| 4788 | 4788 | { |
| 4789 | 4789 | $this->db->commit(); |
@@ -4791,7 +4791,7 @@ discard block |
||
| 4791 | 4791 | } |
| 4792 | 4792 | else |
| 4793 | 4793 | { |
| 4794 | - $this->error=$this->db->error(); |
|
| 4794 | + $this->error = $this->db->error(); |
|
| 4795 | 4795 | $this->db->rollback(); |
| 4796 | 4796 | return -2; |
| 4797 | 4797 | } |
@@ -4810,18 +4810,18 @@ discard block |
||
| 4810 | 4810 | return 0; |
| 4811 | 4811 | } else { |
| 4812 | 4812 | // If invoice is a not a situation invoice, this->fk_prev_id is used for something else |
| 4813 | - $tmpinvoice=new Facture($this->db); |
|
| 4813 | + $tmpinvoice = new Facture($this->db); |
|
| 4814 | 4814 | $tmpinvoice->fetch($invoiceid); |
| 4815 | 4815 | if ($tmpinvoice->type != Facture::TYPE_SITUATION) return 0; |
| 4816 | 4816 | |
| 4817 | - $sql = 'SELECT situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE rowid=' . $this->fk_prev_id; |
|
| 4817 | + $sql = 'SELECT situation_percent FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid='.$this->fk_prev_id; |
|
| 4818 | 4818 | $resql = $this->db->query($sql); |
| 4819 | 4819 | if ($resql && $resql->num_rows > 0) { |
| 4820 | 4820 | $res = $this->db->fetch_array($resql); |
| 4821 | 4821 | return $res['situation_percent']; |
| 4822 | 4822 | } else { |
| 4823 | 4823 | $this->error = $this->db->error(); |
| 4824 | - dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); |
|
| 4824 | + dol_syslog(get_class($this)."::select Error ".$this->error, LOG_ERR); |
|
| 4825 | 4825 | $this->db->rollback(); |
| 4826 | 4826 | return -1; |
| 4827 | 4827 | } |
@@ -236,19 +236,30 @@ discard block |
||
| 236 | 236 | $error=0; |
| 237 | 237 | |
| 238 | 238 | // Clean parameters |
| 239 | - if (empty($this->type)) $this->type = self::TYPE_STANDARD; |
|
| 239 | + if (empty($this->type)) { |
|
| 240 | + $this->type = self::TYPE_STANDARD; |
|
| 241 | + } |
|
| 240 | 242 | $this->ref_client=trim($this->ref_client); |
| 241 | 243 | $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated |
| 242 | 244 | $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note_private)); |
| 243 | 245 | $this->note_public=trim($this->note_public); |
| 244 | - if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; |
|
| 245 | - if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; |
|
| 246 | + if (! $this->cond_reglement_id) { |
|
| 247 | + $this->cond_reglement_id = 0; |
|
| 248 | + } |
|
| 249 | + if (! $this->mode_reglement_id) { |
|
| 250 | + $this->mode_reglement_id = 0; |
|
| 251 | + } |
|
| 246 | 252 | $this->brouillon = 1; |
| 247 | - if (empty($this->entity)) $this->entity = $conf->entity; |
|
| 253 | + if (empty($this->entity)) { |
|
| 254 | + $this->entity = $conf->entity; |
|
| 255 | + } |
|
| 248 | 256 | |
| 249 | 257 | // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) |
| 250 | - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); |
|
| 251 | - else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); |
|
| 258 | + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) { |
|
| 259 | + list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); |
|
| 260 | + } else { |
|
| 261 | + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); |
|
| 262 | + } |
|
| 252 | 263 | if (empty($this->fk_multicurrency)) |
| 253 | 264 | { |
| 254 | 265 | $this->multicurrency_code = $conf->currency; |
@@ -313,7 +324,9 @@ discard block |
||
| 313 | 324 | $this->location_incoterms= $_facrec->location_incoterms; |
| 314 | 325 | |
| 315 | 326 | // Clean parameters |
| 316 | - if (! $this->type) $this->type = self::TYPE_STANDARD; |
|
| 327 | + if (! $this->type) { |
|
| 328 | + $this->type = self::TYPE_STANDARD; |
|
| 329 | + } |
|
| 317 | 330 | $this->ref_client=trim($this->ref_client); |
| 318 | 331 | $this->note_public=trim($this->note_public); |
| 319 | 332 | $this->note_private=trim($this->note_private); |
@@ -322,7 +335,9 @@ discard block |
||
| 322 | 335 | $this->array_options=$_facrec->array_options; |
| 323 | 336 | |
| 324 | 337 | //if (! $this->remise) $this->remise = 0; |
| 325 | - if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; |
|
| 338 | + if (! $this->mode_reglement_id) { |
|
| 339 | + $this->mode_reglement_id = 0; |
|
| 340 | + } |
|
| 326 | 341 | $this->brouillon = 1; |
| 327 | 342 | |
| 328 | 343 | $this->linked_objects = $_facrec->linkedObjectsIds; |
@@ -333,7 +348,9 @@ discard block |
||
| 333 | 348 | if ($_facrec->frequency > 0) |
| 334 | 349 | { |
| 335 | 350 | dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); |
| 336 | - if (empty($_facrec->date_when)) $_facrec->date_when = $now; |
|
| 351 | + if (empty($_facrec->date_when)) { |
|
| 352 | + $_facrec->date_when = $now; |
|
| 353 | + } |
|
| 337 | 354 | $next_date = $_facrec->getNextDate(); // Calculate next date |
| 338 | 355 | $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date', '', $user, ''); |
| 339 | 356 | //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. |
@@ -344,8 +361,14 @@ discard block |
||
| 344 | 361 | $outputlangs = $langs; |
| 345 | 362 | $newlang=''; |
| 346 | 363 | |
| 347 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) $newlang=$this->thirdparty->default_lang; // for proposal, order, invoice, ... |
|
| 348 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) $newlang=$this->default_lang; // for thirdparty |
|
| 364 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) { |
|
| 365 | + $newlang=$this->thirdparty->default_lang; |
|
| 366 | + } |
|
| 367 | + // for proposal, order, invoice, ... |
|
| 368 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) { |
|
| 369 | + $newlang=$this->default_lang; |
|
| 370 | + } |
|
| 371 | + // for thirdparty |
|
| 349 | 372 | if (! empty($newlang)) |
| 350 | 373 | { |
| 351 | 374 | $outputlangs = new Translate("",$conf); |
@@ -448,11 +471,16 @@ discard block |
||
| 448 | 471 | $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET facnumber='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; |
| 449 | 472 | |
| 450 | 473 | $resql=$this->db->query($sql); |
| 451 | - if (! $resql) $error++; |
|
| 474 | + if (! $resql) { |
|
| 475 | + $error++; |
|
| 476 | + } |
|
| 452 | 477 | |
| 453 | - if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects |
|
| 478 | + if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) { |
|
| 479 | + // To use new linkedObjectsIds instead of old linked_objects |
|
| 454 | 480 | { |
| 455 | - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds |
|
| 481 | + $this->linked_objects = $this->linkedObjectsIds; |
|
| 482 | + } |
|
| 483 | + // TODO Replace linked_objects with linkedObjectsIds |
|
| 456 | 484 | } |
| 457 | 485 | |
| 458 | 486 | // Add object linked |
@@ -460,19 +488,20 @@ discard block |
||
| 460 | 488 | { |
| 461 | 489 | foreach($this->linked_objects as $origin => $tmp_origin_id) |
| 462 | 490 | { |
| 463 | - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) |
|
| 491 | + if (is_array($tmp_origin_id)) { |
|
| 492 | + // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) |
|
| 464 | 493 | { |
| 465 | 494 | foreach($tmp_origin_id as $origin_id) |
| 466 | 495 | { |
| 467 | 496 | $ret = $this->add_object_linked($origin, $origin_id); |
| 497 | + } |
|
| 468 | 498 | if (! $ret) |
| 469 | 499 | { |
| 470 | 500 | $this->error=$this->db->lasterror(); |
| 471 | 501 | $error++; |
| 472 | 502 | } |
| 473 | 503 | } |
| 474 | - } |
|
| 475 | - else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) |
|
| 504 | + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) |
|
| 476 | 505 | { |
| 477 | 506 | $origin_id = $tmp_origin_id; |
| 478 | 507 | $ret = $this->add_object_linked($origin, $origin_id); |
@@ -485,13 +514,17 @@ discard block |
||
| 485 | 514 | } |
| 486 | 515 | } |
| 487 | 516 | |
| 488 | - if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object |
|
| 517 | + if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) { |
|
| 518 | + // Get contact from origin object |
|
| 489 | 519 | { |
| 490 | 520 | $originforcontact = $this->origin; |
| 521 | + } |
|
| 491 | 522 | $originidforcontact = $this->origin_id; |
| 492 | - if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order |
|
| 523 | + if ($originforcontact == 'shipping') { |
|
| 524 | + // shipment and order share the same contacts. If creating from shipment we take data of order |
|
| 493 | 525 | { |
| 494 | 526 | require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; |
| 527 | + } |
|
| 495 | 528 | $exp = new Expedition($this->db); |
| 496 | 529 | $exp->fetch($this->origin_id); |
| 497 | 530 | $exp->fetchObjectLinked(); |
@@ -500,8 +533,11 @@ discard block |
||
| 500 | 533 | foreach ($exp->linkedObjectsIds['commande'] as $key => $value) |
| 501 | 534 | { |
| 502 | 535 | $originforcontact = 'commande'; |
| 503 | - if (is_object($value)) $originidforcontact = $value->id; |
|
| 504 | - else $originidforcontact = $value; |
|
| 536 | + if (is_object($value)) { |
|
| 537 | + $originidforcontact = $value->id; |
|
| 538 | + } else { |
|
| 539 | + $originidforcontact = $value; |
|
| 540 | + } |
|
| 505 | 541 | break; // We take first one |
| 506 | 542 | } |
| 507 | 543 | } |
@@ -518,16 +554,19 @@ discard block |
||
| 518 | 554 | //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; |
| 519 | 555 | $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object |
| 520 | 556 | } |
| 557 | + } else { |
|
| 558 | + dol_print_error($resqlcontact); |
|
| 521 | 559 | } |
| 522 | - else dol_print_error($resqlcontact); |
|
| 523 | 560 | } |
| 524 | 561 | |
| 525 | 562 | /* |
| 526 | 563 | * Insert lines of invoices into database |
| 527 | 564 | */ |
| 528 | - if (count($this->lines) && is_object($this->lines[0])) // If this->lines is array of InvoiceLines (preferred mode) |
|
| 565 | + if (count($this->lines) && is_object($this->lines[0])) { |
|
| 566 | + // If this->lines is array of InvoiceLines (preferred mode) |
|
| 529 | 567 | { |
| 530 | 568 | $fk_parent_line = 0; |
| 569 | + } |
|
| 531 | 570 | |
| 532 | 571 | dol_syslog("There is ".count($this->lines)." lines that are invoice lines objects"); |
| 533 | 572 | foreach ($this->lines as $i => $val) |
@@ -561,8 +600,7 @@ discard block |
||
| 561 | 600 | break; |
| 562 | 601 | } |
| 563 | 602 | } |
| 564 | - } |
|
| 565 | - else // If this->lines is an array of invoice line arrays |
|
| 603 | + } else // If this->lines is an array of invoice line arrays |
|
| 566 | 604 | { |
| 567 | 605 | $fk_parent_line = 0; |
| 568 | 606 | |
@@ -574,7 +612,9 @@ discard block |
||
| 574 | 612 | |
| 575 | 613 | // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array |
| 576 | 614 | //if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object. |
| 577 | - if (! is_object($line)) $line = (object) $line; |
|
| 615 | + if (! is_object($line)) { |
|
| 616 | + $line = (object) $line; |
|
| 617 | + } |
|
| 578 | 618 | |
| 579 | 619 | if ($result >= 0) |
| 580 | 620 | { |
@@ -585,7 +625,9 @@ discard block |
||
| 585 | 625 | |
| 586 | 626 | // Complete vat rate with code |
| 587 | 627 | $vatrate = $line->tva_tx; |
| 588 | - if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; |
|
| 628 | + if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) { |
|
| 629 | + $vatrate.=' ('.$line->vat_src_code.')'; |
|
| 630 | + } |
|
| 589 | 631 | |
| 590 | 632 | $result = $this->addline( |
| 591 | 633 | $line->desc, |
@@ -648,7 +690,9 @@ discard block |
||
| 648 | 690 | } |
| 649 | 691 | $tva_tx = get_default_tva($mysoc,$soc,$prod->id); |
| 650 | 692 | $tva_npr = get_default_npr($mysoc,$soc,$prod->id); |
| 651 | - if (empty($tva_tx)) $tva_npr=0; |
|
| 693 | + if (empty($tva_tx)) { |
|
| 694 | + $tva_npr=0; |
|
| 695 | + } |
|
| 652 | 696 | $localtax1_tx=get_localtax($tva_tx,1,$soc,$mysoc,$tva_npr); |
| 653 | 697 | $localtax2_tx=get_localtax($tva_tx,2,$soc,$mysoc,$tva_npr); |
| 654 | 698 | |
@@ -708,7 +752,9 @@ discard block |
||
| 708 | 752 | if (! $error) |
| 709 | 753 | { |
| 710 | 754 | $result=$this->insertExtraFields(); |
| 711 | - if ($result < 0) $error++; |
|
| 755 | + if ($result < 0) { |
|
| 756 | + $error++; |
|
| 757 | + } |
|
| 712 | 758 | } |
| 713 | 759 | /*} |
| 714 | 760 | } |
@@ -716,35 +762,33 @@ discard block |
||
| 716 | 762 | |
| 717 | 763 | // Call trigger |
| 718 | 764 | $result=$this->call_trigger('BILL_CREATE',$user); |
| 719 | - if ($result < 0) $error++; |
|
| 765 | + if ($result < 0) { |
|
| 766 | + $error++; |
|
| 767 | + } |
|
| 720 | 768 | // End call triggers |
| 721 | 769 | |
| 722 | 770 | if (! $error) |
| 723 | 771 | { |
| 724 | 772 | $this->db->commit(); |
| 725 | 773 | return $this->id; |
| 726 | - } |
|
| 727 | - else |
|
| 774 | + } else |
|
| 728 | 775 | { |
| 729 | 776 | $this->db->rollback(); |
| 730 | 777 | return -4; |
| 731 | 778 | } |
| 732 | - } |
|
| 733 | - else |
|
| 779 | + } else |
|
| 734 | 780 | { |
| 735 | 781 | $this->error=$langs->trans('FailedToUpdatePrice'); |
| 736 | 782 | $this->db->rollback(); |
| 737 | 783 | return -3; |
| 738 | 784 | } |
| 739 | - } |
|
| 740 | - else |
|
| 785 | + } else |
|
| 741 | 786 | { |
| 742 | 787 | dol_syslog(get_class($this)."::create error ".$this->error, LOG_ERR); |
| 743 | 788 | $this->db->rollback(); |
| 744 | 789 | return -2; |
| 745 | 790 | } |
| 746 | - } |
|
| 747 | - else |
|
| 791 | + } else |
|
| 748 | 792 | { |
| 749 | 793 | $this->error=$this->db->error(); |
| 750 | 794 | $this->db->rollback(); |
@@ -822,8 +866,7 @@ discard block |
||
| 822 | 866 | { |
| 823 | 867 | $this->error=$facture->error; |
| 824 | 868 | $this->errors=$facture->errors; |
| 825 | - } |
|
| 826 | - elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) |
|
| 869 | + } elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) |
|
| 827 | 870 | { |
| 828 | 871 | $this->fetchObjectLinked('', '', $object->id, 'facture'); |
| 829 | 872 | |
@@ -859,8 +902,9 @@ discard block |
||
| 859 | 902 | $this->db->begin(); |
| 860 | 903 | |
| 861 | 904 | // get extrafields so they will be clone |
| 862 | - foreach($this->lines as $line) |
|
| 863 | - $line->fetch_optionals($line->rowid); |
|
| 905 | + foreach($this->lines as $line) { |
|
| 906 | + $line->fetch_optionals($line->rowid); |
|
| 907 | + } |
|
| 864 | 908 | |
| 865 | 909 | // Load source object |
| 866 | 910 | $objFrom = clone $this; |
@@ -902,26 +946,31 @@ discard block |
||
| 902 | 946 | // Loop on each line of new invoice |
| 903 | 947 | foreach($this->lines as $i => $line) |
| 904 | 948 | { |
| 905 | - if (($this->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts |
|
| 949 | + if (($this->lines[$i]->info_bits & 0x02) == 0x02) { |
|
| 950 | + // We do not clone line of discounts |
|
| 906 | 951 | { |
| 907 | 952 | unset($this->lines[$i]); |
| 953 | + } |
|
| 908 | 954 | unset($this->products[$i]); // Tant que products encore utilise |
| 909 | 955 | } |
| 910 | 956 | } |
| 911 | 957 | |
| 912 | 958 | // Create clone |
| 913 | 959 | $result=$this->create($user); |
| 914 | - if ($result < 0) $error++; |
|
| 915 | - else { |
|
| 960 | + if ($result < 0) { |
|
| 961 | + $error++; |
|
| 962 | + } else { |
|
| 916 | 963 | // copy internal contacts |
| 917 | - if ($this->copy_linked_contact($objFrom, 'internal') < 0) |
|
| 918 | - $error++; |
|
| 964 | + if ($this->copy_linked_contact($objFrom, 'internal') < 0) { |
|
| 965 | + $error++; |
|
| 966 | + } |
|
| 919 | 967 | |
| 920 | 968 | // copy external contacts if same company |
| 921 | 969 | elseif ($objFrom->socid == $this->socid) |
| 922 | 970 | { |
| 923 | - if ($this->copy_linked_contact($objFrom, 'external') < 0) |
|
| 924 | - $error++; |
|
| 971 | + if ($this->copy_linked_contact($objFrom, 'external') < 0) { |
|
| 972 | + $error++; |
|
| 973 | + } |
|
| 925 | 974 | } |
| 926 | 975 | } |
| 927 | 976 | |
@@ -933,12 +982,16 @@ discard block |
||
| 933 | 982 | $parameters=array('objFrom'=>$objFrom); |
| 934 | 983 | $action=''; |
| 935 | 984 | $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 936 | - if ($reshook < 0) $error++; |
|
| 985 | + if ($reshook < 0) { |
|
| 986 | + $error++; |
|
| 987 | + } |
|
| 937 | 988 | } |
| 938 | 989 | |
| 939 | 990 | // Call trigger |
| 940 | 991 | $result=$this->call_trigger('BILL_CLONE',$user); |
| 941 | - if ($result < 0) $error++; |
|
| 992 | + if ($result < 0) { |
|
| 993 | + $error++; |
|
| 994 | + } |
|
| 942 | 995 | // End call triggers |
| 943 | 996 | } |
| 944 | 997 | |
@@ -949,8 +1002,7 @@ discard block |
||
| 949 | 1002 | { |
| 950 | 1003 | $this->db->commit(); |
| 951 | 1004 | return $this->id; |
| 952 | - } |
|
| 953 | - else |
|
| 1005 | + } else |
|
| 954 | 1006 | { |
| 955 | 1007 | $this->db->rollback(); |
| 956 | 1008 | return -1; |
@@ -1011,8 +1063,9 @@ discard block |
||
| 1011 | 1063 | |
| 1012 | 1064 | // get extrafields from original line |
| 1013 | 1065 | $object->lines[$i]->fetch_optionals($object->lines[$i]->rowid); |
| 1014 | - foreach($object->lines[$i]->array_options as $options_key => $value) |
|
| 1015 | - $line->array_options[$options_key] = $value; |
|
| 1066 | + foreach($object->lines[$i]->array_options as $options_key => $value) { |
|
| 1067 | + $line->array_options[$options_key] = $value; |
|
| 1068 | + } |
|
| 1016 | 1069 | |
| 1017 | 1070 | $this->lines[$i] = $line; |
| 1018 | 1071 | } |
@@ -1035,8 +1088,9 @@ discard block |
||
| 1035 | 1088 | |
| 1036 | 1089 | // get extrafields from original line |
| 1037 | 1090 | $object->fetch_optionals($object->id); |
| 1038 | - foreach($object->array_options as $options_key => $value) |
|
| 1039 | - $this->array_options[$options_key] = $value; |
|
| 1091 | + foreach($object->array_options as $options_key => $value) { |
|
| 1092 | + $this->array_options[$options_key] = $value; |
|
| 1093 | + } |
|
| 1040 | 1094 | |
| 1041 | 1095 | // Possibility to add external linked objects with hooks |
| 1042 | 1096 | $this->linked_objects[$this->origin] = $this->origin_id; |
@@ -1055,15 +1109,19 @@ discard block |
||
| 1055 | 1109 | $parameters=array('objFrom'=>$object); |
| 1056 | 1110 | $action=''; |
| 1057 | 1111 | $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 1058 | - if ($reshook < 0) $error++; |
|
| 1112 | + if ($reshook < 0) { |
|
| 1113 | + $error++; |
|
| 1114 | + } |
|
| 1059 | 1115 | |
| 1060 | 1116 | if (! $error) |
| 1061 | 1117 | { |
| 1062 | 1118 | return 1; |
| 1119 | + } else { |
|
| 1120 | + return -1; |
|
| 1063 | 1121 | } |
| 1064 | - else return -1; |
|
| 1122 | + } else { |
|
| 1123 | + return -1; |
|
| 1065 | 1124 | } |
| 1066 | - else return -1; |
|
| 1067 | 1125 | } |
| 1068 | 1126 | |
| 1069 | 1127 | /** |
@@ -1107,50 +1165,88 @@ discard block |
||
| 1107 | 1165 | { |
| 1108 | 1166 | global $langs, $conf, $user, $form; |
| 1109 | 1167 | |
| 1110 | - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
| 1168 | + if (! empty($conf->dol_no_mouse_hover)) { |
|
| 1169 | + $notooltip=1; |
|
| 1170 | + } |
|
| 1171 | + // Force disable tooltips |
|
| 1111 | 1172 | |
| 1112 | 1173 | $result=''; |
| 1113 | 1174 | |
| 1114 | - if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id; |
|
| 1115 | - else $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id; |
|
| 1175 | + if ($option == 'withdraw') { |
|
| 1176 | + $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id; |
|
| 1177 | + } else { |
|
| 1178 | + $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id; |
|
| 1179 | + } |
|
| 1116 | 1180 | |
| 1117 | - if ($short) return $url; |
|
| 1181 | + if ($short) { |
|
| 1182 | + return $url; |
|
| 1183 | + } |
|
| 1118 | 1184 | |
| 1119 | 1185 | if ($option !== 'nolink') |
| 1120 | 1186 | { |
| 1121 | 1187 | // Add param to save lastsearch_values or not |
| 1122 | 1188 | $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
| 1123 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 1124 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 1189 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) { |
|
| 1190 | + $add_save_lastsearch_values=1; |
|
| 1191 | + } |
|
| 1192 | + if ($add_save_lastsearch_values) { |
|
| 1193 | + $url.='&save_lastsearch_values=1'; |
|
| 1194 | + } |
|
| 1125 | 1195 | } |
| 1126 | 1196 | |
| 1127 | 1197 | $picto='bill'; |
| 1128 | - if ($this->type == self::TYPE_REPLACEMENT) $picto.='r'; // Replacement invoice |
|
| 1129 | - if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note |
|
| 1130 | - if ($this->type == self::TYPE_DEPOSIT) $picto.='d'; // Deposit invoice |
|
| 1198 | + if ($this->type == self::TYPE_REPLACEMENT) { |
|
| 1199 | + $picto.='r'; |
|
| 1200 | + } |
|
| 1201 | + // Replacement invoice |
|
| 1202 | + if ($this->type == self::TYPE_CREDIT_NOTE) { |
|
| 1203 | + $picto.='a'; |
|
| 1204 | + } |
|
| 1205 | + // Credit note |
|
| 1206 | + if ($this->type == self::TYPE_DEPOSIT) { |
|
| 1207 | + $picto.='d'; |
|
| 1208 | + } |
|
| 1209 | + // Deposit invoice |
|
| 1131 | 1210 | $label=''; |
| 1132 | 1211 | |
| 1133 | 1212 | if ($user->rights->facture->lire) { |
| 1134 | 1213 | $label = '<u>' . $langs->trans("ShowInvoice") . '</u>'; |
| 1135 | - if (! empty($this->ref)) |
|
| 1136 | - $label .= '<br><b>'.$langs->trans('Ref') . ':</b> ' . $this->ref; |
|
| 1137 | - if (! empty($this->ref_client)) |
|
| 1138 | - $label .= '<br><b>' . $langs->trans('RefCustomer') . ':</b> ' . $this->ref_client; |
|
| 1139 | - if (! empty($this->total_ht)) |
|
| 1140 | - $label.= '<br><b>' . $langs->trans('AmountHT') . ':</b> ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1141 | - if (! empty($this->total_tva)) |
|
| 1142 | - $label.= '<br><b>' . $langs->trans('VAT') . ':</b> ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1143 | - if (! empty($this->total_tva)) |
|
| 1144 | - $label.= '<br><b>' . $langs->trans('LT1') . ':</b> ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1145 | - if (! empty($this->total_tva)) |
|
| 1146 | - $label.= '<br><b>' . $langs->trans('LT2') . ':</b> ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1147 | - if (! empty($this->total_ttc)) |
|
| 1148 | - $label.= '<br><b>' . $langs->trans('AmountTTC') . ':</b> ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1149 | - if ($this->type == self::TYPE_REPLACEMENT) $label=$langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref; |
|
| 1150 | - if ($this->type == self::TYPE_CREDIT_NOTE) $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref; |
|
| 1151 | - if ($this->type == self::TYPE_DEPOSIT) $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref; |
|
| 1152 | - if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref; |
|
| 1153 | - if ($moretitle) $label.=' - '.$moretitle; |
|
| 1214 | + if (! empty($this->ref)) { |
|
| 1215 | + $label .= '<br><b>'.$langs->trans('Ref') . ':</b> ' . $this->ref; |
|
| 1216 | + } |
|
| 1217 | + if (! empty($this->ref_client)) { |
|
| 1218 | + $label .= '<br><b>' . $langs->trans('RefCustomer') . ':</b> ' . $this->ref_client; |
|
| 1219 | + } |
|
| 1220 | + if (! empty($this->total_ht)) { |
|
| 1221 | + $label.= '<br><b>' . $langs->trans('AmountHT') . ':</b> ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1222 | + } |
|
| 1223 | + if (! empty($this->total_tva)) { |
|
| 1224 | + $label.= '<br><b>' . $langs->trans('VAT') . ':</b> ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1225 | + } |
|
| 1226 | + if (! empty($this->total_tva)) { |
|
| 1227 | + $label.= '<br><b>' . $langs->trans('LT1') . ':</b> ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1228 | + } |
|
| 1229 | + if (! empty($this->total_tva)) { |
|
| 1230 | + $label.= '<br><b>' . $langs->trans('LT2') . ':</b> ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1231 | + } |
|
| 1232 | + if (! empty($this->total_ttc)) { |
|
| 1233 | + $label.= '<br><b>' . $langs->trans('AmountTTC') . ':</b> ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); |
|
| 1234 | + } |
|
| 1235 | + if ($this->type == self::TYPE_REPLACEMENT) { |
|
| 1236 | + $label=$langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref; |
|
| 1237 | + } |
|
| 1238 | + if ($this->type == self::TYPE_CREDIT_NOTE) { |
|
| 1239 | + $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref; |
|
| 1240 | + } |
|
| 1241 | + if ($this->type == self::TYPE_DEPOSIT) { |
|
| 1242 | + $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref; |
|
| 1243 | + } |
|
| 1244 | + if ($this->type == self::TYPE_SITUATION) { |
|
| 1245 | + $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref; |
|
| 1246 | + } |
|
| 1247 | + if ($moretitle) { |
|
| 1248 | + $label.=' - '.$moretitle; |
|
| 1249 | + } |
|
| 1154 | 1250 | } |
| 1155 | 1251 | |
| 1156 | 1252 | $linkclose=''; |
@@ -1170,8 +1266,12 @@ discard block |
||
| 1170 | 1266 | $linkend='</a>'; |
| 1171 | 1267 | |
| 1172 | 1268 | $result .= $linkstart; |
| 1173 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
| 1174 | - if ($withpicto != 2) $result.= ($max?dol_trunc($this->ref,$max):$this->ref); |
|
| 1269 | + if ($withpicto) { |
|
| 1270 | + $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
| 1271 | + } |
|
| 1272 | + if ($withpicto != 2) { |
|
| 1273 | + $result.= ($max?dol_trunc($this->ref,$max):$this->ref); |
|
| 1274 | + } |
|
| 1175 | 1275 | $result .= $linkend; |
| 1176 | 1276 | |
| 1177 | 1277 | if ($addlinktonotes) |
@@ -1205,7 +1305,9 @@ discard block |
||
| 1205 | 1305 | { |
| 1206 | 1306 | global $conf; |
| 1207 | 1307 | |
| 1208 | - if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; |
|
| 1308 | + if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) { |
|
| 1309 | + return -1; |
|
| 1310 | + } |
|
| 1209 | 1311 | |
| 1210 | 1312 | $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; |
| 1211 | 1313 | $sql.= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; |
@@ -1230,10 +1332,18 @@ discard block |
||
| 1230 | 1332 | $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id AND p.entity IN ('.getEntity('c_paiement').')'; |
| 1231 | 1333 | $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; |
| 1232 | 1334 | $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; |
| 1233 | - if ($rowid) $sql.= " AND f.rowid=".$rowid; |
|
| 1234 | - if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'"; |
|
| 1235 | - if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; |
|
| 1236 | - if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; |
|
| 1335 | + if ($rowid) { |
|
| 1336 | + $sql.= " AND f.rowid=".$rowid; |
|
| 1337 | + } |
|
| 1338 | + if ($ref) { |
|
| 1339 | + $sql.= " AND f.facnumber='".$this->db->escape($ref)."'"; |
|
| 1340 | + } |
|
| 1341 | + if ($ref_ext) { |
|
| 1342 | + $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; |
|
| 1343 | + } |
|
| 1344 | + if ($ref_int) { |
|
| 1345 | + $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; |
|
| 1346 | + } |
|
| 1237 | 1347 | |
| 1238 | 1348 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
| 1239 | 1349 | $result = $this->db->query($sql); |
@@ -1308,7 +1418,9 @@ discard block |
||
| 1308 | 1418 | $this->fetchPreviousNextSituationInvoice(); |
| 1309 | 1419 | } |
| 1310 | 1420 | |
| 1311 | - if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; |
|
| 1421 | + if ($this->statut == self::STATUS_DRAFT) { |
|
| 1422 | + $this->brouillon = 1; |
|
| 1423 | + } |
|
| 1312 | 1424 | |
| 1313 | 1425 | // Retrieve all extrafield for invoice |
| 1314 | 1426 | // fetch optionals attributes and labels |
@@ -1330,15 +1442,13 @@ discard block |
||
| 1330 | 1442 | return -3; |
| 1331 | 1443 | } |
| 1332 | 1444 | return 1; |
| 1333 | - } |
|
| 1334 | - else |
|
| 1445 | + } else |
|
| 1335 | 1446 | { |
| 1336 | 1447 | $this->error='Bill with id '.$rowid.' or ref '.$ref.' not found'; |
| 1337 | 1448 | dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); |
| 1338 | 1449 | return 0; |
| 1339 | 1450 | } |
| 1340 | - } |
|
| 1341 | - else |
|
| 1451 | + } else |
|
| 1342 | 1452 | { |
| 1343 | 1453 | $this->error=$this->db->error(); |
| 1344 | 1454 | return -1; |
@@ -1444,8 +1554,7 @@ discard block |
||
| 1444 | 1554 | } |
| 1445 | 1555 | $this->db->free($result); |
| 1446 | 1556 | return 1; |
| 1447 | - } |
|
| 1448 | - else |
|
| 1557 | + } else |
|
| 1449 | 1558 | { |
| 1450 | 1559 | $this->error=$this->db->error(); |
| 1451 | 1560 | return -3; |
@@ -1475,8 +1584,11 @@ discard block |
||
| 1475 | 1584 | $invoice = new Facture($this->db); |
| 1476 | 1585 | if ($invoice->fetch($objp->rowid) > 0) |
| 1477 | 1586 | { |
| 1478 | - if ($objp->situation_counter < $this->situation_counter) $this->tab_previous_situation_invoice[] = $invoice; |
|
| 1479 | - else $this->tab_next_situation_invoice[] = $invoice; |
|
| 1587 | + if ($objp->situation_counter < $this->situation_counter) { |
|
| 1588 | + $this->tab_previous_situation_invoice[] = $invoice; |
|
| 1589 | + } else { |
|
| 1590 | + $this->tab_next_situation_invoice[] = $invoice; |
|
| 1591 | + } |
|
| 1480 | 1592 | } |
| 1481 | 1593 | } |
| 1482 | 1594 | } |
@@ -1495,17 +1607,40 @@ discard block |
||
| 1495 | 1607 | $error=0; |
| 1496 | 1608 | |
| 1497 | 1609 | // Clean parameters |
| 1498 | - if (empty($this->type)) $this->type= self::TYPE_STANDARD; |
|
| 1499 | - if (isset($this->facnumber)) $this->facnumber=trim($this->ref); |
|
| 1500 | - if (isset($this->ref_client)) $this->ref_client=trim($this->ref_client); |
|
| 1501 | - if (isset($this->increment)) $this->increment=trim($this->increment); |
|
| 1502 | - if (isset($this->close_code)) $this->close_code=trim($this->close_code); |
|
| 1503 | - if (isset($this->close_note)) $this->close_note=trim($this->close_note); |
|
| 1504 | - if (isset($this->note) || isset($this->note_private)) $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated |
|
| 1505 | - if (isset($this->note) || isset($this->note_private)) $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note)); |
|
| 1506 | - if (isset($this->note_public)) $this->note_public=trim($this->note_public); |
|
| 1507 | - if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); |
|
| 1508 | - if (isset($this->import_key)) $this->import_key=trim($this->import_key); |
|
| 1610 | + if (empty($this->type)) { |
|
| 1611 | + $this->type= self::TYPE_STANDARD; |
|
| 1612 | + } |
|
| 1613 | + if (isset($this->facnumber)) { |
|
| 1614 | + $this->facnumber=trim($this->ref); |
|
| 1615 | + } |
|
| 1616 | + if (isset($this->ref_client)) { |
|
| 1617 | + $this->ref_client=trim($this->ref_client); |
|
| 1618 | + } |
|
| 1619 | + if (isset($this->increment)) { |
|
| 1620 | + $this->increment=trim($this->increment); |
|
| 1621 | + } |
|
| 1622 | + if (isset($this->close_code)) { |
|
| 1623 | + $this->close_code=trim($this->close_code); |
|
| 1624 | + } |
|
| 1625 | + if (isset($this->close_note)) { |
|
| 1626 | + $this->close_note=trim($this->close_note); |
|
| 1627 | + } |
|
| 1628 | + if (isset($this->note) || isset($this->note_private)) { |
|
| 1629 | + $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); |
|
| 1630 | + } |
|
| 1631 | + // deprecated |
|
| 1632 | + if (isset($this->note) || isset($this->note_private)) { |
|
| 1633 | + $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note)); |
|
| 1634 | + } |
|
| 1635 | + if (isset($this->note_public)) { |
|
| 1636 | + $this->note_public=trim($this->note_public); |
|
| 1637 | + } |
|
| 1638 | + if (isset($this->modelpdf)) { |
|
| 1639 | + $this->modelpdf=trim($this->modelpdf); |
|
| 1640 | + } |
|
| 1641 | + if (isset($this->import_key)) { |
|
| 1642 | + $this->import_key=trim($this->import_key); |
|
| 1643 | + } |
|
| 1509 | 1644 | if (empty($this->situation_cycle_ref)) { |
| 1510 | 1645 | $this->situation_cycle_ref = 'null'; |
| 1511 | 1646 | } |
@@ -1576,7 +1711,9 @@ discard block |
||
| 1576 | 1711 | { |
| 1577 | 1712 | // Call trigger |
| 1578 | 1713 | $result=$this->call_trigger('BILL_MODIFY',$user); |
| 1579 | - if ($result < 0) $error++; |
|
| 1714 | + if ($result < 0) { |
|
| 1715 | + $error++; |
|
| 1716 | + } |
|
| 1580 | 1717 | // End call triggers |
| 1581 | 1718 | } |
| 1582 | 1719 | } |
@@ -1591,8 +1728,7 @@ discard block |
||
| 1591 | 1728 | } |
| 1592 | 1729 | $this->db->rollback(); |
| 1593 | 1730 | return -1*$error; |
| 1594 | - } |
|
| 1595 | - else |
|
| 1731 | + } else |
|
| 1596 | 1732 | { |
| 1597 | 1733 | $this->db->commit(); |
| 1598 | 1734 | return 1; |
@@ -1620,9 +1756,11 @@ discard block |
||
| 1620 | 1756 | |
| 1621 | 1757 | if ($result > 0) |
| 1622 | 1758 | { |
| 1623 | - if ($remise->fk_facture) // Protection against multiple submission |
|
| 1759 | + if ($remise->fk_facture) { |
|
| 1760 | + // Protection against multiple submission |
|
| 1624 | 1761 | { |
| 1625 | 1762 | $this->error=$langs->trans("ErrorDiscountAlreadyUsed"); |
| 1763 | + } |
|
| 1626 | 1764 | $this->db->rollback(); |
| 1627 | 1765 | return -5; |
| 1628 | 1766 | } |
@@ -1678,22 +1816,19 @@ discard block |
||
| 1678 | 1816 | |
| 1679 | 1817 | $this->db->commit(); |
| 1680 | 1818 | return 1; |
| 1681 | - } |
|
| 1682 | - else |
|
| 1819 | + } else |
|
| 1683 | 1820 | { |
| 1684 | 1821 | $this->error=$facligne->error; |
| 1685 | 1822 | $this->db->rollback(); |
| 1686 | 1823 | return -1; |
| 1687 | 1824 | } |
| 1688 | - } |
|
| 1689 | - else |
|
| 1825 | + } else |
|
| 1690 | 1826 | { |
| 1691 | 1827 | $this->error=$facligne->error; |
| 1692 | 1828 | $this->db->rollback(); |
| 1693 | 1829 | return -2; |
| 1694 | 1830 | } |
| 1695 | - } |
|
| 1696 | - else |
|
| 1831 | + } else |
|
| 1697 | 1832 | { |
| 1698 | 1833 | $this->db->rollback(); |
| 1699 | 1834 | return -3; |
@@ -1716,10 +1851,11 @@ discard block |
||
| 1716 | 1851 | $this->db->begin(); |
| 1717 | 1852 | |
| 1718 | 1853 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; |
| 1719 | - if (empty($ref_client)) |
|
| 1720 | - $sql .= ' SET ref_client = NULL'; |
|
| 1721 | - else |
|
| 1722 | - $sql .= ' SET ref_client = \''.$this->db->escape($ref_client).'\''; |
|
| 1854 | + if (empty($ref_client)) { |
|
| 1855 | + $sql .= ' SET ref_client = NULL'; |
|
| 1856 | + } else { |
|
| 1857 | + $sql .= ' SET ref_client = \''.$this->db->escape($ref_client).'\''; |
|
| 1858 | + } |
|
| 1723 | 1859 | $sql .= ' WHERE rowid = '.$this->id; |
| 1724 | 1860 | |
| 1725 | 1861 | dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG); |
@@ -1739,7 +1875,9 @@ discard block |
||
| 1739 | 1875 | { |
| 1740 | 1876 | // Call trigger |
| 1741 | 1877 | $result=$this->call_trigger('BILL_MODIFY',$user); |
| 1742 | - if ($result < 0) $error++; |
|
| 1878 | + if ($result < 0) { |
|
| 1879 | + $error++; |
|
| 1880 | + } |
|
| 1743 | 1881 | // End call triggers |
| 1744 | 1882 | } |
| 1745 | 1883 | |
@@ -1750,8 +1888,7 @@ discard block |
||
| 1750 | 1888 | |
| 1751 | 1889 | $this->db->commit(); |
| 1752 | 1890 | return 1; |
| 1753 | - } |
|
| 1754 | - else |
|
| 1891 | + } else |
|
| 1755 | 1892 | { |
| 1756 | 1893 | foreach($this->errors as $errmsg) |
| 1757 | 1894 | { |
@@ -1783,7 +1920,9 @@ discard block |
||
| 1783 | 1920 | // Test to avoid invoice deletion (allowed if draft) |
| 1784 | 1921 | $test = $this->is_erasable(); |
| 1785 | 1922 | |
| 1786 | - if ($test <= 0) return 0; |
|
| 1923 | + if ($test <= 0) { |
|
| 1924 | + return 0; |
|
| 1925 | + } |
|
| 1787 | 1926 | |
| 1788 | 1927 | $error=0; |
| 1789 | 1928 | |
@@ -1793,7 +1932,9 @@ discard block |
||
| 1793 | 1932 | { |
| 1794 | 1933 | // Call trigger |
| 1795 | 1934 | $result=$this->call_trigger('BILL_DELETE',$user); |
| 1796 | - if ($result < 0) $error++; |
|
| 1935 | + if ($result < 0) { |
|
| 1936 | + $error++; |
|
| 1937 | + } |
|
| 1797 | 1938 | // End call triggers |
| 1798 | 1939 | } |
| 1799 | 1940 | |
@@ -1811,7 +1952,9 @@ discard block |
||
| 1811 | 1952 | { |
| 1812 | 1953 | // Delete linked object |
| 1813 | 1954 | $res = $this->deleteObjectLinked(); |
| 1814 | - if ($res < 0) $error++; |
|
| 1955 | + if ($res < 0) { |
|
| 1956 | + $error++; |
|
| 1957 | + } |
|
| 1815 | 1958 | } |
| 1816 | 1959 | |
| 1817 | 1960 | if (! $error) |
@@ -1860,8 +2003,12 @@ discard block |
||
| 1860 | 2003 | $mouvP = new MouvementStock($this->db); |
| 1861 | 2004 | $mouvP->origin = &$this; |
| 1862 | 2005 | // We decrease stock for product |
| 1863 | - if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); |
|
| 1864 | - else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value |
|
| 2006 | + if ($this->type == self::TYPE_CREDIT_NOTE) { |
|
| 2007 | + $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); |
|
| 2008 | + } else { |
|
| 2009 | + $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); |
|
| 2010 | + } |
|
| 2011 | + // we use 0 for price, to not change the weighted average value |
|
| 1865 | 2012 | } |
| 1866 | 2013 | } |
| 1867 | 2014 | } |
@@ -1887,22 +2034,28 @@ discard block |
||
| 1887 | 2034 | { |
| 1888 | 2035 | $dir = $conf->facture->dir_output . "/" . $ref; |
| 1889 | 2036 | $file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf"; |
| 1890 | - if (file_exists($file)) // We must delete all files before deleting directory |
|
| 2037 | + if (file_exists($file)) { |
|
| 2038 | + // We must delete all files before deleting directory |
|
| 1891 | 2039 | { |
| 1892 | 2040 | $ret=dol_delete_preview($this); |
| 2041 | + } |
|
| 1893 | 2042 | |
| 1894 | - if (! dol_delete_file($file,0,0,0,$this)) // For triggers |
|
| 2043 | + if (! dol_delete_file($file,0,0,0,$this)) { |
|
| 2044 | + // For triggers |
|
| 1895 | 2045 | { |
| 1896 | 2046 | $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); |
| 2047 | + } |
|
| 1897 | 2048 | $this->db->rollback(); |
| 1898 | 2049 | return 0; |
| 1899 | 2050 | } |
| 1900 | 2051 | } |
| 1901 | 2052 | if (file_exists($dir)) |
| 1902 | 2053 | { |
| 1903 | - if (! dol_delete_dir_recursive($dir)) // For remove dir and meta |
|
| 2054 | + if (! dol_delete_dir_recursive($dir)) { |
|
| 2055 | + // For remove dir and meta |
|
| 1904 | 2056 | { |
| 1905 | 2057 | $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); |
| 2058 | + } |
|
| 1906 | 2059 | $this->db->rollback(); |
| 1907 | 2060 | return 0; |
| 1908 | 2061 | } |
@@ -1911,22 +2064,19 @@ discard block |
||
| 1911 | 2064 | |
| 1912 | 2065 | $this->db->commit(); |
| 1913 | 2066 | return 1; |
| 1914 | - } |
|
| 1915 | - else |
|
| 2067 | + } else |
|
| 1916 | 2068 | { |
| 1917 | 2069 | $this->error=$this->db->lasterror()." sql=".$sql; |
| 1918 | 2070 | $this->db->rollback(); |
| 1919 | 2071 | return -6; |
| 1920 | 2072 | } |
| 1921 | - } |
|
| 1922 | - else |
|
| 2073 | + } else |
|
| 1923 | 2074 | { |
| 1924 | 2075 | $this->error=$this->db->lasterror()." sql=".$sql; |
| 1925 | 2076 | $this->db->rollback(); |
| 1926 | 2077 | return -4; |
| 1927 | 2078 | } |
| 1928 | - } |
|
| 1929 | - else |
|
| 2079 | + } else |
|
| 1930 | 2080 | { |
| 1931 | 2081 | $this->db->rollback(); |
| 1932 | 2082 | return -2; |
@@ -1953,9 +2103,15 @@ discard block |
||
| 1953 | 2103 | dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG); |
| 1954 | 2104 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; |
| 1955 | 2105 | $sql.= ' fk_statut='.self::STATUS_CLOSED; |
| 1956 | - if (! $close_code) $sql.= ', paye=1'; |
|
| 1957 | - if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; |
|
| 1958 | - if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; |
|
| 2106 | + if (! $close_code) { |
|
| 2107 | + $sql.= ', paye=1'; |
|
| 2108 | + } |
|
| 2109 | + if ($close_code) { |
|
| 2110 | + $sql.= ", close_code='".$this->db->escape($close_code)."'"; |
|
| 2111 | + } |
|
| 2112 | + if ($close_note) { |
|
| 2113 | + $sql.= ", close_note='".$this->db->escape($close_note)."'"; |
|
| 2114 | + } |
|
| 1959 | 2115 | $sql.= ' WHERE rowid = '.$this->id; |
| 1960 | 2116 | |
| 1961 | 2117 | dol_syslog(get_class($this)."::set_paid", LOG_DEBUG); |
@@ -1964,10 +2120,11 @@ discard block |
||
| 1964 | 2120 | { |
| 1965 | 2121 | // Call trigger |
| 1966 | 2122 | $result=$this->call_trigger('BILL_PAYED',$user); |
| 1967 | - if ($result < 0) $error++; |
|
| 2123 | + if ($result < 0) { |
|
| 2124 | + $error++; |
|
| 2125 | + } |
|
| 1968 | 2126 | // End call triggers |
| 1969 | - } |
|
| 1970 | - else |
|
| 2127 | + } else |
|
| 1971 | 2128 | { |
| 1972 | 2129 | $error++; |
| 1973 | 2130 | $this->error=$this->db->lasterror(); |
@@ -1977,14 +2134,12 @@ discard block |
||
| 1977 | 2134 | { |
| 1978 | 2135 | $this->db->commit(); |
| 1979 | 2136 | return 1; |
| 1980 | - } |
|
| 1981 | - else |
|
| 2137 | + } else |
|
| 1982 | 2138 | { |
| 1983 | 2139 | $this->db->rollback(); |
| 1984 | 2140 | return -1; |
| 1985 | 2141 | } |
| 1986 | - } |
|
| 1987 | - else |
|
| 2142 | + } else |
|
| 1988 | 2143 | { |
| 1989 | 2144 | return 0; |
| 1990 | 2145 | } |
@@ -2015,10 +2170,11 @@ discard block |
||
| 2015 | 2170 | { |
| 2016 | 2171 | // Call trigger |
| 2017 | 2172 | $result=$this->call_trigger('BILL_UNPAYED',$user); |
| 2018 | - if ($result < 0) $error++; |
|
| 2173 | + if ($result < 0) { |
|
| 2174 | + $error++; |
|
| 2175 | + } |
|
| 2019 | 2176 | // End call triggers |
| 2020 | - } |
|
| 2021 | - else |
|
| 2177 | + } else |
|
| 2022 | 2178 | { |
| 2023 | 2179 | $error++; |
| 2024 | 2180 | $this->error=$this->db->error(); |
@@ -2029,8 +2185,7 @@ discard block |
||
| 2029 | 2185 | { |
| 2030 | 2186 | $this->db->commit(); |
| 2031 | 2187 | return 1; |
| 2032 | - } |
|
| 2033 | - else |
|
| 2188 | + } else |
|
| 2034 | 2189 | { |
| 2035 | 2190 | $this->db->rollback(); |
| 2036 | 2191 | return -1; |
@@ -2057,8 +2212,12 @@ discard block |
||
| 2057 | 2212 | |
| 2058 | 2213 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; |
| 2059 | 2214 | $sql.= ' fk_statut='.self::STATUS_ABANDONED; |
| 2060 | - if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; |
|
| 2061 | - if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; |
|
| 2215 | + if ($close_code) { |
|
| 2216 | + $sql.= ", close_code='".$this->db->escape($close_code)."'"; |
|
| 2217 | + } |
|
| 2218 | + if ($close_note) { |
|
| 2219 | + $sql.= ", close_note='".$this->db->escape($close_note)."'"; |
|
| 2220 | + } |
|
| 2062 | 2221 | $sql.= ' WHERE rowid = '.$this->id; |
| 2063 | 2222 | |
| 2064 | 2223 | $resql = $this->db->query($sql); |
@@ -2084,15 +2243,13 @@ discard block |
||
| 2084 | 2243 | |
| 2085 | 2244 | $this->db->commit(); |
| 2086 | 2245 | return 1; |
| 2087 | - } |
|
| 2088 | - else |
|
| 2246 | + } else |
|
| 2089 | 2247 | { |
| 2090 | 2248 | $this->error=$this->db->error()." sql=".$sql; |
| 2091 | 2249 | $this->db->rollback(); |
| 2092 | 2250 | return -1; |
| 2093 | 2251 | } |
| 2094 | - } |
|
| 2095 | - else |
|
| 2252 | + } else |
|
| 2096 | 2253 | { |
| 2097 | 2254 | $this->error=$this->db->error()." sql=".$sql; |
| 2098 | 2255 | $this->db->rollback(); |
@@ -2147,12 +2304,14 @@ discard block |
||
| 2147 | 2304 | $this->db->begin(); |
| 2148 | 2305 | |
| 2149 | 2306 | // Check parameters |
| 2150 | - if ($this->type == self::TYPE_REPLACEMENT) // si facture de remplacement |
|
| 2307 | + if ($this->type == self::TYPE_REPLACEMENT) { |
|
| 2308 | + // si facture de remplacement |
|
| 2151 | 2309 | { |
| 2152 | 2310 | // Controle que facture source connue |
| 2153 | 2311 | if ($this->fk_facture_source <= 0) |
| 2154 | 2312 | { |
| 2155 | 2313 | $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("InvoiceReplacement")); |
| 2314 | + } |
|
| 2156 | 2315 | $this->db->rollback(); |
| 2157 | 2316 | return -10; |
| 2158 | 2317 | } |
@@ -2191,17 +2350,17 @@ discard block |
||
| 2191 | 2350 | if ($force_number) |
| 2192 | 2351 | { |
| 2193 | 2352 | $num = $force_number; |
| 2194 | - } |
|
| 2195 | - else if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life |
|
| 2353 | + } else if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) { |
|
| 2354 | + // empty should not happened, but when it occurs, the test save life |
|
| 2196 | 2355 | { |
| 2197 | 2356 | if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date |
| 2198 | 2357 | { |
| 2199 | 2358 | $this->date=dol_now(); |
| 2359 | + } |
|
| 2200 | 2360 | $this->date_lim_reglement=$this->calculate_date_lim_reglement(); |
| 2201 | 2361 | } |
| 2202 | 2362 | $num = $this->getNextNumRef($this->thirdparty); |
| 2203 | - } |
|
| 2204 | - else |
|
| 2363 | + } else |
|
| 2205 | 2364 | { |
| 2206 | 2365 | $num = $this->ref; |
| 2207 | 2366 | } |
@@ -2214,9 +2373,11 @@ discard block |
||
| 2214 | 2373 | // Validate |
| 2215 | 2374 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; |
| 2216 | 2375 | $sql.= " SET facnumber='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; |
| 2217 | - if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date |
|
| 2376 | + if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) { |
|
| 2377 | + // If option enabled, we force invoice date |
|
| 2218 | 2378 | { |
| 2219 | 2379 | $sql.= ", datef='".$this->db->idate($this->date)."'"; |
| 2380 | + } |
|
| 2220 | 2381 | $sql.= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'"; |
| 2221 | 2382 | } |
| 2222 | 2383 | $sql.= ' WHERE rowid = '.$this->id; |
@@ -2255,8 +2416,11 @@ discard block |
||
| 2255 | 2416 | $mouvP = new MouvementStock($this->db); |
| 2256 | 2417 | $mouvP->origin = &$this; |
| 2257 | 2418 | // We decrease stock for product |
| 2258 | - if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr",$num)); |
|
| 2259 | - else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); |
|
| 2419 | + if ($this->type == self::TYPE_CREDIT_NOTE) { |
|
| 2420 | + $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr",$num)); |
|
| 2421 | + } else { |
|
| 2422 | + $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); |
|
| 2423 | + } |
|
| 2260 | 2424 | if ($result < 0) { |
| 2261 | 2425 | $error++; |
| 2262 | 2426 | } |
@@ -2270,7 +2434,9 @@ discard block |
||
| 2270 | 2434 | { |
| 2271 | 2435 | // Call trigger |
| 2272 | 2436 | $result=$this->call_trigger('BILL_VALIDATE',$user); |
| 2273 | - if ($result < 0) $error++; |
|
| 2437 | + if ($result < 0) { |
|
| 2438 | + $error++; |
|
| 2439 | + } |
|
| 2274 | 2440 | // End call triggers |
| 2275 | 2441 | } |
| 2276 | 2442 | |
@@ -2340,8 +2506,7 @@ discard block |
||
| 2340 | 2506 | } |
| 2341 | 2507 | } |
| 2342 | 2508 | } |
| 2343 | - } |
|
| 2344 | - else |
|
| 2509 | + } else |
|
| 2345 | 2510 | { |
| 2346 | 2511 | $error++; |
| 2347 | 2512 | } |
@@ -2350,8 +2515,7 @@ discard block |
||
| 2350 | 2515 | { |
| 2351 | 2516 | $this->db->commit(); |
| 2352 | 2517 | return 1; |
| 2353 | - } |
|
| 2354 | - else |
|
| 2518 | + } else |
|
| 2355 | 2519 | { |
| 2356 | 2520 | $this->db->rollback(); |
| 2357 | 2521 | return -1; |
@@ -2440,8 +2604,12 @@ discard block |
||
| 2440 | 2604 | $mouvP = new MouvementStock($this->db); |
| 2441 | 2605 | $mouvP->origin = &$this; |
| 2442 | 2606 | // We decrease stock for product |
| 2443 | - if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); |
|
| 2444 | - else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value |
|
| 2607 | + if ($this->type == self::TYPE_CREDIT_NOTE) { |
|
| 2608 | + $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); |
|
| 2609 | + } else { |
|
| 2610 | + $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); |
|
| 2611 | + } |
|
| 2612 | + // we use 0 for price, to not change the weighted average value |
|
| 2445 | 2613 | } |
| 2446 | 2614 | } |
| 2447 | 2615 | } |
@@ -2469,14 +2637,12 @@ discard block |
||
| 2469 | 2637 | { |
| 2470 | 2638 | $this->db->commit(); |
| 2471 | 2639 | return 1; |
| 2472 | - } |
|
| 2473 | - else |
|
| 2640 | + } else |
|
| 2474 | 2641 | { |
| 2475 | 2642 | $this->db->rollback(); |
| 2476 | 2643 | return -1; |
| 2477 | 2644 | } |
| 2478 | - } |
|
| 2479 | - else |
|
| 2645 | + } else |
|
| 2480 | 2646 | { |
| 2481 | 2647 | $this->error=$this->db->error(); |
| 2482 | 2648 | $this->db->rollback(); |
@@ -2536,17 +2702,39 @@ discard block |
||
| 2536 | 2702 | include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; |
| 2537 | 2703 | |
| 2538 | 2704 | // Clean parameters |
| 2539 | - if (empty($remise_percent)) $remise_percent=0; |
|
| 2540 | - if (empty($qty)) $qty=0; |
|
| 2541 | - if (empty($info_bits)) $info_bits=0; |
|
| 2542 | - if (empty($rang)) $rang=0; |
|
| 2543 | - if (empty($ventil)) $ventil=0; |
|
| 2544 | - if (empty($txtva)) $txtva=0; |
|
| 2545 | - if (empty($txlocaltax1)) $txlocaltax1=0; |
|
| 2546 | - if (empty($txlocaltax2)) $txlocaltax2=0; |
|
| 2547 | - if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; |
|
| 2548 | - if (empty($fk_prev_id)) $fk_prev_id = 'null'; |
|
| 2549 | - if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; |
|
| 2705 | + if (empty($remise_percent)) { |
|
| 2706 | + $remise_percent=0; |
|
| 2707 | + } |
|
| 2708 | + if (empty($qty)) { |
|
| 2709 | + $qty=0; |
|
| 2710 | + } |
|
| 2711 | + if (empty($info_bits)) { |
|
| 2712 | + $info_bits=0; |
|
| 2713 | + } |
|
| 2714 | + if (empty($rang)) { |
|
| 2715 | + $rang=0; |
|
| 2716 | + } |
|
| 2717 | + if (empty($ventil)) { |
|
| 2718 | + $ventil=0; |
|
| 2719 | + } |
|
| 2720 | + if (empty($txtva)) { |
|
| 2721 | + $txtva=0; |
|
| 2722 | + } |
|
| 2723 | + if (empty($txlocaltax1)) { |
|
| 2724 | + $txlocaltax1=0; |
|
| 2725 | + } |
|
| 2726 | + if (empty($txlocaltax2)) { |
|
| 2727 | + $txlocaltax2=0; |
|
| 2728 | + } |
|
| 2729 | + if (empty($fk_parent_line) || $fk_parent_line < 0) { |
|
| 2730 | + $fk_parent_line=0; |
|
| 2731 | + } |
|
| 2732 | + if (empty($fk_prev_id)) { |
|
| 2733 | + $fk_prev_id = 'null'; |
|
| 2734 | + } |
|
| 2735 | + if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') { |
|
| 2736 | + $situation_percent = 100; |
|
| 2737 | + } |
|
| 2550 | 2738 | |
| 2551 | 2739 | $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); |
| 2552 | 2740 | |
@@ -2570,14 +2758,15 @@ discard block |
||
| 2570 | 2758 | if ($price_base_type=='HT') |
| 2571 | 2759 | { |
| 2572 | 2760 | $pu=$pu_ht; |
| 2573 | - } |
|
| 2574 | - else |
|
| 2761 | + } else |
|
| 2575 | 2762 | { |
| 2576 | 2763 | $pu=$pu_ttc; |
| 2577 | 2764 | } |
| 2578 | 2765 | |
| 2579 | 2766 | // Check parameters |
| 2580 | - if ($type < 0) return -1; |
|
| 2767 | + if ($type < 0) { |
|
| 2768 | + return -1; |
|
| 2769 | + } |
|
| 2581 | 2770 | |
| 2582 | 2771 | if (! empty($this->brouillon)) |
| 2583 | 2772 | { |
@@ -2689,7 +2878,9 @@ discard block |
||
| 2689 | 2878 | if ($result > 0) |
| 2690 | 2879 | { |
| 2691 | 2880 | // Reorder if child line |
| 2692 | - if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); |
|
| 2881 | + if (! empty($fk_parent_line)) { |
|
| 2882 | + $this->line_order(true,'DESC'); |
|
| 2883 | + } |
|
| 2693 | 2884 | |
| 2694 | 2885 | // Mise a jour informations denormalisees au niveau de la facture meme |
| 2695 | 2886 | $result=$this->update_price(1,'auto',0,$mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. |
@@ -2697,22 +2888,19 @@ discard block |
||
| 2697 | 2888 | { |
| 2698 | 2889 | $this->db->commit(); |
| 2699 | 2890 | return $this->line->rowid; |
| 2700 | - } |
|
| 2701 | - else |
|
| 2891 | + } else |
|
| 2702 | 2892 | { |
| 2703 | 2893 | $this->error=$this->db->error(); |
| 2704 | 2894 | $this->db->rollback(); |
| 2705 | 2895 | return -1; |
| 2706 | 2896 | } |
| 2707 | - } |
|
| 2708 | - else |
|
| 2897 | + } else |
|
| 2709 | 2898 | { |
| 2710 | 2899 | $this->error=$this->line->error; |
| 2711 | 2900 | $this->db->rollback(); |
| 2712 | 2901 | return -2; |
| 2713 | 2902 | } |
| 2714 | - } |
|
| 2715 | - else |
|
| 2903 | + } else |
|
| 2716 | 2904 | { |
| 2717 | 2905 | dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR); |
| 2718 | 2906 | return -3; |
@@ -2768,7 +2956,9 @@ discard block |
||
| 2768 | 2956 | { |
| 2769 | 2957 | if (!$this->checkProgressLine($rowid, $situation_percent)) |
| 2770 | 2958 | { |
| 2771 | - if (!$this->error) $this->error=$langs->trans('invoiceLineProgressError'); |
|
| 2959 | + if (!$this->error) { |
|
| 2960 | + $this->error=$langs->trans('invoiceLineProgressError'); |
|
| 2961 | + } |
|
| 2772 | 2962 | return -3; |
| 2773 | 2963 | } |
| 2774 | 2964 | } |
@@ -2776,10 +2966,18 @@ discard block |
||
| 2776 | 2966 | $this->db->begin(); |
| 2777 | 2967 | |
| 2778 | 2968 | // Clean parameters |
| 2779 | - if (empty($qty)) $qty=0; |
|
| 2780 | - if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; |
|
| 2781 | - if (empty($special_code) || $special_code == 3) $special_code=0; |
|
| 2782 | - if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; |
|
| 2969 | + if (empty($qty)) { |
|
| 2970 | + $qty=0; |
|
| 2971 | + } |
|
| 2972 | + if (empty($fk_parent_line) || $fk_parent_line < 0) { |
|
| 2973 | + $fk_parent_line=0; |
|
| 2974 | + } |
|
| 2975 | + if (empty($special_code) || $special_code == 3) { |
|
| 2976 | + $special_code=0; |
|
| 2977 | + } |
|
| 2978 | + if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') { |
|
| 2979 | + $situation_percent = 100; |
|
| 2980 | + } |
|
| 2783 | 2981 | |
| 2784 | 2982 | $remise_percent = price2num($remise_percent); |
| 2785 | 2983 | $qty = price2num($qty); |
@@ -2790,7 +2988,9 @@ discard block |
||
| 2790 | 2988 | $txlocaltax2 = price2num($txlocaltax2); |
| 2791 | 2989 | |
| 2792 | 2990 | // Check parameters |
| 2793 | - if ($type < 0) return -1; |
|
| 2991 | + if ($type < 0) { |
|
| 2992 | + return -1; |
|
| 2993 | + } |
|
| 2794 | 2994 | |
| 2795 | 2995 | // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva |
| 2796 | 2996 | // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker |
@@ -2910,21 +3110,21 @@ discard block |
||
| 2910 | 3110 | if ($result > 0) |
| 2911 | 3111 | { |
| 2912 | 3112 | // Reorder if child line |
| 2913 | - if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); |
|
| 3113 | + if (! empty($fk_parent_line)) { |
|
| 3114 | + $this->line_order(true,'DESC'); |
|
| 3115 | + } |
|
| 2914 | 3116 | |
| 2915 | 3117 | // Mise a jour info denormalisees au niveau facture |
| 2916 | 3118 | $this->update_price(1); |
| 2917 | 3119 | $this->db->commit(); |
| 2918 | 3120 | return $result; |
| 2919 | - } |
|
| 2920 | - else |
|
| 3121 | + } else |
|
| 2921 | 3122 | { |
| 2922 | 3123 | $this->error=$this->line->error; |
| 2923 | 3124 | $this->db->rollback(); |
| 2924 | 3125 | return -1; |
| 2925 | 3126 | } |
| 2926 | - } |
|
| 2927 | - else |
|
| 3127 | + } else |
|
| 2928 | 3128 | { |
| 2929 | 3129 | $this->error="Invoice statut makes operation forbidden"; |
| 2930 | 3130 | return -2; |
@@ -2954,8 +3154,11 @@ discard block |
||
| 2954 | 3154 | |
| 2955 | 3155 | $obj = $this->db->fetch_object($result); |
| 2956 | 3156 | |
| 2957 | - if ($obj === null) return true; |
|
| 2958 | - else return $situation_percent < $obj->situation_percent; |
|
| 3157 | + if ($obj === null) { |
|
| 3158 | + return true; |
|
| 3159 | + } else { |
|
| 3160 | + return $situation_percent < $obj->situation_percent; |
|
| 3161 | + } |
|
| 2959 | 3162 | } |
| 2960 | 3163 | |
| 2961 | 3164 | /** |
@@ -2972,7 +3175,9 @@ discard block |
||
| 2972 | 3175 | include_once(DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'); |
| 2973 | 3176 | |
| 2974 | 3177 | // Cap percentages to 100 |
| 2975 | - if ($percent > 100) $percent = 100; |
|
| 3178 | + if ($percent > 100) { |
|
| 3179 | + $percent = 100; |
|
| 3180 | + } |
|
| 2976 | 3181 | $line->situation_percent = $percent; |
| 2977 | 3182 | $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, '', $percent); |
| 2978 | 3183 | $line->total_ht = $tabprice[0]; |
@@ -3025,7 +3230,9 @@ discard block |
||
| 3025 | 3230 | |
| 3026 | 3231 | // For triggers |
| 3027 | 3232 | $result = $line->fetch($rowid); |
| 3028 | - if (! ($result > 0)) dol_print_error($db, $line->error, $line->errors); |
|
| 3233 | + if (! ($result > 0)) { |
|
| 3234 | + dol_print_error($db, $line->error, $line->errors); |
|
| 3235 | + } |
|
| 3029 | 3236 | |
| 3030 | 3237 | if ($line->delete($user) > 0) |
| 3031 | 3238 | { |
@@ -3035,15 +3242,13 @@ discard block |
||
| 3035 | 3242 | { |
| 3036 | 3243 | $this->db->commit(); |
| 3037 | 3244 | return 1; |
| 3038 | - } |
|
| 3039 | - else |
|
| 3245 | + } else |
|
| 3040 | 3246 | { |
| 3041 | 3247 | $this->db->rollback(); |
| 3042 | 3248 | $this->error=$this->db->lasterror(); |
| 3043 | 3249 | return -1; |
| 3044 | 3250 | } |
| 3045 | - } |
|
| 3046 | - else |
|
| 3251 | + } else |
|
| 3047 | 3252 | { |
| 3048 | 3253 | $this->db->rollback(); |
| 3049 | 3254 | $this->error=$line->error; |
@@ -3062,7 +3267,9 @@ discard block |
||
| 3062 | 3267 | function set_remise($user, $remise, $notrigger=0) |
| 3063 | 3268 | { |
| 3064 | 3269 | // Clean parameters |
| 3065 | - if (empty($remise)) $remise=0; |
|
| 3270 | + if (empty($remise)) { |
|
| 3271 | + $remise=0; |
|
| 3272 | + } |
|
| 3066 | 3273 | |
| 3067 | 3274 | if ($user->rights->facture->creer) |
| 3068 | 3275 | { |
@@ -3089,7 +3296,9 @@ discard block |
||
| 3089 | 3296 | { |
| 3090 | 3297 | // Call trigger |
| 3091 | 3298 | $result=$this->call_trigger('BILL_MODIFY',$user); |
| 3092 | - if ($result < 0) $error++; |
|
| 3299 | + if ($result < 0) { |
|
| 3300 | + $error++; |
|
| 3301 | + } |
|
| 3093 | 3302 | // End call triggers |
| 3094 | 3303 | } |
| 3095 | 3304 | |
@@ -3100,8 +3309,7 @@ discard block |
||
| 3100 | 3309 | |
| 3101 | 3310 | $this->db->commit(); |
| 3102 | 3311 | return 1; |
| 3103 | - } |
|
| 3104 | - else |
|
| 3312 | + } else |
|
| 3105 | 3313 | { |
| 3106 | 3314 | foreach($this->errors as $errmsg) |
| 3107 | 3315 | { |
@@ -3125,7 +3333,9 @@ discard block |
||
| 3125 | 3333 | */ |
| 3126 | 3334 | function set_remise_absolue($user, $remise, $notrigger=0) |
| 3127 | 3335 | { |
| 3128 | - if (empty($remise)) $remise=0; |
|
| 3336 | + if (empty($remise)) { |
|
| 3337 | + $remise=0; |
|
| 3338 | + } |
|
| 3129 | 3339 | |
| 3130 | 3340 | if ($user->rights->facture->creer) |
| 3131 | 3341 | { |
@@ -3159,7 +3369,9 @@ discard block |
||
| 3159 | 3369 | { |
| 3160 | 3370 | // Call trigger |
| 3161 | 3371 | $result=$this->call_trigger('BILL_MODIFY',$user); |
| 3162 | - if ($result < 0) $error++; |
|
| 3372 | + if ($result < 0) { |
|
| 3373 | + $error++; |
|
| 3374 | + } |
|
| 3163 | 3375 | // End call triggers |
| 3164 | 3376 | } |
| 3165 | 3377 | |
@@ -3167,8 +3379,7 @@ discard block |
||
| 3167 | 3379 | { |
| 3168 | 3380 | $this->db->commit(); |
| 3169 | 3381 | return 1; |
| 3170 | - } |
|
| 3171 | - else |
|
| 3382 | + } else |
|
| 3172 | 3383 | { |
| 3173 | 3384 | foreach($this->errors as $errmsg) |
| 3174 | 3385 | { |
@@ -3212,7 +3423,9 @@ discard block |
||
| 3212 | 3423 | $sql.= ' AND pf.'.$field2.' = p.rowid'; |
| 3213 | 3424 | $sql.= ' AND p.fk_paiement = t.id'; |
| 3214 | 3425 | $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; |
| 3215 | - if ($filtertype) $sql.=" AND t.code='PRE'"; |
|
| 3426 | + if ($filtertype) { |
|
| 3427 | + $sql.=" AND t.code='PRE'"; |
|
| 3428 | + } |
|
| 3216 | 3429 | |
| 3217 | 3430 | dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); |
| 3218 | 3431 | $resql=$this->db->query($sql); |
@@ -3228,8 +3441,7 @@ discard block |
||
| 3228 | 3441 | } |
| 3229 | 3442 | $this->db->free($resql); |
| 3230 | 3443 | return $retarray; |
| 3231 | - } |
|
| 3232 | - else |
|
| 3444 | + } else |
|
| 3233 | 3445 | { |
| 3234 | 3446 | $this->error=$this->db->lasterror(); |
| 3235 | 3447 | dol_print_error($this->db); |
@@ -3252,9 +3464,13 @@ discard block |
||
| 3252 | 3464 | $langs->load("bills"); |
| 3253 | 3465 | |
| 3254 | 3466 | // Clean parameters (if not defined or using deprecated value) |
| 3255 | - if (empty($conf->global->FACTURE_ADDON)) $conf->global->FACTURE_ADDON='mod_facture_terre'; |
|
| 3256 | - else if ($conf->global->FACTURE_ADDON=='terre') $conf->global->FACTURE_ADDON='mod_facture_terre'; |
|
| 3257 | - else if ($conf->global->FACTURE_ADDON=='mercure') $conf->global->FACTURE_ADDON='mod_facture_mercure'; |
|
| 3467 | + if (empty($conf->global->FACTURE_ADDON)) { |
|
| 3468 | + $conf->global->FACTURE_ADDON='mod_facture_terre'; |
|
| 3469 | + } else if ($conf->global->FACTURE_ADDON=='terre') { |
|
| 3470 | + $conf->global->FACTURE_ADDON='mod_facture_terre'; |
|
| 3471 | + } else if ($conf->global->FACTURE_ADDON=='mercure') { |
|
| 3472 | + $conf->global->FACTURE_ADDON='mod_facture_mercure'; |
|
| 3473 | + } |
|
| 3258 | 3474 | |
| 3259 | 3475 | if (! empty($conf->global->FACTURE_ADDON)) |
| 3260 | 3476 | { |
@@ -3318,8 +3534,7 @@ discard block |
||
| 3318 | 3534 | } |
| 3319 | 3535 | |
| 3320 | 3536 | return $numref; |
| 3321 | - } |
|
| 3322 | - else |
|
| 3537 | + } else |
|
| 3323 | 3538 | { |
| 3324 | 3539 | $langs->load("errors"); |
| 3325 | 3540 | print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); |
@@ -3364,8 +3579,7 @@ discard block |
||
| 3364 | 3579 | $this->date_validation = $this->db->jdate($obj->datev); // Should be in log table |
| 3365 | 3580 | } |
| 3366 | 3581 | $this->db->free($result); |
| 3367 | - } |
|
| 3368 | - else |
|
| 3582 | + } else |
|
| 3369 | 3583 | { |
| 3370 | 3584 | dol_print_error($this->db); |
| 3371 | 3585 | } |
@@ -3393,18 +3607,30 @@ discard block |
||
| 3393 | 3607 | |
| 3394 | 3608 | $sql = "SELECT s.rowid, s.nom as name, s.client,"; |
| 3395 | 3609 | $sql.= " f.rowid as fid, f.facnumber as ref, f.datef as df"; |
| 3396 | - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; |
|
| 3610 | + if (! $user->rights->societe->client->voir && ! $socid) { |
|
| 3611 | + $sql .= ", sc.fk_soc, sc.fk_user"; |
|
| 3612 | + } |
|
| 3397 | 3613 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; |
| 3398 | - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 3614 | + if (! $user->rights->societe->client->voir && ! $socid) { |
|
| 3615 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 3616 | + } |
|
| 3399 | 3617 | $sql.= " WHERE f.entity = ".$conf->entity; |
| 3400 | 3618 | $sql.= " AND f.fk_soc = s.rowid"; |
| 3401 | - if (! $user->rights->societe->client->voir && ! $socid) //restriction |
|
| 3619 | + if (! $user->rights->societe->client->voir && ! $socid) { |
|
| 3620 | + //restriction |
|
| 3402 | 3621 | { |
| 3403 | 3622 | $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
| 3404 | 3623 | } |
| 3405 | - if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
| 3406 | - if ($draft) $sql.= " AND f.fk_statut = ".self::STATUS_DRAFT; |
|
| 3407 | - if (is_object($excluser)) $sql.= " AND f.fk_user_author <> ".$excluser->id; |
|
| 3624 | + } |
|
| 3625 | + if ($socid) { |
|
| 3626 | + $sql.= " AND s.rowid = ".$socid; |
|
| 3627 | + } |
|
| 3628 | + if ($draft) { |
|
| 3629 | + $sql.= " AND f.fk_statut = ".self::STATUS_DRAFT; |
|
| 3630 | + } |
|
| 3631 | + if (is_object($excluser)) { |
|
| 3632 | + $sql.= " AND f.fk_user_author <> ".$excluser->id; |
|
| 3633 | + } |
|
| 3408 | 3634 | $sql.= $this->db->order($sortfield,$sortorder); |
| 3409 | 3635 | $sql.= $this->db->plimit($limit,$offset); |
| 3410 | 3636 | |
@@ -3422,12 +3648,10 @@ discard block |
||
| 3422 | 3648 | if ($shortlist == 1) |
| 3423 | 3649 | { |
| 3424 | 3650 | $ga[$obj->fid] = $obj->ref; |
| 3425 | - } |
|
| 3426 | - else if ($shortlist == 2) |
|
| 3651 | + } else if ($shortlist == 2) |
|
| 3427 | 3652 | { |
| 3428 | 3653 | $ga[$obj->fid] = $obj->ref.' ('.$obj->name.')'; |
| 3429 | - } |
|
| 3430 | - else |
|
| 3654 | + } else |
|
| 3431 | 3655 | { |
| 3432 | 3656 | $ga[$i]['id'] = $obj->fid; |
| 3433 | 3657 | $ga[$i]['ref'] = $obj->ref; |
@@ -3437,8 +3661,7 @@ discard block |
||
| 3437 | 3661 | } |
| 3438 | 3662 | } |
| 3439 | 3663 | return $ga; |
| 3440 | - } |
|
| 3441 | - else |
|
| 3664 | + } else |
|
| 3442 | 3665 | { |
| 3443 | 3666 | dol_print_error($this->db); |
| 3444 | 3667 | return -1; |
@@ -3470,7 +3693,9 @@ discard block |
||
| 3470 | 3693 | $sql.= " AND f.paye = 0"; // Pas classee payee completement |
| 3471 | 3694 | $sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait |
| 3472 | 3695 | $sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement |
| 3473 | - if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; |
|
| 3696 | + if ($socid > 0) { |
|
| 3697 | + $sql.=" AND f.fk_soc = ".$socid; |
|
| 3698 | + } |
|
| 3474 | 3699 | $sql.= " ORDER BY f.facnumber"; |
| 3475 | 3700 | |
| 3476 | 3701 | dol_syslog(get_class($this)."::list_replacable_invoices", LOG_DEBUG); |
@@ -3485,8 +3710,7 @@ discard block |
||
| 3485 | 3710 | } |
| 3486 | 3711 | //print_r($return); |
| 3487 | 3712 | return $return; |
| 3488 | - } |
|
| 3489 | - else |
|
| 3713 | + } else |
|
| 3490 | 3714 | { |
| 3491 | 3715 | $this->error=$this->db->error(); |
| 3492 | 3716 | return -1; |
@@ -3519,7 +3743,9 @@ discard block |
||
| 3519 | 3743 | // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement |
| 3520 | 3744 | $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement |
| 3521 | 3745 | $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir |
| 3522 | - if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; |
|
| 3746 | + if ($socid > 0) { |
|
| 3747 | + $sql.=" AND f.fk_soc = ".$socid; |
|
| 3748 | + } |
|
| 3523 | 3749 | $sql.= " ORDER BY f.facnumber"; |
| 3524 | 3750 | |
| 3525 | 3751 | dol_syslog(get_class($this)."::list_qualified_avoir_invoices", LOG_DEBUG); |
@@ -3529,8 +3755,12 @@ discard block |
||
| 3529 | 3755 | while ($obj=$this->db->fetch_object($resql)) |
| 3530 | 3756 | { |
| 3531 | 3757 | $qualified=0; |
| 3532 | - if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified=1; |
|
| 3533 | - if ($obj->fk_statut == self::STATUS_CLOSED) $qualified=1; |
|
| 3758 | + if ($obj->fk_statut == self::STATUS_VALIDATED) { |
|
| 3759 | + $qualified=1; |
|
| 3760 | + } |
|
| 3761 | + if ($obj->fk_statut == self::STATUS_CLOSED) { |
|
| 3762 | + $qualified=1; |
|
| 3763 | + } |
|
| 3534 | 3764 | if ($qualified) |
| 3535 | 3765 | { |
| 3536 | 3766 | //$ref=$obj->facnumber; |
@@ -3540,8 +3770,7 @@ discard block |
||
| 3540 | 3770 | } |
| 3541 | 3771 | |
| 3542 | 3772 | return $return; |
| 3543 | - } |
|
| 3544 | - else |
|
| 3773 | + } else |
|
| 3545 | 3774 | { |
| 3546 | 3775 | $this->error=$this->db->error(); |
| 3547 | 3776 | return -1; |
@@ -3593,7 +3822,9 @@ discard block |
||
| 3593 | 3822 | // For example print 239.2 - 229.3 - 9.9; does not return 0. |
| 3594 | 3823 | //$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); |
| 3595 | 3824 | //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); |
| 3596 | - if (empty($amount)) $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT'); |
|
| 3825 | + if (empty($amount)) { |
|
| 3826 | + $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT'); |
|
| 3827 | + } |
|
| 3597 | 3828 | |
| 3598 | 3829 | if (is_numeric($amount) && $amount != 0) |
| 3599 | 3830 | { |
@@ -3616,8 +3847,7 @@ discard block |
||
| 3616 | 3847 | dol_syslog(get_class($this).'::demandeprelevement Erreur'); |
| 3617 | 3848 | $error++; |
| 3618 | 3849 | } |
| 3619 | - } |
|
| 3620 | - else |
|
| 3850 | + } else |
|
| 3621 | 3851 | { |
| 3622 | 3852 | $this->error='WithdrawRequestErrorNilAmount'; |
| 3623 | 3853 | dol_syslog(get_class($this).'::demandeprelevement WithdrawRequestErrorNilAmount'); |
@@ -3634,24 +3864,23 @@ discard block |
||
| 3634 | 3864 | } |
| 3635 | 3865 | } |
| 3636 | 3866 | |
| 3637 | - if ($error) return -1; |
|
| 3867 | + if ($error) { |
|
| 3868 | + return -1; |
|
| 3869 | + } |
|
| 3638 | 3870 | return 1; |
| 3639 | - } |
|
| 3640 | - else |
|
| 3871 | + } else |
|
| 3641 | 3872 | { |
| 3642 | 3873 | $this->error="A request already exists"; |
| 3643 | 3874 | dol_syslog(get_class($this).'::demandeprelevement Impossible de creer une demande, demande deja en cours'); |
| 3644 | 3875 | return 0; |
| 3645 | 3876 | } |
| 3646 | - } |
|
| 3647 | - else |
|
| 3877 | + } else |
|
| 3648 | 3878 | { |
| 3649 | 3879 | $this->error=$this->db->error(); |
| 3650 | 3880 | dol_syslog(get_class($this).'::demandeprelevement Erreur -2'); |
| 3651 | 3881 | return -2; |
| 3652 | 3882 | } |
| 3653 | - } |
|
| 3654 | - else |
|
| 3883 | + } else |
|
| 3655 | 3884 | { |
| 3656 | 3885 | $this->error="Status of invoice does not allow this"; |
| 3657 | 3886 | dol_syslog(get_class($this)."::demandeprelevement ".$this->error." $this->statut, $this->paye, $this->mode_reglement_id"); |
@@ -3674,8 +3903,7 @@ discard block |
||
| 3674 | 3903 | if ( $this->db->query($sql) ) |
| 3675 | 3904 | { |
| 3676 | 3905 | return 0; |
| 3677 | - } |
|
| 3678 | - else |
|
| 3906 | + } else |
|
| 3679 | 3907 | { |
| 3680 | 3908 | $this->error=$this->db->lasterror(); |
| 3681 | 3909 | dol_syslog(get_class($this).'::demande_prelevement_delete Error '.$this->error); |
@@ -3707,7 +3935,9 @@ discard block |
||
| 3707 | 3935 | $sql.= $clause." f.paye=0"; |
| 3708 | 3936 | $sql.= " AND f.entity = ".$conf->entity; |
| 3709 | 3937 | $sql.= " AND f.fk_statut = ".self::STATUS_VALIDATED; |
| 3710 | - if ($user->societe_id) $sql.= " AND f.fk_soc = ".$user->societe_id; |
|
| 3938 | + if ($user->societe_id) { |
|
| 3939 | + $sql.= " AND f.fk_soc = ".$user->societe_id; |
|
| 3940 | + } |
|
| 3711 | 3941 | |
| 3712 | 3942 | $resql=$this->db->query($sql); |
| 3713 | 3943 | if ($resql) |
@@ -3736,8 +3966,7 @@ discard block |
||
| 3736 | 3966 | } |
| 3737 | 3967 | |
| 3738 | 3968 | return $response; |
| 3739 | - } |
|
| 3740 | - else |
|
| 3969 | + } else |
|
| 3741 | 3970 | { |
| 3742 | 3971 | dol_print_error($this->db); |
| 3743 | 3972 | $this->error=$this->db->error(); |
@@ -3841,9 +4070,11 @@ discard block |
||
| 3841 | 4070 | $line->localtax1_tx=0; |
| 3842 | 4071 | $line->localtax2_tx=0; |
| 3843 | 4072 | $line->remise_percent=0; |
| 3844 | - if ($xnbp == 1) // Qty is negative (product line) |
|
| 4073 | + if ($xnbp == 1) { |
|
| 4074 | + // Qty is negative (product line) |
|
| 3845 | 4075 | { |
| 3846 | 4076 | $prodid = mt_rand(1, $num_prods); |
| 4077 | + } |
|
| 3847 | 4078 | $line->fk_product=$prodids[$prodid]; |
| 3848 | 4079 | $line->qty=-1; |
| 3849 | 4080 | $line->total_ht=-100; |
@@ -3852,10 +4083,11 @@ discard block |
||
| 3852 | 4083 | $line->multicurrency_total_ht=-200; |
| 3853 | 4084 | $line->multicurrency_total_ttc=-239.2; |
| 3854 | 4085 | $line->multicurrency_total_tva=-39.2; |
| 3855 | - } |
|
| 3856 | - else if ($xnbp == 2) // UP is negative (free line) |
|
| 4086 | + } else if ($xnbp == 2) { |
|
| 4087 | + // UP is negative (free line) |
|
| 3857 | 4088 | { |
| 3858 | 4089 | $line->subprice=-100; |
| 4090 | + } |
|
| 3859 | 4091 | $line->total_ht=-100; |
| 3860 | 4092 | $line->total_ttc=-119.6; |
| 3861 | 4093 | $line->total_tva=-19.6; |
@@ -3863,10 +4095,11 @@ discard block |
||
| 3863 | 4095 | $line->multicurrency_total_ht=-200; |
| 3864 | 4096 | $line->multicurrency_total_ttc=-239.2; |
| 3865 | 4097 | $line->multicurrency_total_tva=-39.2; |
| 3866 | - } |
|
| 3867 | - else if ($xnbp == 3) // Discount is 50% (product line) |
|
| 4098 | + } else if ($xnbp == 3) { |
|
| 4099 | + // Discount is 50% (product line) |
|
| 3868 | 4100 | { |
| 3869 | 4101 | $prodid = mt_rand(1, $num_prods); |
| 4102 | + } |
|
| 3870 | 4103 | $line->fk_product=$prodids[$prodid]; |
| 3871 | 4104 | $line->total_ht=50; |
| 3872 | 4105 | $line->total_ttc=59.8; |
@@ -3875,8 +4108,7 @@ discard block |
||
| 3875 | 4108 | $line->multicurrency_total_ttc=119.6; |
| 3876 | 4109 | $line->multicurrency_total_tva=19.6; |
| 3877 | 4110 | $line->remise_percent=50; |
| 3878 | - } |
|
| 3879 | - else // (product line) |
|
| 4111 | + } else // (product line) |
|
| 3880 | 4112 | { |
| 3881 | 4113 | $prodid = mt_rand(1, $num_prods); |
| 3882 | 4114 | $line->fk_product=$prodids[$prodid]; |
@@ -3960,8 +4192,7 @@ discard block |
||
| 3960 | 4192 | } |
| 3961 | 4193 | $this->db->free($resql); |
| 3962 | 4194 | return 1; |
| 3963 | - } |
|
| 3964 | - else |
|
| 4195 | + } else |
|
| 3965 | 4196 | { |
| 3966 | 4197 | dol_print_error($this->db); |
| 3967 | 4198 | $this->error=$this->db->error(); |
@@ -4108,7 +4339,9 @@ discard block |
||
| 4108 | 4339 | { |
| 4109 | 4340 | // Call trigger |
| 4110 | 4341 | $result=$this->call_trigger('BILL_MODIFY',$user); |
| 4111 | - if ($result < 0) $error++; |
|
| 4342 | + if ($result < 0) { |
|
| 4343 | + $error++; |
|
| 4344 | + } |
|
| 4112 | 4345 | // End call triggers |
| 4113 | 4346 | } |
| 4114 | 4347 | |
@@ -4116,8 +4349,7 @@ discard block |
||
| 4116 | 4349 | { |
| 4117 | 4350 | $this->db->commit(); |
| 4118 | 4351 | return 1; |
| 4119 | - } |
|
| 4120 | - else |
|
| 4352 | + } else |
|
| 4121 | 4353 | { |
| 4122 | 4354 | foreach($this->errors as $errmsg) |
| 4123 | 4355 | { |
@@ -4187,7 +4419,9 @@ discard block |
||
| 4187 | 4419 | $now = dol_now(); |
| 4188 | 4420 | |
| 4189 | 4421 | // Paid invoices have status STATUS_CLOSED |
| 4190 | - if ($this->statut != Facture::STATUS_VALIDATED) return false; |
|
| 4422 | + if ($this->statut != Facture::STATUS_VALIDATED) { |
|
| 4423 | + return false; |
|
| 4424 | + } |
|
| 4191 | 4425 | |
| 4192 | 4426 | return $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); |
| 4193 | 4427 | } |
@@ -4360,8 +4594,7 @@ discard block |
||
| 4360 | 4594 | $this->db->free($result); |
| 4361 | 4595 | |
| 4362 | 4596 | return 1; |
| 4363 | - } |
|
| 4364 | - else |
|
| 4597 | + } else |
|
| 4365 | 4598 | { |
| 4366 | 4599 | $this->error = $this->db->lasterror(); |
| 4367 | 4600 | return -1; |
@@ -4387,27 +4620,67 @@ discard block |
||
| 4387 | 4620 | |
| 4388 | 4621 | // Clean parameters |
| 4389 | 4622 | $this->desc=trim($this->desc); |
| 4390 | - if (empty($this->tva_tx)) $this->tva_tx=0; |
|
| 4391 | - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; |
|
| 4392 | - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; |
|
| 4393 | - if (empty($this->localtax1_type)) $this->localtax1_type=0; |
|
| 4394 | - if (empty($this->localtax2_type)) $this->localtax2_type=0; |
|
| 4395 | - if (empty($this->total_localtax1)) $this->total_localtax1=0; |
|
| 4396 | - if (empty($this->total_localtax2)) $this->total_localtax2=0; |
|
| 4397 | - if (empty($this->rang)) $this->rang=0; |
|
| 4398 | - if (empty($this->remise_percent)) $this->remise_percent=0; |
|
| 4399 | - if (empty($this->info_bits)) $this->info_bits=0; |
|
| 4400 | - if (empty($this->subprice)) $this->subprice=0; |
|
| 4401 | - if (empty($this->special_code)) $this->special_code=0; |
|
| 4402 | - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; |
|
| 4403 | - if (empty($this->fk_prev_id)) $this->fk_prev_id = 'null'; |
|
| 4404 | - if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; |
|
| 4405 | - |
|
| 4406 | - if (empty($this->pa_ht)) $this->pa_ht=0; |
|
| 4407 | - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; |
|
| 4408 | - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; |
|
| 4409 | - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; |
|
| 4410 | - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; |
|
| 4623 | + if (empty($this->tva_tx)) { |
|
| 4624 | + $this->tva_tx=0; |
|
| 4625 | + } |
|
| 4626 | + if (empty($this->localtax1_tx)) { |
|
| 4627 | + $this->localtax1_tx=0; |
|
| 4628 | + } |
|
| 4629 | + if (empty($this->localtax2_tx)) { |
|
| 4630 | + $this->localtax2_tx=0; |
|
| 4631 | + } |
|
| 4632 | + if (empty($this->localtax1_type)) { |
|
| 4633 | + $this->localtax1_type=0; |
|
| 4634 | + } |
|
| 4635 | + if (empty($this->localtax2_type)) { |
|
| 4636 | + $this->localtax2_type=0; |
|
| 4637 | + } |
|
| 4638 | + if (empty($this->total_localtax1)) { |
|
| 4639 | + $this->total_localtax1=0; |
|
| 4640 | + } |
|
| 4641 | + if (empty($this->total_localtax2)) { |
|
| 4642 | + $this->total_localtax2=0; |
|
| 4643 | + } |
|
| 4644 | + if (empty($this->rang)) { |
|
| 4645 | + $this->rang=0; |
|
| 4646 | + } |
|
| 4647 | + if (empty($this->remise_percent)) { |
|
| 4648 | + $this->remise_percent=0; |
|
| 4649 | + } |
|
| 4650 | + if (empty($this->info_bits)) { |
|
| 4651 | + $this->info_bits=0; |
|
| 4652 | + } |
|
| 4653 | + if (empty($this->subprice)) { |
|
| 4654 | + $this->subprice=0; |
|
| 4655 | + } |
|
| 4656 | + if (empty($this->special_code)) { |
|
| 4657 | + $this->special_code=0; |
|
| 4658 | + } |
|
| 4659 | + if (empty($this->fk_parent_line)) { |
|
| 4660 | + $this->fk_parent_line=0; |
|
| 4661 | + } |
|
| 4662 | + if (empty($this->fk_prev_id)) { |
|
| 4663 | + $this->fk_prev_id = 'null'; |
|
| 4664 | + } |
|
| 4665 | + if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') { |
|
| 4666 | + $this->situation_percent = 100; |
|
| 4667 | + } |
|
| 4668 | + |
|
| 4669 | + if (empty($this->pa_ht)) { |
|
| 4670 | + $this->pa_ht=0; |
|
| 4671 | + } |
|
| 4672 | + if (empty($this->multicurrency_subprice)) { |
|
| 4673 | + $this->multicurrency_subprice=0; |
|
| 4674 | + } |
|
| 4675 | + if (empty($this->multicurrency_total_ht)) { |
|
| 4676 | + $this->multicurrency_total_ht=0; |
|
| 4677 | + } |
|
| 4678 | + if (empty($this->multicurrency_total_tva)) { |
|
| 4679 | + $this->multicurrency_total_tva=0; |
|
| 4680 | + } |
|
| 4681 | + if (empty($this->multicurrency_total_ttc)) { |
|
| 4682 | + $this->multicurrency_total_ttc=0; |
|
| 4683 | + } |
|
| 4411 | 4684 | |
| 4412 | 4685 | // if buy price not defined, define buyprice as configured in margin admin |
| 4413 | 4686 | if ($this->pa_ht == 0 && $pa_ht_isemptystring) |
@@ -4415,8 +4688,7 @@ discard block |
||
| 4415 | 4688 | if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) |
| 4416 | 4689 | { |
| 4417 | 4690 | return $result; |
| 4418 | - } |
|
| 4419 | - else |
|
| 4691 | + } else |
|
| 4420 | 4692 | { |
| 4421 | 4693 | $this->pa_ht = $result; |
| 4422 | 4694 | } |
@@ -4501,9 +4773,11 @@ discard block |
||
| 4501 | 4773 | { |
| 4502 | 4774 | $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); |
| 4503 | 4775 | |
| 4504 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 4776 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 4777 | + // For avoid conflicts if trigger used |
|
| 4505 | 4778 | { |
| 4506 | 4779 | $this->id=$this->rowid; |
| 4780 | + } |
|
| 4507 | 4781 | $result=$this->insertExtraFields(); |
| 4508 | 4782 | if ($result < 0) |
| 4509 | 4783 | { |
@@ -4532,8 +4806,7 @@ discard block |
||
| 4532 | 4806 | $this->db->rollback(); |
| 4533 | 4807 | return -3; |
| 4534 | 4808 | } |
| 4535 | - } |
|
| 4536 | - else |
|
| 4809 | + } else |
|
| 4537 | 4810 | { |
| 4538 | 4811 | $result=$discount->link_to_invoice($this->rowid,0); |
| 4539 | 4812 | if ($result < 0) |
@@ -4544,16 +4817,14 @@ discard block |
||
| 4544 | 4817 | return -3; |
| 4545 | 4818 | } |
| 4546 | 4819 | } |
| 4547 | - } |
|
| 4548 | - else |
|
| 4820 | + } else |
|
| 4549 | 4821 | { |
| 4550 | 4822 | $this->error=$langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded"); |
| 4551 | 4823 | dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); |
| 4552 | 4824 | $this->db->rollback(); |
| 4553 | 4825 | return -3; |
| 4554 | 4826 | } |
| 4555 | - } |
|
| 4556 | - else |
|
| 4827 | + } else |
|
| 4557 | 4828 | { |
| 4558 | 4829 | $this->error=$discount->error; |
| 4559 | 4830 | dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); |
@@ -4577,8 +4848,7 @@ discard block |
||
| 4577 | 4848 | $this->db->commit(); |
| 4578 | 4849 | return $this->rowid; |
| 4579 | 4850 | |
| 4580 | - } |
|
| 4581 | - else |
|
| 4851 | + } else |
|
| 4582 | 4852 | { |
| 4583 | 4853 | $this->error=$this->db->error(); |
| 4584 | 4854 | $this->db->rollback(); |
@@ -4603,28 +4873,66 @@ discard block |
||
| 4603 | 4873 | |
| 4604 | 4874 | // Clean parameters |
| 4605 | 4875 | $this->desc=trim($this->desc); |
| 4606 | - if (empty($this->tva_tx)) $this->tva_tx=0; |
|
| 4607 | - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; |
|
| 4608 | - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; |
|
| 4609 | - if (empty($this->localtax1_type)) $this->localtax1_type=0; |
|
| 4610 | - if (empty($this->localtax2_type)) $this->localtax2_type=0; |
|
| 4611 | - if (empty($this->total_localtax1)) $this->total_localtax1=0; |
|
| 4612 | - if (empty($this->total_localtax2)) $this->total_localtax2=0; |
|
| 4613 | - if (empty($this->remise_percent)) $this->remise_percent=0; |
|
| 4614 | - if (empty($this->info_bits)) $this->info_bits=0; |
|
| 4615 | - if (empty($this->special_code)) $this->special_code=0; |
|
| 4616 | - if (empty($this->product_type)) $this->product_type=0; |
|
| 4617 | - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; |
|
| 4618 | - if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; |
|
| 4619 | - if (empty($this->pa_ht)) $this->pa_ht=0; |
|
| 4620 | - |
|
| 4621 | - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; |
|
| 4622 | - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; |
|
| 4623 | - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; |
|
| 4624 | - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; |
|
| 4876 | + if (empty($this->tva_tx)) { |
|
| 4877 | + $this->tva_tx=0; |
|
| 4878 | + } |
|
| 4879 | + if (empty($this->localtax1_tx)) { |
|
| 4880 | + $this->localtax1_tx=0; |
|
| 4881 | + } |
|
| 4882 | + if (empty($this->localtax2_tx)) { |
|
| 4883 | + $this->localtax2_tx=0; |
|
| 4884 | + } |
|
| 4885 | + if (empty($this->localtax1_type)) { |
|
| 4886 | + $this->localtax1_type=0; |
|
| 4887 | + } |
|
| 4888 | + if (empty($this->localtax2_type)) { |
|
| 4889 | + $this->localtax2_type=0; |
|
| 4890 | + } |
|
| 4891 | + if (empty($this->total_localtax1)) { |
|
| 4892 | + $this->total_localtax1=0; |
|
| 4893 | + } |
|
| 4894 | + if (empty($this->total_localtax2)) { |
|
| 4895 | + $this->total_localtax2=0; |
|
| 4896 | + } |
|
| 4897 | + if (empty($this->remise_percent)) { |
|
| 4898 | + $this->remise_percent=0; |
|
| 4899 | + } |
|
| 4900 | + if (empty($this->info_bits)) { |
|
| 4901 | + $this->info_bits=0; |
|
| 4902 | + } |
|
| 4903 | + if (empty($this->special_code)) { |
|
| 4904 | + $this->special_code=0; |
|
| 4905 | + } |
|
| 4906 | + if (empty($this->product_type)) { |
|
| 4907 | + $this->product_type=0; |
|
| 4908 | + } |
|
| 4909 | + if (empty($this->fk_parent_line)) { |
|
| 4910 | + $this->fk_parent_line=0; |
|
| 4911 | + } |
|
| 4912 | + if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') { |
|
| 4913 | + $this->situation_percent = 100; |
|
| 4914 | + } |
|
| 4915 | + if (empty($this->pa_ht)) { |
|
| 4916 | + $this->pa_ht=0; |
|
| 4917 | + } |
|
| 4918 | + |
|
| 4919 | + if (empty($this->multicurrency_subprice)) { |
|
| 4920 | + $this->multicurrency_subprice=0; |
|
| 4921 | + } |
|
| 4922 | + if (empty($this->multicurrency_total_ht)) { |
|
| 4923 | + $this->multicurrency_total_ht=0; |
|
| 4924 | + } |
|
| 4925 | + if (empty($this->multicurrency_total_tva)) { |
|
| 4926 | + $this->multicurrency_total_tva=0; |
|
| 4927 | + } |
|
| 4928 | + if (empty($this->multicurrency_total_ttc)) { |
|
| 4929 | + $this->multicurrency_total_ttc=0; |
|
| 4930 | + } |
|
| 4625 | 4931 | |
| 4626 | 4932 | // Check parameters |
| 4627 | - if ($this->product_type < 0) return -1; |
|
| 4933 | + if ($this->product_type < 0) { |
|
| 4934 | + return -1; |
|
| 4935 | + } |
|
| 4628 | 4936 | |
| 4629 | 4937 | // if buy price not defined, define buyprice as configured in margin admin |
| 4630 | 4938 | if ($this->pa_ht == 0 && $pa_ht_isemptystring) |
@@ -4632,8 +4940,7 @@ discard block |
||
| 4632 | 4940 | if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) |
| 4633 | 4941 | { |
| 4634 | 4942 | return $result; |
| 4635 | - } |
|
| 4636 | - else |
|
| 4943 | + } else |
|
| 4637 | 4944 | { |
| 4638 | 4945 | $this->pa_ht = $result; |
| 4639 | 4946 | } |
@@ -4647,8 +4954,11 @@ discard block |
||
| 4647 | 4954 | $sql.= ", label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); |
| 4648 | 4955 | $sql.= ", subprice=".price2num($this->subprice).""; |
| 4649 | 4956 | $sql.= ", remise_percent=".price2num($this->remise_percent).""; |
| 4650 | - if ($this->fk_remise_except) $sql.= ", fk_remise_except=".$this->fk_remise_except; |
|
| 4651 | - else $sql.= ", fk_remise_except=null"; |
|
| 4957 | + if ($this->fk_remise_except) { |
|
| 4958 | + $sql.= ", fk_remise_except=".$this->fk_remise_except; |
|
| 4959 | + } else { |
|
| 4960 | + $sql.= ", fk_remise_except=null"; |
|
| 4961 | + } |
|
| 4652 | 4962 | $sql.= ", vat_src_code = '".(empty($this->vat_src_code)?'':$this->db->escape($this->vat_src_code))."'"; |
| 4653 | 4963 | $sql.= ", tva_tx=".price2num($this->tva_tx).""; |
| 4654 | 4964 | $sql.= ", localtax1_tx=".price2num($this->localtax1_tx).""; |
@@ -4672,7 +4982,9 @@ discard block |
||
| 4672 | 4982 | $sql.= ", fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); |
| 4673 | 4983 | $sql.= ", buy_price_ht='".price2num($this->pa_ht)."'"; |
| 4674 | 4984 | $sql.= ", fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); |
| 4675 | - if (! empty($this->rang)) $sql.= ", rang=".$this->rang; |
|
| 4985 | + if (! empty($this->rang)) { |
|
| 4986 | + $sql.= ", rang=".$this->rang; |
|
| 4987 | + } |
|
| 4676 | 4988 | $sql.= ", situation_percent=" . $this->situation_percent; |
| 4677 | 4989 | $sql.= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); |
| 4678 | 4990 | $sql.= ", fk_user_modif =".$user->id; |
@@ -4689,9 +5001,11 @@ discard block |
||
| 4689 | 5001 | $resql=$this->db->query($sql); |
| 4690 | 5002 | if ($resql) |
| 4691 | 5003 | { |
| 4692 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 5004 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 5005 | + // For avoid conflicts if trigger used |
|
| 4693 | 5006 | { |
| 4694 | 5007 | $this->id=$this->rowid; |
| 5008 | + } |
|
| 4695 | 5009 | $result=$this->insertExtraFields(); |
| 4696 | 5010 | if ($result < 0) |
| 4697 | 5011 | { |
@@ -4712,8 +5026,7 @@ discard block |
||
| 4712 | 5026 | } |
| 4713 | 5027 | $this->db->commit(); |
| 4714 | 5028 | return 1; |
| 4715 | - } |
|
| 4716 | - else |
|
| 5029 | + } else |
|
| 4717 | 5030 | { |
| 4718 | 5031 | $this->error=$this->db->error(); |
| 4719 | 5032 | $this->db->rollback(); |
@@ -4749,8 +5062,7 @@ discard block |
||
| 4749 | 5062 | { |
| 4750 | 5063 | $this->db->commit(); |
| 4751 | 5064 | return 1; |
| 4752 | - } |
|
| 4753 | - else |
|
| 5065 | + } else |
|
| 4754 | 5066 | { |
| 4755 | 5067 | $this->error=$this->db->error()." sql=".$sql; |
| 4756 | 5068 | $this->db->rollback(); |
@@ -4769,8 +5081,12 @@ discard block |
||
| 4769 | 5081 | dol_syslog(get_class($this)."::update_total", LOG_DEBUG); |
| 4770 | 5082 | |
| 4771 | 5083 | // Clean parameters |
| 4772 | - if (empty($this->total_localtax1)) $this->total_localtax1=0; |
|
| 4773 | - if (empty($this->total_localtax2)) $this->total_localtax2=0; |
|
| 5084 | + if (empty($this->total_localtax1)) { |
|
| 5085 | + $this->total_localtax1=0; |
|
| 5086 | + } |
|
| 5087 | + if (empty($this->total_localtax2)) { |
|
| 5088 | + $this->total_localtax2=0; |
|
| 5089 | + } |
|
| 4774 | 5090 | |
| 4775 | 5091 | // Mise a jour ligne en base |
| 4776 | 5092 | $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; |
@@ -4788,8 +5104,7 @@ discard block |
||
| 4788 | 5104 | { |
| 4789 | 5105 | $this->db->commit(); |
| 4790 | 5106 | return 1; |
| 4791 | - } |
|
| 4792 | - else |
|
| 5107 | + } else |
|
| 4793 | 5108 | { |
| 4794 | 5109 | $this->error=$this->db->error(); |
| 4795 | 5110 | $this->db->rollback(); |
@@ -4812,7 +5127,9 @@ discard block |
||
| 4812 | 5127 | // If invoice is a not a situation invoice, this->fk_prev_id is used for something else |
| 4813 | 5128 | $tmpinvoice=new Facture($this->db); |
| 4814 | 5129 | $tmpinvoice->fetch($invoiceid); |
| 4815 | - if ($tmpinvoice->type != Facture::TYPE_SITUATION) return 0; |
|
| 5130 | + if ($tmpinvoice->type != Facture::TYPE_SITUATION) { |
|
| 5131 | + return 0; |
|
| 5132 | + } |
|
| 4816 | 5133 | |
| 4817 | 5134 | $sql = 'SELECT situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE rowid=' . $this->fk_prev_id; |
| 4818 | 5135 | $resql = $this->db->query($sql); |
@@ -31,26 +31,26 @@ discard block |
||
| 31 | 31 | require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; |
| 32 | 32 | require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
| 33 | 33 | |
| 34 | -$langs->loadLangs(array("banks","categories",'withdrawals','bills')); |
|
| 34 | +$langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills')); |
|
| 35 | 35 | |
| 36 | 36 | // Securite acces client |
| 37 | 37 | if ($user->societe_id > 0) accessforbidden(); |
| 38 | 38 | |
| 39 | 39 | // Get supervariables |
| 40 | -$prev_id = GETPOST('id','int'); |
|
| 40 | +$prev_id = GETPOST('id', 'int'); |
|
| 41 | 41 | $ref = GETPOST('ref', 'alpha'); |
| 42 | 42 | |
| 43 | 43 | // Load variable for pagination |
| 44 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
| 45 | -$sortfield = GETPOST('sortfield','alpha'); |
|
| 46 | -$sortorder = GETPOST('sortorder','alpha'); |
|
| 47 | -$page = GETPOST('page','int'); |
|
| 44 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
| 45 | +$sortfield = GETPOST('sortfield', 'alpha'); |
|
| 46 | +$sortorder = GETPOST('sortorder', 'alpha'); |
|
| 47 | +$page = GETPOST('page', 'int'); |
|
| 48 | 48 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
| 49 | 49 | $offset = $limit * $page; |
| 50 | 50 | $pageprev = $page - 1; |
| 51 | 51 | $pagenext = $page + 1; |
| 52 | 52 | |
| 53 | -$object = new BonPrelevement($db,""); |
|
| 53 | +$object = new BonPrelevement($db, ""); |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * View |
| 60 | 60 | */ |
| 61 | 61 | |
| 62 | -llxHeader('',$langs->trans("WithdrawalsReceipts")); |
|
| 62 | +llxHeader('', $langs->trans("WithdrawalsReceipts")); |
|
| 63 | 63 | |
| 64 | 64 | if ($prev_id > 0 || $ref) |
| 65 | 65 | { |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | print '<table class="border centpercent">'."\n"; |
| 76 | 76 | |
| 77 | 77 | //print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>'; |
| 78 | - print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec,'day').'</td></tr>'; |
|
| 78 | + print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>'; |
|
| 79 | 79 | print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>'; |
| 80 | 80 | |
| 81 | 81 | // Status |
@@ -85,22 +85,22 @@ discard block |
||
| 85 | 85 | print '</tr>'; |
| 86 | 86 | */ |
| 87 | 87 | |
| 88 | - if($object->date_trans <> 0) |
|
| 88 | + if ($object->date_trans <> 0) |
|
| 89 | 89 | { |
| 90 | 90 | $muser = new User($db); |
| 91 | 91 | $muser->fetch($object->user_trans); |
| 92 | 92 | |
| 93 | 93 | print '<tr><td>'.$langs->trans("TransData").'</td><td>'; |
| 94 | - print dol_print_date($object->date_trans,'day'); |
|
| 94 | + print dol_print_date($object->date_trans, 'day'); |
|
| 95 | 95 | print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'</td></tr>'; |
| 96 | 96 | print '<tr><td>'.$langs->trans("TransMetod").'</td><td>'; |
| 97 | 97 | print $object->methodes_trans[$object->method_trans]; |
| 98 | 98 | print '</td></tr>'; |
| 99 | 99 | } |
| 100 | - if($object->date_credit <> 0) |
|
| 100 | + if ($object->date_credit <> 0) |
|
| 101 | 101 | { |
| 102 | 102 | print '<tr><td>'.$langs->trans('CreditDate').'</td><td>'; |
| 103 | - print dol_print_date($object->date_credit,'day'); |
|
| 103 | + print dol_print_date($object->date_credit, 'day'); |
|
| 104 | 104 | print '</td></tr>'; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | print '<table class="border" width="100%">'; |
| 113 | 113 | |
| 114 | 114 | $acc = new Account($db); |
| 115 | - $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); |
|
| 115 | + $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); |
|
| 116 | 116 | |
| 117 | 117 | print '<tr><td class="titlefield">'; |
| 118 | 118 | print $langs->trans("BankToReceiveWithdraw"); |
@@ -146,20 +146,20 @@ discard block |
||
| 146 | 146 | * List errors |
| 147 | 147 | */ |
| 148 | 148 | $sql = "SELECT pl.rowid, pl.amount, pl.statut"; |
| 149 | -$sql.= " , s.rowid as socid, s.nom as name"; |
|
| 150 | -$sql.= " , pr.motif, pr.afacturer, pr.fk_facture"; |
|
| 151 | -$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; |
|
| 152 | -$sql.= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; |
|
| 153 | -$sql.= " , ".MAIN_DB_PREFIX."societe as s"; |
|
| 154 | -$sql.= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr"; |
|
| 155 | -$sql.= " WHERE p.rowid=".$prev_id; |
|
| 156 | -$sql.= " AND pl.fk_prelevement_bons = p.rowid"; |
|
| 157 | -$sql.= " AND p.entity = ".$conf->entity; |
|
| 158 | -$sql.= " AND pl.fk_soc = s.rowid"; |
|
| 159 | -$sql.= " AND pl.statut = 3 "; |
|
| 160 | -$sql.= " AND pr.fk_prelevement_lignes = pl.rowid"; |
|
| 161 | -if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
| 162 | -$sql.= " ORDER BY pl.amount DESC"; |
|
| 149 | +$sql .= " , s.rowid as socid, s.nom as name"; |
|
| 150 | +$sql .= " , pr.motif, pr.afacturer, pr.fk_facture"; |
|
| 151 | +$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; |
|
| 152 | +$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; |
|
| 153 | +$sql .= " , ".MAIN_DB_PREFIX."societe as s"; |
|
| 154 | +$sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr"; |
|
| 155 | +$sql .= " WHERE p.rowid=".$prev_id; |
|
| 156 | +$sql .= " AND pl.fk_prelevement_bons = p.rowid"; |
|
| 157 | +$sql .= " AND p.entity = ".$conf->entity; |
|
| 158 | +$sql .= " AND pl.fk_soc = s.rowid"; |
|
| 159 | +$sql .= " AND pl.statut = 3 "; |
|
| 160 | +$sql .= " AND pr.fk_prelevement_lignes = pl.rowid"; |
|
| 161 | +if ($socid) $sql .= " AND s.rowid = ".$socid; |
|
| 162 | +$sql .= " ORDER BY pl.amount DESC"; |
|
| 163 | 163 | |
| 164 | 164 | // Count total nb of records |
| 165 | 165 | $nbtotalofrecords = ''; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | $nbtotalofrecords = $db->num_rows($result); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | -$sql.= $db->plimit($limit+1, $offset); |
|
| 172 | +$sql .= $db->plimit($limit + 1, $offset); |
|
| 173 | 173 | |
| 174 | 174 | $resql = $db->query($sql); |
| 175 | 175 | if ($resql) |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); |
| 180 | 180 | |
| 181 | 181 | print"\n<!-- debut table -->\n"; |
| 182 | - print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
| 182 | + print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
| 183 | 183 | print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">'; |
| 184 | 184 | print '<tr class="liste_titre">'; |
| 185 | 185 | print '<td>'.$langs->trans("Line").'</td><td>'.$langs->trans("ThirdParty").'</td><td align="right">'.$langs->trans("Amount").'</td>'; |
@@ -34,7 +34,9 @@ discard block |
||
| 34 | 34 | $langs->loadLangs(array("banks","categories",'withdrawals','bills')); |
| 35 | 35 | |
| 36 | 36 | // Securite acces client |
| 37 | -if ($user->societe_id > 0) accessforbidden(); |
|
| 37 | +if ($user->societe_id > 0) { |
|
| 38 | + accessforbidden(); |
|
| 39 | +} |
|
| 38 | 40 | |
| 39 | 41 | // Get supervariables |
| 40 | 42 | $prev_id = GETPOST('id','int'); |
@@ -118,8 +120,9 @@ discard block |
||
| 118 | 120 | print $langs->trans("BankToReceiveWithdraw"); |
| 119 | 121 | print '</td>'; |
| 120 | 122 | print '<td>'; |
| 121 | - if ($acc->id > 0) |
|
| 122 | - print $acc->getNomUrl(1); |
|
| 123 | + if ($acc->id > 0) { |
|
| 124 | + print $acc->getNomUrl(1); |
|
| 125 | + } |
|
| 123 | 126 | print '</td>'; |
| 124 | 127 | print '</tr>'; |
| 125 | 128 | |
@@ -133,8 +136,7 @@ discard block |
||
| 133 | 136 | |
| 134 | 137 | dol_fiche_end(); |
| 135 | 138 | |
| 136 | - } |
|
| 137 | - else |
|
| 139 | + } else |
|
| 138 | 140 | { |
| 139 | 141 | dol_print_error($db); |
| 140 | 142 | } |
@@ -158,7 +160,9 @@ discard block |
||
| 158 | 160 | $sql.= " AND pl.fk_soc = s.rowid"; |
| 159 | 161 | $sql.= " AND pl.statut = 3 "; |
| 160 | 162 | $sql.= " AND pr.fk_prelevement_lignes = pl.rowid"; |
| 161 | -if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
| 163 | +if ($socid) { |
|
| 164 | + $sql.= " AND s.rowid = ".$socid; |
|
| 165 | +} |
|
| 162 | 166 | $sql.= " ORDER BY pl.amount DESC"; |
| 163 | 167 | |
| 164 | 168 | // Count total nb of records |
@@ -213,8 +217,7 @@ discard block |
||
| 213 | 217 | |
| 214 | 218 | $i++; |
| 215 | 219 | } |
| 216 | - } |
|
| 217 | - else |
|
| 220 | + } else |
|
| 218 | 221 | { |
| 219 | 222 | print '<tr><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; |
| 220 | 223 | } |
@@ -231,8 +234,7 @@ discard block |
||
| 231 | 234 | print '</div>'; |
| 232 | 235 | |
| 233 | 236 | $db->free($resql); |
| 234 | -} |
|
| 235 | -else |
|
| 237 | +} else |
|
| 236 | 238 | { |
| 237 | 239 | dol_print_error($db); |
| 238 | 240 | } |
@@ -29,34 +29,34 @@ discard block |
||
| 29 | 29 | require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php'; |
| 30 | 30 | require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
| 31 | 31 | |
| 32 | -$langs->loadLangs(array("banks","categories",'withdrawals','bills')); |
|
| 32 | +$langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills')); |
|
| 33 | 33 | |
| 34 | 34 | // Security check |
| 35 | 35 | if ($user->societe_id > 0) accessforbidden(); |
| 36 | 36 | |
| 37 | 37 | // Get supervariables |
| 38 | -$prev_id = GETPOST('id','int'); |
|
| 38 | +$prev_id = GETPOST('id', 'int'); |
|
| 39 | 39 | $ref = GETPOST('ref', 'alpha'); |
| 40 | 40 | |
| 41 | 41 | // Load variable for pagination |
| 42 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
| 43 | -$sortfield = GETPOST('sortfield','alpha'); |
|
| 44 | -$sortorder = GETPOST('sortorder','alpha'); |
|
| 45 | -$page = GETPOST('page','int'); |
|
| 42 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
| 43 | +$sortfield = GETPOST('sortfield', 'alpha'); |
|
| 44 | +$sortorder = GETPOST('sortorder', 'alpha'); |
|
| 45 | +$page = GETPOST('page', 'int'); |
|
| 46 | 46 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
| 47 | 47 | $offset = $limit * $page; |
| 48 | 48 | $pageprev = $page - 1; |
| 49 | 49 | $pagenext = $page + 1; |
| 50 | 50 | |
| 51 | 51 | |
| 52 | -$object = new BonPrelevement($db,""); |
|
| 52 | +$object = new BonPrelevement($db, ""); |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | /* |
| 56 | 56 | * View |
| 57 | 57 | */ |
| 58 | 58 | |
| 59 | -llxHeader('',$langs->trans("WithdrawalsReceipts")); |
|
| 59 | +llxHeader('', $langs->trans("WithdrawalsReceipts")); |
|
| 60 | 60 | |
| 61 | 61 | if ($prev_id) |
| 62 | 62 | { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | print '<table class="border centpercent">'."\n"; |
| 73 | 73 | |
| 74 | 74 | //print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>'; |
| 75 | - print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec,'day').'</td></tr>'; |
|
| 75 | + print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>'; |
|
| 76 | 76 | print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>'; |
| 77 | 77 | |
| 78 | 78 | // Status |
@@ -82,22 +82,22 @@ discard block |
||
| 82 | 82 | print '</tr>'; |
| 83 | 83 | */ |
| 84 | 84 | |
| 85 | - if($object->date_trans <> 0) |
|
| 85 | + if ($object->date_trans <> 0) |
|
| 86 | 86 | { |
| 87 | 87 | $muser = new User($db); |
| 88 | 88 | $muser->fetch($object->user_trans); |
| 89 | 89 | |
| 90 | 90 | print '<tr><td>'.$langs->trans("TransData").'</td><td>'; |
| 91 | - print dol_print_date($object->date_trans,'day'); |
|
| 91 | + print dol_print_date($object->date_trans, 'day'); |
|
| 92 | 92 | print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'</td></tr>'; |
| 93 | 93 | print '<tr><td>'.$langs->trans("TransMetod").'</td><td>'; |
| 94 | 94 | print $object->methodes_trans[$object->method_trans]; |
| 95 | 95 | print '</td></tr>'; |
| 96 | 96 | } |
| 97 | - if($object->date_credit <> 0) |
|
| 97 | + if ($object->date_credit <> 0) |
|
| 98 | 98 | { |
| 99 | 99 | print '<tr><td>'.$langs->trans('CreditDate').'</td><td>'; |
| 100 | - print dol_print_date($object->date_credit,'day'); |
|
| 100 | + print dol_print_date($object->date_credit, 'day'); |
|
| 101 | 101 | print '</td></tr>'; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | print '<table class="border" width="100%">'; |
| 110 | 110 | |
| 111 | 111 | $acc = new Account($db); |
| 112 | - $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); |
|
| 112 | + $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); |
|
| 113 | 113 | |
| 114 | 114 | print '<tr><td class="titlefield">'; |
| 115 | 115 | print $langs->trans("BankToReceiveWithdraw"); |
@@ -140,20 +140,20 @@ discard block |
||
| 140 | 140 | /* |
| 141 | 141 | * Stats |
| 142 | 142 | */ |
| 143 | - $ligne=new LignePrelevement($db,$user); |
|
| 143 | + $ligne = new LignePrelevement($db, $user); |
|
| 144 | 144 | |
| 145 | 145 | $sql = "SELECT sum(pl.amount), pl.statut"; |
| 146 | - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; |
|
| 147 | - $sql.= " WHERE pl.fk_prelevement_bons = ".$prev_id; |
|
| 148 | - $sql.= " GROUP BY pl.statut"; |
|
| 146 | + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; |
|
| 147 | + $sql .= " WHERE pl.fk_prelevement_bons = ".$prev_id; |
|
| 148 | + $sql .= " GROUP BY pl.statut"; |
|
| 149 | 149 | |
| 150 | - $resql=$db->query($sql); |
|
| 150 | + $resql = $db->query($sql); |
|
| 151 | 151 | if ($resql) |
| 152 | 152 | { |
| 153 | 153 | $num = $db->num_rows($resql); |
| 154 | 154 | $i = 0; |
| 155 | 155 | |
| 156 | - print load_fiche_titre($langs->trans("StatisticsByLineStatus"),'',''); |
|
| 156 | + print load_fiche_titre($langs->trans("StatisticsByLineStatus"), '', ''); |
|
| 157 | 157 | |
| 158 | 158 | print"\n<!-- debut table -->\n"; |
| 159 | 159 | print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">'; |
@@ -166,13 +166,13 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | print '<tr class="oddeven"><td>'; |
| 168 | 168 | |
| 169 | - print $ligne->LibStatut($row[1],1); |
|
| 169 | + print $ligne->LibStatut($row[1], 1); |
|
| 170 | 170 | |
| 171 | 171 | print '</td><td align="right">'; |
| 172 | 172 | print price($row[0]); |
| 173 | 173 | |
| 174 | 174 | print '</td><td align="right">'; |
| 175 | - if ($object->amount) print round($row[0]/$object->amount*100,2)." %"; |
|
| 175 | + if ($object->amount) print round($row[0] / $object->amount * 100, 2)." %"; |
|
| 176 | 176 | print '</td>'; |
| 177 | 177 | |
| 178 | 178 | print "</tr>\n"; |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | else |
| 188 | 188 | { |
| 189 | - print $db->error() . ' ' . $sql; |
|
| 189 | + print $db->error().' '.$sql; |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
@@ -32,7 +32,9 @@ discard block |
||
| 32 | 32 | $langs->loadLangs(array("banks","categories",'withdrawals','bills')); |
| 33 | 33 | |
| 34 | 34 | // Security check |
| 35 | -if ($user->societe_id > 0) accessforbidden(); |
|
| 35 | +if ($user->societe_id > 0) { |
|
| 36 | + accessforbidden(); |
|
| 37 | +} |
|
| 36 | 38 | |
| 37 | 39 | // Get supervariables |
| 38 | 40 | $prev_id = GETPOST('id','int'); |
@@ -115,8 +117,9 @@ discard block |
||
| 115 | 117 | print $langs->trans("BankToReceiveWithdraw"); |
| 116 | 118 | print '</td>'; |
| 117 | 119 | print '<td>'; |
| 118 | - if ($acc->id > 0) |
|
| 119 | - print $acc->getNomUrl(1); |
|
| 120 | + if ($acc->id > 0) { |
|
| 121 | + print $acc->getNomUrl(1); |
|
| 122 | + } |
|
| 120 | 123 | print '</td>'; |
| 121 | 124 | print '</tr>'; |
| 122 | 125 | |
@@ -130,8 +133,7 @@ discard block |
||
| 130 | 133 | |
| 131 | 134 | dol_fiche_end(); |
| 132 | 135 | |
| 133 | - } |
|
| 134 | - else |
|
| 136 | + } else |
|
| 135 | 137 | { |
| 136 | 138 | $langs->load("errors"); |
| 137 | 139 | print $langs->trans("Error"); |
@@ -172,7 +174,9 @@ discard block |
||
| 172 | 174 | print price($row[0]); |
| 173 | 175 | |
| 174 | 176 | print '</td><td align="right">'; |
| 175 | - if ($object->amount) print round($row[0]/$object->amount*100,2)." %"; |
|
| 177 | + if ($object->amount) { |
|
| 178 | + print round($row[0]/$object->amount*100,2)." %"; |
|
| 179 | + } |
|
| 176 | 180 | print '</td>'; |
| 177 | 181 | |
| 178 | 182 | print "</tr>\n"; |
@@ -183,8 +187,7 @@ discard block |
||
| 183 | 187 | |
| 184 | 188 | print "</table>"; |
| 185 | 189 | $db->free($resql); |
| 186 | - } |
|
| 187 | - else |
|
| 190 | + } else |
|
| 188 | 191 | { |
| 189 | 192 | print $db->error() . ' ' . $sql; |
| 190 | 193 | } |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | if (!$user->admin) accessforbidden(); |
| 42 | 42 | |
| 43 | -$value = GETPOST('value','alpha'); |
|
| 44 | -$action = GETPOST('action','alpha'); |
|
| 45 | -$label = GETPOST('label','alpha'); |
|
| 46 | -$scandir = GETPOST('scan_dir','alpha'); |
|
| 47 | -$type='project'; |
|
| 43 | +$value = GETPOST('value', 'alpha'); |
|
| 44 | +$action = GETPOST('action', 'alpha'); |
|
| 45 | +$label = GETPOST('label', 'alpha'); |
|
| 46 | +$scandir = GETPOST('scan_dir', 'alpha'); |
|
| 47 | +$type = 'project'; |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | /* |
@@ -55,23 +55,23 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | if ($action == 'setmainoptions') |
| 57 | 57 | { |
| 58 | - if (GETPOST('PROJECT_USE_OPPORTUNITIES')) dolibarr_set_const($db, "PROJECT_USE_OPPORTUNITIES",GETPOST('PROJECT_USE_OPPORTUNITIES'),'chaine',0,'',$conf->entity); |
|
| 58 | + if (GETPOST('PROJECT_USE_OPPORTUNITIES')) dolibarr_set_const($db, "PROJECT_USE_OPPORTUNITIES", GETPOST('PROJECT_USE_OPPORTUNITIES'), 'chaine', 0, '', $conf->entity); |
|
| 59 | 59 | else dolibarr_del_const($db, "PROJECT_USE_OPPORTUNITIES", $conf->entity); |
| 60 | 60 | |
| 61 | 61 | if (GETPOST('PROJECT_USE_TASKS')) dolibarr_del_const($db, "PROJECT_HIDE_TASKS", $conf->entity); |
| 62 | - else dolibarr_set_const($db, "PROJECT_HIDE_TASKS",1,'chaine',0,'',$conf->entity); |
|
| 62 | + else dolibarr_set_const($db, "PROJECT_HIDE_TASKS", 1, 'chaine', 0, '', $conf->entity); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | else if ($action == 'updateMask') |
| 66 | 66 | { |
| 67 | - $maskconstproject=GETPOST('maskconstproject','alpha'); |
|
| 68 | - $maskproject=GETPOST('maskproject','alpha'); |
|
| 67 | + $maskconstproject = GETPOST('maskconstproject', 'alpha'); |
|
| 68 | + $maskproject = GETPOST('maskproject', 'alpha'); |
|
| 69 | 69 | |
| 70 | - if ($maskconstproject) $res = dolibarr_set_const($db,$maskconstproject,$maskproject,'chaine',0,'',$conf->entity); |
|
| 70 | + if ($maskconstproject) $res = dolibarr_set_const($db, $maskconstproject, $maskproject, 'chaine', 0, '', $conf->entity); |
|
| 71 | 71 | |
| 72 | - if (! $res > 0) $error++; |
|
| 72 | + if (!$res > 0) $error++; |
|
| 73 | 73 | |
| 74 | - if (! $error) |
|
| 74 | + if (!$error) |
|
| 75 | 75 | { |
| 76 | 76 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
| 77 | 77 | } |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | if ($action == 'updateMaskTask') |
| 85 | 85 | { |
| 86 | - $maskconstmasktask=GETPOST('maskconsttask','alpha'); |
|
| 87 | - $masktaskt=GETPOST('masktask','alpha'); |
|
| 86 | + $maskconstmasktask = GETPOST('maskconsttask', 'alpha'); |
|
| 87 | + $masktaskt = GETPOST('masktask', 'alpha'); |
|
| 88 | 88 | |
| 89 | - if ($maskconstmasktask) $res = dolibarr_set_const($db,$maskconstmasktask,$masktaskt,'chaine',0,'',$conf->entity); |
|
| 89 | + if ($maskconstmasktask) $res = dolibarr_set_const($db, $maskconstmasktask, $masktaskt, 'chaine', 0, '', $conf->entity); |
|
| 90 | 90 | |
| 91 | - if (! $res > 0) $error++; |
|
| 91 | + if (!$res > 0) $error++; |
|
| 92 | 92 | |
| 93 | - if (! $error) |
|
| 93 | + if (!$error) |
|
| 94 | 94 | { |
| 95 | 95 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
| 96 | 96 | } |
@@ -102,20 +102,20 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | else if ($action == 'specimen') |
| 104 | 104 | { |
| 105 | - $modele=GETPOST('module','alpha'); |
|
| 105 | + $modele = GETPOST('module', 'alpha'); |
|
| 106 | 106 | |
| 107 | 107 | $project = new Project($db); |
| 108 | 108 | $project->initAsSpecimen(); |
| 109 | 109 | |
| 110 | 110 | // Search template files |
| 111 | - $file=''; $classname=''; $filefound=0; |
|
| 112 | - $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); |
|
| 113 | - foreach($dirmodels as $reldir) |
|
| 111 | + $file = ''; $classname = ''; $filefound = 0; |
|
| 112 | + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); |
|
| 113 | + foreach ($dirmodels as $reldir) |
|
| 114 | 114 | { |
| 115 | - $file=dol_buildpath($reldir."core/modules/project/doc/pdf_".$modele.".modules.php",0); |
|
| 115 | + $file = dol_buildpath($reldir."core/modules/project/doc/pdf_".$modele.".modules.php", 0); |
|
| 116 | 116 | if (file_exists($file)) |
| 117 | 117 | { |
| 118 | - $filefound=1; |
|
| 118 | + $filefound = 1; |
|
| 119 | 119 | $classname = "pdf_".$modele; |
| 120 | 120 | break; |
| 121 | 121 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | $module = new $classname($db); |
| 129 | 129 | |
| 130 | - if ($module->write_file($project,$langs) > 0) |
|
| 130 | + if ($module->write_file($project, $langs) > 0) |
|
| 131 | 131 | { |
| 132 | 132 | header("Location: ".DOL_URL_ROOT."/document.php?modulepart=project&file=SPECIMEN.pdf"); |
| 133 | 133 | return; |
@@ -147,20 +147,20 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | else if ($action == 'specimentask') |
| 149 | 149 | { |
| 150 | - $modele=GETPOST('module','alpha'); |
|
| 150 | + $modele = GETPOST('module', 'alpha'); |
|
| 151 | 151 | |
| 152 | 152 | $project = new Project($db); |
| 153 | 153 | $project->initAsSpecimen(); |
| 154 | 154 | |
| 155 | 155 | // Search template files |
| 156 | - $file=''; $classname=''; $filefound=0; |
|
| 157 | - $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); |
|
| 158 | - foreach($dirmodels as $reldir) |
|
| 156 | + $file = ''; $classname = ''; $filefound = 0; |
|
| 157 | + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); |
|
| 158 | + foreach ($dirmodels as $reldir) |
|
| 159 | 159 | { |
| 160 | - $file=dol_buildpath($reldir."core/modules/project/task/doc/pdf_".$modele.".modules.php",0); |
|
| 160 | + $file = dol_buildpath($reldir."core/modules/project/task/doc/pdf_".$modele.".modules.php", 0); |
|
| 161 | 161 | if (file_exists($file)) |
| 162 | 162 | { |
| 163 | - $filefound=1; |
|
| 163 | + $filefound = 1; |
|
| 164 | 164 | $classname = "pdf_".$modele; |
| 165 | 165 | break; |
| 166 | 166 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $module = new $classname($db); |
| 174 | 174 | |
| 175 | - if ($module->write_file($project,$langs) > 0) |
|
| 175 | + if ($module->write_file($project, $langs) > 0) |
|
| 176 | 176 | { |
| 177 | 177 | header("Location: ".DOL_URL_ROOT."/document.php?modulepart=project_task&file=SPECIMEN.pdf"); |
| 178 | 178 | return; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | // Activate a model for task |
| 199 | 199 | else if ($action == 'settask') |
| 200 | 200 | { |
| 201 | - $ret = addDocumentModel($value,'project_task', $label, $scandir); |
|
| 201 | + $ret = addDocumentModel($value, 'project_task', $label, $scandir); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | else if ($action == 'del') |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | $ret = delDocumentModel($value, $type); |
| 207 | 207 | if ($ret > 0) |
| 208 | 208 | { |
| 209 | - if ($conf->global->PROJECT_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_ADDON_PDF',$conf->entity); |
|
| 209 | + if ($conf->global->PROJECT_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_ADDON_PDF', $conf->entity); |
|
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | if ($action == 'deltask') |
@@ -214,14 +214,14 @@ discard block |
||
| 214 | 214 | $ret = delDocumentModel($value, 'project_task'); |
| 215 | 215 | if ($ret > 0) |
| 216 | 216 | { |
| 217 | - if ($conf->global->PROJECT_TASK_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_TASK_ADDON_PDF',$conf->entity); |
|
| 217 | + if ($conf->global->PROJECT_TASK_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_TASK_ADDON_PDF', $conf->entity); |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | // Set default model |
| 222 | 222 | else if ($action == 'setdoc') |
| 223 | 223 | { |
| 224 | - dolibarr_set_const($db, "PROJECT_ADDON_PDF",$value,'chaine',0,'',$conf->entity); |
|
| 224 | + dolibarr_set_const($db, "PROJECT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity); |
|
| 225 | 225 | |
| 226 | 226 | // On active le modele |
| 227 | 227 | $ret = delDocumentModel($value, $type); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | else if ($action == 'setdoctask') |
| 235 | 235 | { |
| 236 | - if (dolibarr_set_const($db, "PROJECT_TASK_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) |
|
| 236 | + if (dolibarr_set_const($db, "PROJECT_TASK_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) |
|
| 237 | 237 | { |
| 238 | 238 | // La constante qui a ete lue en avant du nouveau set |
| 239 | 239 | // on passe donc par une variable pour avoir un affichage coherent |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | // TODO Verifier si module numerotation choisi peut etre active |
| 254 | 254 | // par appel methode canBeActivated |
| 255 | 255 | |
| 256 | - dolibarr_set_const($db, "PROJECT_ADDON",$value,'chaine',0,'',$conf->entity); |
|
| 256 | + dolibarr_set_const($db, "PROJECT_ADDON", $value, 'chaine', 0, '', $conf->entity); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | else if ($action == 'setmodtask') |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | // TODO Verifier si module numerotation choisi peut etre active |
| 262 | 262 | // par appel methode canBeActivated |
| 263 | 263 | |
| 264 | - dolibarr_set_const($db, "PROJECT_TASK_ADDON",$value,'chaine',0,'',$conf->entity); |
|
| 264 | + dolibarr_set_const($db, "PROJECT_TASK_ADDON", $value, 'chaine', 0, '', $conf->entity); |
|
| 265 | 265 | } |
| 266 | 266 | elseif ($action == 'updateoptions') |
| 267 | 267 | { |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | { |
| 279 | 279 | $projectToSelect = GETPOST('projectToSelect'); |
| 280 | 280 | |
| 281 | - dolibarr_set_const($db, 'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY', $projectToSelect, 'chaine', 0, '', $conf->entity); //Allow to disable this configuration if empty value |
|
| 281 | + dolibarr_set_const($db, 'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY', $projectToSelect, 'chaine', 0, '', $conf->entity); //Allow to disable this configuration if empty value |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | |
@@ -286,24 +286,24 @@ discard block |
||
| 286 | 286 | * View |
| 287 | 287 | */ |
| 288 | 288 | |
| 289 | -$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); |
|
| 289 | +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); |
|
| 290 | 290 | |
| 291 | -llxHeader("",$langs->trans("ProjectsSetup")); |
|
| 291 | +llxHeader("", $langs->trans("ProjectsSetup")); |
|
| 292 | 292 | |
| 293 | -$form=new Form($db); |
|
| 293 | +$form = new Form($db); |
|
| 294 | 294 | |
| 295 | -$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; |
|
| 296 | -print load_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'title_setup'); |
|
| 295 | +$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; |
|
| 296 | +print load_fiche_titre($langs->trans("ProjectsSetup"), $linkback, 'title_setup'); |
|
| 297 | 297 | |
| 298 | -$head=project_admin_prepare_head(); |
|
| 298 | +$head = project_admin_prepare_head(); |
|
| 299 | 299 | |
| 300 | 300 | dol_fiche_head($head, 'project', $langs->trans("Projects"), -1, 'project'); |
| 301 | 301 | |
| 302 | 302 | |
| 303 | 303 | |
| 304 | 304 | // Main options |
| 305 | -$form=new Form($db); |
|
| 306 | -$var=true; |
|
| 305 | +$form = new Form($db); |
|
| 306 | +$var = true; |
|
| 307 | 307 | |
| 308 | 308 | print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">'; |
| 309 | 309 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | print '<tr class="oddeven">'; |
| 321 | 321 | print '<td width="80%">'.$langs->trans("ManageOpportunitiesStatus").'</td>'; |
| 322 | 322 | print '<td width="60" align="right">'; |
| 323 | -$arrval=array('0'=>$langs->trans("No"), |
|
| 323 | +$arrval = array('0'=>$langs->trans("No"), |
|
| 324 | 324 | '1'=>$langs->trans("Yes"), |
| 325 | 325 | ); |
| 326 | 326 | print $form->selectyesno('PROJECT_USE_OPPORTUNITIES', $conf->global->PROJECT_USE_OPPORTUNITIES, 1); |
@@ -333,10 +333,10 @@ discard block |
||
| 333 | 333 | print '<tr class="oddeven">'; |
| 334 | 334 | print '<td width="80%">'.$langs->trans("ManageTasks").'</td>'; |
| 335 | 335 | print '<td width="60" align="right">'; |
| 336 | -$arrval=array('0'=>$langs->trans("No"), |
|
| 336 | +$arrval = array('0'=>$langs->trans("No"), |
|
| 337 | 337 | '1'=>$langs->trans("Yes"), |
| 338 | 338 | ); |
| 339 | -print $form->selectyesno('PROJECT_USE_TASKS', empty($conf->global->PROJECT_HIDE_TASKS)?1:0, 1); |
|
| 339 | +print $form->selectyesno('PROJECT_USE_TASKS', empty($conf->global->PROJECT_HIDE_TASKS) ? 1 : 0, 1); |
|
| 340 | 340 | print '</td><td align="right">'; |
| 341 | 341 | print '<input type="submit" class="button" name="modifyPROJECT_USE_TASKS" value="'.$langs->trans("Modify").'">'; |
| 342 | 342 | print "</td>"; |
@@ -374,21 +374,21 @@ discard block |
||
| 374 | 374 | $handle = opendir($dir); |
| 375 | 375 | if (is_resource($handle)) |
| 376 | 376 | { |
| 377 | - $var=true; |
|
| 377 | + $var = true; |
|
| 378 | 378 | |
| 379 | - while (($file = readdir($handle))!==false) |
|
| 379 | + while (($file = readdir($handle)) !== false) |
|
| 380 | 380 | { |
| 381 | - if (preg_match('/^(mod_.*)\.php$/i',$file,$reg)) |
|
| 381 | + if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) |
|
| 382 | 382 | { |
| 383 | 383 | $file = $reg[1]; |
| 384 | - $classname = substr($file,4); |
|
| 384 | + $classname = substr($file, 4); |
|
| 385 | 385 | |
| 386 | 386 | require_once $dir.$file.'.php'; |
| 387 | 387 | |
| 388 | 388 | $module = new $file; |
| 389 | 389 | |
| 390 | 390 | // Show modules according to features level |
| 391 | - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; |
|
| 391 | + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; |
|
| 392 | 392 | if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; |
| 393 | 393 | |
| 394 | 394 | if ($module->isEnabled()) |
@@ -400,45 +400,45 @@ discard block |
||
| 400 | 400 | |
| 401 | 401 | // Show example of numbering model |
| 402 | 402 | print '<td class="nowrap">'; |
| 403 | - $tmp=$module->getExample(); |
|
| 404 | - if (preg_match('/^Error/',$tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>'; |
|
| 405 | - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); |
|
| 403 | + $tmp = $module->getExample(); |
|
| 404 | + if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>'; |
|
| 405 | + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); |
|
| 406 | 406 | else print $tmp; |
| 407 | 407 | print '</td>'."\n"; |
| 408 | 408 | |
| 409 | 409 | print '<td align="center">'; |
| 410 | 410 | if ($conf->global->PROJECT_ADDON == 'mod_'.$classname) |
| 411 | 411 | { |
| 412 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
| 412 | + print img_picto($langs->trans("Activated"), 'switch_on'); |
|
| 413 | 413 | } |
| 414 | 414 | else |
| 415 | 415 | { |
| 416 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; |
|
| 416 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; |
|
| 417 | 417 | } |
| 418 | 418 | print '</td>'; |
| 419 | 419 | |
| 420 | - $project=new Project($db); |
|
| 420 | + $project = new Project($db); |
|
| 421 | 421 | $project->initAsSpecimen(); |
| 422 | 422 | |
| 423 | 423 | // Info |
| 424 | - $htmltooltip=''; |
|
| 425 | - $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; |
|
| 426 | - $nextval=$module->getNextValue($mysoc,$project); |
|
| 424 | + $htmltooltip = ''; |
|
| 425 | + $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; |
|
| 426 | + $nextval = $module->getNextValue($mysoc, $project); |
|
| 427 | 427 | if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval |
| 428 | 428 | { |
| 429 | - $htmltooltip.=''.$langs->trans("NextValue").': '; |
|
| 429 | + $htmltooltip .= ''.$langs->trans("NextValue").': '; |
|
| 430 | 430 | if ($nextval) |
| 431 | 431 | { |
| 432 | - $htmltooltip.=$nextval.'<br>'; |
|
| 432 | + $htmltooltip .= $nextval.'<br>'; |
|
| 433 | 433 | } |
| 434 | 434 | else |
| 435 | 435 | { |
| 436 | - $htmltooltip.=$langs->trans($module->error).'<br>'; |
|
| 436 | + $htmltooltip .= $langs->trans($module->error).'<br>'; |
|
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | print '<td align="center">'; |
| 441 | - print $form->textwithpicto('',$htmltooltip,1,0); |
|
| 441 | + print $form->textwithpicto('', $htmltooltip, 1, 0); |
|
| 442 | 442 | print '</td>'; |
| 443 | 443 | |
| 444 | 444 | print '</tr>'; |
@@ -478,21 +478,21 @@ discard block |
||
| 478 | 478 | $handle = opendir($dir); |
| 479 | 479 | if (is_resource($handle)) |
| 480 | 480 | { |
| 481 | - $var=true; |
|
| 481 | + $var = true; |
|
| 482 | 482 | |
| 483 | - while (($file = readdir($handle))!==false) |
|
| 483 | + while (($file = readdir($handle)) !== false) |
|
| 484 | 484 | { |
| 485 | - if (preg_match('/^(mod_.*)\.php$/i',$file,$reg)) |
|
| 485 | + if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) |
|
| 486 | 486 | { |
| 487 | 487 | $file = $reg[1]; |
| 488 | - $classname = substr($file,4); |
|
| 488 | + $classname = substr($file, 4); |
|
| 489 | 489 | |
| 490 | 490 | require_once $dir.$file.'.php'; |
| 491 | 491 | |
| 492 | 492 | $module = new $file; |
| 493 | 493 | |
| 494 | 494 | // Show modules according to features level |
| 495 | - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; |
|
| 495 | + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; |
|
| 496 | 496 | if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; |
| 497 | 497 | |
| 498 | 498 | if ($module->isEnabled()) |
@@ -504,45 +504,45 @@ discard block |
||
| 504 | 504 | |
| 505 | 505 | // Show example of numbering module |
| 506 | 506 | print '<td class="nowrap">'; |
| 507 | - $tmp=$module->getExample(); |
|
| 508 | - if (preg_match('/^Error/',$tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>'; |
|
| 509 | - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); |
|
| 507 | + $tmp = $module->getExample(); |
|
| 508 | + if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>'; |
|
| 509 | + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); |
|
| 510 | 510 | else print $tmp; |
| 511 | 511 | print '</td>'."\n"; |
| 512 | 512 | |
| 513 | 513 | print '<td align="center">'; |
| 514 | 514 | if ($conf->global->PROJECT_TASK_ADDON == 'mod_'.$classname) |
| 515 | 515 | { |
| 516 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
| 516 | + print img_picto($langs->trans("Activated"), 'switch_on'); |
|
| 517 | 517 | } |
| 518 | 518 | else |
| 519 | 519 | { |
| 520 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodtask&value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; |
|
| 520 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodtask&value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; |
|
| 521 | 521 | } |
| 522 | 522 | print '</td>'; |
| 523 | 523 | |
| 524 | - $project=new Project($db); |
|
| 524 | + $project = new Project($db); |
|
| 525 | 525 | $project->initAsSpecimen(); |
| 526 | 526 | |
| 527 | 527 | // Info |
| 528 | - $htmltooltip=''; |
|
| 529 | - $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; |
|
| 530 | - $nextval=$module->getNextValue($mysoc,$project); |
|
| 528 | + $htmltooltip = ''; |
|
| 529 | + $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; |
|
| 530 | + $nextval = $module->getNextValue($mysoc, $project); |
|
| 531 | 531 | if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval |
| 532 | 532 | { |
| 533 | - $htmltooltip.=''.$langs->trans("NextValue").': '; |
|
| 533 | + $htmltooltip .= ''.$langs->trans("NextValue").': '; |
|
| 534 | 534 | if ($nextval) |
| 535 | 535 | { |
| 536 | - $htmltooltip.=$nextval.'<br>'; |
|
| 536 | + $htmltooltip .= $nextval.'<br>'; |
|
| 537 | 537 | } |
| 538 | 538 | else |
| 539 | 539 | { |
| 540 | - $htmltooltip.=$langs->trans($module->error).'<br>'; |
|
| 540 | + $htmltooltip .= $langs->trans($module->error).'<br>'; |
|
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | print '<td align="center">'; |
| 545 | - print $form->textwithpicto('',$htmltooltip,1,0); |
|
| 545 | + print $form->textwithpicto('', $htmltooltip, 1, 0); |
|
| 546 | 546 | print '</td>'; |
| 547 | 547 | |
| 548 | 548 | print '</tr>'; |
@@ -565,19 +565,19 @@ discard block |
||
| 565 | 565 | print load_fiche_titre($langs->trans("ProjectsModelModule"), '', ''); |
| 566 | 566 | |
| 567 | 567 | // Defini tableau def de modele |
| 568 | -$type='project'; |
|
| 568 | +$type = 'project'; |
|
| 569 | 569 | $def = array(); |
| 570 | 570 | |
| 571 | 571 | $sql = "SELECT nom"; |
| 572 | -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; |
|
| 573 | -$sql.= " WHERE type = '".$type."'"; |
|
| 574 | -$sql.= " AND entity = ".$conf->entity; |
|
| 572 | +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; |
|
| 573 | +$sql .= " WHERE type = '".$type."'"; |
|
| 574 | +$sql .= " AND entity = ".$conf->entity; |
|
| 575 | 575 | |
| 576 | -$resql=$db->query($sql); |
|
| 576 | +$resql = $db->query($sql); |
|
| 577 | 577 | if ($resql) |
| 578 | 578 | { |
| 579 | 579 | $i = 0; |
| 580 | - $num_rows=$db->num_rows($resql); |
|
| 580 | + $num_rows = $db->num_rows($resql); |
|
| 581 | 581 | while ($i < $num_rows) |
| 582 | 582 | { |
| 583 | 583 | $array = $db->fetch_array($resql); |
@@ -602,48 +602,48 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | clearstatcache(); |
| 604 | 604 | |
| 605 | -$var=true; |
|
| 605 | +$var = true; |
|
| 606 | 606 | foreach ($dirmodels as $reldir) |
| 607 | 607 | { |
| 608 | - foreach (array('','/doc') as $valdir) |
|
| 608 | + foreach (array('', '/doc') as $valdir) |
|
| 609 | 609 | { |
| 610 | 610 | $dir = dol_buildpath($reldir."core/modules/project/".$valdir); |
| 611 | 611 | |
| 612 | 612 | if (is_dir($dir)) |
| 613 | 613 | { |
| 614 | - $handle=opendir($dir); |
|
| 614 | + $handle = opendir($dir); |
|
| 615 | 615 | if (is_resource($handle)) |
| 616 | 616 | { |
| 617 | - while (($file = readdir($handle))!==false) |
|
| 617 | + while (($file = readdir($handle)) !== false) |
|
| 618 | 618 | { |
| 619 | - $filelist[]=$file; |
|
| 619 | + $filelist[] = $file; |
|
| 620 | 620 | } |
| 621 | 621 | closedir($handle); |
| 622 | 622 | arsort($filelist); |
| 623 | 623 | |
| 624 | - foreach($filelist as $file) |
|
| 624 | + foreach ($filelist as $file) |
|
| 625 | 625 | { |
| 626 | - if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) |
|
| 626 | + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) |
|
| 627 | 627 | { |
| 628 | 628 | if (file_exists($dir.'/'.$file)) |
| 629 | 629 | { |
| 630 | - $name = substr($file, 4, dol_strlen($file) -16); |
|
| 631 | - $classname = substr($file, 0, dol_strlen($file) -12); |
|
| 630 | + $name = substr($file, 4, dol_strlen($file) - 16); |
|
| 631 | + $classname = substr($file, 0, dol_strlen($file) - 12); |
|
| 632 | 632 | |
| 633 | 633 | require_once $dir.'/'.$file; |
| 634 | 634 | $module = new $classname($db); |
| 635 | 635 | |
| 636 | - $modulequalified=1; |
|
| 637 | - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; |
|
| 638 | - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; |
|
| 636 | + $modulequalified = 1; |
|
| 637 | + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; |
|
| 638 | + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; |
|
| 639 | 639 | |
| 640 | 640 | if ($modulequalified) |
| 641 | 641 | { |
| 642 | 642 | |
| 643 | 643 | print '<tr class="oddeven"><td width="100">'; |
| 644 | - print (empty($module->name)?$name:$module->name); |
|
| 644 | + print (empty($module->name) ? $name : $module->name); |
|
| 645 | 645 | print "</td><td>\n"; |
| 646 | - if (method_exists($module,'info')) print $module->info($langs); |
|
| 646 | + if (method_exists($module, 'info')) print $module->info($langs); |
|
| 647 | 647 | else print $module->description; |
| 648 | 648 | print "</td>\n"; |
| 649 | 649 | |
@@ -652,14 +652,14 @@ discard block |
||
| 652 | 652 | { |
| 653 | 653 | print "<td align=\"center\">\n"; |
| 654 | 654 | print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'; |
| 655 | - print img_picto($langs->trans("Enabled"),'switch_on'); |
|
| 655 | + print img_picto($langs->trans("Enabled"), 'switch_on'); |
|
| 656 | 656 | print '</a>'; |
| 657 | 657 | print "</td>"; |
| 658 | 658 | } |
| 659 | 659 | else |
| 660 | 660 | { |
| 661 | 661 | print "<td align=\"center\">\n"; |
| 662 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; |
|
| 662 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; |
|
| 663 | 663 | print "</td>"; |
| 664 | 664 | } |
| 665 | 665 | |
@@ -667,37 +667,37 @@ discard block |
||
| 667 | 667 | print "<td align=\"center\">"; |
| 668 | 668 | if ($conf->global->PROJECT_ADDON_PDF == "$name") |
| 669 | 669 | { |
| 670 | - print img_picto($langs->trans("Default"),'on'); |
|
| 670 | + print img_picto($langs->trans("Default"), 'on'); |
|
| 671 | 671 | } |
| 672 | 672 | else |
| 673 | 673 | { |
| 674 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
| 674 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; |
|
| 675 | 675 | } |
| 676 | 676 | print '</td>'; |
| 677 | 677 | |
| 678 | 678 | // Info |
| 679 | - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; |
|
| 680 | - $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); |
|
| 679 | + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; |
|
| 680 | + $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); |
|
| 681 | 681 | if ($module->type == 'pdf') |
| 682 | 682 | { |
| 683 | - $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; |
|
| 683 | + $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; |
|
| 684 | 684 | } |
| 685 | - $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; |
|
| 686 | - $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); |
|
| 685 | + $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; |
|
| 686 | + $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); |
|
| 687 | 687 | |
| 688 | 688 | print '<td align="center">'; |
| 689 | - print $form->textwithpicto('',$htmltooltip,1,0); |
|
| 689 | + print $form->textwithpicto('', $htmltooltip, 1, 0); |
|
| 690 | 690 | print '</td>'; |
| 691 | 691 | |
| 692 | 692 | // Preview |
| 693 | 693 | print '<td align="center">'; |
| 694 | 694 | if ($module->type == 'pdf') |
| 695 | 695 | { |
| 696 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>'; |
|
| 696 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>'; |
|
| 697 | 697 | } |
| 698 | 698 | else |
| 699 | 699 | { |
| 700 | - print img_object($langs->trans("PreviewNotAvailable"),'generic'); |
|
| 700 | + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); |
|
| 701 | 701 | } |
| 702 | 702 | print '</td>'; |
| 703 | 703 | |
@@ -724,19 +724,19 @@ discard block |
||
| 724 | 724 | print load_fiche_titre($langs->trans("TaskModelModule"), '', ''); |
| 725 | 725 | |
| 726 | 726 | // Defini tableau def de modele |
| 727 | - $type='project_task'; |
|
| 727 | + $type = 'project_task'; |
|
| 728 | 728 | $def = array(); |
| 729 | 729 | |
| 730 | 730 | $sql = "SELECT nom"; |
| 731 | - $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; |
|
| 732 | - $sql.= " WHERE type = '".$type."'"; |
|
| 733 | - $sql.= " AND entity = ".$conf->entity; |
|
| 731 | + $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; |
|
| 732 | + $sql .= " WHERE type = '".$type."'"; |
|
| 733 | + $sql .= " AND entity = ".$conf->entity; |
|
| 734 | 734 | |
| 735 | - $resql=$db->query($sql); |
|
| 735 | + $resql = $db->query($sql); |
|
| 736 | 736 | if ($resql) |
| 737 | 737 | { |
| 738 | 738 | $i = 0; |
| 739 | - $num_rows=$db->num_rows($resql); |
|
| 739 | + $num_rows = $db->num_rows($resql); |
|
| 740 | 740 | while ($i < $num_rows) |
| 741 | 741 | { |
| 742 | 742 | $array = $db->fetch_array($resql); |
@@ -761,48 +761,48 @@ discard block |
||
| 761 | 761 | |
| 762 | 762 | clearstatcache(); |
| 763 | 763 | |
| 764 | - $var=true; |
|
| 764 | + $var = true; |
|
| 765 | 765 | foreach ($dirmodels as $reldir) |
| 766 | 766 | { |
| 767 | - foreach (array('','/doc') as $valdir) |
|
| 767 | + foreach (array('', '/doc') as $valdir) |
|
| 768 | 768 | { |
| 769 | 769 | $dir = dol_buildpath($reldir."core/modules/project/task/".$valdir); |
| 770 | 770 | |
| 771 | 771 | if (is_dir($dir)) |
| 772 | 772 | { |
| 773 | - $handle=opendir($dir); |
|
| 773 | + $handle = opendir($dir); |
|
| 774 | 774 | if (is_resource($handle)) |
| 775 | 775 | { |
| 776 | - while (($file = readdir($handle))!==false) |
|
| 776 | + while (($file = readdir($handle)) !== false) |
|
| 777 | 777 | { |
| 778 | - $filelist[]=$file; |
|
| 778 | + $filelist[] = $file; |
|
| 779 | 779 | } |
| 780 | 780 | closedir($handle); |
| 781 | 781 | arsort($filelist); |
| 782 | 782 | |
| 783 | - foreach($filelist as $file) |
|
| 783 | + foreach ($filelist as $file) |
|
| 784 | 784 | { |
| 785 | - if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) |
|
| 785 | + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) |
|
| 786 | 786 | { |
| 787 | 787 | if (file_exists($dir.'/'.$file)) |
| 788 | 788 | { |
| 789 | - $name = substr($file, 4, dol_strlen($file) -16); |
|
| 790 | - $classname = substr($file, 0, dol_strlen($file) -12); |
|
| 789 | + $name = substr($file, 4, dol_strlen($file) - 16); |
|
| 790 | + $classname = substr($file, 0, dol_strlen($file) - 12); |
|
| 791 | 791 | |
| 792 | 792 | require_once $dir.'/'.$file; |
| 793 | 793 | $module = new $classname($db); |
| 794 | 794 | |
| 795 | - $modulequalified=1; |
|
| 796 | - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; |
|
| 797 | - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; |
|
| 795 | + $modulequalified = 1; |
|
| 796 | + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; |
|
| 797 | + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; |
|
| 798 | 798 | |
| 799 | 799 | if ($modulequalified) |
| 800 | 800 | { |
| 801 | 801 | $var = !$var; |
| 802 | 802 | print '<tr class="oddeven"><td width="100">'; |
| 803 | - print (empty($module->name)?$name:$module->name); |
|
| 803 | + print (empty($module->name) ? $name : $module->name); |
|
| 804 | 804 | print "</td><td>\n"; |
| 805 | - if (method_exists($module,'info')) print $module->info($langs); |
|
| 805 | + if (method_exists($module, 'info')) print $module->info($langs); |
|
| 806 | 806 | else print $module->description; |
| 807 | 807 | print "</td>\n"; |
| 808 | 808 | |
@@ -811,14 +811,14 @@ discard block |
||
| 811 | 811 | { |
| 812 | 812 | print "<td align=\"center\">\n"; |
| 813 | 813 | print '<a href="'.$_SERVER["PHP_SELF"].'?action=deltask&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'; |
| 814 | - print img_picto($langs->trans("Enabled"),'switch_on'); |
|
| 814 | + print img_picto($langs->trans("Enabled"), 'switch_on'); |
|
| 815 | 815 | print '</a>'; |
| 816 | 816 | print "</td>"; |
| 817 | 817 | } |
| 818 | 818 | else |
| 819 | 819 | { |
| 820 | 820 | print "<td align=\"center\">\n"; |
| 821 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=settask&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; |
|
| 821 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=settask&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; |
|
| 822 | 822 | print "</td>"; |
| 823 | 823 | } |
| 824 | 824 | |
@@ -826,37 +826,37 @@ discard block |
||
| 826 | 826 | print "<td align=\"center\">"; |
| 827 | 827 | if ($conf->global->PROJECT_TASK_ADDON_PDF == "$name") |
| 828 | 828 | { |
| 829 | - print img_picto($langs->trans("Default"),'on'); |
|
| 829 | + print img_picto($langs->trans("Default"), 'on'); |
|
| 830 | 830 | } |
| 831 | 831 | else |
| 832 | 832 | { |
| 833 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoctask&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
| 833 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoctask&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; |
|
| 834 | 834 | } |
| 835 | 835 | print '</td>'; |
| 836 | 836 | |
| 837 | 837 | // Info |
| 838 | - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; |
|
| 839 | - $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); |
|
| 838 | + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; |
|
| 839 | + $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); |
|
| 840 | 840 | if ($module->type == 'pdf') |
| 841 | 841 | { |
| 842 | - $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; |
|
| 842 | + $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; |
|
| 843 | 843 | } |
| 844 | - $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; |
|
| 845 | - $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); |
|
| 844 | + $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; |
|
| 845 | + $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); |
|
| 846 | 846 | |
| 847 | 847 | print '<td align="center">'; |
| 848 | - print $form->textwithpicto('',$htmltooltip,1,0); |
|
| 848 | + print $form->textwithpicto('', $htmltooltip, 1, 0); |
|
| 849 | 849 | print '</td>'; |
| 850 | 850 | |
| 851 | 851 | // Preview |
| 852 | 852 | print '<td align="center">'; |
| 853 | 853 | if ($module->type == 'pdf') |
| 854 | 854 | { |
| 855 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimentask&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>'; |
|
| 855 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimentask&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>'; |
|
| 856 | 856 | } |
| 857 | 857 | else |
| 858 | 858 | { |
| 859 | - print img_object($langs->trans("PreviewNotAvailable"),'generic'); |
|
| 859 | + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); |
|
| 860 | 860 | } |
| 861 | 861 | print '</td>'; |
| 862 | 862 | print "</tr>\n"; |
@@ -876,8 +876,8 @@ discard block |
||
| 876 | 876 | print load_fiche_titre($langs->trans("Other"), '', ''); |
| 877 | 877 | |
| 878 | 878 | // Other options |
| 879 | -$form=new Form($db); |
|
| 880 | -$var=true; |
|
| 879 | +$form = new Form($db); |
|
| 880 | +$var = true; |
|
| 881 | 881 | |
| 882 | 882 | print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">'; |
| 883 | 883 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | |
| 894 | 894 | print '<tr class="oddeven">'; |
| 895 | 895 | print '<td width="80%">'.$langs->trans("UseSearchToSelectProject").'</td>'; |
| 896 | -if (! $conf->use_javascript_ajax) |
|
| 896 | +if (!$conf->use_javascript_ajax) |
|
| 897 | 897 | { |
| 898 | 898 | print '<td class="nowrap" align="right" colspan="2">'; |
| 899 | 899 | print $langs->trans("NotAvailableWhenAjaxDisabled"); |
@@ -902,12 +902,12 @@ discard block |
||
| 902 | 902 | else |
| 903 | 903 | { |
| 904 | 904 | print '<td width="60" align="right">'; |
| 905 | - $arrval=array('0'=>$langs->trans("No"), |
|
| 906 | - '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')', |
|
| 907 | - '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')', |
|
| 908 | - '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')', |
|
| 905 | + $arrval = array('0'=>$langs->trans("No"), |
|
| 906 | + '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')', |
|
| 907 | + '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', |
|
| 908 | + '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', |
|
| 909 | 909 | ); |
| 910 | - print $form->selectarray("activate_PROJECT_USE_SEARCH_TO_SELECT",$arrval,$conf->global->PROJECT_USE_SEARCH_TO_SELECT); |
|
| 910 | + print $form->selectarray("activate_PROJECT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->PROJECT_USE_SEARCH_TO_SELECT); |
|
| 911 | 911 | print '</td><td align="right">'; |
| 912 | 912 | print '<input type="submit" class="button" name="PROJECT_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">'; |
| 913 | 913 | print "</td>"; |
@@ -38,7 +38,9 @@ discard block |
||
| 38 | 38 | $langs->load("other"); |
| 39 | 39 | $langs->load("projects"); |
| 40 | 40 | |
| 41 | -if (!$user->admin) accessforbidden(); |
|
| 41 | +if (!$user->admin) { |
|
| 42 | + accessforbidden(); |
|
| 43 | +} |
|
| 42 | 44 | |
| 43 | 45 | $value = GETPOST('value','alpha'); |
| 44 | 46 | $action = GETPOST('action','alpha'); |
@@ -55,27 +57,34 @@ discard block |
||
| 55 | 57 | |
| 56 | 58 | if ($action == 'setmainoptions') |
| 57 | 59 | { |
| 58 | - if (GETPOST('PROJECT_USE_OPPORTUNITIES')) dolibarr_set_const($db, "PROJECT_USE_OPPORTUNITIES",GETPOST('PROJECT_USE_OPPORTUNITIES'),'chaine',0,'',$conf->entity); |
|
| 59 | - else dolibarr_del_const($db, "PROJECT_USE_OPPORTUNITIES", $conf->entity); |
|
| 60 | - |
|
| 61 | - if (GETPOST('PROJECT_USE_TASKS')) dolibarr_del_const($db, "PROJECT_HIDE_TASKS", $conf->entity); |
|
| 62 | - else dolibarr_set_const($db, "PROJECT_HIDE_TASKS",1,'chaine',0,'',$conf->entity); |
|
| 63 | -} |
|
| 60 | + if (GETPOST('PROJECT_USE_OPPORTUNITIES')) { |
|
| 61 | + dolibarr_set_const($db, "PROJECT_USE_OPPORTUNITIES",GETPOST('PROJECT_USE_OPPORTUNITIES'),'chaine',0,'',$conf->entity); |
|
| 62 | + } else { |
|
| 63 | + dolibarr_del_const($db, "PROJECT_USE_OPPORTUNITIES", $conf->entity); |
|
| 64 | + } |
|
| 64 | 65 | |
| 65 | -else if ($action == 'updateMask') |
|
| 66 | + if (GETPOST('PROJECT_USE_TASKS')) { |
|
| 67 | + dolibarr_del_const($db, "PROJECT_HIDE_TASKS", $conf->entity); |
|
| 68 | + } else { |
|
| 69 | + dolibarr_set_const($db, "PROJECT_HIDE_TASKS",1,'chaine',0,'',$conf->entity); |
|
| 70 | + } |
|
| 71 | + } else if ($action == 'updateMask') |
|
| 66 | 72 | { |
| 67 | 73 | $maskconstproject=GETPOST('maskconstproject','alpha'); |
| 68 | 74 | $maskproject=GETPOST('maskproject','alpha'); |
| 69 | 75 | |
| 70 | - if ($maskconstproject) $res = dolibarr_set_const($db,$maskconstproject,$maskproject,'chaine',0,'',$conf->entity); |
|
| 76 | + if ($maskconstproject) { |
|
| 77 | + $res = dolibarr_set_const($db,$maskconstproject,$maskproject,'chaine',0,'',$conf->entity); |
|
| 78 | + } |
|
| 71 | 79 | |
| 72 | - if (! $res > 0) $error++; |
|
| 80 | + if (! $res > 0) { |
|
| 81 | + $error++; |
|
| 82 | + } |
|
| 73 | 83 | |
| 74 | 84 | if (! $error) |
| 75 | 85 | { |
| 76 | 86 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
| 77 | - } |
|
| 78 | - else |
|
| 87 | + } else |
|
| 79 | 88 | { |
| 80 | 89 | setEventMessages($langs->trans("Error"), null, 'errors'); |
| 81 | 90 | } |
@@ -86,21 +95,22 @@ discard block |
||
| 86 | 95 | $maskconstmasktask=GETPOST('maskconsttask','alpha'); |
| 87 | 96 | $masktaskt=GETPOST('masktask','alpha'); |
| 88 | 97 | |
| 89 | - if ($maskconstmasktask) $res = dolibarr_set_const($db,$maskconstmasktask,$masktaskt,'chaine',0,'',$conf->entity); |
|
| 98 | + if ($maskconstmasktask) { |
|
| 99 | + $res = dolibarr_set_const($db,$maskconstmasktask,$masktaskt,'chaine',0,'',$conf->entity); |
|
| 100 | + } |
|
| 90 | 101 | |
| 91 | - if (! $res > 0) $error++; |
|
| 102 | + if (! $res > 0) { |
|
| 103 | + $error++; |
|
| 104 | + } |
|
| 92 | 105 | |
| 93 | 106 | if (! $error) |
| 94 | 107 | { |
| 95 | 108 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
| 96 | - } |
|
| 97 | - else |
|
| 109 | + } else |
|
| 98 | 110 | { |
| 99 | 111 | setEventMessages($langs->trans("Error"), null, 'errors'); |
| 100 | 112 | } |
| 101 | -} |
|
| 102 | - |
|
| 103 | -else if ($action == 'specimen') |
|
| 113 | +} else if ($action == 'specimen') |
|
| 104 | 114 | { |
| 105 | 115 | $modele=GETPOST('module','alpha'); |
| 106 | 116 | |
@@ -131,21 +141,17 @@ discard block |
||
| 131 | 141 | { |
| 132 | 142 | header("Location: ".DOL_URL_ROOT."/document.php?modulepart=project&file=SPECIMEN.pdf"); |
| 133 | 143 | return; |
| 134 | - } |
|
| 135 | - else |
|
| 144 | + } else |
|
| 136 | 145 | { |
| 137 | 146 | setEventMessages($obj->error, $obj->errors, 'errors'); |
| 138 | 147 | dol_syslog($obj->error, LOG_ERR); |
| 139 | 148 | } |
| 140 | - } |
|
| 141 | - else |
|
| 149 | + } else |
|
| 142 | 150 | { |
| 143 | 151 | setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); |
| 144 | 152 | dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); |
| 145 | 153 | } |
| 146 | -} |
|
| 147 | - |
|
| 148 | -else if ($action == 'specimentask') |
|
| 154 | +} else if ($action == 'specimentask') |
|
| 149 | 155 | { |
| 150 | 156 | $modele=GETPOST('module','alpha'); |
| 151 | 157 | |
@@ -176,14 +182,12 @@ discard block |
||
| 176 | 182 | { |
| 177 | 183 | header("Location: ".DOL_URL_ROOT."/document.php?modulepart=project_task&file=SPECIMEN.pdf"); |
| 178 | 184 | return; |
| 179 | - } |
|
| 180 | - else |
|
| 185 | + } else |
|
| 181 | 186 | { |
| 182 | 187 | setEventMessages($obj->error, $obj->errors, 'errors'); |
| 183 | 188 | dol_syslog($obj->error, LOG_ERR); |
| 184 | 189 | } |
| 185 | - } |
|
| 186 | - else |
|
| 190 | + } else |
|
| 187 | 191 | { |
| 188 | 192 | setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); |
| 189 | 193 | dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); |
@@ -199,14 +203,14 @@ discard block |
||
| 199 | 203 | else if ($action == 'settask') |
| 200 | 204 | { |
| 201 | 205 | $ret = addDocumentModel($value,'project_task', $label, $scandir); |
| 202 | -} |
|
| 203 | - |
|
| 204 | -else if ($action == 'del') |
|
| 206 | +} else if ($action == 'del') |
|
| 205 | 207 | { |
| 206 | 208 | $ret = delDocumentModel($value, $type); |
| 207 | 209 | if ($ret > 0) |
| 208 | 210 | { |
| 209 | - if ($conf->global->PROJECT_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_ADDON_PDF',$conf->entity); |
|
| 211 | + if ($conf->global->PROJECT_ADDON_PDF == "$value") { |
|
| 212 | + dolibarr_del_const($db, 'PROJECT_ADDON_PDF',$conf->entity); |
|
| 213 | + } |
|
| 210 | 214 | } |
| 211 | 215 | } |
| 212 | 216 | if ($action == 'deltask') |
@@ -214,7 +218,9 @@ discard block |
||
| 214 | 218 | $ret = delDocumentModel($value, 'project_task'); |
| 215 | 219 | if ($ret > 0) |
| 216 | 220 | { |
| 217 | - if ($conf->global->PROJECT_TASK_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_TASK_ADDON_PDF',$conf->entity); |
|
| 221 | + if ($conf->global->PROJECT_TASK_ADDON_PDF == "$value") { |
|
| 222 | + dolibarr_del_const($db, 'PROJECT_TASK_ADDON_PDF',$conf->entity); |
|
| 223 | + } |
|
| 218 | 224 | } |
| 219 | 225 | } |
| 220 | 226 | |
@@ -229,9 +235,7 @@ discard block |
||
| 229 | 235 | { |
| 230 | 236 | $ret = addDocumentModel($value, $type, $label, $scandir); |
| 231 | 237 | } |
| 232 | -} |
|
| 233 | - |
|
| 234 | -else if ($action == 'setdoctask') |
|
| 238 | +} else if ($action == 'setdoctask') |
|
| 235 | 239 | { |
| 236 | 240 | if (dolibarr_set_const($db, "PROJECT_TASK_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) |
| 237 | 241 | { |
@@ -246,24 +250,19 @@ discard block |
||
| 246 | 250 | { |
| 247 | 251 | $ret = addDocumentModel($value, 'project_task', $label, $scandir); |
| 248 | 252 | } |
| 249 | -} |
|
| 250 | - |
|
| 251 | -else if ($action == 'setmod') |
|
| 253 | +} else if ($action == 'setmod') |
|
| 252 | 254 | { |
| 253 | 255 | // TODO Verifier si module numerotation choisi peut etre active |
| 254 | 256 | // par appel methode canBeActivated |
| 255 | 257 | |
| 256 | 258 | dolibarr_set_const($db, "PROJECT_ADDON",$value,'chaine',0,'',$conf->entity); |
| 257 | -} |
|
| 258 | - |
|
| 259 | -else if ($action == 'setmodtask') |
|
| 259 | +} else if ($action == 'setmodtask') |
|
| 260 | 260 | { |
| 261 | 261 | // TODO Verifier si module numerotation choisi peut etre active |
| 262 | 262 | // par appel methode canBeActivated |
| 263 | 263 | |
| 264 | 264 | dolibarr_set_const($db, "PROJECT_TASK_ADDON",$value,'chaine',0,'',$conf->entity); |
| 265 | -} |
|
| 266 | -elseif ($action == 'updateoptions') |
|
| 265 | +} elseif ($action == 'updateoptions') |
|
| 267 | 266 | { |
| 268 | 267 | if (GETPOST('PROJECT_USE_SEARCH_TO_SELECT')) |
| 269 | 268 | { |
@@ -273,8 +272,7 @@ discard block |
||
| 273 | 272 | $conf->global->PROJECT_USE_SEARCH_TO_SELECT = $companysearch; |
| 274 | 273 | } |
| 275 | 274 | } |
| 276 | -} |
|
| 277 | -else if ($action == "linkOtherCompany") |
|
| 275 | +} else if ($action == "linkOtherCompany") |
|
| 278 | 276 | { |
| 279 | 277 | $projectToSelect = GETPOST('projectToSelect'); |
| 280 | 278 | |
@@ -388,8 +386,12 @@ discard block |
||
| 388 | 386 | $module = new $file; |
| 389 | 387 | |
| 390 | 388 | // Show modules according to features level |
| 391 | - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; |
|
| 392 | - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; |
|
| 389 | + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { |
|
| 390 | + continue; |
|
| 391 | + } |
|
| 392 | + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { |
|
| 393 | + continue; |
|
| 394 | + } |
|
| 393 | 395 | |
| 394 | 396 | if ($module->isEnabled()) |
| 395 | 397 | { |
@@ -401,17 +403,20 @@ discard block |
||
| 401 | 403 | // Show example of numbering model |
| 402 | 404 | print '<td class="nowrap">'; |
| 403 | 405 | $tmp=$module->getExample(); |
| 404 | - if (preg_match('/^Error/',$tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>'; |
|
| 405 | - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); |
|
| 406 | - else print $tmp; |
|
| 406 | + if (preg_match('/^Error/',$tmp)) { |
|
| 407 | + print '<div class="error">'.$langs->trans($tmp).'</div>'; |
|
| 408 | + } elseif ($tmp=='NotConfigured') { |
|
| 409 | + print $langs->trans($tmp); |
|
| 410 | + } else { |
|
| 411 | + print $tmp; |
|
| 412 | + } |
|
| 407 | 413 | print '</td>'."\n"; |
| 408 | 414 | |
| 409 | 415 | print '<td align="center">'; |
| 410 | 416 | if ($conf->global->PROJECT_ADDON == 'mod_'.$classname) |
| 411 | 417 | { |
| 412 | 418 | print img_picto($langs->trans("Activated"),'switch_on'); |
| 413 | - } |
|
| 414 | - else |
|
| 419 | + } else |
|
| 415 | 420 | { |
| 416 | 421 | print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; |
| 417 | 422 | } |
@@ -424,14 +429,15 @@ discard block |
||
| 424 | 429 | $htmltooltip=''; |
| 425 | 430 | $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; |
| 426 | 431 | $nextval=$module->getNextValue($mysoc,$project); |
| 427 | - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval |
|
| 432 | + if ("$nextval" != $langs->trans("NotAvailable")) { |
|
| 433 | + // Keep " on nextval |
|
| 428 | 434 | { |
| 429 | 435 | $htmltooltip.=''.$langs->trans("NextValue").': '; |
| 436 | + } |
|
| 430 | 437 | if ($nextval) |
| 431 | 438 | { |
| 432 | 439 | $htmltooltip.=$nextval.'<br>'; |
| 433 | - } |
|
| 434 | - else |
|
| 440 | + } else |
|
| 435 | 441 | { |
| 436 | 442 | $htmltooltip.=$langs->trans($module->error).'<br>'; |
| 437 | 443 | } |
@@ -492,8 +498,12 @@ discard block |
||
| 492 | 498 | $module = new $file; |
| 493 | 499 | |
| 494 | 500 | // Show modules according to features level |
| 495 | - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; |
|
| 496 | - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; |
|
| 501 | + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { |
|
| 502 | + continue; |
|
| 503 | + } |
|
| 504 | + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { |
|
| 505 | + continue; |
|
| 506 | + } |
|
| 497 | 507 | |
| 498 | 508 | if ($module->isEnabled()) |
| 499 | 509 | { |
@@ -505,17 +515,20 @@ discard block |
||
| 505 | 515 | // Show example of numbering module |
| 506 | 516 | print '<td class="nowrap">'; |
| 507 | 517 | $tmp=$module->getExample(); |
| 508 | - if (preg_match('/^Error/',$tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>'; |
|
| 509 | - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); |
|
| 510 | - else print $tmp; |
|
| 518 | + if (preg_match('/^Error/',$tmp)) { |
|
| 519 | + print '<div class="error">'.$langs->trans($tmp).'</div>'; |
|
| 520 | + } elseif ($tmp=='NotConfigured') { |
|
| 521 | + print $langs->trans($tmp); |
|
| 522 | + } else { |
|
| 523 | + print $tmp; |
|
| 524 | + } |
|
| 511 | 525 | print '</td>'."\n"; |
| 512 | 526 | |
| 513 | 527 | print '<td align="center">'; |
| 514 | 528 | if ($conf->global->PROJECT_TASK_ADDON == 'mod_'.$classname) |
| 515 | 529 | { |
| 516 | 530 | print img_picto($langs->trans("Activated"),'switch_on'); |
| 517 | - } |
|
| 518 | - else |
|
| 531 | + } else |
|
| 519 | 532 | { |
| 520 | 533 | print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodtask&value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; |
| 521 | 534 | } |
@@ -528,14 +541,15 @@ discard block |
||
| 528 | 541 | $htmltooltip=''; |
| 529 | 542 | $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; |
| 530 | 543 | $nextval=$module->getNextValue($mysoc,$project); |
| 531 | - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval |
|
| 544 | + if ("$nextval" != $langs->trans("NotAvailable")) { |
|
| 545 | + // Keep " on nextval |
|
| 532 | 546 | { |
| 533 | 547 | $htmltooltip.=''.$langs->trans("NextValue").': '; |
| 548 | + } |
|
| 534 | 549 | if ($nextval) |
| 535 | 550 | { |
| 536 | 551 | $htmltooltip.=$nextval.'<br>'; |
| 537 | - } |
|
| 538 | - else |
|
| 552 | + } else |
|
| 539 | 553 | { |
| 540 | 554 | $htmltooltip.=$langs->trans($module->error).'<br>'; |
| 541 | 555 | } |
@@ -584,8 +598,7 @@ discard block |
||
| 584 | 598 | array_push($def, $array[0]); |
| 585 | 599 | $i++; |
| 586 | 600 | } |
| 587 | -} |
|
| 588 | -else |
|
| 601 | +} else |
|
| 589 | 602 | { |
| 590 | 603 | dol_print_error($db); |
| 591 | 604 | } |
@@ -634,8 +647,12 @@ discard block |
||
| 634 | 647 | $module = new $classname($db); |
| 635 | 648 | |
| 636 | 649 | $modulequalified=1; |
| 637 | - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; |
|
| 638 | - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; |
|
| 650 | + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { |
|
| 651 | + $modulequalified=0; |
|
| 652 | + } |
|
| 653 | + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { |
|
| 654 | + $modulequalified=0; |
|
| 655 | + } |
|
| 639 | 656 | |
| 640 | 657 | if ($modulequalified) |
| 641 | 658 | { |
@@ -643,8 +660,11 @@ discard block |
||
| 643 | 660 | print '<tr class="oddeven"><td width="100">'; |
| 644 | 661 | print (empty($module->name)?$name:$module->name); |
| 645 | 662 | print "</td><td>\n"; |
| 646 | - if (method_exists($module,'info')) print $module->info($langs); |
|
| 647 | - else print $module->description; |
|
| 663 | + if (method_exists($module,'info')) { |
|
| 664 | + print $module->info($langs); |
|
| 665 | + } else { |
|
| 666 | + print $module->description; |
|
| 667 | + } |
|
| 648 | 668 | print "</td>\n"; |
| 649 | 669 | |
| 650 | 670 | // Active |
@@ -655,8 +675,7 @@ discard block |
||
| 655 | 675 | print img_picto($langs->trans("Enabled"),'switch_on'); |
| 656 | 676 | print '</a>'; |
| 657 | 677 | print "</td>"; |
| 658 | - } |
|
| 659 | - else |
|
| 678 | + } else |
|
| 660 | 679 | { |
| 661 | 680 | print "<td align=\"center\">\n"; |
| 662 | 681 | print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; |
@@ -668,8 +687,7 @@ discard block |
||
| 668 | 687 | if ($conf->global->PROJECT_ADDON_PDF == "$name") |
| 669 | 688 | { |
| 670 | 689 | print img_picto($langs->trans("Default"),'on'); |
| 671 | - } |
|
| 672 | - else |
|
| 690 | + } else |
|
| 673 | 691 | { |
| 674 | 692 | print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
| 675 | 693 | } |
@@ -694,8 +712,7 @@ discard block |
||
| 694 | 712 | if ($module->type == 'pdf') |
| 695 | 713 | { |
| 696 | 714 | print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>'; |
| 697 | - } |
|
| 698 | - else |
|
| 715 | + } else |
|
| 699 | 716 | { |
| 700 | 717 | print img_object($langs->trans("PreviewNotAvailable"),'generic'); |
| 701 | 718 | } |
@@ -743,8 +760,7 @@ discard block |
||
| 743 | 760 | array_push($def, $array[0]); |
| 744 | 761 | $i++; |
| 745 | 762 | } |
| 746 | - } |
|
| 747 | - else |
|
| 763 | + } else |
|
| 748 | 764 | { |
| 749 | 765 | dol_print_error($db); |
| 750 | 766 | } |
@@ -793,8 +809,12 @@ discard block |
||
| 793 | 809 | $module = new $classname($db); |
| 794 | 810 | |
| 795 | 811 | $modulequalified=1; |
| 796 | - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; |
|
| 797 | - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; |
|
| 812 | + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { |
|
| 813 | + $modulequalified=0; |
|
| 814 | + } |
|
| 815 | + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { |
|
| 816 | + $modulequalified=0; |
|
| 817 | + } |
|
| 798 | 818 | |
| 799 | 819 | if ($modulequalified) |
| 800 | 820 | { |
@@ -802,8 +822,11 @@ discard block |
||
| 802 | 822 | print '<tr class="oddeven"><td width="100">'; |
| 803 | 823 | print (empty($module->name)?$name:$module->name); |
| 804 | 824 | print "</td><td>\n"; |
| 805 | - if (method_exists($module,'info')) print $module->info($langs); |
|
| 806 | - else print $module->description; |
|
| 825 | + if (method_exists($module,'info')) { |
|
| 826 | + print $module->info($langs); |
|
| 827 | + } else { |
|
| 828 | + print $module->description; |
|
| 829 | + } |
|
| 807 | 830 | print "</td>\n"; |
| 808 | 831 | |
| 809 | 832 | // Active |
@@ -814,8 +837,7 @@ discard block |
||
| 814 | 837 | print img_picto($langs->trans("Enabled"),'switch_on'); |
| 815 | 838 | print '</a>'; |
| 816 | 839 | print "</td>"; |
| 817 | - } |
|
| 818 | - else |
|
| 840 | + } else |
|
| 819 | 841 | { |
| 820 | 842 | print "<td align=\"center\">\n"; |
| 821 | 843 | print '<a href="'.$_SERVER["PHP_SELF"].'?action=settask&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; |
@@ -827,8 +849,7 @@ discard block |
||
| 827 | 849 | if ($conf->global->PROJECT_TASK_ADDON_PDF == "$name") |
| 828 | 850 | { |
| 829 | 851 | print img_picto($langs->trans("Default"),'on'); |
| 830 | - } |
|
| 831 | - else |
|
| 852 | + } else |
|
| 832 | 853 | { |
| 833 | 854 | print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoctask&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
| 834 | 855 | } |
@@ -853,8 +874,7 @@ discard block |
||
| 853 | 874 | if ($module->type == 'pdf') |
| 854 | 875 | { |
| 855 | 876 | print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimentask&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>'; |
| 856 | - } |
|
| 857 | - else |
|
| 877 | + } else |
|
| 858 | 878 | { |
| 859 | 879 | print img_object($langs->trans("PreviewNotAvailable"),'generic'); |
| 860 | 880 | } |
@@ -898,8 +918,7 @@ discard block |
||
| 898 | 918 | print '<td class="nowrap" align="right" colspan="2">'; |
| 899 | 919 | print $langs->trans("NotAvailableWhenAjaxDisabled"); |
| 900 | 920 | print "</td>"; |
| 901 | -} |
|
| 902 | -else |
|
| 921 | +} else |
|
| 903 | 922 | { |
| 904 | 923 | print '<td width="60" align="right">'; |
| 905 | 924 | $arrval=array('0'=>$langs->trans("No"), |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | $head[$h][2] = 'payment'; |
| 37 | 37 | $h++; |
| 38 | 38 | |
| 39 | - // Show more tabs from modules |
|
| 40 | - // Entries must be declared in modules descriptor with line |
|
| 41 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
| 42 | - // $this->tabs = array('entity:-tabname); to remove a tab |
|
| 43 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment'); |
|
| 39 | + // Show more tabs from modules |
|
| 40 | + // Entries must be declared in modules descriptor with line |
|
| 41 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
| 42 | + // $this->tabs = array('entity:-tabname); to remove a tab |
|
| 43 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'payment'); |
|
| 44 | 44 | |
| 45 | 45 | $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$object->id; |
| 46 | 46 | $head[$h][1] = $langs->trans("Info"); |
@@ -71,11 +71,11 @@ discard block |
||
| 71 | 71 | $head[$h][2] = 'payment'; |
| 72 | 72 | $h++; |
| 73 | 73 | |
| 74 | - // Show more tabs from modules |
|
| 75 | - // Entries must be declared in modules descriptor with line |
|
| 76 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
| 77 | - // $this->tabs = array('entity:-tabname); to remove a tab |
|
| 78 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_supplier'); |
|
| 74 | + // Show more tabs from modules |
|
| 75 | + // Entries must be declared in modules descriptor with line |
|
| 76 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
| 77 | + // $this->tabs = array('entity:-tabname); to remove a tab |
|
| 78 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_supplier'); |
|
| 79 | 79 | |
| 80 | 80 | $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$object->id; |
| 81 | 81 | $head[$h][1] = $langs->trans('Info'); |
@@ -229,82 +229,82 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | function htmlPrintOnlinePaymentFooter($fromcompany,$langs,$addformmessage=0,$suffix='',$object=null) |
| 231 | 231 | { |
| 232 | - global $conf; |
|
| 233 | - |
|
| 234 | - // Juridical status |
|
| 235 | - $line1=""; |
|
| 236 | - if ($fromcompany->forme_juridique_code) |
|
| 237 | - { |
|
| 238 | - $line1.=($line1?" - ":"").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); |
|
| 239 | - } |
|
| 240 | - // Capital |
|
| 241 | - if ($fromcompany->capital) |
|
| 242 | - { |
|
| 243 | - $line1.=($line1?" - ":"").$langs->transnoentities("CapitalOf",$fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); |
|
| 244 | - } |
|
| 245 | - // Prof Id 1 |
|
| 246 | - if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) |
|
| 247 | - { |
|
| 248 | - $field=$langs->transcountrynoentities("ProfId1",$fromcompany->country_code); |
|
| 249 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 250 | - $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof1; |
|
| 251 | - } |
|
| 252 | - // Prof Id 2 |
|
| 253 | - if ($fromcompany->idprof2) |
|
| 254 | - { |
|
| 255 | - $field=$langs->transcountrynoentities("ProfId2",$fromcompany->country_code); |
|
| 256 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 257 | - $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof2; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - // Second line of company infos |
|
| 261 | - $line2=""; |
|
| 262 | - // Prof Id 3 |
|
| 263 | - if ($fromcompany->idprof3) |
|
| 264 | - { |
|
| 265 | - $field=$langs->transcountrynoentities("ProfId3",$fromcompany->country_code); |
|
| 266 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 267 | - $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof3; |
|
| 268 | - } |
|
| 269 | - // Prof Id 4 |
|
| 270 | - if ($fromcompany->idprof4) |
|
| 271 | - { |
|
| 272 | - $field=$langs->transcountrynoentities("ProfId4",$fromcompany->country_code); |
|
| 273 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 274 | - $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof4; |
|
| 275 | - } |
|
| 276 | - // IntraCommunautary VAT |
|
| 277 | - if ($fromcompany->tva_intra != '') |
|
| 278 | - { |
|
| 279 | - $line2.=($line2?" - ":"").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - print '<br>'; |
|
| 283 | - |
|
| 284 | - print '<div class="center">'."\n"; |
|
| 285 | - if ($addformmessage) |
|
| 286 | - { |
|
| 287 | - print '<!-- object = '.$object->element.' -->'; |
|
| 288 | - print '<br>'; |
|
| 289 | - |
|
| 290 | - $parammessageform='ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix; |
|
| 291 | - if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
| 292 | - else if (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); |
|
| 293 | - |
|
| 294 | - // Add other message if VAT exists |
|
| 295 | - if ($object->total_vat != 0 || $object->total_tva != 0) |
|
| 296 | - { |
|
| 297 | - $parammessageform='ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix; |
|
| 298 | - if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
| 299 | - else if (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - print '<font style="font-size: 10px;"><br><hr>'."\n"; |
|
| 304 | - print $fromcompany->name.'<br>'; |
|
| 305 | - print $line1; |
|
| 306 | - if (strlen($line1+$line2) > 50) print '<br>'; |
|
| 307 | - else print ' - '; |
|
| 308 | - print $line2; |
|
| 309 | - print '</font></div>'."\n"; |
|
| 232 | + global $conf; |
|
| 233 | + |
|
| 234 | + // Juridical status |
|
| 235 | + $line1=""; |
|
| 236 | + if ($fromcompany->forme_juridique_code) |
|
| 237 | + { |
|
| 238 | + $line1.=($line1?" - ":"").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); |
|
| 239 | + } |
|
| 240 | + // Capital |
|
| 241 | + if ($fromcompany->capital) |
|
| 242 | + { |
|
| 243 | + $line1.=($line1?" - ":"").$langs->transnoentities("CapitalOf",$fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); |
|
| 244 | + } |
|
| 245 | + // Prof Id 1 |
|
| 246 | + if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) |
|
| 247 | + { |
|
| 248 | + $field=$langs->transcountrynoentities("ProfId1",$fromcompany->country_code); |
|
| 249 | + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 250 | + $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof1; |
|
| 251 | + } |
|
| 252 | + // Prof Id 2 |
|
| 253 | + if ($fromcompany->idprof2) |
|
| 254 | + { |
|
| 255 | + $field=$langs->transcountrynoentities("ProfId2",$fromcompany->country_code); |
|
| 256 | + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 257 | + $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof2; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + // Second line of company infos |
|
| 261 | + $line2=""; |
|
| 262 | + // Prof Id 3 |
|
| 263 | + if ($fromcompany->idprof3) |
|
| 264 | + { |
|
| 265 | + $field=$langs->transcountrynoentities("ProfId3",$fromcompany->country_code); |
|
| 266 | + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 267 | + $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof3; |
|
| 268 | + } |
|
| 269 | + // Prof Id 4 |
|
| 270 | + if ($fromcompany->idprof4) |
|
| 271 | + { |
|
| 272 | + $field=$langs->transcountrynoentities("ProfId4",$fromcompany->country_code); |
|
| 273 | + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 274 | + $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof4; |
|
| 275 | + } |
|
| 276 | + // IntraCommunautary VAT |
|
| 277 | + if ($fromcompany->tva_intra != '') |
|
| 278 | + { |
|
| 279 | + $line2.=($line2?" - ":"").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + print '<br>'; |
|
| 283 | + |
|
| 284 | + print '<div class="center">'."\n"; |
|
| 285 | + if ($addformmessage) |
|
| 286 | + { |
|
| 287 | + print '<!-- object = '.$object->element.' -->'; |
|
| 288 | + print '<br>'; |
|
| 289 | + |
|
| 290 | + $parammessageform='ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix; |
|
| 291 | + if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
| 292 | + else if (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); |
|
| 293 | + |
|
| 294 | + // Add other message if VAT exists |
|
| 295 | + if ($object->total_vat != 0 || $object->total_tva != 0) |
|
| 296 | + { |
|
| 297 | + $parammessageform='ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix; |
|
| 298 | + if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
| 299 | + else if (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + print '<font style="font-size: 10px;"><br><hr>'."\n"; |
|
| 304 | + print $fromcompany->name.'<br>'; |
|
| 305 | + print $line1; |
|
| 306 | + if (strlen($line1+$line2) > 50) print '<br>'; |
|
| 307 | + else print ' - '; |
|
| 308 | + print $line2; |
|
| 309 | + print '</font></div>'."\n"; |
|
| 310 | 310 | } |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | // Entries must be declared in modules descriptor with line |
| 41 | 41 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
| 42 | 42 | // $this->tabs = array('entity:-tabname); to remove a tab |
| 43 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment'); |
|
| 43 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment'); |
|
| 44 | 44 | |
| 45 | 45 | $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$object->id; |
| 46 | 46 | $head[$h][1] = $langs->trans("Info"); |
| 47 | 47 | $head[$h][2] = 'info'; |
| 48 | 48 | $h++; |
| 49 | 49 | |
| 50 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment', 'remove'); |
|
| 50 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment', 'remove'); |
|
| 51 | 51 | |
| 52 | 52 | return $head; |
| 53 | 53 | } |
@@ -75,14 +75,14 @@ discard block |
||
| 75 | 75 | // Entries must be declared in modules descriptor with line |
| 76 | 76 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
| 77 | 77 | // $this->tabs = array('entity:-tabname); to remove a tab |
| 78 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_supplier'); |
|
| 78 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_supplier'); |
|
| 79 | 79 | |
| 80 | 80 | $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$object->id; |
| 81 | 81 | $head[$h][1] = $langs->trans('Info'); |
| 82 | 82 | $head[$h][2] = 'info'; |
| 83 | 83 | $h++; |
| 84 | 84 | |
| 85 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_supplier', 'remove'); |
|
| 85 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_supplier', 'remove'); |
|
| 86 | 86 | |
| 87 | 87 | return $head; |
| 88 | 88 | } |
@@ -95,18 +95,18 @@ discard block |
||
| 95 | 95 | * @param string $ref Ref of object |
| 96 | 96 | * @return string Url string |
| 97 | 97 | */ |
| 98 | -function showOnlinePaymentUrl($type,$ref) |
|
| 98 | +function showOnlinePaymentUrl($type, $ref) |
|
| 99 | 99 | { |
| 100 | 100 | global $conf, $langs; |
| 101 | 101 | |
| 102 | 102 | $langs->load("payment"); |
| 103 | 103 | $langs->load("paybox"); |
| 104 | - $servicename='Online'; |
|
| 104 | + $servicename = 'Online'; |
|
| 105 | 105 | |
| 106 | - $out = img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'<br>'; |
|
| 107 | - $url = getOnlinePaymentUrl(0,$type,$ref); |
|
| 108 | - $out.= '<input type="text" id="onlinepaymenturl" class="quatrevingtpercent" value="'.$url.'">'; |
|
| 109 | - $out.= ajax_autoselect("onlinepaymenturl", 0); |
|
| 106 | + $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'<br>'; |
|
| 107 | + $url = getOnlinePaymentUrl(0, $type, $ref); |
|
| 108 | + $out .= '<input type="text" id="onlinepaymenturl" class="quatrevingtpercent" value="'.$url.'">'; |
|
| 109 | + $out .= ajax_autoselect("onlinepaymenturl", 0); |
|
| 110 | 110 | return $out; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -120,97 +120,97 @@ discard block |
||
| 120 | 120 | * @param string $freetag Free tag |
| 121 | 121 | * @return string Url string |
| 122 | 122 | */ |
| 123 | -function getOnlinePaymentUrl($mode, $type, $ref='', $amount='9.99', $freetag='your_free_tag') |
|
| 123 | +function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_free_tag') |
|
| 124 | 124 | { |
| 125 | 125 | global $conf; |
| 126 | 126 | |
| 127 | - $ref=str_replace(' ','',$ref); |
|
| 128 | - $out=''; |
|
| 127 | + $ref = str_replace(' ', '', $ref); |
|
| 128 | + $out = ''; |
|
| 129 | 129 | |
| 130 | 130 | if ($type == 'free') |
| 131 | 131 | { |
| 132 | - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?amount='.($mode?'<font color="#666666">':'').$amount.($mode?'</font>':'').'&tag='.($mode?'<font color="#666666">':'').$freetag.($mode?'</font>':''); |
|
| 133 | - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
| 132 | + $out = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?amount='.($mode ? '<font color="#666666">' : '').$amount.($mode ? '</font>' : '').'&tag='.($mode ? '<font color="#666666">' : '').$freetag.($mode ? '</font>' : ''); |
|
| 133 | + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
| 134 | 134 | { |
| 135 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 136 | - else $out.='&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); |
|
| 135 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 136 | + else $out .= '&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | if ($type == 'order') |
| 140 | 140 | { |
| 141 | - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=order&ref='.($mode?'<font color="#666666">':''); |
|
| 142 | - if ($mode == 1) $out.='order_ref'; |
|
| 143 | - if ($mode == 0) $out.=urlencode($ref); |
|
| 144 | - $out.=($mode?'</font>':''); |
|
| 145 | - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
| 141 | + $out = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=order&ref='.($mode ? '<font color="#666666">' : ''); |
|
| 142 | + if ($mode == 1) $out .= 'order_ref'; |
|
| 143 | + if ($mode == 0) $out .= urlencode($ref); |
|
| 144 | + $out .= ($mode ? '</font>' : ''); |
|
| 145 | + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
| 146 | 146 | { |
| 147 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 147 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 148 | 148 | else |
| 149 | 149 | { |
| 150 | - $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
| 151 | - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)"; |
|
| 152 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
| 153 | - $out.=($mode?'</font>':''); |
|
| 150 | + $out .= '&securekey='.($mode ? '<font color="#666666">' : ''); |
|
| 151 | + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)"; |
|
| 152 | + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); |
|
| 153 | + $out .= ($mode ? '</font>' : ''); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | if ($type == 'invoice') |
| 158 | 158 | { |
| 159 | - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'<font color="#666666">':''); |
|
| 160 | - if ($mode == 1) $out.='invoice_ref'; |
|
| 161 | - if ($mode == 0) $out.=urlencode($ref); |
|
| 162 | - $out.=($mode?'</font>':''); |
|
| 163 | - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
| 159 | + $out = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=invoice&ref='.($mode ? '<font color="#666666">' : ''); |
|
| 160 | + if ($mode == 1) $out .= 'invoice_ref'; |
|
| 161 | + if ($mode == 0) $out .= urlencode($ref); |
|
| 162 | + $out .= ($mode ? '</font>' : ''); |
|
| 163 | + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
| 164 | 164 | { |
| 165 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 165 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 166 | 166 | else |
| 167 | 167 | { |
| 168 | - $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
| 169 | - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; |
|
| 170 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
| 171 | - $out.=($mode?'</font>':''); |
|
| 168 | + $out .= '&securekey='.($mode ? '<font color="#666666">' : ''); |
|
| 169 | + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; |
|
| 170 | + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); |
|
| 171 | + $out .= ($mode ? '</font>' : ''); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | if ($type == 'contractline') |
| 176 | 176 | { |
| 177 | - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'<font color="#666666">':''); |
|
| 178 | - if ($mode == 1) $out.='contractline_ref'; |
|
| 179 | - if ($mode == 0) $out.=urlencode($ref); |
|
| 180 | - $out.=($mode?'</font>':''); |
|
| 181 | - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
| 177 | + $out = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=contractline&ref='.($mode ? '<font color="#666666">' : ''); |
|
| 178 | + if ($mode == 1) $out .= 'contractline_ref'; |
|
| 179 | + if ($mode == 0) $out .= urlencode($ref); |
|
| 180 | + $out .= ($mode ? '</font>' : ''); |
|
| 181 | + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
| 182 | 182 | { |
| 183 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 183 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 184 | 184 | else |
| 185 | 185 | { |
| 186 | - $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
| 187 | - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; |
|
| 188 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
| 189 | - $out.=($mode?'</font>':''); |
|
| 186 | + $out .= '&securekey='.($mode ? '<font color="#666666">' : ''); |
|
| 187 | + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; |
|
| 188 | + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); |
|
| 189 | + $out .= ($mode ? '</font>' : ''); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | if ($type == 'membersubscription') |
| 194 | 194 | { |
| 195 | - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'<font color="#666666">':''); |
|
| 196 | - if ($mode == 1) $out.='member_ref'; |
|
| 197 | - if ($mode == 0) $out.=urlencode($ref); |
|
| 198 | - $out.=($mode?'</font>':''); |
|
| 199 | - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
| 195 | + $out = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode ? '<font color="#666666">' : ''); |
|
| 196 | + if ($mode == 1) $out .= 'member_ref'; |
|
| 197 | + if ($mode == 0) $out .= urlencode($ref); |
|
| 198 | + $out .= ($mode ? '</font>' : ''); |
|
| 199 | + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
| 200 | 200 | { |
| 201 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 201 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 202 | 202 | else |
| 203 | 203 | { |
| 204 | - $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
| 205 | - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)"; |
|
| 206 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
| 207 | - $out.=($mode?'</font>':''); |
|
| 204 | + $out .= '&securekey='.($mode ? '<font color="#666666">' : ''); |
|
| 205 | + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)"; |
|
| 206 | + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); |
|
| 207 | + $out .= ($mode ? '</font>' : ''); |
|
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // For multicompany |
| 213 | - if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities |
|
| 213 | + if (!empty($out)) $out .= "&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities |
|
| 214 | 214 | |
| 215 | 215 | return $out; |
| 216 | 216 | } |
@@ -227,56 +227,56 @@ discard block |
||
| 227 | 227 | * @param Object $object Object related to payment |
| 228 | 228 | * @return void |
| 229 | 229 | */ |
| 230 | -function htmlPrintOnlinePaymentFooter($fromcompany,$langs,$addformmessage=0,$suffix='',$object=null) |
|
| 230 | +function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null) |
|
| 231 | 231 | { |
| 232 | 232 | global $conf; |
| 233 | 233 | |
| 234 | 234 | // Juridical status |
| 235 | - $line1=""; |
|
| 235 | + $line1 = ""; |
|
| 236 | 236 | if ($fromcompany->forme_juridique_code) |
| 237 | 237 | { |
| 238 | - $line1.=($line1?" - ":"").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); |
|
| 238 | + $line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); |
|
| 239 | 239 | } |
| 240 | 240 | // Capital |
| 241 | 241 | if ($fromcompany->capital) |
| 242 | 242 | { |
| 243 | - $line1.=($line1?" - ":"").$langs->transnoentities("CapitalOf",$fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); |
|
| 243 | + $line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); |
|
| 244 | 244 | } |
| 245 | 245 | // Prof Id 1 |
| 246 | - if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) |
|
| 246 | + if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) |
|
| 247 | 247 | { |
| 248 | - $field=$langs->transcountrynoentities("ProfId1",$fromcompany->country_code); |
|
| 249 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 250 | - $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof1; |
|
| 248 | + $field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code); |
|
| 249 | + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; |
|
| 250 | + $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1; |
|
| 251 | 251 | } |
| 252 | 252 | // Prof Id 2 |
| 253 | 253 | if ($fromcompany->idprof2) |
| 254 | 254 | { |
| 255 | - $field=$langs->transcountrynoentities("ProfId2",$fromcompany->country_code); |
|
| 256 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 257 | - $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof2; |
|
| 255 | + $field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code); |
|
| 256 | + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; |
|
| 257 | + $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | // Second line of company infos |
| 261 | - $line2=""; |
|
| 261 | + $line2 = ""; |
|
| 262 | 262 | // Prof Id 3 |
| 263 | 263 | if ($fromcompany->idprof3) |
| 264 | 264 | { |
| 265 | - $field=$langs->transcountrynoentities("ProfId3",$fromcompany->country_code); |
|
| 266 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 267 | - $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof3; |
|
| 265 | + $field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code); |
|
| 266 | + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; |
|
| 267 | + $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3; |
|
| 268 | 268 | } |
| 269 | 269 | // Prof Id 4 |
| 270 | 270 | if ($fromcompany->idprof4) |
| 271 | 271 | { |
| 272 | - $field=$langs->transcountrynoentities("ProfId4",$fromcompany->country_code); |
|
| 273 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 274 | - $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof4; |
|
| 272 | + $field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code); |
|
| 273 | + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; |
|
| 274 | + $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4; |
|
| 275 | 275 | } |
| 276 | 276 | // IntraCommunautary VAT |
| 277 | 277 | if ($fromcompany->tva_intra != '') |
| 278 | 278 | { |
| 279 | - $line2.=($line2?" - ":"").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; |
|
| 279 | + $line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | print '<br>'; |
@@ -287,23 +287,23 @@ discard block |
||
| 287 | 287 | print '<!-- object = '.$object->element.' -->'; |
| 288 | 288 | print '<br>'; |
| 289 | 289 | |
| 290 | - $parammessageform='ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix; |
|
| 291 | - if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
| 292 | - else if (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); |
|
| 290 | + $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix; |
|
| 291 | + if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
| 292 | + else if (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); |
|
| 293 | 293 | |
| 294 | 294 | // Add other message if VAT exists |
| 295 | 295 | if ($object->total_vat != 0 || $object->total_tva != 0) |
| 296 | 296 | { |
| 297 | - $parammessageform='ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix; |
|
| 298 | - if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
| 299 | - else if (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); |
|
| 297 | + $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix; |
|
| 298 | + if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
| 299 | + else if (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); |
|
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | print '<font style="font-size: 10px;"><br><hr>'."\n"; |
| 304 | 304 | print $fromcompany->name.'<br>'; |
| 305 | 305 | print $line1; |
| 306 | - if (strlen($line1+$line2) > 50) print '<br>'; |
|
| 306 | + if (strlen($line1 + $line2) > 50) print '<br>'; |
|
| 307 | 307 | else print ' - '; |
| 308 | 308 | print $line2; |
| 309 | 309 | print '</font></div>'."\n"; |
@@ -132,24 +132,36 @@ discard block |
||
| 132 | 132 | $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?amount='.($mode?'<font color="#666666">':'').$amount.($mode?'</font>':'').'&tag='.($mode?'<font color="#666666">':'').$freetag.($mode?'</font>':''); |
| 133 | 133 | if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
| 134 | 134 | { |
| 135 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 136 | - else $out.='&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); |
|
| 135 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { |
|
| 136 | + $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 137 | + } else { |
|
| 138 | + $out.='&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); |
|
| 139 | + } |
|
| 137 | 140 | } |
| 138 | 141 | } |
| 139 | 142 | if ($type == 'order') |
| 140 | 143 | { |
| 141 | 144 | $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=order&ref='.($mode?'<font color="#666666">':''); |
| 142 | - if ($mode == 1) $out.='order_ref'; |
|
| 143 | - if ($mode == 0) $out.=urlencode($ref); |
|
| 145 | + if ($mode == 1) { |
|
| 146 | + $out.='order_ref'; |
|
| 147 | + } |
|
| 148 | + if ($mode == 0) { |
|
| 149 | + $out.=urlencode($ref); |
|
| 150 | + } |
|
| 144 | 151 | $out.=($mode?'</font>':''); |
| 145 | 152 | if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
| 146 | 153 | { |
| 147 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 148 | - else |
|
| 154 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { |
|
| 155 | + $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 156 | + } else |
|
| 149 | 157 | { |
| 150 | 158 | $out.='&securekey='.($mode?'<font color="#666666">':''); |
| 151 | - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)"; |
|
| 152 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
| 159 | + if ($mode == 1) { |
|
| 160 | + $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)"; |
|
| 161 | + } |
|
| 162 | + if ($mode == 0) { |
|
| 163 | + $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
| 164 | + } |
|
| 153 | 165 | $out.=($mode?'</font>':''); |
| 154 | 166 | } |
| 155 | 167 | } |
@@ -157,17 +169,26 @@ discard block |
||
| 157 | 169 | if ($type == 'invoice') |
| 158 | 170 | { |
| 159 | 171 | $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'<font color="#666666">':''); |
| 160 | - if ($mode == 1) $out.='invoice_ref'; |
|
| 161 | - if ($mode == 0) $out.=urlencode($ref); |
|
| 172 | + if ($mode == 1) { |
|
| 173 | + $out.='invoice_ref'; |
|
| 174 | + } |
|
| 175 | + if ($mode == 0) { |
|
| 176 | + $out.=urlencode($ref); |
|
| 177 | + } |
|
| 162 | 178 | $out.=($mode?'</font>':''); |
| 163 | 179 | if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
| 164 | 180 | { |
| 165 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 166 | - else |
|
| 181 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { |
|
| 182 | + $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 183 | + } else |
|
| 167 | 184 | { |
| 168 | 185 | $out.='&securekey='.($mode?'<font color="#666666">':''); |
| 169 | - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; |
|
| 170 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
| 186 | + if ($mode == 1) { |
|
| 187 | + $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; |
|
| 188 | + } |
|
| 189 | + if ($mode == 0) { |
|
| 190 | + $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
| 191 | + } |
|
| 171 | 192 | $out.=($mode?'</font>':''); |
| 172 | 193 | } |
| 173 | 194 | } |
@@ -175,17 +196,26 @@ discard block |
||
| 175 | 196 | if ($type == 'contractline') |
| 176 | 197 | { |
| 177 | 198 | $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'<font color="#666666">':''); |
| 178 | - if ($mode == 1) $out.='contractline_ref'; |
|
| 179 | - if ($mode == 0) $out.=urlencode($ref); |
|
| 199 | + if ($mode == 1) { |
|
| 200 | + $out.='contractline_ref'; |
|
| 201 | + } |
|
| 202 | + if ($mode == 0) { |
|
| 203 | + $out.=urlencode($ref); |
|
| 204 | + } |
|
| 180 | 205 | $out.=($mode?'</font>':''); |
| 181 | 206 | if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
| 182 | 207 | { |
| 183 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 184 | - else |
|
| 208 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { |
|
| 209 | + $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 210 | + } else |
|
| 185 | 211 | { |
| 186 | 212 | $out.='&securekey='.($mode?'<font color="#666666">':''); |
| 187 | - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; |
|
| 188 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
| 213 | + if ($mode == 1) { |
|
| 214 | + $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; |
|
| 215 | + } |
|
| 216 | + if ($mode == 0) { |
|
| 217 | + $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
| 218 | + } |
|
| 189 | 219 | $out.=($mode?'</font>':''); |
| 190 | 220 | } |
| 191 | 221 | } |
@@ -193,24 +223,36 @@ discard block |
||
| 193 | 223 | if ($type == 'membersubscription') |
| 194 | 224 | { |
| 195 | 225 | $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'<font color="#666666">':''); |
| 196 | - if ($mode == 1) $out.='member_ref'; |
|
| 197 | - if ($mode == 0) $out.=urlencode($ref); |
|
| 226 | + if ($mode == 1) { |
|
| 227 | + $out.='member_ref'; |
|
| 228 | + } |
|
| 229 | + if ($mode == 0) { |
|
| 230 | + $out.=urlencode($ref); |
|
| 231 | + } |
|
| 198 | 232 | $out.=($mode?'</font>':''); |
| 199 | 233 | if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
| 200 | 234 | { |
| 201 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 202 | - else |
|
| 235 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { |
|
| 236 | + $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 237 | + } else |
|
| 203 | 238 | { |
| 204 | 239 | $out.='&securekey='.($mode?'<font color="#666666">':''); |
| 205 | - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)"; |
|
| 206 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
| 240 | + if ($mode == 1) { |
|
| 241 | + $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)"; |
|
| 242 | + } |
|
| 243 | + if ($mode == 0) { |
|
| 244 | + $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
| 245 | + } |
|
| 207 | 246 | $out.=($mode?'</font>':''); |
| 208 | 247 | } |
| 209 | 248 | } |
| 210 | 249 | } |
| 211 | 250 | |
| 212 | 251 | // For multicompany |
| 213 | - if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities |
|
| 252 | + if (! empty($out)) { |
|
| 253 | + $out.="&entity=".$conf->entity; |
|
| 254 | + } |
|
| 255 | + // Check the entity because He may be the same reference in several entities |
|
| 214 | 256 | |
| 215 | 257 | return $out; |
| 216 | 258 | } |
@@ -246,14 +288,18 @@ discard block |
||
| 246 | 288 | if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) |
| 247 | 289 | { |
| 248 | 290 | $field=$langs->transcountrynoentities("ProfId1",$fromcompany->country_code); |
| 249 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 291 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
| 292 | + $field=$reg[1]; |
|
| 293 | + } |
|
| 250 | 294 | $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof1; |
| 251 | 295 | } |
| 252 | 296 | // Prof Id 2 |
| 253 | 297 | if ($fromcompany->idprof2) |
| 254 | 298 | { |
| 255 | 299 | $field=$langs->transcountrynoentities("ProfId2",$fromcompany->country_code); |
| 256 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 300 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
| 301 | + $field=$reg[1]; |
|
| 302 | + } |
|
| 257 | 303 | $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof2; |
| 258 | 304 | } |
| 259 | 305 | |
@@ -263,14 +309,18 @@ discard block |
||
| 263 | 309 | if ($fromcompany->idprof3) |
| 264 | 310 | { |
| 265 | 311 | $field=$langs->transcountrynoentities("ProfId3",$fromcompany->country_code); |
| 266 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 312 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
| 313 | + $field=$reg[1]; |
|
| 314 | + } |
|
| 267 | 315 | $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof3; |
| 268 | 316 | } |
| 269 | 317 | // Prof Id 4 |
| 270 | 318 | if ($fromcompany->idprof4) |
| 271 | 319 | { |
| 272 | 320 | $field=$langs->transcountrynoentities("ProfId4",$fromcompany->country_code); |
| 273 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
| 321 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
| 322 | + $field=$reg[1]; |
|
| 323 | + } |
|
| 274 | 324 | $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof4; |
| 275 | 325 | } |
| 276 | 326 | // IntraCommunautary VAT |
@@ -288,23 +338,32 @@ discard block |
||
| 288 | 338 | print '<br>'; |
| 289 | 339 | |
| 290 | 340 | $parammessageform='ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix; |
| 291 | - if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
| 292 | - else if (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); |
|
| 341 | + if (! empty($conf->global->$parammessageform)) { |
|
| 342 | + print $langs->transnoentities($conf->global->$parammessageform); |
|
| 343 | + } else if (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) { |
|
| 344 | + print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); |
|
| 345 | + } |
|
| 293 | 346 | |
| 294 | 347 | // Add other message if VAT exists |
| 295 | 348 | if ($object->total_vat != 0 || $object->total_tva != 0) |
| 296 | 349 | { |
| 297 | 350 | $parammessageform='ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix; |
| 298 | - if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
| 299 | - else if (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); |
|
| 351 | + if (! empty($conf->global->$parammessageform)) { |
|
| 352 | + print $langs->transnoentities($conf->global->$parammessageform); |
|
| 353 | + } else if (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) { |
|
| 354 | + print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); |
|
| 355 | + } |
|
| 300 | 356 | } |
| 301 | 357 | } |
| 302 | 358 | |
| 303 | 359 | print '<font style="font-size: 10px;"><br><hr>'."\n"; |
| 304 | 360 | print $fromcompany->name.'<br>'; |
| 305 | 361 | print $line1; |
| 306 | - if (strlen($line1+$line2) > 50) print '<br>'; |
|
| 307 | - else print ' - '; |
|
| 362 | + if (strlen($line1+$line2) > 50) { |
|
| 363 | + print '<br>'; |
|
| 364 | + } else { |
|
| 365 | + print ' - '; |
|
| 366 | + } |
|
| 308 | 367 | print $line2; |
| 309 | 368 | print '</font></div>'."\n"; |
| 310 | 369 | } |