diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index 377feaa0cae..a343d09ddc2 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -33,8 +33,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories')); -$action=GETPOST('action', 'aZ09'); -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'aZ09'); +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') if (!$user->rights->banque->configurer) accessforbidden(); @@ -92,7 +92,7 @@ print ''; print ''; */ -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; @@ -109,9 +109,9 @@ if ($action != 'edit') $sql = "SELECT rowid, label"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_categ"; -$sql.= " WHERE entity = ".$conf->entity; -$sql.= " ORDER BY label"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank_categ"; +$sql .= " WHERE entity = ".$conf->entity; +$sql .= " ORDER BY label"; $result = $db->query($sql); if ($result) @@ -125,7 +125,7 @@ if ($result) print ''; print ''; - if (GETPOST('action', 'aZ09') == 'edit' && GETPOST("categid")== $objp->rowid) + if (GETPOST('action', 'aZ09') == 'edit' && GETPOST("categid") == $objp->rowid) { print "'; - print ''; + print ''; + print ''; print ''; // Multicurrency Amount VAT - print ''; - print ''; + print ''; + print ''; print ''; // Multicurrency Amount TTC - print ''; - print ''; + print ''; + print ''; print ''; } // Amount print ''; print ''; // Amount Local Taxes //TODO: Place into a function to control showing by country or study better option - if ($societe->localtax1_assuj=="1") //Localtax1 + if ($societe->localtax1_assuj == "1") //Localtax1 { print ''; print ''; print ''; } - if ($societe->localtax2_assuj=="1") //Localtax2 + if ($societe->localtax2_assuj == "1") //Localtax2 { print ''; print ''; @@ -2708,27 +2708,27 @@ else $sign = 1; if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign = - 1; - $nbrows=9; $nbcols=3; - if (! empty($conf->projet->enabled)) $nbrows++; - if (! empty($conf->banque->enabled)) { $nbrows++; $nbcols++; } - if (! empty($conf->incoterm->enabled)) $nbrows++; - if (! empty($conf->multicurrency->enabled)) $nbrows += 5; + $nbrows = 9; $nbcols = 3; + if (!empty($conf->projet->enabled)) $nbrows++; + if (!empty($conf->banque->enabled)) { $nbrows++; $nbcols++; } + if (!empty($conf->incoterm->enabled)) $nbrows++; + if (!empty($conf->multicurrency->enabled)) $nbrows += 5; // Local taxes - if ($societe->localtax1_assuj=="1") $nbrows++; - if ($societe->localtax2_assuj=="1") $nbrows++; + if ($societe->localtax1_assuj == "1") $nbrows++; + if ($societe->localtax2_assuj == "1") $nbrows++; $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement, p.rowid, p.fk_bank,'; - $sql.= ' c.id as paiement_type,'; - $sql.= ' pf.amount,'; - $sql.= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; - $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; - $sql.= ' ORDER BY p.datep, p.tms'; + $sql .= ' c.id as paiement_type,'; + $sql .= ' pf.amount,'; + $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; + $sql .= ' WHERE pf.fk_facturefourn = '.$object->id; + $sql .= ' ORDER BY p.datep, p.tms'; $result = $db->query($sql); if ($result) @@ -2739,10 +2739,10 @@ else print '
'; print '
'.$langs->trans("Ref").''.$langs->trans("Label").'
'.$objp->rowid.'"; print ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ed63af9753b..df41f2e5595 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -45,8 +45,8 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; /** * Class to manage invoices @@ -56,12 +56,12 @@ class Facture extends CommonInvoice /** * @var string ID to identify managed object */ - public $element='facture'; + public $element = 'facture'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='facture'; + public $table_element = 'facture'; /** * @var int Name of subtable line @@ -76,7 +76,7 @@ class Facture extends CommonInvoice /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='bill'; + public $picto = 'bill'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -109,7 +109,7 @@ class Facture extends CommonInvoice */ public $fk_user_valid; - public $date; // Date invoice + public $date; // Date invoice public $datem; public $ref_client; public $ref_int; @@ -119,11 +119,11 @@ class Facture extends CommonInvoice //var $amount; public $remise_absolue; public $remise_percent; - public $total_ht=0; - public $total_tva=0; - public $total_localtax1=0; - public $total_localtax2=0; - public $total_ttc=0; + public $total_ht = 0; + public $total_tva = 0; + public $total_localtax1 = 0; + public $total_localtax2 = 0; + public $total_ttc = 0; public $revenuestamp; //! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon @@ -141,10 +141,10 @@ class Facture extends CommonInvoice public $fk_fac_rec_source; //! id of source invoice if replacement invoice or credit note public $fk_facture_source; - public $linked_objects=array(); + public $linked_objects = array(); public $date_lim_reglement; - public $cond_reglement_code; // Code in llx_c_paiement - public $mode_reglement_code; // Code in llx_c_paiement + public $cond_reglement_code; // Code in llx_c_paiement + public $mode_reglement_code; // Code in llx_c_paiement /** * @var int ID Field to store bank id to use when payment mode is withdraw @@ -154,15 +154,15 @@ class Facture extends CommonInvoice /** * @deprecated */ - public $products=array(); + public $products = array(); /** * @var FactureLigne[] */ - public $lines=array(); + public $lines = array(); public $line; - public $extraparams=array(); + public $extraparams = array(); public $specimen; public $fac_rec; @@ -197,12 +197,12 @@ class Facture extends CommonInvoice /** * @var array Table of previous situations */ - public $tab_previous_situation_invoice=array(); + public $tab_previous_situation_invoice = array(); /** * @var array Table of next situations */ - public $tab_next_situation_invoice=array(); + public $tab_next_situation_invoice = array(); public $oldcopy; @@ -279,10 +279,10 @@ class Facture extends CommonInvoice */ const STATUS_ABANDONED = 3; - const CLOSECODE_DISCOUNTVAT = 'discount_vat'; // Abandonned remain - escompte - const CLOSECODE_BADDEBT = 'badcustomer'; // Abandonned - bad - const CLOSECODE_ABANDONED = 'abandon'; // Abandonned - other - const CLOSECODE_REPLACED = 'replaced'; // Closed after doing a replacement invoice + const CLOSECODE_DISCOUNTVAT = 'discount_vat'; // Abandonned remain - escompte + const CLOSECODE_BADDEBT = 'badcustomer'; // Abandonned - bad + const CLOSECODE_ABANDONED = 'abandon'; // Abandonned - other + const CLOSECODE_REPLACED = 'replaced'; // Closed after doing a replacement invoice /** * Constructor @@ -306,21 +306,21 @@ class Facture extends CommonInvoice */ public function create(User $user, $notrigger = 0, $forceduedate = 0) { - global $langs,$conf,$mysoc,$hookmanager; - $error=0; + global $langs, $conf, $mysoc, $hookmanager; + $error = 0; // Clean parameters if (empty($this->type)) $this->type = self::TYPE_STANDARD; - $this->ref_client=trim($this->ref_client); - $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated - $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note_private)); - $this->note_public=trim($this->note_public); - if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; - if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; + $this->ref_client = trim($this->ref_client); + $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated + $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note_private)); + $this->note_public = trim($this->note_public); + if (!$this->cond_reglement_id) $this->cond_reglement_id = 0; + if (!$this->mode_reglement_id) $this->mode_reglement_id = 0; $this->brouillon = 1; // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); if (empty($this->fk_multicurrency)) { @@ -334,26 +334,26 @@ class Facture extends CommonInvoice // Check parameters if (empty($this->date)) { - $this->error="Try to create an invoice with an empty parameter (date)"; + $this->error = "Try to create an invoice with an empty parameter (date)"; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -3; } $soc = new Societe($this->db); - $result=$soc->fetch($this->socid); + $result = $soc->fetch($this->socid); if ($result < 0) { - $this->error="Failed to fetch company: ".$soc->error; + $this->error = "Failed to fetch company: ".$soc->error; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -2; } - $now=dol_now(); + $now = dol_now(); $this->db->begin(); - $originaldatewhen=null; - $nextdatewhen=null; - $previousdaynextdatewhen=null; + $originaldatewhen = null; + $nextdatewhen = null; + $previousdaynextdatewhen = null; // Create invoice from a template invoice if ($this->fac_rec > 0) @@ -362,17 +362,17 @@ class Facture extends CommonInvoice require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; $_facrec = new FactureRec($this->db); - $result=$_facrec->fetch($this->fac_rec); - $result=$_facrec->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); // This load $_facrec->linkedObjectsIds + $result = $_facrec->fetch($this->fac_rec); + $result = $_facrec->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); // This load $_facrec->linkedObjectsIds // Define some dates $originaldatewhen = $_facrec->date_when; - $nextdatewhen=dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency); - $previousdaynextdatewhen=dol_time_plus_duree($nextdatewhen, -1, 'd'); + $nextdatewhen = dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency); + $previousdaynextdatewhen = dol_time_plus_duree($nextdatewhen, -1, 'd'); - if (! empty($_facrec->frequency)) // Invoice are created on same thirdparty than template when there is a recurrence, but not necessarly when there is no recurrence. + if (!empty($_facrec->frequency)) // Invoice are created on same thirdparty than template when there is a recurrence, but not necessarly when there is no recurrence. { - $this->socid = $_facrec->socid; + $this->socid = $_facrec->socid; } $this->entity = $_facrec->entity; // Invoice created in same entity than template @@ -392,20 +392,20 @@ class Facture extends CommonInvoice // Fields always coming from template $this->remise_absolue = $_facrec->remise_absolue; $this->remise_percent = $_facrec->remise_percent; - $this->fk_incoterms = $_facrec->fk_incoterms; - $this->location_incoterms= $_facrec->location_incoterms; + $this->fk_incoterms = $_facrec->fk_incoterms; + $this->location_incoterms = $_facrec->location_incoterms; // Clean parameters - if (! $this->type) $this->type = self::TYPE_STANDARD; - $this->ref_client=trim($this->ref_client); - $this->note_public=trim($this->note_public); - $this->note_private=trim($this->note_private); - $this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); + if (!$this->type) $this->type = self::TYPE_STANDARD; + $this->ref_client = trim($this->ref_client); + $this->note_public = trim($this->note_public); + $this->note_private = trim($this->note_private); + $this->note_private = dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); - $this->array_options=$_facrec->array_options; + $this->array_options = $_facrec->array_options; //if (! $this->remise) $this->remise = 0; - if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; + if (!$this->mode_reglement_id) $this->mode_reglement_id = 0; $this->brouillon = 1; $this->linked_objects = $_facrec->linkedObjectsIds; @@ -419,7 +419,7 @@ class Facture extends CommonInvoice { dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); if (empty($_facrec->date_when)) $_facrec->date_when = $now; - $next_date = $_facrec->getNextDate(); // Calculate next date + $next_date = $_facrec->getNextDate(); // Calculate next date $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date', '', $user, ''); //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. $result = $_facrec->setNextDate($next_date, 1); @@ -427,18 +427,18 @@ class Facture extends CommonInvoice // Define lang of customer $outputlangs = $langs; - $newlang=''; + $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) $newlang=$this->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) $newlang=$this->default_lang; // for thirdparty - if (! empty($newlang)) + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) $newlang = $this->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) $newlang = $this->default_lang; // for thirdparty + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $this); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $this); $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%m'); $substitutionarray['__INVOICE_MONTH__'] = dol_print_date($this->date, '%m'); $substitutionarray['__INVOICE_NEXT_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%m'); @@ -457,8 +457,8 @@ class Facture extends CommonInvoice complete_substitutions_array($substitutionarray, $outputlangs); - $this->note_public=make_substitutions($this->note_public, $substitutionarray); - $this->note_private=make_substitutions($this->note_private, $substitutionarray); + $this->note_public = make_substitutions($this->note_public, $substitutionarray); + $this->note_private = make_substitutions($this->note_private, $substitutionarray); } // Define due date if not already defined @@ -474,103 +474,103 @@ class Facture extends CommonInvoice } // Insert into database - $socid = $this->socid; + $socid = $this->socid; $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture ("; - $sql.= " ref"; - $sql.= ", entity"; - $sql.= ", ref_ext"; - $sql.= ", type"; - $sql.= ", fk_soc"; - $sql.= ", datec"; - $sql.= ", remise_absolue"; - $sql.= ", remise_percent"; - $sql.= ", datef"; - $sql.= ", date_pointoftax"; - $sql.= ", note_private"; - $sql.= ", note_public"; - $sql.= ", ref_client, ref_int"; - $sql.= ", fk_account"; - $sql.= ", module_source, pos_source, fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; - $sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; - $sql.= ", situation_cycle_ref, situation_counter, situation_final"; - $sql.= ", fk_incoterms, location_incoterms"; - $sql.= ", fk_multicurrency"; - $sql.= ", multicurrency_code"; - $sql.= ", multicurrency_tx"; - $sql.= ", retained_warranty"; - $sql.= ", retained_warranty_date_limit"; - $sql.= ", retained_warranty_fk_cond_reglement"; - $sql.= ")"; - $sql.= " VALUES ("; - $sql.= "'(PROV)'"; - $sql.= ", ".setEntity($this); - $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null"); - $sql.= ", '".$this->db->escape($this->type)."'"; - $sql.= ", '".$socid."'"; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", ".($this->remise_absolue>0?$this->remise_absolue:'NULL'); - $sql.= ", ".($this->remise_percent>0?$this->remise_percent:'NULL'); - $sql.= ", '".$this->db->idate($this->date)."'"; - $sql.= ", ".(strval($this->date_pointoftax)!='' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null'); - $sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); - $sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); - $sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); - $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); - $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); - $sql.= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); - $sql.= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null"); - $sql.= ", ".($this->fk_fac_rec_source?"'".$this->db->escape($this->fk_fac_rec_source)."'":"null"); - $sql.= ", ".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null"); - $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); - $sql.= ", ".($this->fk_project?$this->fk_project:"null"); - $sql.= ", ".$this->cond_reglement_id; - $sql.= ", ".$this->mode_reglement_id; - $sql.= ", '".$this->db->idate($this->date_lim_reglement)."', '".$this->db->escape($this->modelpdf)."'"; - $sql.= ", ".($this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null"); - $sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null"); - $sql.= ", ".($this->situation_final?$this->situation_final:0); - $sql.= ", ".(int) $this->fk_incoterms; - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".(double) $this->multicurrency_tx; - $sql.= ", ".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty)); - $sql.= ", ".(!empty($this->retained_warranty_date_limit)?"'".$this->db->idate($this->retained_warranty_date_limit)."'":'NULL'); - $sql.= ", ".(int) $this->retained_warranty_fk_cond_reglement; + $sql .= " ref"; + $sql .= ", entity"; + $sql .= ", ref_ext"; + $sql .= ", type"; + $sql .= ", fk_soc"; + $sql .= ", datec"; + $sql .= ", remise_absolue"; + $sql .= ", remise_percent"; + $sql .= ", datef"; + $sql .= ", date_pointoftax"; + $sql .= ", note_private"; + $sql .= ", note_public"; + $sql .= ", ref_client, ref_int"; + $sql .= ", fk_account"; + $sql .= ", module_source, pos_source, fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; + $sql .= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; + $sql .= ", situation_cycle_ref, situation_counter, situation_final"; + $sql .= ", fk_incoterms, location_incoterms"; + $sql .= ", fk_multicurrency"; + $sql .= ", multicurrency_code"; + $sql .= ", multicurrency_tx"; + $sql .= ", retained_warranty"; + $sql .= ", retained_warranty_date_limit"; + $sql .= ", retained_warranty_fk_cond_reglement"; + $sql .= ")"; + $sql .= " VALUES ("; + $sql .= "'(PROV)'"; + $sql .= ", ".setEntity($this); + $sql .= ", ".($this->ref_ext ? "'".$this->db->escape($this->ref_ext)."'" : "null"); + $sql .= ", '".$this->db->escape($this->type)."'"; + $sql .= ", '".$socid."'"; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", ".($this->remise_absolue > 0 ? $this->remise_absolue : 'NULL'); + $sql .= ", ".($this->remise_percent > 0 ? $this->remise_percent : 'NULL'); + $sql .= ", '".$this->db->idate($this->date)."'"; + $sql .= ", ".(strval($this->date_pointoftax) != '' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null'); + $sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); + $sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); + $sql .= ", ".($this->ref_client ? "'".$this->db->escape($this->ref_client)."'" : "null"); + $sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null"); + $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); + $sql .= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); + $sql .= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null"); + $sql .= ", ".($this->fk_fac_rec_source ? "'".$this->db->escape($this->fk_fac_rec_source)."'" : "null"); + $sql .= ", ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'" : "null"); + $sql .= ", ".($user->id > 0 ? "'".$user->id."'" : "null"); + $sql .= ", ".($this->fk_project ? $this->fk_project : "null"); + $sql .= ", ".$this->cond_reglement_id; + $sql .= ", ".$this->mode_reglement_id; + $sql .= ", '".$this->db->idate($this->date_lim_reglement)."', '".$this->db->escape($this->modelpdf)."'"; + $sql .= ", ".($this->situation_cycle_ref ? "'".$this->db->escape($this->situation_cycle_ref)."'" : "null"); + $sql .= ", ".($this->situation_counter ? "'".$this->db->escape($this->situation_counter)."'" : "null"); + $sql .= ", ".($this->situation_final ? $this->situation_final : 0); + $sql .= ", ".(int) $this->fk_incoterms; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql .= ", ".(int) $this->fk_multicurrency; + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql .= ", ".(double) $this->multicurrency_tx; + $sql .= ", ".(empty($this->retained_warranty) ? "0" : $this->db->escape($this->retained_warranty)); + $sql .= ", ".(!empty($this->retained_warranty_date_limit) ? "'".$this->db->idate($this->retained_warranty_date_limit)."'" : 'NULL'); + $sql .= ", ".(int) $this->retained_warranty_fk_cond_reglement; - $sql.=")"; + $sql .= ")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture'); // Update ref with new one - $this->ref='(PROV'.$this->id.')'; + $this->ref = '(PROV'.$this->id.')'; $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; - $resql=$this->db->query($sql); - if (! $resql) $error++; + $resql = $this->db->query($sql); + if (!$resql) $error++; - if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) { - foreach($this->linked_objects as $origin => $tmp_origin_id) + foreach ($this->linked_objects as $origin => $tmp_origin_id) { 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, ...)) { - foreach($tmp_origin_id as $origin_id) + foreach ($tmp_origin_id as $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -579,9 +579,9 @@ class Facture extends CommonInvoice { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -589,13 +589,13 @@ class Facture extends CommonInvoice } // Propagate contacts - if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object + if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object { $originforcontact = $this->origin; $originidforcontact = $this->origin_id; if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order { - require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $exp = new Expedition($this->db); $exp->fetch($this->origin_id); $exp->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); @@ -612,15 +612,15 @@ class Facture extends CommonInvoice } $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"; - $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; + $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; $resqlcontact = $this->db->query($sqlcontact); if ($resqlcontact) { - while($objcontact = $this->db->fetch_object($resqlcontact)) + while ($objcontact = $this->db->fetch_object($resqlcontact)) { //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; - $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 + $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 } } else dol_print_error($resqlcontact); @@ -629,15 +629,15 @@ class Facture extends CommonInvoice /* * Insert lines of invoices, if not from template invoice, into database */ - if (! $error && empty($this->fac_rec) && count($this->lines) && is_object($this->lines[0])) // If this->lines is array of InvoiceLines (preferred mode) + if (!$error && empty($this->fac_rec) && count($this->lines) && is_object($this->lines[0])) // If this->lines is array of InvoiceLines (preferred mode) { $fk_parent_line = 0; dol_syslog("There is ".count($this->lines)." lines that are invoice lines objects"); foreach ($this->lines as $i => $val) { - $newinvoiceline=$this->lines[$i]; - $newinvoiceline->fk_facture=$this->id; + $newinvoiceline = $this->lines[$i]; + $newinvoiceline->fk_facture = $this->id; $newinvoiceline->origin = $this->lines[$i]->element; $newinvoiceline->origin_id = $this->lines[$i]->id; @@ -659,9 +659,9 @@ class Facture extends CommonInvoice $fk_parent_line = 0; } - $newinvoiceline->fk_parent_line=$fk_parent_line; + $newinvoiceline->fk_parent_line = $fk_parent_line; - if($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except){ + if ($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except) { $discount = new DiscountAbsolute($this->db); $discount->fetch($newinvoiceline->fk_remise_except); @@ -669,7 +669,7 @@ class Facture extends CommonInvoice $newinvoiceline->fk_remise_except = $discountId; } - $result=$newinvoiceline->insert(); + $result = $newinvoiceline->insert(); // Defined the new fk_parent_line if ($result > 0 && $newinvoiceline->product_type == 9) { @@ -678,13 +678,13 @@ class Facture extends CommonInvoice } if ($result < 0) { - $this->error=$newinvoiceline->error; + $this->error = $newinvoiceline->error; $error++; break; } } } - elseif (! $error && empty($this->fac_rec)) // If this->lines is an array of invoice line arrays + elseif (!$error && empty($this->fac_rec)) // If this->lines is an array of invoice line arrays { $fk_parent_line = 0; @@ -696,7 +696,7 @@ class Facture extends CommonInvoice // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. - if (! is_object($line)) $line = (object) $line; + if (!is_object($line)) $line = (object) $line; if ($result >= 0) { @@ -707,7 +707,7 @@ class Facture extends CommonInvoice // Complete vat rate with code $vatrate = $line->tva_tx; - if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; + if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; $result = $this->addline( $line->desc, @@ -742,7 +742,7 @@ class Facture extends CommonInvoice ); if ($result < 0) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_print_error($this->db); $this->db->rollback(); return -1; @@ -759,14 +759,14 @@ class Facture extends CommonInvoice /* * Insert lines of template invoices */ - if (! $error && $this->fac_rec > 0) + if (!$error && $this->fac_rec > 0) { foreach ($_facrec->lines as $i => $val) { if ($_facrec->lines[$i]->fk_product) { $prod = new Product($this->db); - $res=$prod->fetch($_facrec->lines[$i]->fk_product); + $res = $prod->fetch($_facrec->lines[$i]->fk_product); } // For line from template invoice, we use data from template invoice @@ -779,14 +779,14 @@ class Facture extends CommonInvoice */ $tva_tx = $_facrec->lines[$i]->tva_tx.($_facrec->lines[$i]->vat_src_code ? '('.$_facrec->lines[$i]->vat_src_code.')' : ''); $tva_npr = $_facrec->lines[$i]->info_bits; - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; $localtax1_tx = $_facrec->lines[$i]->localtax1_tx; $localtax2_tx = $_facrec->lines[$i]->localtax2_tx; - $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price)?null:$_facrec->lines[$i]->fk_product_fournisseur_price; - $buyprice = empty($_facrec->lines[$i]->buyprice)?0:$_facrec->lines[$i]->buyprice; + $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price) ?null:$_facrec->lines[$i]->fk_product_fournisseur_price; + $buyprice = empty($_facrec->lines[$i]->buyprice) ? 0 : $_facrec->lines[$i]->buyprice; // If buyprice not defined from template invoice, we try to guess the best value - if (! $buyprice && $_facrec->lines[$i]->fk_product > 0) + if (!$buyprice && $_facrec->lines[$i]->fk_product > 0) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $producttmp = new ProductFournisseur($this->db); @@ -795,14 +795,14 @@ class Facture extends CommonInvoice // If margin module defined on costprice, we try the costprice // If not defined or if module margin defined and pmp and stock module enabled, we try pmp price // else we get the best supplier price - if ($conf->global->MARGIN_TYPE == 'costprice' && ! empty($producttmp->cost_price)) $buyprice = $producttmp->cost_price; - elseif (! empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && ! empty($producttmp->pmp)) $buyprice = $producttmp->pmp; + if ($conf->global->MARGIN_TYPE == 'costprice' && !empty($producttmp->cost_price)) $buyprice = $producttmp->cost_price; + elseif (!empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && !empty($producttmp->pmp)) $buyprice = $producttmp->pmp; else { if ($producttmp->find_min_price_product_fournisseur($_facrec->lines[$i]->fk_product) > 0) { if ($producttmp->product_fourn_price_id > 0) { - $buyprice = price2num($producttmp->fourn_unitprice * (1 - $producttmp->fourn_remise_percent/100) + $producttmp->fourn_remise, 'MU'); + $buyprice = price2num($producttmp->fourn_unitprice * (1 - $producttmp->fourn_remise_percent / 100) + $producttmp->fourn_remise, 'MU'); } } } @@ -817,8 +817,8 @@ class Facture extends CommonInvoice $localtax2_tx, $_facrec->lines[$i]->fk_product, $_facrec->lines[$i]->remise_percent, - ($_facrec->lines[$i]->date_start_fill == 1 && $originaldatewhen)?$originaldatewhen:'', - ($_facrec->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen)?$previousdaynextdatewhen:'', + ($_facrec->lines[$i]->date_start_fill == 1 && $originaldatewhen) ? $originaldatewhen : '', + ($_facrec->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen) ? $previousdaynextdatewhen : '', 0, $tva_npr, '', @@ -833,45 +833,45 @@ class Facture extends CommonInvoice $fk_product_fournisseur_price, $buyprice, $_facrec->lines[$i]->label, - empty($_facrec->lines[$i]->array_options)?null:$_facrec->lines[$i]->array_options, + empty($_facrec->lines[$i]->array_options) ?null:$_facrec->lines[$i]->array_options, $_facrec->lines[$i]->situation_percent, '', $_facrec->lines[$i]->fk_unit, $_facrec->lines[$i]->pu_ht_devise ); - if ( $result_insert < 0) + if ($result_insert < 0) { $error++; - $this->error=$this->db->error(); + $this->error = $this->db->error(); break; } } } - if (! $error) + if (!$error) { - $result=$this->update_price(1); + $result = $this->update_price(1); if ($result > 0) { - $action='create'; + $action = 'create'; // Actions on extra fields - if (! $error) + if (!$error) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BILL_CREATE', $user); + $result = $this->call_trigger('BILL_CREATE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -884,7 +884,7 @@ class Facture extends CommonInvoice } else { - $this->error=$langs->trans('FailedToUpdatePrice'); + $this->error = $langs->trans('FailedToUpdatePrice'); $this->db->rollback(); return -3; } @@ -898,7 +898,7 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -917,18 +917,18 @@ class Facture extends CommonInvoice global $conf; // Charge facture source - $facture=new Facture($this->db); + $facture = new Facture($this->db); // Retreive all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); - if(!empty($this->array_options)){ + if (!empty($this->array_options)) { $facture->array_options = $this->array_options; } - foreach($this->lines as &$line){ - $line->fetch_optionals();//fetch extrafields + foreach ($this->lines as &$line) { + $line->fetch_optionals(); //fetch extrafields } $facture->fk_facture_source = $this->fk_facture_source; @@ -949,14 +949,14 @@ class Facture extends CommonInvoice $facture->origin = $this->origin; $facture->origin_id = $this->origin_id; - $facture->lines = $this->lines; // Array of lines of invoice - $facture->products = $this->lines; // Tant que products encore utilise + $facture->lines = $this->lines; // Array of lines of invoice + $facture->products = $this->lines; // Tant que products encore utilise $facture->situation_counter = $this->situation_counter; - $facture->situation_cycle_ref=$this->situation_cycle_ref; - $facture->situation_final = $this->situation_final; + $facture->situation_cycle_ref = $this->situation_cycle_ref; + $facture->situation_final = $this->situation_final; // Loop on each line of new invoice - foreach($facture->lines as $i => $tmpline) + foreach ($facture->lines as $i => $tmpline) { $facture->lines[$i]->fk_prev_id = $this->lines[$i]->rowid; if ($invertdetail) @@ -975,8 +975,8 @@ class Facture extends CommonInvoice $facid = $facture->create($user); if ($facid <= 0) { - $this->error=$facture->error; - $this->errors=$facture->errors; + $this->error = $facture->error; + $this->errors = $facture->errors; } elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) { @@ -1008,33 +1008,33 @@ class Facture extends CommonInvoice { global $hookmanager; - $error=0; + $error = 0; - $object=new Facture($this->db); + $object = new Facture($this->db); $this->db->begin(); $object->fetch($fromid); // Change socid if needed - if (! empty($this->socid) && $this->socid != $object->socid) + if (!empty($this->socid) && $this->socid != $object->socid) { $objsoc = new Societe($this->db); - if ($objsoc->fetch($this->socid)>0) + if ($objsoc->fetch($this->socid) > 0) { - $object->socid = $objsoc->id; - $object->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); - $object->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); - $object->fk_project = ''; - $object->fk_delivery_address = ''; + $object->socid = $objsoc->id; + $object->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); + $object->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); + $object->fk_project = ''; + $object->fk_delivery_address = ''; } // TODO Change product price if multi-prices } - $object->id=0; - $object->statut= self::STATUS_DRAFT; + $object->id = 0; + $object->statut = self::STATUS_DRAFT; // Clear fields $object->date = (empty($this->date) ? dol_now() : $this->date); @@ -1047,26 +1047,26 @@ class Facture extends CommonInvoice $object->ref_client = ''; $object->close_code = ''; $object->close_note = ''; - $object->products = $object->lines; // For backward compatibility - if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING==1) + $object->products = $object->lines; // For backward compatibility + if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1) { $object->note_private = ''; $object->note_public = ''; } // Loop on each line of new invoice - foreach($object->lines as $i => $line) + foreach ($object->lines as $i => $line) { if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts { unset($object->lines[$i]); - unset($object->products[$i]); // Tant que products encore utilise + unset($object->products[$i]); // Tant que products encore utilise } } // Create clone $object->context['createfromclone'] = 'createfromclone'; - $result=$object->create($user); + $result = $object->create($user); if ($result < 0) $error++; else { // copy internal contacts @@ -1081,14 +1081,14 @@ class Facture extends CommonInvoice } } - if (! $error) + if (!$error) { // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters=array('objFrom'=>$this); - $action=''; - $reshook=$hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('objFrom'=>$this); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } } @@ -1096,7 +1096,7 @@ class Facture extends CommonInvoice unset($object->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $object->id; @@ -1119,18 +1119,18 @@ class Facture extends CommonInvoice { global $conf, $hookmanager; - $error=0; + $error = 0; // Closed order $this->date = dol_now(); $this->source = 0; - $num=count($object->lines); + $num = count($object->lines); for ($i = 0; $i < $num; $i++) { $line = new FactureLigne($this->db); - $line->libelle = $object->lines[$i]->libelle; // deprecated + $line->libelle = $object->lines[$i]->libelle; // deprecated $line->label = $object->lines[$i]->label; $line->desc = $object->lines[$i]->desc; $line->subprice = $object->lines[$i]->subprice; @@ -1139,30 +1139,30 @@ class Facture extends CommonInvoice $line->total_localtax1 = $object->lines[$i]->total_localtax1; $line->total_localtax2 = $object->lines[$i]->total_localtax2; $line->total_ttc = $object->lines[$i]->total_ttc; - $line->vat_src_code = $object->lines[$i]->vat_src_code; - $line->tva_tx = $object->lines[$i]->tva_tx; + $line->vat_src_code = $object->lines[$i]->vat_src_code; + $line->tva_tx = $object->lines[$i]->tva_tx; $line->localtax1_tx = $object->lines[$i]->localtax1_tx; $line->localtax2_tx = $object->lines[$i]->localtax2_tx; - $line->qty = $object->lines[$i]->qty; - $line->fk_remise_except = $object->lines[$i]->fk_remise_except; - $line->remise_percent = $object->lines[$i]->remise_percent; - $line->fk_product = $object->lines[$i]->fk_product; - $line->info_bits = $object->lines[$i]->info_bits; + $line->qty = $object->lines[$i]->qty; + $line->fk_remise_except = $object->lines[$i]->fk_remise_except; + $line->remise_percent = $object->lines[$i]->remise_percent; + $line->fk_product = $object->lines[$i]->fk_product; + $line->info_bits = $object->lines[$i]->info_bits; $line->product_type = $object->lines[$i]->product_type; - $line->rang = $object->lines[$i]->rang; + $line->rang = $object->lines[$i]->rang; $line->special_code = $object->lines[$i]->special_code; - $line->fk_parent_line = $object->lines[$i]->fk_parent_line; - $line->fk_unit = $object->lines[$i]->fk_unit; - $line->date_start = $object->lines[$i]->date_start; - $line->date_end = $object->lines[$i]->date_end; + $line->fk_parent_line = $object->lines[$i]->fk_parent_line; + $line->fk_unit = $object->lines[$i]->fk_unit; + $line->date_start = $object->lines[$i]->date_start; + $line->date_end = $object->lines[$i]->date_end; - $line->fk_fournprice = $object->lines[$i]->fk_fournprice; + $line->fk_fournprice = $object->lines[$i]->fk_fournprice; $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); $line->pa_ht = $marginInfos[0]; // get extrafields from original line $object->lines[$i]->fetch_optionals(); - foreach($object->lines[$i]->array_options as $options_key => $value) + foreach ($object->lines[$i]->array_options as $options_key => $value) $line->array_options[$options_key] = $value; $this->lines[$i] = $line; @@ -1181,24 +1181,24 @@ class Facture extends CommonInvoice if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN)) { - $this->note_private = $object->note_private; - $this->note_public = $object->note_public; + $this->note_private = $object->note_private; + $this->note_public = $object->note_public; } - $this->module_source = $object->module_source; - $this->pos_source = $object->pos_source; + $this->module_source = $object->module_source; + $this->pos_source = $object->pos_source; - $this->origin = $object->element; - $this->origin_id = $object->id; + $this->origin = $object->element; + $this->origin_id = $object->id; // get extrafields from original line $object->fetch_optionals($object->id); - foreach($object->array_options as $options_key => $value) + foreach ($object->array_options as $options_key => $value) $this->array_options[$options_key] = $value; // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; - if (! empty($object->other_linked_objects) && is_array($object->other_linked_objects)) + if (!empty($object->other_linked_objects) && is_array($object->other_linked_objects)) { $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); } @@ -1210,12 +1210,12 @@ class Facture extends CommonInvoice // Actions hooked (by external module) $hookmanager->initHooks(array('invoicedao')); - $parameters=array('objFrom'=>$object); - $action=''; - $reshook=$hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('objFrom'=>$object); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; - if (! $error) + if (!$error) { return 1; } @@ -1242,9 +1242,9 @@ class Facture extends CommonInvoice { global $langs, $conf, $user, $mysoc; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $result=''; + $result = ''; if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id; else $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id; @@ -1255,59 +1255,59 @@ class Facture extends CommonInvoice if ($option !== 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } if ($short) return $url; - $picto=$this->picto; - if ($this->type == self::TYPE_REPLACEMENT) $picto.='r'; // Replacement invoice - if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note - if ($this->type == self::TYPE_DEPOSIT) $picto.='d'; // Deposit invoice - $label=''; + $picto = $this->picto; + if ($this->type == self::TYPE_REPLACEMENT) $picto .= 'r'; // Replacement invoice + if ($this->type == self::TYPE_CREDIT_NOTE) $picto .= 'a'; // Credit note + if ($this->type == self::TYPE_DEPOSIT) $picto .= 'd'; // Deposit invoice + $label = ''; if ($user->rights->facture->lire) { - $label = '' . $langs->trans("ShowInvoice") . ''; - if ($this->type == self::TYPE_REPLACEMENT) $label='' . $langs->transnoentitiesnoconv("ShowInvoiceReplace") . ''; - if ($this->type == self::TYPE_CREDIT_NOTE) $label='' . $langs->transnoentitiesnoconv("ShowInvoiceAvoir") . ''; - if ($this->type == self::TYPE_DEPOSIT) $label='' . $langs->transnoentitiesnoconv("ShowInvoiceDeposit") . ''; - if ($this->type == self::TYPE_SITUATION) $label='' . $langs->transnoentitiesnoconv("ShowInvoiceSituation") . ''; - if (! empty($this->ref)) - $label .= '
'.$langs->trans('Ref') . ': ' . $this->ref; - if (! empty($this->ref_client)) - $label .= '
' . $langs->trans('RefCustomer') . ': ' . $this->ref_client; - if (! empty($this->date)) - $label .= '
' . $langs->trans('Date') . ': ' . dol_print_date($this->date, 'day'); - if (! empty($this->total_ht)) - $label.= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_tva)) - $label.= '
' . $langs->trans('AmountVAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_localtax1) && $this->total_localtax1 != 0) // We keep test != 0 because $this->total_localtax1 can be '0.00000000' - $label.= '
' . $langs->transcountry('AmountLT1', $mysoc->country_code) . ': ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_localtax2) && $this->total_localtax2 != 0) - $label.= '
' . $langs->transcountry('AmountLT2', $mysoc->country_code) . ': ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_ttc)) - $label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - if ($moretitle) $label.=' - '.$moretitle; + $label = ''.$langs->trans("ShowInvoice").''; + if ($this->type == self::TYPE_REPLACEMENT) $label = ''.$langs->transnoentitiesnoconv("ShowInvoiceReplace").''; + if ($this->type == self::TYPE_CREDIT_NOTE) $label = ''.$langs->transnoentitiesnoconv("ShowInvoiceAvoir").''; + if ($this->type == self::TYPE_DEPOSIT) $label = ''.$langs->transnoentitiesnoconv("ShowInvoiceDeposit").''; + if ($this->type == self::TYPE_SITUATION) $label = ''.$langs->transnoentitiesnoconv("ShowInvoiceSituation").''; + if (!empty($this->ref)) + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->ref_client)) + $label .= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; + if (!empty($this->date)) + $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); + if (!empty($this->total_ht)) + $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_tva)) + $label .= '
'.$langs->trans('AmountVAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_localtax1) && $this->total_localtax1 != 0) // We keep test != 0 because $this->total_localtax1 can be '0.00000000' + $label .= '
'.$langs->transcountry('AmountLT1', $mysoc->country_code).': '.price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_localtax2) && $this->total_localtax2 != 0) + $label .= '
'.$langs->transcountry('AmountLT2', $mysoc->country_code).': '.price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_ttc)) + $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + if ($moretitle) $label .= ' - '.$moretitle; } - $linkclose=($target?' target="'.$target.'"':''); + $linkclose = ($target ? ' target="'.$target.'"' : ''); if (empty($notooltip) && $user->rights->facture->lire) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowInvoice"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowInvoice"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } - $linkstart=''; - $linkend=''; + $linkstart = ''; + $linkend = ''; if ($option == 'nolink') { $linkstart = ''; @@ -1315,23 +1315,23 @@ class Facture extends CommonInvoice } $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= ($max?dol_trunc($this->ref, $max):$this->ref); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($max ?dol_trunc($this->ref, $max) : $this->ref); $result .= $linkend; if ($addlinktonotes) { - $txttoshow=($user->socid > 0 ? $this->note_public : $this->note_private); + $txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private); if ($txttoshow) { - $notetoshow=$langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow, 1); - $result.=' '; - $result.=''; - $result.=img_picto('', 'note'); - $result.=''; + $notetoshow = $langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow, 1); + $result .= ' '; + $result .= ''; + $result .= img_picto('', 'note'); + $result .= ''; //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); //$result.=''; - $result.=''; + $result .= '
'; } } @@ -1355,36 +1355,36 @@ class Facture extends CommonInvoice if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; $sql = 'SELECT f.rowid,f.entity,f.ref,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; - $sql.= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; - $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; - $sql.= ', f.datef as df, f.date_pointoftax'; - $sql.= ', f.date_lim_reglement as dlr'; - $sql.= ', f.datec as datec'; - $sql.= ', f.date_valid as datev'; - $sql.= ', f.tms as datem'; - $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'; - $sql.= ', f.fk_facture_source, f.fk_fac_rec_source'; - $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project, f.extraparams'; - $sql.= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; - $sql.= ', f.fk_account'; - $sql.= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; - $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; - $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; - $sql.= ', f.fk_incoterms, f.location_incoterms'; - $sql.= ', f.module_source, f.pos_source'; - $sql.= ", i.libelle as label_incoterms"; - $sql.= ", f.retained_warranty as retained_warranty, f.retained_warranty_date_limit as retained_warranty_date_limit, f.retained_warranty_fk_cond_reglement as retained_warranty_fk_cond_reglement"; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; + $sql .= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; + $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; + $sql .= ', f.datef as df, f.date_pointoftax'; + $sql .= ', f.date_lim_reglement as dlr'; + $sql .= ', f.datec as datec'; + $sql .= ', f.date_valid as datev'; + $sql .= ', f.tms as datem'; + $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'; + $sql .= ', f.fk_facture_source, f.fk_fac_rec_source'; + $sql .= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project, f.extraparams'; + $sql .= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; + $sql .= ', f.fk_account'; + $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; + $sql .= ', f.fk_incoterms, f.location_incoterms'; + $sql .= ', f.module_source, f.pos_source'; + $sql .= ", i.libelle as label_incoterms"; + $sql .= ", f.retained_warranty as retained_warranty, f.retained_warranty_date_limit as retained_warranty_date_limit, f.retained_warranty_fk_cond_reglement as retained_warranty_fk_cond_reglement"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; - if ($rowid) $sql.= " WHERE f.rowid=".$rowid; - else $sql.= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Dont't use entity if you use rowid + if ($rowid) $sql .= " WHERE f.rowid=".$rowid; + else $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Dont't use entity if you use rowid - if ($ref) $sql.= " AND f.ref='".$this->db->escape($ref)."'"; - if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; + if ($ref) $sql .= " AND f.ref='".$this->db->escape($ref)."'"; + if ($ref_ext) $sql .= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql .= " AND f.ref_int='".$this->db->escape($ref_int)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -1394,20 +1394,20 @@ class Facture extends CommonInvoice { $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - $this->entity = $obj->entity; + $this->id = $obj->rowid; + $this->entity = $obj->entity; - $this->ref = $obj->ref; - $this->ref_client = $obj->ref_client; + $this->ref = $obj->ref; + $this->ref_client = $obj->ref_client; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; $this->type = $obj->type; $this->date = $this->db->jdate($obj->df); $this->date_pointoftax = $this->db->jdate($obj->date_pointoftax); - $this->date_creation = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->date_validation = $this->db->jdate($obj->datev); - $this->date_modification = $this->db->jdate($obj->datem); - $this->datem = $this->db->jdate($obj->datem); + $this->date_modification = $this->db->jdate($obj->datem); + $this->datem = $this->db->jdate($obj->datem); $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; $this->total_ht = $obj->total; @@ -1415,31 +1415,31 @@ class Facture extends CommonInvoice $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; $this->total_ttc = $obj->total_ttc; - $this->revenuestamp = $obj->revenuestamp; + $this->revenuestamp = $obj->revenuestamp; $this->paye = $obj->paye; $this->close_code = $obj->close_code; $this->close_note = $obj->close_note; $this->socid = $obj->fk_soc; - $this->statut = $obj->fk_statut; - $this->date_lim_reglement = $this->db->jdate($obj->dlr); + $this->statut = $obj->fk_statut; + $this->date_lim_reglement = $this->db->jdate($obj->dlr); $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement = $obj->mode_reglement_libelle; $this->cond_reglement_id = $obj->fk_cond_reglement; $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement_libelle; - $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; - $this->fk_account = ($obj->fk_account>0)?$obj->fk_account:null; - $this->fk_project = $obj->fk_project; + $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; + $this->fk_account = ($obj->fk_account > 0) ? $obj->fk_account : null; + $this->fk_project = $obj->fk_project; $this->fk_facture_source = $obj->fk_facture_source; $this->fk_fac_rec_source = $obj->fk_fac_rec_source; - $this->note = $obj->note_private; // deprecated - $this->note_private = $obj->note_private; + $this->note = $obj->note_private; // deprecated + $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->user_author = $obj->fk_user_author; - $this->user_valid = $obj->fk_user_valid; - $this->modelpdf = $obj->model_pdf; - $this->last_main_doc = $obj->last_main_doc; + $this->user_valid = $obj->fk_user_valid; + $this->modelpdf = $obj->model_pdf; + $this->last_main_doc = $obj->last_main_doc; $this->situation_cycle_ref = $obj->situation_cycle_ref; $this->situation_counter = $obj->situation_counter; $this->situation_final = $obj->situation_final; @@ -1447,25 +1447,25 @@ class Facture extends CommonInvoice $this->retained_warranty_date_limit = $this->db->jdate($obj->retained_warranty_date_limit); $this->retained_warranty_fk_cond_reglement = $obj->retained_warranty_fk_cond_reglement; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); //Incoterms $this->fk_incoterms = $obj->fk_incoterms; $this->location_incoterms = $obj->location_incoterms; - $this->label_incoterms = $obj->label_incoterms; + $this->label_incoterms = $obj->label_incoterms; - $this->module_source = $obj->module_source; - $this->pos_source = $obj->pos_source; + $this->module_source = $obj->module_source; + $this->pos_source = $obj->pos_source; // Multicurrency $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_code = $obj->multicurrency_code; $this->multicurrency_tx = $obj->multicurrency_tx; - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) + if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) { $this->fetchPreviousNextSituationInvoice(); } @@ -1480,26 +1480,26 @@ class Facture extends CommonInvoice * Lines */ - $this->lines = array(); + $this->lines = array(); - $result=$this->fetch_lines(); + $result = $this->fetch_lines(); if ($result < 0) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -3; } return 1; } else { - $this->error='Invoice with id='.$rowid.' or ref='.$ref.' or ref_ext='.$ref_ext.' not found'; + $this->error = 'Invoice with id='.$rowid.' or ref='.$ref.' or ref_ext='.$ref_ext.' not found'; dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1518,21 +1518,21 @@ class Facture extends CommonInvoice { global $langs, $conf; // phpcs:enable - $this->lines=array(); + $this->lines = array(); $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,'; - $sql.= ' l.situation_percent, l.fk_prev_id,'; - $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; - $sql.= ' l.rang, l.special_code,'; - $sql.= ' l.date_start as date_start, l.date_end as date_end,'; - $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,'; - $sql.= ' l.fk_unit,'; - $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; - $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - $sql.= ' WHERE l.fk_facture = '.$this->id; - $sql.= ' ORDER BY l.rang, l.rowid'; + $sql .= ' l.situation_percent, l.fk_prev_id,'; + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; + $sql .= ' l.rang, l.special_code,'; + $sql .= ' l.date_start as date_start, l.date_end as date_end,'; + $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,'; + $sql .= ' l.fk_unit,'; + $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; + $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; + $sql .= ' WHERE l.fk_facture = '.$this->id; + $sql .= ' ORDER BY l.rang, l.rowid'; dol_syslog(get_class($this).'::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); @@ -1546,22 +1546,22 @@ class Facture extends CommonInvoice $line = new FactureLigne($this->db); $line->id = $objp->rowid; - $line->rowid = $objp->rowid; // deprecated + $line->rowid = $objp->rowid; // deprecated $line->fk_facture = $objp->fk_facture; - $line->label = $objp->custom_label; // deprecated - $line->desc = $objp->description; // Description line - $line->description = $objp->description; // Description line - $line->product_type = $objp->product_type; // Type of line - $line->ref = $objp->product_ref; // Ref product - $line->product_ref = $objp->product_ref; // Ref product - $line->libelle = $objp->product_label; // deprecated - $line->product_label = $objp->product_label; // Label product - $line->product_desc = $objp->product_desc; // Description product - $line->fk_product_type = $objp->fk_product_type; // Type of product + $line->label = $objp->custom_label; // deprecated + $line->desc = $objp->description; // Description line + $line->description = $objp->description; // Description line + $line->product_type = $objp->product_type; // Type of line + $line->ref = $objp->product_ref; // Ref product + $line->product_ref = $objp->product_ref; // Ref product + $line->libelle = $objp->product_label; // deprecated + $line->product_label = $objp->product_label; // Label product + $line->product_desc = $objp->product_desc; // Description product + $line->fk_product_type = $objp->fk_product_type; // Type of product $line->qty = $objp->qty; $line->subprice = $objp->subprice; - $line->vat_src_code = $objp->vat_src_code; + $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; @@ -1581,24 +1581,24 @@ class Facture extends CommonInvoice $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; $line->code_ventilation = $objp->fk_code_ventilation; - $line->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; $line->marge_tx = $marginInfos[1]; $line->marque_tx = $marginInfos[2]; - $line->rang = $objp->rang; - $line->special_code = $objp->special_code; - $line->fk_parent_line = $objp->fk_parent_line; - $line->situation_percent= $objp->situation_percent; + $line->rang = $objp->rang; + $line->special_code = $objp->special_code; + $line->fk_parent_line = $objp->fk_parent_line; + $line->situation_percent = $objp->situation_percent; $line->fk_prev_id = $objp->fk_prev_id; - $line->fk_unit = $objp->fk_unit; + $line->fk_unit = $objp->fk_unit; // Accountancy - $line->fk_accounting_account = $objp->fk_code_ventilation; + $line->fk_accounting_account = $objp->fk_code_ventilation; // Multicurrency - $line->fk_multicurrency = $objp->fk_multicurrency; - $line->multicurrency_code = $objp->multicurrency_code; + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; $line->multicurrency_subprice = $objp->multicurrency_subprice; $line->multicurrency_total_ht = $objp->multicurrency_total_ht; $line->multicurrency_total_tva = $objp->multicurrency_total_tva; @@ -1607,7 +1607,7 @@ class Facture extends CommonInvoice $line->fetch_optionals(); // multilangs - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { $line = new Product($this->db); $line->fetch($objp->fk_product); $line->getMultiLangs(); @@ -1622,7 +1622,7 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -3; } } @@ -1640,10 +1640,10 @@ class Facture extends CommonInvoice $this->tab_next_situation_invoice = array(); $sql = 'SELECT rowid, situation_counter FROM '.MAIN_DB_PREFIX.'facture'; - $sql.= ' WHERE rowid <> '.$this->id; - $sql.= ' AND entity = '.$this->entity; - $sql.= ' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref; - $sql.= ' ORDER BY situation_counter ASC'; + $sql .= ' WHERE rowid <> '.$this->id; + $sql .= ' AND entity = '.$this->entity; + $sql .= ' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref; + $sql .= ' ORDER BY situation_counter ASC'; dol_syslog(get_class($this).'::fetchPreviousNextSituationInvoice ', LOG_DEBUG); $result = $this->db->query($sql); @@ -1680,20 +1680,20 @@ class Facture extends CommonInvoice { global $conf; - $error=0; + $error = 0; // Clean parameters - if (empty($this->type)) $this->type= self::TYPE_STANDARD; - if (isset($this->ref)) $this->ref=trim($this->ref); - if (isset($this->ref_client)) $this->ref_client=trim($this->ref_client); - if (isset($this->increment)) $this->increment=trim($this->increment); - if (isset($this->close_code)) $this->close_code=trim($this->close_code); - if (isset($this->close_note)) $this->close_note=trim($this->close_note); - if (isset($this->note) || isset($this->note_private)) $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated - if (isset($this->note) || isset($this->note_private)) $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note)); - if (isset($this->note_public)) $this->note_public=trim($this->note_public); - if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); - if (isset($this->import_key)) $this->import_key=trim($this->import_key); + if (empty($this->type)) $this->type = self::TYPE_STANDARD; + if (isset($this->ref)) $this->ref = trim($this->ref); + if (isset($this->ref_client)) $this->ref_client = trim($this->ref_client); + if (isset($this->increment)) $this->increment = trim($this->increment); + if (isset($this->close_code)) $this->close_code = trim($this->close_code); + if (isset($this->close_note)) $this->close_note = trim($this->close_note); + if (isset($this->note) || isset($this->note_private)) $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated + if (isset($this->note) || isset($this->note_private)) $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note)); + if (isset($this->note_public)) $this->note_public = trim($this->note_public); + if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); + if (isset($this->import_key)) $this->import_key = trim($this->import_key); if (isset($this->retained_warranty)) $this->retained_warranty = floatval($this->retained_warranty); @@ -1702,67 +1702,67 @@ class Facture extends CommonInvoice // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."facture SET"; - $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; - $sql.= " type=".(isset($this->type)?$this->db->escape($this->type):"null").","; - $sql.= " ref_client=".(isset($this->ref_client)?"'".$this->db->escape($this->ref_client)."'":"null").","; - $sql.= " increment=".(isset($this->increment)?"'".$this->db->escape($this->increment)."'":"null").","; - $sql.= " fk_soc=".(isset($this->socid)?$this->db->escape($this->socid):"null").","; - $sql.= " datec=".(strval($this->date_creation)!='' ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; - $sql.= " datef=".(strval($this->date)!='' ? "'".$this->db->idate($this->date)."'" : 'null').","; - $sql.= " date_pointoftax=".(strval($this->date_pointoftax)!='' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null').","; - $sql.= " date_valid=".(strval($this->date_validation)!='' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; - $sql.= " paye=".(isset($this->paye)?$this->db->escape($this->paye):0).","; - $sql.= " remise_percent=".(isset($this->remise_percent)?$this->db->escape($this->remise_percent):"null").","; - $sql.= " remise_absolue=".(isset($this->remise_absolue)?$this->db->escape($this->remise_absolue):"null").","; - $sql.= " close_code=".(isset($this->close_code)?"'".$this->db->escape($this->close_code)."'":"null").","; - $sql.= " close_note=".(isset($this->close_note)?"'".$this->db->escape($this->close_note)."'":"null").","; - $sql.= " tva=".(isset($this->total_tva)?$this->total_tva:"null").","; - $sql.= " localtax1=".(isset($this->total_localtax1)?$this->total_localtax1:"null").","; - $sql.= " localtax2=".(isset($this->total_localtax2)?$this->total_localtax2:"null").","; - $sql.= " total=".(isset($this->total_ht)?$this->total_ht:"null").","; - $sql.= " total_ttc=".(isset($this->total_ttc)?$this->total_ttc:"null").","; - $sql.= " revenuestamp=".((isset($this->revenuestamp) && $this->revenuestamp != '')?$this->db->escape($this->revenuestamp):"null").","; - $sql.= " fk_statut=".(isset($this->statut)?$this->db->escape($this->statut):"null").","; - $sql.= " fk_user_author=".(isset($this->user_author)?$this->db->escape($this->user_author):"null").","; - $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->db->escape($this->fk_user_valid):"null").","; - $sql.= " fk_facture_source=".(isset($this->fk_facture_source)?$this->db->escape($this->fk_facture_source):"null").","; - $sql.= " fk_projet=".(isset($this->fk_project)?$this->db->escape($this->fk_project):"null").","; - $sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->db->escape($this->cond_reglement_id):"null").","; - $sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->db->escape($this->mode_reglement_id):"null").","; - $sql.= " date_lim_reglement=".(strval($this->date_lim_reglement)!='' ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'null').","; - $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; - $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; - $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; - $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").","; - $sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).","; - $sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).","; - $sql.= " situation_final=".(empty($this->situation_final)?"0":$this->db->escape($this->situation_final)).","; - $sql.= " retained_warranty=".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty)).","; - $sql.= " retained_warranty_date_limit=".(strval($this->retained_warranty_date_limit)!='' ? "'".$this->db->idate($this->retained_warranty_date_limit)."'" : 'null').","; - $sql.= " retained_warranty_fk_cond_reglement=".(isset($this->retained_warranty_fk_cond_reglement)?intval($this->retained_warranty_fk_cond_reglement):"null"); - $sql.= " WHERE rowid=".$this->id; + $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; + $sql .= " type=".(isset($this->type) ? $this->db->escape($this->type) : "null").","; + $sql .= " ref_client=".(isset($this->ref_client) ? "'".$this->db->escape($this->ref_client)."'" : "null").","; + $sql .= " increment=".(isset($this->increment) ? "'".$this->db->escape($this->increment)."'" : "null").","; + $sql .= " fk_soc=".(isset($this->socid) ? $this->db->escape($this->socid) : "null").","; + $sql .= " datec=".(strval($this->date_creation) != '' ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; + $sql .= " datef=".(strval($this->date) != '' ? "'".$this->db->idate($this->date)."'" : 'null').","; + $sql .= " date_pointoftax=".(strval($this->date_pointoftax) != '' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null').","; + $sql .= " date_valid=".(strval($this->date_validation) != '' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; + $sql .= " paye=".(isset($this->paye) ? $this->db->escape($this->paye) : 0).","; + $sql .= " remise_percent=".(isset($this->remise_percent) ? $this->db->escape($this->remise_percent) : "null").","; + $sql .= " remise_absolue=".(isset($this->remise_absolue) ? $this->db->escape($this->remise_absolue) : "null").","; + $sql .= " close_code=".(isset($this->close_code) ? "'".$this->db->escape($this->close_code)."'" : "null").","; + $sql .= " close_note=".(isset($this->close_note) ? "'".$this->db->escape($this->close_note)."'" : "null").","; + $sql .= " tva=".(isset($this->total_tva) ? $this->total_tva : "null").","; + $sql .= " localtax1=".(isset($this->total_localtax1) ? $this->total_localtax1 : "null").","; + $sql .= " localtax2=".(isset($this->total_localtax2) ? $this->total_localtax2 : "null").","; + $sql .= " total=".(isset($this->total_ht) ? $this->total_ht : "null").","; + $sql .= " total_ttc=".(isset($this->total_ttc) ? $this->total_ttc : "null").","; + $sql .= " revenuestamp=".((isset($this->revenuestamp) && $this->revenuestamp != '') ? $this->db->escape($this->revenuestamp) : "null").","; + $sql .= " fk_statut=".(isset($this->statut) ? $this->db->escape($this->statut) : "null").","; + $sql .= " fk_user_author=".(isset($this->user_author) ? $this->db->escape($this->user_author) : "null").","; + $sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? $this->db->escape($this->fk_user_valid) : "null").","; + $sql .= " fk_facture_source=".(isset($this->fk_facture_source) ? $this->db->escape($this->fk_facture_source) : "null").","; + $sql .= " fk_projet=".(isset($this->fk_project) ? $this->db->escape($this->fk_project) : "null").","; + $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->db->escape($this->cond_reglement_id) : "null").","; + $sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->db->escape($this->mode_reglement_id) : "null").","; + $sql .= " date_lim_reglement=".(strval($this->date_lim_reglement) != '' ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'null').","; + $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; + $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; + $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").","; + $sql .= " situation_cycle_ref=".(empty($this->situation_cycle_ref) ? "null" : $this->db->escape($this->situation_cycle_ref)).","; + $sql .= " situation_counter=".(empty($this->situation_counter) ? "null" : $this->db->escape($this->situation_counter)).","; + $sql .= " situation_final=".(empty($this->situation_final) ? "0" : $this->db->escape($this->situation_final)).","; + $sql .= " retained_warranty=".(empty($this->retained_warranty) ? "0" : $this->db->escape($this->retained_warranty)).","; + $sql .= " retained_warranty_date_limit=".(strval($this->retained_warranty_date_limit) != '' ? "'".$this->db->idate($this->retained_warranty_date_limit)."'" : 'null').","; + $sql .= " retained_warranty_fk_cond_reglement=".(isset($this->retained_warranty_fk_cond_reglement) ?intval($this->retained_warranty_fk_cond_reglement) : "null"); + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BILL_MODIFY', $user); + $result = $this->call_trigger('BILL_MODIFY', $user); if ($result < 0) $error++; // End call triggers } @@ -1770,13 +1770,13 @@ class Facture extends CommonInvoice // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -1803,40 +1803,40 @@ class Facture extends CommonInvoice $this->db->begin(); - $remise=new DiscountAbsolute($this->db); - $result=$remise->fetch($idremise); + $remise = new DiscountAbsolute($this->db); + $result = $remise->fetch($idremise); if ($result > 0) { if ($remise->fk_facture) // Protection against multiple submission { - $this->error=$langs->trans("ErrorDiscountAlreadyUsed"); + $this->error = $langs->trans("ErrorDiscountAlreadyUsed"); $this->db->rollback(); return -5; } - $facligne=new FactureLigne($this->db); - $facligne->fk_facture=$this->id; - $facligne->fk_remise_except=$remise->id; - $facligne->desc=$remise->description; // Description ligne - $facligne->vat_src_code=$remise->vat_src_code; - $facligne->tva_tx=$remise->tva_tx; + $facligne = new FactureLigne($this->db); + $facligne->fk_facture = $this->id; + $facligne->fk_remise_except = $remise->id; + $facligne->desc = $remise->description; // Description ligne + $facligne->vat_src_code = $remise->vat_src_code; + $facligne->tva_tx = $remise->tva_tx; $facligne->subprice = -$remise->amount_ht; - $facligne->fk_product=0; // Id produit predefini - $facligne->qty=1; - $facligne->remise_percent=0; - $facligne->rang=-1; - $facligne->info_bits=2; + $facligne->fk_product = 0; // Id produit predefini + $facligne->qty = 1; + $facligne->remise_percent = 0; + $facligne->rang = -1; + $facligne->info_bits = 2; // Get buy/cost price of invoice that is source of discount if ($remise->fk_facture_source > 0) { - $srcinvoice=new Facture($this->db); + $srcinvoice = new Facture($this->db); $srcinvoice->fetch($remise->fk_facture_source); - $totalcostpriceofinvoice=0; - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject - $formmargin=new FormMargin($this->db); - $arraytmp=$formmargin->getMarginInfosArray($srcinvoice, false); + $totalcostpriceofinvoice = 0; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject + $formmargin = new FormMargin($this->db); + $arraytmp = $formmargin->getMarginInfosArray($srcinvoice, false); $facligne->pa_ht = $arraytmp['pa_total']; } @@ -1849,17 +1849,17 @@ class Facture extends CommonInvoice $facligne->multicurrency_total_tva = -$remise->multicurrency_amount_tva; $facligne->multicurrency_total_ttc = -$remise->multicurrency_amount_ttc; - $lineid=$facligne->insert(); + $lineid = $facligne->insert(); if ($lineid > 0) { - $result=$this->update_price(1); + $result = $this->update_price(1); if ($result > 0) { // Create link between discount and invoice line - $result=$remise->link_to_invoice($lineid, 0); + $result = $remise->link_to_invoice($lineid, 0); if ($result < 0) { - $this->error=$remise->error; + $this->error = $remise->error; $this->db->rollback(); return -4; } @@ -1869,14 +1869,14 @@ class Facture extends CommonInvoice } else { - $this->error=$facligne->error; + $this->error = $facligne->error; $this->db->rollback(); return -1; } } else { - $this->error=$facligne->error; + $this->error = $facligne->error; $this->db->rollback(); return -2; } @@ -1901,7 +1901,7 @@ class Facture extends CommonInvoice // phpcs:enable global $user; - $error=0; + $error = 0; $this->db->begin(); @@ -1913,27 +1913,27 @@ class Facture extends CommonInvoice $sql .= ' WHERE rowid = '.$this->id; dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $error) + if (!$error) { $this->ref_client = $ref_client; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('BILL_MODIFY', $user); + $result = $this->call_trigger('BILL_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->ref_client = $ref_client; @@ -1942,13 +1942,13 @@ class Facture extends CommonInvoice } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -1962,10 +1962,10 @@ class Facture extends CommonInvoice */ public function delete($user, $notrigger = 0, $idwarehouse = -1) { - global $langs,$conf; + global $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $rowid=$this->id; + $rowid = $this->id; dol_syslog(get_class($this)."::delete rowid=".$rowid.", ref=".$this->ref.", thirdparty=".$this->thirdparty->name, LOG_DEBUG); @@ -1974,21 +1974,21 @@ class Facture extends CommonInvoice if ($result <= 0) return 0; - $error=0; + $error = 0; $this->db->begin(); - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BILL_DELETE', $user); + $result = $this->call_trigger('BILL_DELETE', $user); if ($result < 0) $error++; // End call triggers } // Removed extrafields - if (! $error) { - $result=$this->deleteExtraFields(); + if (!$error) { + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -1996,52 +1996,52 @@ class Facture extends CommonInvoice } } - if (! $error) + if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; } - if (! $error) + if (!$error) { // If invoice was converted into a discount not yet consumed, we remove discount $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' WHERE fk_facture_source = '.$rowid; - $sql.= ' AND fk_facture_line IS NULL'; - $resql=$this->db->query($sql); + $sql .= ' WHERE fk_facture_source = '.$rowid; + $sql .= ' AND fk_facture_line IS NULL'; + $resql = $this->db->query($sql); // If invoice has consumned discounts $this->fetch_lines(); - $list_rowid_det=array(); - foreach($this->lines as $key => $invoiceline) + $list_rowid_det = array(); + foreach ($this->lines as $key => $invoiceline) { - $list_rowid_det[]=$invoiceline->rowid; + $list_rowid_det[] = $invoiceline->rowid; } // Consumned discounts are freed if (count($list_rowid_det)) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' SET fk_facture = NULL, fk_facture_line = NULL'; - $sql.= ' WHERE fk_facture_line IN ('.join(',', $list_rowid_det).')'; + $sql .= ' SET fk_facture = NULL, fk_facture_line = NULL'; + $sql .= ' WHERE fk_facture_line IN ('.join(',', $list_rowid_det).')'; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -5; } } // If we decrement stock on invoice validation, we increment - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse!=-1) + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse != -1) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); - $num=count($this->lines); + $num = count($this->lines); for ($i = 0; $i < $num; $i++) { if ($this->lines[$i]->fk_product > 0) @@ -2049,8 +2049,8 @@ class Facture extends CommonInvoice $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrease stock for product - 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)); - 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 + 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)); + 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 } } } @@ -2067,33 +2067,33 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { // On efface le repertoire de pdf provisoire $ref = dol_sanitizeFileName($this->ref); if ($conf->facture->dir_output && !empty($this->ref)) { - $dir = $conf->facture->dir_output . "/" . $ref; - $file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf"; + $dir = $conf->facture->dir_output."/".$ref; + $file = $conf->facture->dir_output."/".$ref."/".$ref.".pdf"; if (file_exists($file)) // We must delete all files before deleting directory { - $ret=dol_delete_preview($this); + $ret = dol_delete_preview($this); - if (! dol_delete_file($file, 0, 0, 0, $this)) // For triggers + if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers { $langs->load("errors"); - $this->error=$langs->trans("ErrorFailToDeleteFile", $file); + $this->error = $langs->trans("ErrorFailToDeleteFile", $file); $this->db->rollback(); return 0; } } if (file_exists($dir)) { - if (! dol_delete_dir_recursive($dir)) // For remove dir and meta + if (!dol_delete_dir_recursive($dir)) // For remove dir and meta { $langs->load("errors"); - $this->error=$langs->trans("ErrorFailToDeleteDir", $dir); + $this->error = $langs->trans("ErrorFailToDeleteDir", $dir); $this->db->rollback(); return 0; } @@ -2105,14 +2105,14 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->lasterror()." sql=".$sql; + $this->error = $this->db->lasterror()." sql=".$sql; $this->db->rollback(); return -6; } } else { - $this->error=$this->db->lasterror()." sql=".$sql; + $this->error = $this->db->lasterror()." sql=".$sql; $this->db->rollback(); return -4; } @@ -2137,40 +2137,40 @@ class Facture extends CommonInvoice public function set_paid($user, $close_code = '', $close_note = '') { // phpcs:enable - $error=0; + $error = 0; if ($this->paye != 1) { $this->db->begin(); - $now=dol_now(); + $now = dol_now(); dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; - $sql.= ' fk_statut='.self::STATUS_CLOSED; - if (! $close_code) $sql.= ', paye=1'; - if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; - if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; - $sql.= ', fk_user_closing = '.$user->id; - $sql.= ", date_closing = '".$this->db->idate($now)."'"; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' fk_statut='.self::STATUS_CLOSED; + if (!$close_code) $sql .= ', paye=1'; + if ($close_code) $sql .= ", close_code='".$this->db->escape($close_code)."'"; + if ($close_note) $sql .= ", close_note='".$this->db->escape($close_note)."'"; + $sql .= ', fk_user_closing = '.$user->id; + $sql .= ", date_closing = '".$this->db->idate($now)."'"; + $sql .= ' WHERE rowid = '.$this->id; $resql = $this->db->query($sql); if ($resql) { // Call trigger - $result=$this->call_trigger('BILL_PAYED', $user); + $result = $this->call_trigger('BILL_PAYED', $user); if ($result < 0) $error++; // End call triggers } else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -2200,33 +2200,33 @@ class Facture extends CommonInvoice public function set_unpaid($user) { // phpcs:enable - $error=0; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null,'; - $sql.= ' date_closing=null,'; - $sql.= ' fk_user_closing=null'; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null,'; + $sql .= ' date_closing=null,'; + $sql .= ' fk_user_closing=null'; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_unpaid", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { // Call trigger - $result=$this->call_trigger('BILL_UNPAYED', $user); + $result = $this->call_trigger('BILL_UNPAYED', $user); if ($result < 0) $error++; // End call triggers } else { $error++; - $this->error=$this->db->error(); + $this->error = $this->db->error(); dol_print_error($this->db); } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -2259,10 +2259,10 @@ class Facture extends CommonInvoice $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; - $sql.= ' fk_statut='.self::STATUS_ABANDONED; - if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; - if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' fk_statut='.self::STATUS_ABANDONED; + if ($close_code) $sql .= ", close_code='".$this->db->escape($close_code)."'"; + if ($close_note) $sql .= ", close_note='".$this->db->escape($close_note)."'"; + $sql .= ' WHERE rowid = '.$this->id; $resql = $this->db->query($sql); if ($resql) @@ -2270,14 +2270,14 @@ class Facture extends CommonInvoice // On desaffecte de la facture les remises liees // car elles n'ont pas ete utilisees vu que la facture est abandonnee. $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' SET fk_facture = NULL'; - $sql.= ' WHERE fk_facture = '.$this->id; + $sql .= ' SET fk_facture = NULL'; + $sql .= ' WHERE fk_facture = '.$this->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { // Call trigger - $result=$this->call_trigger('BILL_CANCEL', $user); + $result = $this->call_trigger('BILL_CANCEL', $user); if ($result < 0) { $this->db->rollback(); @@ -2290,14 +2290,14 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -1; } } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -2; } @@ -2315,12 +2315,12 @@ class Facture extends CommonInvoice */ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0) { - global $conf,$langs; + global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $now=dol_now(); + $now = dol_now(); - $error=0; + $error = 0; dol_syslog(get_class($this).'::validate user='.$user->id.', force_number='.$force_number.', idwarehouse='.$idwarehouse); // Force to have object complete for checks @@ -2328,7 +2328,7 @@ class Facture extends CommonInvoice $this->fetch_lines(); // Check parameters - if (! $this->brouillon) + if (!$this->brouillon) { dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING); return 0; @@ -2336,13 +2336,13 @@ class Facture extends CommonInvoice if (count($this->lines) <= 0) { $langs->load("errors"); - $this->error=$langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); + $this->error = $langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); return -1; } if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) { - $this->error='Permission denied'; + $this->error = 'Permission denied'; dol_syslog(get_class($this)."::validate ".$this->error.' MAIN_USE_ADVANCED_PERMS='.$conf->global->MAIN_USE_ADVANCED_PERMS, LOG_ERR); return -1; } @@ -2355,36 +2355,36 @@ class Facture extends CommonInvoice // Controle que facture source connue if ($this->fk_facture_source <= 0) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InvoiceReplacement")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InvoiceReplacement")); $this->db->rollback(); return -10; } // Charge la facture source a remplacer - $facreplaced=new Facture($this->db); - $result=$facreplaced->fetch($this->fk_facture_source); + $facreplaced = new Facture($this->db); + $result = $facreplaced->fetch($this->fk_facture_source); if ($result <= 0) { - $this->error=$langs->trans("ErrorBadInvoice"); + $this->error = $langs->trans("ErrorBadInvoice"); $this->db->rollback(); return -11; } // Controle que facture source non deja remplacee par une autre - $idreplacement=$facreplaced->getIdReplacingInvoice('validated'); + $idreplacement = $facreplaced->getIdReplacingInvoice('validated'); if ($idreplacement && $idreplacement != $this->id) { - $facreplacement=new Facture($this->db); + $facreplacement = new Facture($this->db); $facreplacement->fetch($idreplacement); - $this->error=$langs->trans("ErrorInvoiceAlreadyReplaced", $facreplaced->ref, $facreplacement->ref); + $this->error = $langs->trans("ErrorInvoiceAlreadyReplaced", $facreplaced->ref, $facreplacement->ref); $this->db->rollback(); return -12; } - $result=$facreplaced->set_canceled($user, self::CLOSECODE_REPLACED, ''); + $result = $facreplaced->set_canceled($user, self::CLOSECODE_REPLACED, ''); if ($result < 0) { - $this->error=$facreplaced->error; + $this->error = $facreplaced->error; $this->db->rollback(); return -13; } @@ -2397,10 +2397,10 @@ class Facture extends CommonInvoice } elseif (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life { - if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date + if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date { - $this->date=dol_now(); - $this->date_lim_reglement=$this->calculate_date_lim_reglement(); + $this->date = dol_now(); + $this->date_lim_reglement = $this->calculate_date_lim_reglement(); } $num = $this->getNextNumRef($this->thirdparty); } @@ -2416,41 +2416,41 @@ class Facture extends CommonInvoice // Validate $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= " SET ref='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'"; - if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date + $sql .= " SET ref='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'"; + if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date { - $sql.= ", datef='".$this->db->idate($this->date)."'"; - $sql.= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'"; + $sql .= ", datef='".$this->db->idate($this->date)."'"; + $sql .= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'"; } - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::validate", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { dol_print_error($this->db); $error++; } // On verifie si la facture etait une provisoire - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref))) { // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne } - if (! $error) + if (!$error) { // Define third party as a customer - $result=$this->thirdparty->set_as_client(); + $result = $this->thirdparty->set_as_client(); // Si active on decremente le produit principal et ses composants a la validation de facture - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); // Loop on each line - $cpt=count($this->lines); + $cpt = count($this->lines); for ($i = 0; $i < $cpt; $i++) { if ($this->lines[$i]->fk_product > 0) @@ -2458,8 +2458,8 @@ class Facture extends CommonInvoice $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrease stock for product - 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)); - else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num)); + 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)); + else $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num)); if ($result < 0) { $error++; $this->error = $mouvP->error; @@ -2470,15 +2470,15 @@ class Facture extends CommonInvoice } // Trigger calls - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BILL_VALIDATE', $user); + $result = $this->call_trigger('BILL_VALIDATE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->oldref = $this->ref; @@ -2486,17 +2486,17 @@ class Facture extends CommonInvoice if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'facture/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'facture/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'facture/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'facture/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->facture->dir_output.'/'.$oldref; $dirdest = $conf->facture->dir_output.'/'.$newref; - if (! $error && file_exists($dirsource)) + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); @@ -2504,13 +2504,13 @@ class Facture extends CommonInvoice { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) + $listoffiles = dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); } } @@ -2518,22 +2518,22 @@ class Facture extends CommonInvoice } } - if (! $error && !$this->is_last_in_cycle()) + if (!$error && !$this->is_last_in_cycle()) { - if (! $this->updatePriceNextInvoice($langs)) + if (!$this->updatePriceNextInvoice($langs)) { $error++; } } // Set new ref and define current status - if (! $error) + if (!$error) { $this->ref = $num; - $this->ref=$num; - $this->statut= self::STATUS_VALIDATED; - $this->brouillon=0; - $this->date_validation=$now; + $this->ref = $num; + $this->statut = self::STATUS_VALIDATED; + $this->brouillon = 0; + $this->date_validation = $now; $i = 0; if (!empty($conf->global->INVOICE_USE_SITUATION)) @@ -2557,7 +2557,7 @@ class Facture extends CommonInvoice $error++; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -2620,9 +2620,9 @@ class Facture extends CommonInvoice public function setDraft($user, $idwarehouse = -1) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; - $error=0; + $error = 0; if ($this->statut == self::STATUS_DRAFT) { @@ -2635,24 +2635,24 @@ class Facture extends CommonInvoice $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; - $sql.= " SET fk_statut = ".self::STATUS_DRAFT; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET fk_statut = ".self::STATUS_DRAFT; + $sql .= " WHERE rowid = ".$this->id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; } // Si on decremente le produit principal et ses composants a la validation de facture, on réincrement - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); - $num=count($this->lines); + $num = count($this->lines); for ($i = 0; $i < $num; $i++) { if ($this->lines[$i]->fk_product > 0) @@ -2660,25 +2660,25 @@ class Facture extends CommonInvoice $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrease stock for product - 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)); - 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 + 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)); + 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 } } } if ($error == 0) { - $old_statut=$this->statut; + $old_statut = $this->statut; $this->brouillon = 1; $this->statut = self::STATUS_DRAFT; // Call trigger - $result=$this->call_trigger('BILL_UNVALIDATE', $user); + $result = $this->call_trigger('BILL_UNVALIDATE', $user); if ($result < 0) { $error++; - $this->statut=$old_statut; - $this->brouillon=0; + $this->statut = $old_statut; + $this->brouillon = 0; } // End call triggers } else { @@ -2699,7 +2699,7 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -2777,7 +2777,7 @@ class Facture extends CommonInvoice ) { // Deprecation warning if ($label) { - dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); + dol_syslog(__METHOD__.": using line label is deprecated", LOG_WARNING); //var_dump(debug_backtrace(false));exit; } @@ -2790,37 +2790,37 @@ class Facture extends CommonInvoice include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters - if (empty($remise_percent)) $remise_percent=0; - if (empty($qty)) $qty=0; - if (empty($info_bits)) $info_bits=0; - if (empty($rang)) $rang=0; - if (empty($ventil)) $ventil=0; - if (empty($txtva)) $txtva=0; - if (empty($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2)) $txlocaltax2=0; - if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; + if (empty($remise_percent)) $remise_percent = 0; + if (empty($qty)) $qty = 0; + if (empty($info_bits)) $info_bits = 0; + if (empty($rang)) $rang = 0; + if (empty($ventil)) $ventil = 0; + if (empty($txtva)) $txtva = 0; + if (empty($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2)) $txlocaltax2 = 0; + if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; if (empty($fk_prev_id)) $fk_prev_id = 'null'; - if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; + if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); - $pu_ht=price2num($pu_ht); - $pu_ht_devise=price2num($pu_ht_devise); - $pu_ttc=price2num($pu_ttc); - $pa_ht=price2num($pa_ht); + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + $pu_ht = price2num($pu_ht); + $pu_ht_devise = price2num($pu_ht_devise); + $pu_ttc = price2num($pu_ttc); + $pa_ht = price2num($pa_ht); if (!preg_match('/\((.*)\)/', $txtva)) { - $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' } - $txlocaltax1=price2num($txlocaltax1); - $txlocaltax2=price2num($txlocaltax2); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); - if ($price_base_type=='HT') + if ($price_base_type == 'HT') { - $pu=$pu_ht; + $pu = $pu_ht; } else { - $pu=$pu_ttc; + $pu = $pu_ttc; } // Check parameters @@ -2828,35 +2828,35 @@ class Facture extends CommonInvoice if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + $this->error = $langs->trans('ErrorStartDateGreaterEnd'); return -1; } $this->db->begin(); - $product_type=$type; + $product_type = $type; if (!empty($fk_product)) { - $product=new Product($this->db); - $result=$product->fetch($fk_product); - $product_type=$product->type; + $product = new Product($this->db); + $result = $product->fetch($fk_product); + $product_type = $product->type; - if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { + if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); $this->db->rollback(); return -3; } } - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } // Calcul du total TTC et de la TVA pour la ligne a partir de @@ -2874,7 +2874,7 @@ class Facture extends CommonInvoice $pu_ht = $tabprice[3]; // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; @@ -2888,72 +2888,72 @@ class Facture extends CommonInvoice } // Insert line - $this->line=new FactureLigne($this->db); + $this->line = new FactureLigne($this->db); $this->line->context = $this->context; - $this->line->fk_facture=$this->id; - $this->line->label=$label; // deprecated - $this->line->desc=$desc; + $this->line->fk_facture = $this->id; + $this->line->label = $label; // deprecated + $this->line->desc = $desc; - $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative - $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative + $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise - $this->line->vat_src_code=$vat_src_code; - $this->line->tva_tx=$txtva; - $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0); - $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0); + $this->line->vat_src_code = $vat_src_code; + $this->line->tva_tx = $txtva; + $this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0); + $this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0); $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; - $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 - $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 - $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 - $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 - $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 + $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 + $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 + $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 + $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 + $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 - $this->line->fk_product=$fk_product; - $this->line->product_type=$product_type; - $this->line->remise_percent=$remise_percent; - $this->line->date_start=$date_start; - $this->line->date_end=$date_end; - $this->line->ventil=$ventil; - $this->line->rang=$ranktouse; - $this->line->info_bits=$info_bits; - $this->line->fk_remise_except=$fk_remise_except; + $this->line->fk_product = $fk_product; + $this->line->product_type = $product_type; + $this->line->remise_percent = $remise_percent; + $this->line->date_start = $date_start; + $this->line->date_end = $date_end; + $this->line->ventil = $ventil; + $this->line->rang = $ranktouse; + $this->line->info_bits = $info_bits; + $this->line->fk_remise_except = $fk_remise_except; - $this->line->special_code=$special_code; - $this->line->fk_parent_line=$fk_parent_line; - $this->line->origin=$origin; - $this->line->origin_id=$origin_id; + $this->line->special_code = $special_code; + $this->line->fk_parent_line = $fk_parent_line; + $this->line->origin = $origin; + $this->line->origin_id = $origin_id; $this->line->situation_percent = $situation_percent; $this->line->fk_prev_id = $fk_prev_id; - $this->line->fk_unit=$fk_unit; + $this->line->fk_unit = $fk_unit; // infos marge $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; // Multicurrency - $this->line->fk_multicurrency = $this->fk_multicurrency; - $this->line->multicurrency_code = $this->multicurrency_code; + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - if (is_array($array_options) && count($array_options)>0) { - $this->line->array_options=$array_options; + if (is_array($array_options) && count($array_options) > 0) { + $this->line->array_options = $array_options; } - $result=$this->line->insert(); + $result = $this->line->insert(); if ($result > 0) { // Reorder if child line - if (! empty($fk_parent_line)) $this->line_order(true, 'DESC'); + if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); // Mise a jour informations denormalisees au niveau de la facture meme - $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. + $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. if ($result > 0) { @@ -2962,14 +2962,14 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } } else { - $this->error=$this->line->error; + $this->error = $this->line->error; $this->db->rollback(); return -2; } @@ -3012,15 +3012,15 @@ class Facture extends CommonInvoice */ public 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) { - global $conf,$user; + global $conf, $user; // Deprecation warning if ($label) { - dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); + dol_syslog(__METHOD__.": using line label is deprecated", LOG_WARNING); } include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - global $mysoc,$langs; + global $mysoc, $langs; 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); @@ -3030,29 +3030,29 @@ class Facture extends CommonInvoice { if (!$this->checkProgressLine($rowid, $situation_percent)) { - if (!$this->error) $this->error=$langs->trans('invoiceLineProgressError'); + if (!$this->error) $this->error = $langs->trans('invoiceLineProgressError'); return -3; } } if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + $this->error = $langs->trans('ErrorStartDateGreaterEnd'); return -1; } $this->db->begin(); // Clean parameters - if (empty($qty)) $qty=0; - if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; - if (empty($special_code) || $special_code == 3) $special_code=0; - if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; + if (empty($qty)) $qty = 0; + if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; + if (empty($special_code) || $special_code == 3) $special_code = 0; + if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; - $remise_percent = price2num($remise_percent); + $remise_percent = price2num($remise_percent); $qty = price2num($qty); $pu = price2num($pu); - $pu_ht_devise = price2num($pu_ht_devise); + $pu_ht_devise = price2num($pu_ht_devise); $pa_ht = price2num($pa_ht); $txtva = price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); @@ -3065,29 +3065,29 @@ class Facture extends CommonInvoice // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $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); + $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); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; - $total_localtax1=$tabprice[9]; - $total_localtax2=$tabprice[10]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; $pu_ht = $tabprice[3]; $pu_tva = $tabprice[4]; $pu_ttc = $tabprice[5]; // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; @@ -3100,7 +3100,7 @@ class Facture extends CommonInvoice $remise = round(($pu * $remise_percent / 100), 2); $price = ($pu - $remise); } - $price = price2num($price); + $price = price2num($price); //Fetch current line from the database and then clone the object and set it in $oldline property $line = new FactureLigne($this->db); @@ -3108,13 +3108,13 @@ class Facture extends CommonInvoice if (!empty($line->fk_product)) { - $product=new Product($this->db); - $result=$product->fetch($line->fk_product); - $product_type=$product->type; + $product = new Product($this->db); + $result = $product->fetch($line->fk_product); + $product_type = $product->type; - if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { + if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); $this->db->rollback(); return -3; } @@ -3127,7 +3127,7 @@ class Facture extends CommonInvoice $this->line->context = $this->context; // Reorder if fk_parent_line change - if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) + if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) { $rangmax = $this->line_max($fk_parent_line); $this->line->rang = $rangmax + 1; @@ -3135,32 +3135,32 @@ class Facture extends CommonInvoice $this->line->rowid = $rowid; $this->line->label = $label; - $this->line->desc = $desc; - $this->line->qty = ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative + $this->line->desc = $desc; + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative - $this->line->vat_src_code = $vat_src_code; - $this->line->tva_tx = $txtva; + $this->line->vat_src_code = $vat_src_code; + $this->line->tva_tx = $txtva; $this->line->localtax1_tx = $txlocaltax1; $this->line->localtax2_tx = $txlocaltax2; $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; $this->line->remise_percent = $remise_percent; - $this->line->subprice = ($this->type==2?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise - $this->line->date_start = $date_start; + $this->line->subprice = ($this->type == 2 ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->date_start = $date_start; $this->line->date_end = $date_end; - $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 - $this->line->total_tva = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); + $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 + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva); $this->line->total_localtax1 = $total_localtax1; $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); $this->line->info_bits = $info_bits; $this->line->special_code = $special_code; $this->line->product_type = $type; - $this->line->fk_parent_line = $fk_parent_line; - $this->line->skip_update_total = $skip_update_total; - $this->line->situation_percent = $situation_percent; - $this->line->fk_unit = $fk_unit; + $this->line->fk_parent_line = $fk_parent_line; + $this->line->skip_update_total = $skip_update_total; + $this->line->situation_percent = $situation_percent; + $this->line->fk_unit = $fk_unit; $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; @@ -3171,15 +3171,15 @@ class Facture extends CommonInvoice $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - if (is_array($array_options) && count($array_options)>0) { - $this->line->array_options=$array_options; + if (is_array($array_options) && count($array_options) > 0) { + $this->line->array_options = $array_options; } - $result=$this->line->update($user, $notrigger); + $result = $this->line->update($user, $notrigger); if ($result > 0) { // Reorder if child line - if (! empty($fk_parent_line)) $this->line_order(true, 'DESC'); + if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); // Mise a jour info denormalisees au niveau facture $this->update_price(1); @@ -3188,14 +3188,14 @@ class Facture extends CommonInvoice } else { - $this->error=$this->line->error; + $this->error = $this->line->error; $this->db->rollback(); return -1; } } else { - $this->error="Invoice statut makes operation forbidden"; + $this->error = "Invoice statut makes operation forbidden"; return -2; } } @@ -3215,9 +3215,9 @@ class Facture extends CommonInvoice AND f.fk_statut <> 0'; $result = $this->db->query($sql); - if (! $result) + if (!$result) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return false; } @@ -3238,7 +3238,7 @@ class Facture extends CommonInvoice public function update_percent($line, $percent) { // phpcs:enable - global $mysoc,$user; + global $mysoc, $user; // Progress should never be changed for discount lines if (($line->info_bits & 2) == 2) @@ -3276,9 +3276,9 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG); - if (! $this->brouillon) + if (!$this->brouillon) { - $this->error='ErrorDeleteLineNotAllowedByObjectStatus'; + $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -1; } @@ -3286,29 +3286,29 @@ class Facture extends CommonInvoice // Libere remise liee a ligne de facture $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' SET fk_facture_line = NULL'; - $sql.= ' WHERE fk_facture_line = '.$rowid; + $sql .= ' SET fk_facture_line = NULL'; + $sql .= ' WHERE fk_facture_line = '.$rowid; dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); $result = $this->db->query($sql); - if (! $result) + if (!$result) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } - $line=new FactureLigne($this->db); + $line = new FactureLigne($this->db); $line->context = $this->context; // For triggers $result = $line->fetch($rowid); - if (! ($result > 0)) dol_print_error($this->db, $line->error, $line->errors); + if (!($result > 0)) dol_print_error($this->db, $line->error, $line->errors); if ($line->delete($user) > 0) { - $result=$this->update_price(1); + $result = $this->update_price(1); if ($result > 0) { @@ -3318,14 +3318,14 @@ class Facture extends CommonInvoice else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } else { $this->db->rollback(); - $this->error=$line->error; + $this->error = $line->error; return -1; } } @@ -3343,38 +3343,38 @@ class Facture extends CommonInvoice { // phpcs:enable // Clean parameters - if (empty($remise)) $remise=0; + if (empty($remise)) $remise = 0; if ($user->rights->facture->creer) { - $remise=price2num($remise); + $remise = price2num($remise); - $error=0; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= ' SET remise_percent = '.$remise; - $sql.= ' WHERE rowid = '.$this->id; - $sql.= ' AND fk_statut = '.self::STATUS_DRAFT; + $sql .= ' SET remise_percent = '.$remise; + $sql .= ' WHERE rowid = '.$this->id; + $sql .= ' AND fk_statut = '.self::STATUS_DRAFT; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('BILL_MODIFY', $user); + $result = $this->call_trigger('BILL_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->remise_percent = $remise; $this->update_price(1); @@ -3384,13 +3384,13 @@ class Facture extends CommonInvoice } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } } @@ -3408,58 +3408,58 @@ class Facture extends CommonInvoice public function set_remise_absolue($user, $remise, $notrigger = 0) { // phpcs:enable - if (empty($remise)) $remise=0; + if (empty($remise)) $remise = 0; if ($user->rights->facture->creer) { - $error=0; + $error = 0; $this->db->begin(); - $remise=price2num($remise); + $remise = price2num($remise); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= ' SET remise_absolue = '.$remise; - $sql.= ' WHERE rowid = '.$this->id; - $sql.= ' AND fk_statut = '.self::STATUS_DRAFT; + $sql .= ' SET remise_absolue = '.$remise; + $sql .= ' WHERE rowid = '.$this->id; + $sql .= ' AND fk_statut = '.self::STATUS_DRAFT; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; $this->remise_absolue = $remise; $this->update_price(1); } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('BILL_MODIFY', $user); + $result = $this->call_trigger('BILL_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } } @@ -3478,15 +3478,15 @@ class Facture extends CommonInvoice $langs->load("bills"); // Clean parameters (if not defined or using deprecated value) - if (empty($conf->global->FACTURE_ADDON)) $conf->global->FACTURE_ADDON='mod_facture_terre'; - elseif ($conf->global->FACTURE_ADDON=='terre') $conf->global->FACTURE_ADDON='mod_facture_terre'; - elseif ($conf->global->FACTURE_ADDON=='mercure') $conf->global->FACTURE_ADDON='mod_facture_mercure'; + if (empty($conf->global->FACTURE_ADDON)) $conf->global->FACTURE_ADDON = 'mod_facture_terre'; + elseif ($conf->global->FACTURE_ADDON == 'terre') $conf->global->FACTURE_ADDON = 'mod_facture_terre'; + elseif ($conf->global->FACTURE_ADDON == 'mercure') $conf->global->FACTURE_ADDON = 'mod_facture_mercure'; - if (! empty($conf->global->FACTURE_ADDON)) + if (!empty($conf->global->FACTURE_ADDON)) { dol_syslog("Call getNextNumRef with FACTURE_ADDON = ".$conf->global->FACTURE_ADDON.", thirdparty=".$soc->nom.", type=".$soc->typent_code, LOG_DEBUG); - $mybool=false; + $mybool = false; $file = $conf->global->FACTURE_ADDON.".php"; @@ -3502,12 +3502,12 @@ class Facture extends CommonInvoice // Load file with numbering class (if found) if (is_file($dir.$file) && is_readable($dir.$file)) { - $mybool |= include_once $dir . $file; + $mybool |= include_once $dir.$file; } } // For compatibility - if (! $mybool) + if (!$mybool) { $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; $classname = "mod_facture_".$conf->global->FACTURE_ADDON; @@ -3519,12 +3519,12 @@ class Facture extends CommonInvoice // Load file with numbering class (if found) if (is_file($dir.$file) && is_readable($dir.$file)) { - $mybool |= include_once $dir . $file; + $mybool |= include_once $dir.$file; } } } - if (! $mybool) + if (!$mybool) { dol_print_error('', "Failed to include file ".$file); return ''; @@ -3539,7 +3539,7 @@ class Facture extends CommonInvoice * set up mask. */ if ($mode != 'last' && !$numref) { - $this->error=$obj->error; + $this->error = $obj->error; //dol_print_error($this->db,"Facture::getNextNumRef ".$obj->error); return ""; } @@ -3563,12 +3563,12 @@ class Facture extends CommonInvoice public function info($id) { $sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,'; - $sql.= ' date_closing as dateclosing,'; - $sql.= ' fk_user_author, fk_user_valid, fk_user_closing'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as c'; - $sql.= ' WHERE c.rowid = '.$id; + $sql .= ' date_closing as dateclosing,'; + $sql .= ' fk_user_author, fk_user_valid, fk_user_closing'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as c'; + $sql .= ' WHERE c.rowid = '.$id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -3579,7 +3579,7 @@ class Facture extends CommonInvoice { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) { @@ -3591,7 +3591,7 @@ class Facture extends CommonInvoice { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_closing); - $this->user_closing = $cluser; + $this->user_closing = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); @@ -3625,28 +3625,28 @@ class Facture extends CommonInvoice public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') { // phpcs:enable - global $conf,$user; + global $conf, $user; $ga = array(); $sql = "SELECT s.rowid, s.nom as name, s.client,"; - $sql.= " f.rowid as fid, f.ref as ref, f.datef as df"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.entity IN (".getEntity('invoice').")"; - $sql.= " AND f.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) //restriction + $sql .= " f.rowid as fid, f.ref as ref, f.datef as df"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.entity IN (".getEntity('invoice').")"; + $sql .= " AND f.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) //restriction { - $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } - if ($socid) $sql.= " AND s.rowid = ".$socid; - if ($draft) $sql.= " AND f.fk_statut = ".self::STATUS_DRAFT; - if (is_object($excluser)) $sql.= " AND f.fk_user_author <> ".$excluser->id; - $sql.= $this->db->order($sortfield, $sortorder); - $sql.= $this->db->plimit($limit, $offset); + if ($socid) $sql .= " AND s.rowid = ".$socid; + if ($draft) $sql .= " AND f.fk_statut = ".self::STATUS_DRAFT; + if (is_object($excluser)) $sql .= " AND f.fk_user_author <> ".$excluser->id; + $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->plimit($limit, $offset); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { $numc = $this->db->num_rows($result); @@ -3667,7 +3667,7 @@ class Facture extends CommonInvoice } else { - $ga[$i]['id'] = $obj->fid; + $ga[$i]['id'] = $obj->fid; $ga[$i]['ref'] = $obj->ref; $ga[$i]['name'] = $obj->name; } @@ -3701,25 +3701,25 @@ class Facture extends CommonInvoice $return = array(); $sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut,"; - $sql.= " ff.rowid as rowidnext"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source"; - $sql.= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - $sql.= " AND f.paye = 0"; // Pas classee payee completement - $sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait - $sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement - if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; - $sql.= " ORDER BY f.ref"; + $sql .= " ff.rowid as rowidnext"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source"; + $sql .= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= " AND f.paye = 0"; // Pas classee payee completement + $sql .= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait + $sql .= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement + if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; + $sql .= " ORDER BY f.ref"; dol_syslog(get_class($this)."::list_replacable_invoices", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $return[$obj->rowid]=array( 'id' => $obj->rowid, + $return[$obj->rowid] = array('id' => $obj->rowid, 'ref' => $obj->ref, 'status' => $obj->fk_statut); } @@ -3728,7 +3728,7 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -3752,50 +3752,50 @@ class Facture extends CommonInvoice $sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut, f.type, f.paye, pf.fk_paiement"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")"; - $sql.= " WHERE f.entity IN (".getEntity('invoice').")"; - $sql.= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")"; + $sql .= " WHERE f.entity IN (".getEntity('invoice').")"; + $sql .= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; // $sql.= " WHERE f.fk_statut >= 1"; // $sql.= " AND (f.paye = 1"; // Classee payee completement // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement - $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement - $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir + $sql .= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement + $sql .= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir - if (! empty($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE)) { + if (!empty($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE)) { // Select the last situation invoice $sqlSit = 'SELECT MAX(fs.rowid)'; - $sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs"; - $sqlSit.= " WHERE fs.entity IN (".getEntity('invoice').")"; - $sqlSit.= " AND fs.type = ".self::TYPE_SITUATION; - $sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; - $sqlSit.= " GROUP BY fs.situation_cycle_ref"; - $sqlSit.= " ORDER BY fs.situation_counter"; - $sql.= " AND ( f.type != ".self::TYPE_SITUATION . " OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir + $sqlSit .= " FROM ".MAIN_DB_PREFIX."facture as fs"; + $sqlSit .= " WHERE fs.entity IN (".getEntity('invoice').")"; + $sqlSit .= " AND fs.type = ".self::TYPE_SITUATION; + $sqlSit .= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; + $sqlSit .= " GROUP BY fs.situation_cycle_ref"; + $sqlSit .= " ORDER BY fs.situation_counter"; + $sql .= " AND ( f.type != ".self::TYPE_SITUATION." OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir } else { - $sql.= " AND f.type != ".self::TYPE_SITUATION ; // Type non 5 si facture non avoir + $sql .= " AND f.type != ".self::TYPE_SITUATION; // Type non 5 si facture non avoir } - if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; - $sql.= " ORDER BY f.ref"; + if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; + $sql .= " ORDER BY f.ref"; dol_syslog(get_class($this)."::list_qualified_avoir_invoices", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $qualified=0; - if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified=1; - if ($obj->fk_statut == self::STATUS_CLOSED) $qualified=1; + $qualified = 0; + if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified = 1; + if ($obj->fk_statut == self::STATUS_CLOSED) $qualified = 1; if ($qualified) { //$ref=$obj->ref; - $paymentornot=($obj->fk_paiement?1:0); - $return[$obj->rowid]=array('ref'=>$obj->ref,'status'=>$obj->fk_statut,'type'=>$obj->type,'paye'=>$obj->paye,'paymentornot'=>$paymentornot); + $paymentornot = ($obj->fk_paiement ? 1 : 0); + $return[$obj->rowid] = array('ref'=>$obj->ref, 'status'=>$obj->fk_statut, 'type'=>$obj->type, 'paye'=>$obj->paye, 'paymentornot'=>$paymentornot); } } @@ -3803,7 +3803,7 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -3822,31 +3822,31 @@ class Facture extends CommonInvoice { // phpcs:enable - $error=0; + $error = 0; dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); if ($this->statut > self::STATUS_DRAFT && $this->paye == 0) { - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $bac = new CompanyBankAccount($this->db); $bac->fetch(0, $this->socid); $sql = 'SELECT count(*)'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; - $sql.= ' WHERE fk_facture = '.$this->id; - $sql.= ' AND traite = 0'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; + $sql .= ' WHERE fk_facture = '.$this->id; + $sql .= ' AND traite = 0'; dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $row = $this->db->fetch_row($resql); if ($row[0] == 0) { - $now=dol_now(); + $now = dol_now(); - $totalpaye = $this->getSommePaiement(); + $totalpaye = $this->getSommePaiement(); $totalcreditnotes = $this->getSumCreditNotesUsed(); $totaldeposits = $this->getSumDepositsUsed(); //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; @@ -3871,28 +3871,28 @@ class Facture extends CommonInvoice $sql .= ",'".$bac->cle_rib."')"; dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::demandeprelevement Erreur'); $error++; } } else { - $this->error='WithdrawRequestErrorNilAmount'; + $this->error = 'WithdrawRequestErrorNilAmount'; dol_syslog(get_class($this).'::demandeprelevement WithdrawRequestErrorNilAmount'); $error++; } - if (! $error) + if (!$error) { // Force payment mode of invoice to withdraw $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1); if ($payment_mode_id > 0) { - $result=$this->setPaymentMethods($payment_mode_id); + $result = $this->setPaymentMethods($payment_mode_id); } } @@ -3901,21 +3901,21 @@ class Facture extends CommonInvoice } else { - $this->error="A request already exists"; + $this->error = "A request already exists"; dol_syslog(get_class($this).'::demandeprelevement Impossible de creer une demande, demande deja en cours'); return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); dol_syslog(get_class($this).'::demandeprelevement Erreur -2'); return -2; } } else { - $this->error="Status of invoice does not allow this"; + $this->error = "Status of invoice does not allow this"; dol_syslog(get_class($this)."::demandeprelevement ".$this->error." $this->statut, $this->paye, $this->mode_reglement_id"); return -3; } @@ -3935,13 +3935,13 @@ class Facture extends CommonInvoice $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; $sql .= ' WHERE rowid = '.$did; $sql .= ' AND traite = 0'; - if ( $this->db->query($sql) ) + if ($this->db->query($sql)) { return 0; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::demande_prelevement_delete Error '.$this->error); return -1; } @@ -3963,34 +3963,34 @@ class Facture extends CommonInvoice $clause = " WHERE"; $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut, f.total"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".$user->id; $clause = " AND"; } - $sql.= $clause." f.paye=0"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - $sql.= " AND f.fk_statut = ".self::STATUS_VALIDATED; - if ($user->socid) $sql.= " AND f.fk_soc = ".$user->socid; + $sql .= $clause." f.paye=0"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= " AND f.fk_statut = ".self::STATUS_VALIDATED; + if ($user->socid) $sql .= " AND f.fk_soc = ".$user->socid; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $langs->load("bills"); - $now=dol_now(); + $now = dol_now(); $response = new WorkboardResponse(); - $response->warning_delay=$conf->facture->client->warning_delay/60/60/24; - $response->label=$langs->trans("CustomerBillsUnpaid"); - $response->labelShort=$langs->trans("Unpaid"); - $response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=billing&leftmenu=customers_bills'; - $response->img=img_object('', "bill"); + $response->warning_delay = $conf->facture->client->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("CustomerBillsUnpaid"); + $response->labelShort = $langs->trans("Unpaid"); + $response->url = DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=billing&leftmenu=customers_bills'; + $response->img = img_object('', "bill"); $generic_facture = new Facture($this->db); - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { $generic_facture->date_lim_reglement = $this->db->jdate($obj->datefin); $generic_facture->statut = $obj->fk_statut; @@ -4008,7 +4008,7 @@ class Facture extends CommonInvoice else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -4049,16 +4049,16 @@ class Facture extends CommonInvoice { global $langs; - $now=dol_now(); - $arraynow=dol_getdate($now); - $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); + $now = dol_now(); + $arraynow = dol_getdate($now); + $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); // Load array of products prodids $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { @@ -4073,27 +4073,27 @@ class Facture extends CommonInvoice } //Avoid php warning Warning: mt_rand(): max(0) is smaller than min(1) when no product exists if (empty($num_prods)) { - $num_prods=1; + $num_prods = 1; } // Initialize parameters - $this->id=0; + $this->id = 0; $this->entity = 1; $this->ref = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->socid = 1; $this->date = $nownotime; - $this->date_lim_reglement = $nownotime + 3600 * 24 *30; + $this->date_lim_reglement = $nownotime + 3600 * 24 * 30; $this->cond_reglement_id = 1; $this->cond_reglement_code = 'RECEP'; - $this->date_lim_reglement=$this->calculate_date_lim_reglement(); - $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR - $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR - $this->note_public='This is a comment (public)'; - $this->note_private='This is a comment (private)'; - $this->note='This is a comment (private)'; - $this->fk_incoterms=0; - $this->location_incoterms=''; + $this->date_lim_reglement = $this->calculate_date_lim_reglement(); + $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR + $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR + $this->note_public = 'This is a comment (public)'; + $this->note_private = 'This is a comment (private)'; + $this->note = 'This is a comment (private)'; + $this->fk_incoterms = 0; + $this->location_incoterms = ''; if (empty($option) || $option != 'nolines') { @@ -4102,63 +4102,63 @@ class Facture extends CommonInvoice $xnbp = 0; while ($xnbp < $nbp) { - $line=new FactureLigne($this->db); - $line->desc=$langs->trans("Description")." ".$xnbp; - $line->qty=1; - $line->subprice=100; - $line->tva_tx=19.6; - $line->localtax1_tx=0; - $line->localtax2_tx=0; - $line->remise_percent=0; + $line = new FactureLigne($this->db); + $line->desc = $langs->trans("Description")." ".$xnbp; + $line->qty = 1; + $line->subprice = 100; + $line->tva_tx = 19.6; + $line->localtax1_tx = 0; + $line->localtax2_tx = 0; + $line->remise_percent = 0; if ($xnbp == 1) // Qty is negative (product line) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->qty=-1; - $line->total_ht=-100; - $line->total_ttc=-119.6; - $line->total_tva=-19.6; - $line->multicurrency_total_ht=-200; - $line->multicurrency_total_ttc=-239.2; - $line->multicurrency_total_tva=-39.2; + $line->fk_product = $prodids[$prodid]; + $line->qty = -1; + $line->total_ht = -100; + $line->total_ttc = -119.6; + $line->total_tva = -19.6; + $line->multicurrency_total_ht = -200; + $line->multicurrency_total_ttc = -239.2; + $line->multicurrency_total_tva = -39.2; } elseif ($xnbp == 2) // UP is negative (free line) { - $line->subprice=-100; - $line->total_ht=-100; - $line->total_ttc=-119.6; - $line->total_tva=-19.6; - $line->remise_percent=0; - $line->multicurrency_total_ht=-200; - $line->multicurrency_total_ttc=-239.2; - $line->multicurrency_total_tva=-39.2; + $line->subprice = -100; + $line->total_ht = -100; + $line->total_ttc = -119.6; + $line->total_tva = -19.6; + $line->remise_percent = 0; + $line->multicurrency_total_ht = -200; + $line->multicurrency_total_ttc = -239.2; + $line->multicurrency_total_tva = -39.2; } elseif ($xnbp == 3) // Discount is 50% (product line) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->total_ht=50; - $line->total_ttc=59.8; - $line->total_tva=9.8; - $line->multicurrency_total_ht=100; - $line->multicurrency_total_ttc=119.6; - $line->multicurrency_total_tva=19.6; - $line->remise_percent=50; + $line->fk_product = $prodids[$prodid]; + $line->total_ht = 50; + $line->total_ttc = 59.8; + $line->total_tva = 9.8; + $line->multicurrency_total_ht = 100; + $line->multicurrency_total_ttc = 119.6; + $line->multicurrency_total_tva = 19.6; + $line->remise_percent = 50; } else // (product line) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->total_ht=100; - $line->total_ttc=119.6; - $line->total_tva=19.6; - $line->multicurrency_total_ht=200; - $line->multicurrency_total_ttc=239.2; - $line->multicurrency_total_tva=39.2; - $line->remise_percent=0; + $line->fk_product = $prodids[$prodid]; + $line->total_ht = 100; + $line->total_ttc = 119.6; + $line->total_tva = 19.6; + $line->multicurrency_total_ht = 200; + $line->multicurrency_total_ttc = 239.2; + $line->multicurrency_total_tva = 39.2; + $line->remise_percent = 0; } - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; $this->total_ht += $line->total_ht; @@ -4174,24 +4174,24 @@ class Facture extends CommonInvoice $this->revenuestamp = 0; // Add a line "offered" - $line=new FactureLigne($this->db); - $line->desc=$langs->trans("Description")." (offered line)"; - $line->qty=1; - $line->subprice=100; - $line->tva_tx=19.6; - $line->localtax1_tx=0; - $line->localtax2_tx=0; - $line->remise_percent=100; - $line->total_ht=0; - $line->total_ttc=0; // 90 * 1.196 - $line->total_tva=0; - $line->multicurrency_total_ht=0; - $line->multicurrency_total_ttc=0; - $line->multicurrency_total_tva=0; + $line = new FactureLigne($this->db); + $line->desc = $langs->trans("Description")." (offered line)"; + $line->qty = 1; + $line->subprice = 100; + $line->tva_tx = 19.6; + $line->localtax1_tx = 0; + $line->localtax2_tx = 0; + $line->remise_percent = 100; + $line->total_ht = 0; + $line->total_ttc = 0; // 90 * 1.196 + $line->total_tva = 0; + $line->multicurrency_total_ht = 0; + $line->multicurrency_total_ttc = 0; + $line->multicurrency_total_tva = 0; $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; + $line->fk_product = $prodids[$prodid]; - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; $xnbp++; } } @@ -4207,27 +4207,27 @@ class Facture extends CommonInvoice // phpcs:enable global $conf, $user; - $this->nb=array(); + $this->nb = array(); $clause = "WHERE"; $sql = "SELECT count(f.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".$user->id; $clause = "AND"; } - $sql.= " ".$clause." f.entity IN (".getEntity('invoice').")"; + $sql .= " ".$clause." f.entity IN (".getEntity('invoice').")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["invoices"]=$obj->nb; + $this->nb["invoices"] = $obj->nb; } $this->db->free($resql); return 1; @@ -4235,7 +4235,7 @@ class Facture extends CommonInvoice else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -4263,20 +4263,20 @@ class Facture extends CommonInvoice */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("bills"); - if (! dol_strlen($modele)) + if (!dol_strlen($modele)) { $modele = 'crabe'; $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$this->type; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->$thisTypeConfName)) { + } elseif (!empty($conf->global->$thisTypeConfName)) { $modele = $conf->global->$thisTypeConfName; - } elseif (! empty($conf->global->FACTURE_ADDON_PDF)) { + } elseif (!empty($conf->global->FACTURE_ADDON_PDF)) { $modele = $conf->global->FACTURE_ADDON_PDF; } } @@ -4293,8 +4293,8 @@ class Facture extends CommonInvoice */ public function newCycle() { - $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f'; - $sql.= " WHERE f.entity IN (".getEntity('invoice', 0).")"; + $sql = 'SELECT max(situation_cycle_ref) FROM '.MAIN_DB_PREFIX.'facture as f'; + $sql .= " WHERE f.entity IN (".getEntity('invoice', 0).")"; $resql = $this->db->query($sql); if ($resql) { if ($resql->num_rows > 0) @@ -4309,7 +4309,7 @@ class Facture extends CommonInvoice return $ref; } else { $this->error = $this->db->lasterror(); - dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); + dol_syslog("Error sql=".$sql.", error=".$this->error, LOG_ERR); return -1; } } @@ -4337,10 +4337,10 @@ class Facture extends CommonInvoice // phpcs:enable global $conf; - $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture'; - $sql .= ' WHERE situation_cycle_ref = ' . $this->situation_cycle_ref; - $sql .= ' AND situation_counter < ' . $this->situation_counter; - $sql .= ' AND entity = '. ($this->entity > 0 ? $this->entity : $conf->entity); + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture'; + $sql .= ' WHERE situation_cycle_ref = '.$this->situation_cycle_ref; + $sql .= ' AND situation_counter < '.$this->situation_counter; + $sql .= ' AND entity = '.($this->entity > 0 ? $this->entity : $conf->entity); $resql = $this->db->query($sql); $res = array(); if ($resql && $resql->num_rows > 0) { @@ -4352,7 +4352,7 @@ class Facture extends CommonInvoice } } else { $this->error = $this->db->error(); - dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); + dol_syslog("Error sql=".$sql.", error=".$this->error, LOG_ERR); return -1; } @@ -4368,42 +4368,42 @@ class Facture extends CommonInvoice */ public function setFinal(User $user, $notrigger = 0) { - $error=0; + $error = 0; $this->db->begin(); - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET situation_final = '.$this->situation_final.' where rowid = '.$this->id; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('BILL_MODIFY', $user); + $result = $this->call_trigger('BILL_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -4420,9 +4420,9 @@ class Facture extends CommonInvoice if (!empty($this->situation_cycle_ref)) { // No point in testing anything if we're not inside a cycle - $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture'; - $sql.= ' WHERE situation_cycle_ref = ' . $this->situation_cycle_ref; - $sql.= ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity); + $sql = 'SELECT max(situation_counter) FROM '.MAIN_DB_PREFIX.'facture'; + $sql .= ' WHERE situation_cycle_ref = '.$this->situation_cycle_ref; + $sql .= ' AND entity = '.($this->entity > 0 ? $this->entity : $conf->entity); $resql = $this->db->query($sql); if ($resql && $resql->num_rows > 0) { @@ -4431,7 +4431,7 @@ class Facture extends CommonInvoice return ($last == $this->situation_counter); } else { $this->error = $this->db->lasterror(); - dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::select Error ".$this->error, LOG_ERR); return false; } } else { @@ -4479,40 +4479,40 @@ class Facture extends CommonInvoice */ public function getRetainedWarrantyAmount() { - if(empty($this->retained_warranty) ){ + if (empty($this->retained_warranty)) { return -1; } $retainedWarrantyAmount = 0; // Billed - retained warranty - if($this->type == Facture::TYPE_SITUATION) + if ($this->type == Facture::TYPE_SITUATION) { $displayWarranty = true; // Check if this situation invoice is 100% for real - if(!empty($this->lines)){ - foreach($this->lines as $i => $line){ - if($line->product_type < 2 && $line->situation_percent < 100){ + if (!empty($this->lines)) { + foreach ($this->lines as $i => $line) { + if ($line->product_type < 2 && $line->situation_percent < 100) { $displayWarranty = false; break; } } } - if($displayWarranty && !empty($this->situation_final)) + if ($displayWarranty && !empty($this->situation_final)) { $this->fetchPreviousNextSituationInvoice(); $TPreviousIncoice = $this->tab_previous_situation_invoice; $total2BillWT = 0; - foreach ($TPreviousIncoice as &$fac){ + foreach ($TPreviousIncoice as &$fac) { $total2BillWT += $fac->total_ttc; } $total2BillWT += $this->total_ttc; $retainedWarrantyAmount = $total2BillWT * $this->retained_warranty / 100; } - else{ + else { return -1; } } @@ -4549,14 +4549,14 @@ class Facture extends CommonInvoice else { dol_syslog(get_class($this).'::setRetainedWarranty Erreur '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } else { dol_syslog(get_class($this).'::setRetainedWarranty, status of the object is incompatible'); - $this->error='Status of the object is incompatible '.$this->statut; + $this->error = 'Status of the object is incompatible '.$this->statut; return -2; } } @@ -4571,7 +4571,7 @@ class Facture extends CommonInvoice */ public function setRetainedWarrantyDateLimit($timestamp, $dateYmd = false) { - if(!$timestamp && $dateYmd){ + if (!$timestamp && $dateYmd) { $timestamp = $this->db->jdate($dateYmd); } @@ -4581,7 +4581,7 @@ class Facture extends CommonInvoice { $fieldname = 'retained_warranty_date_limit'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.(strval($timestamp)!='' ? '\'' .$this->db->idate($timestamp).'\'' : 'null' ); + $sql .= ' SET '.$fieldname.' = '.(strval($timestamp) != '' ? '\''.$this->db->idate($timestamp).'\'' : 'null'); $sql .= ' WHERE rowid='.$this->id; if ($this->db->query($sql)) @@ -4592,14 +4592,14 @@ class Facture extends CommonInvoice else { dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit Erreur '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } else { dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit, status of the object is incompatible'); - $this->error='Status of the object is incompatible '.$this->statut; + $this->error = 'Status of the object is incompatible '.$this->statut; return -2; } } @@ -4614,12 +4614,12 @@ class FactureLigne extends CommonInvoiceLine /** * @var string ID to identify managed object */ - public $element='facturedet'; + public $element = 'facturedet'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='facturedet'; + public $table_element = 'facturedet'; public $oldline; @@ -4635,9 +4635,9 @@ class FactureLigne extends CommonInvoiceLine //! Description ligne public $desc; - public $localtax1_type; // Local tax 1 type - public $localtax2_type; // Local tax 2 type - public $fk_remise_except; // Link to line into llx_remise_except + public $localtax1_type; // Local tax 1 type + public $localtax2_type; // Local tax 2 type + public $fk_remise_except; // Link to line into llx_remise_except public $rang = 0; public $fk_fournprice; @@ -4647,7 +4647,7 @@ class FactureLigne extends CommonInvoiceLine public $remise_percent; - public $special_code; // Liste d'options non cumulabels: + public $special_code; // Liste d'options non cumulabels: // 1: frais de port // 2: ecotaxe // 3: ?? @@ -4665,15 +4665,15 @@ class FactureLigne extends CommonInvoiceLine * @deprecated * @see $product_ref */ - public $ref; // Product ref (deprecated) - public $product_ref; // Product ref + public $ref; // Product ref (deprecated) + public $product_ref; // Product ref /** * @deprecated * @see $product_label */ - public $libelle; // Product label (deprecated) - public $product_label; // Product label - public $product_desc; // Description produit + public $libelle; // Product label (deprecated) + public $product_label; // Product label + public $product_desc; // Description produit public $skip_update_total; // Skip update price total for special lines @@ -4704,76 +4704,76 @@ class FactureLigne extends CommonInvoiceLine public function fetch($rowid) { $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,'; - $sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; - $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,'; - $sql.= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; - $sql.= ' fd.fk_code_ventilation,'; - $sql.= ' fd.fk_unit, fd.fk_user_author, fd.fk_user_modif,'; - $sql.= ' fd.situation_percent, fd.fk_prev_id,'; - $sql.= ' fd.multicurrency_subprice,'; - $sql.= ' fd.multicurrency_total_ht,'; - $sql.= ' fd.multicurrency_total_tva,'; - $sql.= ' fd.multicurrency_total_ttc,'; - $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid'; - $sql.= ' WHERE fd.rowid = '.$rowid; + $sql .= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; + $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,'; + $sql .= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; + $sql .= ' fd.fk_code_ventilation,'; + $sql .= ' fd.fk_unit, fd.fk_user_author, fd.fk_user_modif,'; + $sql .= ' fd.situation_percent, fd.fk_prev_id,'; + $sql .= ' fd.multicurrency_subprice,'; + $sql .= ' fd.multicurrency_total_ht,'; + $sql .= ' fd.multicurrency_total_tva,'; + $sql .= ' fd.multicurrency_total_ttc,'; + $sql .= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid'; + $sql .= ' WHERE fd.rowid = '.$rowid; $result = $this->db->query($sql); if ($result) { $objp = $this->db->fetch_object($result); - $this->rowid = $objp->rowid; - $this->id = $objp->rowid; - $this->fk_facture = $objp->fk_facture; - $this->fk_parent_line = $objp->fk_parent_line; + $this->rowid = $objp->rowid; + $this->id = $objp->rowid; + $this->fk_facture = $objp->fk_facture; + $this->fk_parent_line = $objp->fk_parent_line; $this->label = $objp->custom_label; $this->desc = $objp->description; - $this->qty = $objp->qty; - $this->subprice = $objp->subprice; - $this->vat_src_code = $objp->vat_src_code; - $this->tva_tx = $objp->tva_tx; + $this->qty = $objp->qty; + $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; + $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; $this->localtax2_tx = $objp->localtax2_tx; - $this->remise_percent = $objp->remise_percent; - $this->fk_remise_except = $objp->fk_remise_except; + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; $this->fk_product = $objp->fk_product; - $this->product_type = $objp->product_type; + $this->product_type = $objp->product_type; $this->date_start = $this->db->jdate($objp->date_start); $this->date_end = $this->db->jdate($objp->date_end); $this->info_bits = $objp->info_bits; - $this->tva_npr = ($objp->info_bits & 1 == 1) ? 1 : 0; - $this->special_code = $objp->special_code; + $this->tva_npr = ($objp->info_bits & 1 == 1) ? 1 : 0; + $this->special_code = $objp->special_code; $this->total_ht = $objp->total_ht; $this->total_tva = $objp->total_tva; $this->total_localtax1 = $objp->total_localtax1; $this->total_localtax2 = $objp->total_localtax2; $this->total_ttc = $objp->total_ttc; - $this->fk_code_ventilation = $objp->fk_code_ventilation; + $this->fk_code_ventilation = $objp->fk_code_ventilation; $this->rang = $objp->rang; - $this->fk_fournprice = $objp->fk_fournprice; + $this->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); $this->pa_ht = $marginInfos[0]; $this->marge_tx = $marginInfos[1]; $this->marque_tx = $marginInfos[2]; - $this->ref = $objp->product_ref; // deprecated - $this->product_ref = $objp->product_ref; - $this->libelle = $objp->product_libelle; // deprecated + $this->ref = $objp->product_ref; // deprecated + $this->product_ref = $objp->product_ref; + $this->libelle = $objp->product_libelle; // deprecated $this->product_label = $objp->product_libelle; $this->product_desc = $objp->product_desc; $this->fk_unit = $objp->fk_unit; $this->fk_user_modif = $objp->fk_user_modif; - $this->fk_user_author = $objp->fk_user_author; + $this->fk_user_author = $objp->fk_user_author; $this->situation_percent = $objp->situation_percent; $this->fk_prev_id = $objp->fk_prev_id; $this->multicurrency_subprice = $objp->multicurrency_subprice; $this->multicurrency_total_ht = $objp->multicurrency_total_ht; - $this->multicurrency_total_tva= $objp->multicurrency_total_tva; - $this->multicurrency_total_ttc= $objp->multicurrency_total_ttc; + $this->multicurrency_total_tva = $objp->multicurrency_total_tva; + $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; $this->db->free($result); @@ -4795,37 +4795,37 @@ class FactureLigne extends CommonInvoiceLine */ public function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0) { - global $langs,$user,$conf; + global $langs, $user, $conf; - $error=0; + $error = 0; $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'. dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG); // Clean parameters - $this->desc=trim($this->desc); - if (empty($this->tva_tx)) $this->tva_tx=0; - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; - if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->rang)) $this->rang=0; - if (empty($this->remise_percent)) $this->remise_percent=0; - if (empty($this->info_bits)) $this->info_bits=0; - if (empty($this->subprice)) $this->subprice=0; - if (empty($this->special_code)) $this->special_code=0; - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; + $this->desc = trim($this->desc); + if (empty($this->tva_tx)) $this->tva_tx = 0; + if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; + if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; + if (empty($this->localtax1_type)) $this->localtax1_type = 0; + if (empty($this->localtax2_type)) $this->localtax2_type = 0; + if (empty($this->total_localtax1)) $this->total_localtax1 = 0; + if (empty($this->total_localtax2)) $this->total_localtax2 = 0; + if (empty($this->rang)) $this->rang = 0; + if (empty($this->remise_percent)) $this->remise_percent = 0; + if (empty($this->info_bits)) $this->info_bits = 0; + if (empty($this->subprice)) $this->subprice = 0; + if (empty($this->special_code)) $this->special_code = 0; + if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; if (empty($this->fk_prev_id)) $this->fk_prev_id = 0; - if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; + if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; - if (empty($this->pa_ht)) $this->pa_ht=0; - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; + if (empty($this->pa_ht)) $this->pa_ht = 0; + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) @@ -4843,16 +4843,16 @@ class FactureLigne extends CommonInvoiceLine // Check parameters if ($this->product_type < 0) { - $this->error='ErrorProductTypeMustBe0orMore'; + $this->error = 'ErrorProductTypeMustBe0orMore'; return -1; } - if (! empty($this->fk_product)) + if (!empty($this->fk_product)) { // Check product exists - $result=Product::isExistingObject('product', $this->fk_product); + $result = Product::isExistingObject('product', $this->fk_product); if ($result <= 0) { - $this->error='ErrorProductIdDoesNotExists'; + $this->error = 'ErrorProductIdDoesNotExists'; dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); return -1; } @@ -4862,68 +4862,68 @@ class FactureLigne extends CommonInvoiceLine // Insertion dans base de la ligne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet'; - $sql.= ' (fk_facture, fk_parent_line, label, description, qty,'; - $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; - $sql.= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; - $sql.= ' date_start, date_end, fk_code_ventilation, '; - $sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; - $sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; - $sql.= ' situation_percent, fk_prev_id,'; - $sql.= ' fk_unit, fk_user_author, fk_user_modif,'; - $sql.= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; - $sql.= ')'; - $sql.= " VALUES (".$this->fk_facture.","; - $sql.= " ".($this->fk_parent_line>0 ? $this->fk_parent_line:"null").","; - $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; - $sql.= " '".$this->db->escape($this->desc)."',"; - $sql.= " ".price2num($this->qty).","; - $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").","; - $sql.= " ".price2num($this->tva_tx).","; - $sql.= " ".price2num($this->localtax1_tx).","; - $sql.= " ".price2num($this->localtax2_tx).","; - $sql.= " '".$this->db->escape($this->localtax1_type)."',"; - $sql.= " '".$this->db->escape($this->localtax2_type)."',"; - $sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").','; - $sql.= " ".((int) $this->product_type).","; - $sql.= " ".price2num($this->remise_percent).","; - $sql.= " ".price2num($this->subprice).","; - $sql.= ' '.(! empty($this->fk_remise_except)?$this->fk_remise_except:"null").','; - $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").","; - $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").","; - $sql.= ' '.$this->fk_code_ventilation.','; - $sql.= ' '.$this->rang.','; - $sql.= ' '.$this->special_code.','; - $sql.= ' '.(! empty($this->fk_fournprice)?$this->fk_fournprice:"null").','; - $sql.= ' '.price2num($this->pa_ht).','; - $sql.= " '".$this->db->escape($this->info_bits)."',"; - $sql.= " ".price2num($this->total_ht).","; - $sql.= " ".price2num($this->total_tva).","; - $sql.= " ".price2num($this->total_ttc).","; - $sql.= " ".price2num($this->total_localtax1).","; - $sql.= " ".price2num($this->total_localtax2); - $sql.= ", " . $this->situation_percent; - $sql.= ", " . (!empty($this->fk_prev_id)?$this->fk_prev_id:"null"); - $sql.= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= ", ".$user->id; - $sql.= ", ".$user->id; - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".price2num($this->multicurrency_subprice); - $sql.= ", ".price2num($this->multicurrency_total_ht); - $sql.= ", ".price2num($this->multicurrency_total_tva); - $sql.= ", ".price2num($this->multicurrency_total_ttc); - $sql.= ')'; + $sql .= ' (fk_facture, fk_parent_line, label, description, qty,'; + $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; + $sql .= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; + $sql .= ' date_start, date_end, fk_code_ventilation, '; + $sql .= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; + $sql .= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; + $sql .= ' situation_percent, fk_prev_id,'; + $sql .= ' fk_unit, fk_user_author, fk_user_modif,'; + $sql .= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; + $sql .= ')'; + $sql .= " VALUES (".$this->fk_facture.","; + $sql .= " ".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null").","; + $sql .= " ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; + $sql .= " '".$this->db->escape($this->desc)."',"; + $sql .= " ".price2num($this->qty).","; + $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").","; + $sql .= " ".price2num($this->tva_tx).","; + $sql .= " ".price2num($this->localtax1_tx).","; + $sql .= " ".price2num($this->localtax2_tx).","; + $sql .= " '".$this->db->escape($this->localtax1_type)."',"; + $sql .= " '".$this->db->escape($this->localtax2_type)."',"; + $sql .= ' '.(!empty($this->fk_product) ? $this->fk_product : "null").','; + $sql .= " ".((int) $this->product_type).","; + $sql .= " ".price2num($this->remise_percent).","; + $sql .= " ".price2num($this->subprice).","; + $sql .= ' '.(!empty($this->fk_remise_except) ? $this->fk_remise_except : "null").','; + $sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").","; + $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").","; + $sql .= ' '.$this->fk_code_ventilation.','; + $sql .= ' '.$this->rang.','; + $sql .= ' '.$this->special_code.','; + $sql .= ' '.(!empty($this->fk_fournprice) ? $this->fk_fournprice : "null").','; + $sql .= ' '.price2num($this->pa_ht).','; + $sql .= " '".$this->db->escape($this->info_bits)."',"; + $sql .= " ".price2num($this->total_ht).","; + $sql .= " ".price2num($this->total_tva).","; + $sql .= " ".price2num($this->total_ttc).","; + $sql .= " ".price2num($this->total_localtax1).","; + $sql .= " ".price2num($this->total_localtax2); + $sql .= ", ".$this->situation_percent; + $sql .= ", ".(!empty($this->fk_prev_id) ? $this->fk_prev_id : "null"); + $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql .= ", ".$user->id; + $sql .= ", ".$user->id; + $sql .= ", ".(int) $this->fk_multicurrency; + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql .= ", ".price2num($this->multicurrency_subprice); + $sql .= ", ".price2num($this->multicurrency_total_ht); + $sql .= ", ".price2num($this->multicurrency_total_tva); + $sql .= ", ".price2num($this->multicurrency_total_ttc); + $sql .= ')'; dol_syslog(get_class($this)."::insert", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); - $this->rowid=$this->id; // For backward compatibility + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); + $this->rowid = $this->id; // For backward compatibility if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -4934,8 +4934,8 @@ class FactureLigne extends CommonInvoiceLine // ce qui la flague comme "consommee". if ($this->fk_remise_except) { - $discount=new DiscountAbsolute($this->db); - $result=$discount->fetch($this->fk_remise_except); + $discount = new DiscountAbsolute($this->db); + $result = $discount->fetch($this->fk_remise_except); if ($result >= 0) { // Check if discount was found @@ -4946,7 +4946,7 @@ class FactureLigne extends CommonInvoiceLine { if (empty($noerrorifdiscountalreadylinked)) { - $this->error=$langs->trans("ErrorDiscountAlreadyUsed", $discount->id); + $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id); dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); return -3; @@ -4954,10 +4954,10 @@ class FactureLigne extends CommonInvoiceLine } else { - $result=$discount->link_to_invoice($this->rowid, 0); + $result = $discount->link_to_invoice($this->rowid, 0); if ($result < 0) { - $this->error=$discount->error; + $this->error = $discount->error; dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); return -3; @@ -4966,7 +4966,7 @@ class FactureLigne extends CommonInvoiceLine } else { - $this->error=$langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded"); + $this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded"); dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); return -3; @@ -4974,17 +4974,17 @@ class FactureLigne extends CommonInvoiceLine } else { - $this->error=$discount->error; + $this->error = $discount->error; dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); return -3; } } - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('LINEBILL_INSERT', $user); + $result = $this->call_trigger('LINEBILL_INSERT', $user); if ($result < 0) { $this->db->rollback(); @@ -4998,7 +4998,7 @@ class FactureLigne extends CommonInvoiceLine } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } @@ -5013,33 +5013,33 @@ class FactureLigne extends CommonInvoiceLine */ public function update($user = '', $notrigger = 0) { - global $user,$conf; + global $user, $conf; - $error=0; + $error = 0; $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'. // Clean parameters - $this->desc=trim($this->desc); - if (empty($this->tva_tx)) $this->tva_tx=0; - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; - if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->remise_percent)) $this->remise_percent=0; - if (empty($this->info_bits)) $this->info_bits=0; - if (empty($this->special_code)) $this->special_code=0; - if (empty($this->product_type)) $this->product_type=0; - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; - if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; - if (empty($this->pa_ht)) $this->pa_ht=0; + $this->desc = trim($this->desc); + if (empty($this->tva_tx)) $this->tva_tx = 0; + if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; + if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; + if (empty($this->localtax1_type)) $this->localtax1_type = 0; + if (empty($this->localtax2_type)) $this->localtax2_type = 0; + if (empty($this->total_localtax1)) $this->total_localtax1 = 0; + if (empty($this->total_localtax2)) $this->total_localtax2 = 0; + if (empty($this->remise_percent)) $this->remise_percent = 0; + if (empty($this->info_bits)) $this->info_bits = 0; + if (empty($this->special_code)) $this->special_code = 0; + if (empty($this->product_type)) $this->product_type = 0; + if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; + if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; + if (empty($this->pa_ht)) $this->pa_ht = 0; - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; // Check parameters if ($this->product_type < 0) return -1; @@ -5061,66 +5061,66 @@ class FactureLigne extends CommonInvoiceLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; - $sql.= " description='".$this->db->escape($this->desc)."'"; - $sql.= ", label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); - $sql.= ", subprice=".price2num($this->subprice).""; - $sql.= ", remise_percent=".price2num($this->remise_percent).""; - if ($this->fk_remise_except) $sql.= ", fk_remise_except=".$this->fk_remise_except; - else $sql.= ", fk_remise_except=null"; - $sql.= ", vat_src_code = '".(empty($this->vat_src_code)?'':$this->db->escape($this->vat_src_code))."'"; - $sql.= ", tva_tx=".price2num($this->tva_tx).""; - $sql.= ", localtax1_tx=".price2num($this->localtax1_tx).""; - $sql.= ", localtax2_tx=".price2num($this->localtax2_tx).""; - $sql.= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; - $sql.= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; - $sql.= ", qty=".price2num($this->qty); - $sql.= ", date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null"); - $sql.= ", date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null"); - $sql.= ", product_type=".$this->product_type; - $sql.= ", info_bits='".$this->db->escape($this->info_bits)."'"; - $sql.= ", special_code='".$this->db->escape($this->special_code)."'"; + $sql .= " description='".$this->db->escape($this->desc)."'"; + $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", subprice=".price2num($this->subprice).""; + $sql .= ", remise_percent=".price2num($this->remise_percent).""; + if ($this->fk_remise_except) $sql .= ", fk_remise_except=".$this->fk_remise_except; + else $sql .= ", fk_remise_except=null"; + $sql .= ", vat_src_code = '".(empty($this->vat_src_code) ? '' : $this->db->escape($this->vat_src_code))."'"; + $sql .= ", tva_tx=".price2num($this->tva_tx).""; + $sql .= ", localtax1_tx=".price2num($this->localtax1_tx).""; + $sql .= ", localtax2_tx=".price2num($this->localtax2_tx).""; + $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; + $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; + $sql .= ", qty=".price2num($this->qty); + $sql .= ", date_start=".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null"); + $sql .= ", date_end=".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null"); + $sql .= ", product_type=".$this->product_type; + $sql .= ", info_bits='".$this->db->escape($this->info_bits)."'"; + $sql .= ", special_code='".$this->db->escape($this->special_code)."'"; if (empty($this->skip_update_total)) { - $sql.= ", total_ht=".price2num($this->total_ht); - $sql.= ", total_tva=".price2num($this->total_tva); - $sql.= ", total_ttc=".price2num($this->total_ttc); - $sql.= ", total_localtax1=".price2num($this->total_localtax1); - $sql.= ", total_localtax2=".price2num($this->total_localtax2); + $sql .= ", total_ht=".price2num($this->total_ht); + $sql .= ", total_tva=".price2num($this->total_tva); + $sql .= ", total_ttc=".price2num($this->total_ttc); + $sql .= ", total_localtax1=".price2num($this->total_localtax1); + $sql .= ", total_localtax2=".price2num($this->total_localtax2); } - $sql.= ", fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); - $sql.= ", buy_price_ht='".price2num($this->pa_ht)."'"; - $sql.= ", fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); - if (! empty($this->rang)) $sql.= ", rang=".$this->rang; - $sql.= ", situation_percent=" . $this->situation_percent; - $sql.= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= ", fk_user_modif =".$user->id; + $sql .= ", fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null"); + $sql .= ", buy_price_ht='".price2num($this->pa_ht)."'"; + $sql .= ", fk_parent_line=".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); + if (!empty($this->rang)) $sql .= ", rang=".$this->rang; + $sql .= ", situation_percent=".$this->situation_percent; + $sql .= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql .= ", fk_user_modif =".$user->id; // Multicurrency - $sql.= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql.= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql.= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql.= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql .= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; + $sql .= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; + $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; + $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $this->id=$this->rowid; - $result=$this->insertExtraFields(); + $this->id = $this->rowid; + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINEBILL_UPDATE', $user); + $result = $this->call_trigger('LINEBILL_UPDATE', $user); if ($result < 0) { $this->db->rollback(); @@ -5133,7 +5133,7 @@ class FactureLigne extends CommonInvoiceLine } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -2; } @@ -5152,7 +5152,7 @@ class FactureLigne extends CommonInvoiceLine $this->db->begin(); // Call trigger - $result=$this->call_trigger('LINEBILL_DELETE', $user); + $result = $this->call_trigger('LINEBILL_DELETE', $user); if ($result < 0) { $this->db->rollback(); @@ -5163,14 +5163,14 @@ class FactureLigne extends CommonInvoiceLine $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if ($this->db->query($sql) ) + if ($this->db->query($sql)) { $this->db->commit(); return 1; } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -1; } @@ -5190,21 +5190,21 @@ class FactureLigne extends CommonInvoiceLine dol_syslog(get_class($this)."::update_total", LOG_DEBUG); // Clean parameters - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; + if (empty($this->total_localtax1)) $this->total_localtax1 = 0; + if (empty($this->total_localtax2)) $this->total_localtax2 = 0; // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; - $sql.= " total_ht=".price2num($this->total_ht).""; - $sql.= ",total_tva=".price2num($this->total_tva).""; - $sql.= ",total_localtax1=".price2num($this->total_localtax1).""; - $sql.= ",total_localtax2=".price2num($this->total_localtax2).""; - $sql.= ",total_ttc=".price2num($this->total_ttc).""; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " total_ht=".price2num($this->total_ht).""; + $sql .= ",total_tva=".price2num($this->total_tva).""; + $sql .= ",total_localtax1=".price2num($this->total_localtax1).""; + $sql .= ",total_localtax2=".price2num($this->total_localtax2).""; + $sql .= ",total_ttc=".price2num($this->total_ttc).""; + $sql .= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update_total", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->db->commit(); @@ -5212,7 +5212,7 @@ class FactureLigne extends CommonInvoiceLine } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -2; } @@ -5236,28 +5236,28 @@ class FactureLigne extends CommonInvoiceLine } else { // If invoice is not a situation invoice, this->fk_prev_id is used for something else if (!isset($invoicecache[$invoiceid])) { - $invoicecache[$invoiceid]=new Facture($this->db); + $invoicecache[$invoiceid] = new Facture($this->db); $invoicecache[$invoiceid]->fetch($invoiceid); } if ($invoicecache[$invoiceid]->type != Facture::TYPE_SITUATION) return 0; - $sql = 'SELECT situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE rowid=' . $this->fk_prev_id; + $sql = 'SELECT situation_percent FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid='.$this->fk_prev_id; $resql = $this->db->query($sql); if ($resql && $resql->num_rows > 0) { $res = $this->db->fetch_array($resql); $returnPercent = floatval($res['situation_percent']); - if($include_credit_note) { - $sql = 'SELECT fd.situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet fd'; - $sql.= ' JOIN ' . MAIN_DB_PREFIX . 'facture f ON (f.rowid = fd.fk_facture) '; - $sql.= ' WHERE fd.fk_prev_id =' . $this->fk_prev_id; - $sql.= ' AND f.situation_cycle_ref = '.$tmpinvoice->situation_cycle_ref; // Prevent cycle outed - $sql.= ' AND f.type = '.Facture::TYPE_CREDIT_NOTE; + if ($include_credit_note) { + $sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd'; + $sql .= ' JOIN '.MAIN_DB_PREFIX.'facture f ON (f.rowid = fd.fk_facture) '; + $sql .= ' WHERE fd.fk_prev_id ='.$this->fk_prev_id; + $sql .= ' AND f.situation_cycle_ref = '.$tmpinvoice->situation_cycle_ref; // Prevent cycle outed + $sql .= ' AND f.type = '.Facture::TYPE_CREDIT_NOTE; $res = $this->db->query($sql); - if($res) { - while($obj = $this->db->fetch_object($res)) { + if ($res) { + while ($obj = $this->db->fetch_object($res)) { $returnPercent = $returnPercent + floatval($obj->situation_percent); } } @@ -5266,7 +5266,7 @@ class FactureLigne extends CommonInvoiceLine return $returnPercent; } else { $this->error = $this->db->error(); - dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::select Error ".$this->error, LOG_ERR); $this->db->rollback(); return -1; } diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index fbc09ea4e12..a5a98b052c4 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -31,12 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; // Load translation files required by the page -$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); +$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin")); -$local=GETPOST('localTaxType', 'int'); +$local = GETPOST('localTaxType', 'int'); // Date range -$year=GETPOST("year", "int"); +$year = GETPOST("year", "int"); if (empty($year)) { $year_current = strftime("%Y", dol_now()); @@ -45,29 +45,29 @@ if (empty($year)) $year_current = $year; $year_start = $year; } -$date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); -$date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); +$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); +$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q"); + $q = GETPOST("q"); if (empty($q)) { - if (GETPOST("month")) { $date_start=dol_get_first_day($year_start, GETPOST("month"), false); $date_end=dol_get_last_day($year_start, GETPOST("month"), false); } + if (GETPOST("month")) { $date_start = dol_get_first_day($year_start, GETPOST("month"), false); $date_end = dol_get_last_day($year_start, GETPOST("month"), false); } else { - $date_start=dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START, false); - if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1; - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 1; + $date_start = dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false); + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; + elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; + elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; } } else { - if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); } - if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); } - if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); } - if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); } + if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } + if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } + if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } + if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } } } @@ -77,12 +77,12 @@ if (empty($min)) $min = 0; // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax", 'int'); -if (empty($modetax)) $modetax=0; +if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int'); +if (empty($modetax)) $modetax = 0; // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); if (empty($local)) @@ -97,72 +97,72 @@ if (empty($local)) * View */ -$form=new Form($db); -$company_static=new Societe($db); +$form = new Form($db); +$company_static = new Societe($db); -$morequerystring=''; -$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); -foreach($listofparams as $param) +$morequerystring = ''; +$listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday'); +foreach ($listofparams as $param) { - if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param); + if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); } llxHeader('', '', '', '', 0, 0, '', '', $morequerystring); -$name=$langs->transcountry($local==1?"LT1ReportByCustomers":"LT2ReportByCustomers", $mysoc->country_code); +$name = $langs->transcountry($local == 1 ? "LT1ReportByCustomers" : "LT2ReportByCustomers", $mysoc->country_code); -$fsearch =''; -$fsearch.=''; -$fsearch.=''; -$fsearch.=''; -$fsearch.=$langs->trans("SalesTurnoverMinimum").': '; -$fsearch.=''; +$fsearch = ''; +$fsearch .= ''; +$fsearch .= ''; +$fsearch .= ''; +$fsearch .= $langs->trans("SalesTurnoverMinimum").': '; +$fsearch .= ''; -$calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; +$calc = $conf->global->MAIN_INFO_LOCALTAX_CALC.$local; // Affiche en-tete du rapport -if ($calc==0 || $calc==1) // Calculate on invoice for goods and services +if ($calc == 0 || $calc == 1) // Calculate on invoice for goods and services { - $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); - $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; - $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); - if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); - $description.=$fsearch; - $description.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; - $builddate=dol_now(); + $calcmode = $calc == 0 ? $langs->trans("CalcModeLT".$local) : $langs->trans("CalcModeLT".$local."Rec"); + $calcmode .= '
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; + $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); + if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description .= '
'.$langs->trans("WarningDepositsNotIncluded"); + $description .= $fsearch; + $description .= '
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; + $builddate = dol_now(); - $elementcust=$langs->trans("CustomersInvoices"); - $productcust=$langs->trans("Description"); - $amountcust=$langs->trans("AmountHT"); - $elementsup=$langs->trans("SuppliersInvoices"); - $productsup=$langs->trans("Description"); - $amountsup=$langs->trans("AmountHT"); + $elementcust = $langs->trans("CustomersInvoices"); + $productcust = $langs->trans("Description"); + $amountcust = $langs->trans("AmountHT"); + $elementsup = $langs->trans("SuppliersInvoices"); + $productsup = $langs->trans("Description"); + $amountsup = $langs->trans("AmountHT"); } -if ($calc==2) // Invoice for goods, payment for services +if ($calc == 2) // Invoice for goods, payment for services { - $calcmode=$langs->trans("CalcModeLT2Debt"); - $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; - $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); - if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); - $description.=$fsearch; - $description.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; - $builddate=dol_now(); + $calcmode = $langs->trans("CalcModeLT2Debt"); + $calcmode .= '
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; + $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); + if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description .= '
'.$langs->trans("WarningDepositsNotIncluded"); + $description .= $fsearch; + $description .= '
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; + $builddate = dol_now(); - $elementcust=$langs->trans("CustomersInvoices"); - $productcust=$langs->trans("Description"); - $amountcust=$langs->trans("AmountHT"); - $elementsup=$langs->trans("SuppliersInvoices"); - $productsup=$langs->trans("Description"); - $amountsup=$langs->trans("AmountHT"); + $elementcust = $langs->trans("CustomersInvoices"); + $productcust = $langs->trans("Description"); + $amountcust = $langs->trans("AmountHT"); + $elementsup = $langs->trans("SuppliersInvoices"); + $productsup = $langs->trans("Description"); + $amountsup = $langs->trans("AmountHT"); } report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); -$vatcust=$langs->transcountry($local==1?"LT1":"LT2", $mysoc->country_code); -$vatsup=$langs->transcountry($local==1?"LT1":"LT2", $mysoc->country_code); +$vatcust = $langs->transcountry($local == 1 ? "LT1" : "LT2", $mysoc->country_code); +$vatsup = $langs->transcountry($local == 1 ? "LT1" : "LT2", $mysoc->country_code); // IRPF that the customer has retained me -if($calc ==0 || $calc == 2) +if ($calc == 0 || $calc == 2) { print ''; print ''; @@ -185,20 +185,20 @@ if($calc ==0 || $calc == 2) // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('externalbalance')); - $reshook=$hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (is_array($coll_list)) { - $total = 0; $totalamount = 0; + $total = 0; $totalamount = 0; $i = 1; - foreach($coll_list as $coll) + foreach ($coll_list as $coll) { - if(($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local==1?$coll->localtax1:$coll->localtax2) !=0) + if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) { $intra = str_replace($find, $replace, $coll->tva_intra); - if(empty($intra)) + if (empty($intra)) { - if($coll->assuj == '1') + if ($coll->assuj == '1') { $intra = $langs->trans('Unknown'); } @@ -209,16 +209,16 @@ if($calc ==0 || $calc == 2) } print ''; print '"; - $company_static->id=$coll->socid; - $company_static->name=$coll->name; + $company_static->id = $coll->socid; + $company_static->name = $coll->name; print ''; - $find = array(' ','.'); - $replace = array('',''); + $find = array(' ', '.'); + $replace = array('', ''); print ''; print ''; - print ''; + print ''; $totalamount = $totalamount + $coll->amount; - $total = $total + ($local==1?$coll->localtax1:$coll->localtax2); + $total = $total + ($local == 1 ? $coll->localtax1 : $coll->localtax2); print "\n"; $i++; } @@ -243,7 +243,7 @@ if($calc ==0 || $calc == 2) } // IRPF I retained my supplier -if($calc ==0 || $calc == 1){ +if ($calc == 0 || $calc == 1) { print '
'.$i."'.$company_static->getNomUrl(1).''.$intra.''.price($coll->amount).''.price($local==1?$coll->localtax1:$coll->localtax2).''.price($local == 1 ? $coll->localtax1 : $coll->localtax2).'
'; print ''; print '"; @@ -253,25 +253,25 @@ if($calc ==0 || $calc == 1){ print ''; print "\n"; - $company_static=new Societe($db); + $company_static = new Societe($db); $coll_list = tax_by_thirdparty('localtax'.$local, $db, 0, $date_start, $date_end, $modetax, 'buy'); $parameters["direction"] = 'buy'; $parameters["type"] = 'localtax'.$local; - $reshook=$hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (is_array($coll_list)) { - $total = 0; $totalamount = 0; + $total = 0; $totalamount = 0; $i = 1; - foreach($coll_list as $coll) + foreach ($coll_list as $coll) { - if(($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local==1?$coll->localtax1:$coll->localtax2) != 0) + if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) { $intra = str_replace($find, $replace, $coll->tva_intra); - if(empty($intra)) + if (empty($intra)) { - if($coll->assuj == '1') + if ($coll->assuj == '1') { $intra = $langs->trans('Unknown'); } @@ -282,16 +282,16 @@ if($calc ==0 || $calc == 1){ } print ''; print '"; - $company_static->id=$coll->socid; - $company_static->name=$coll->name; + $company_static->id = $coll->socid; + $company_static->name = $coll->name; print ''; - $find = array(' ','.'); - $replace = array('',''); + $find = array(' ', '.'); + $replace = array('', ''); print '"; print ''; - print ''; + print ''; $totalamount = $totalamount + $coll->amount; - $total = $total + ($local==1?$coll->localtax1:$coll->localtax2); + $total = $total + ($local == 1 ? $coll->localtax1 : $coll->localtax2); print "\n"; $i++; } @@ -317,13 +317,13 @@ if($calc ==0 || $calc == 1){ } } -if($calc ==0){ +if ($calc == 0) { // Total to pay print '

'; print '
'.$langs->trans("Num")."'.$vatsup.'
'.$i."'.$company_static->getNomUrl(1).''.$intra."'.price($coll->amount).''.price($local==1?$coll->localtax1:$coll->localtax2).''.price($local == 1 ? $coll->localtax1 : $coll->localtax2).'
'; - $diff = $x_coll_sum - $x_paye_sum ; + $diff = $x_coll_sum - $x_paye_sum; print ''; - print ''; + print ''; print '\n"; print "\n"; } diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 0008a948c16..fb41142d970 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.p require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array('banks', 'categories','bills','withdrawals')); +$langs->loadLangs(array('banks', 'categories', 'bills', 'withdrawals')); if (!$user->rights->prelevement->bons->lire) accessforbidden(); @@ -46,7 +46,7 @@ $ref = GETPOST('ref', 'alpha'); $socid = GETPOST('socid', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -55,15 +55,15 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='pl.fk_soc'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'pl.fk_soc'; +if (!$sortorder) $sortorder = 'DESC'; $object = new BonPrelevement($db, ""); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -$hookmanager->initHooks(array('directdebitprevcard','globalcard')); +$hookmanager->initHooks(array('directdebitprevcard', 'globalcard')); /* * Actions @@ -75,9 +75,9 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ( $action == 'confirm_delete' ) + if ($action == 'confirm_delete') { - $res=$object->delete($user); + $res = $object->delete($user); if ($res > 0) { header("Location: index.php"); @@ -86,9 +86,9 @@ if (empty($reshook)) } // Seems to no be used and replaced with $action == 'infocredit' - if ( $action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes') + if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes') { - $res=$object->set_credite(); + $res = $object->set_credite(); if ($res >= 0) { header("Location: card.php?id=".$id); @@ -160,7 +160,7 @@ if ($id > 0 || $ref) $head = prelevement_prepare_head($object); dol_fiche_head($head, 'prelevement', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); - if (GETPOST('error', 'alpha')!='') + if (GETPOST('error', 'alpha') != '') { print '
'.$object->getErrorString(GETPOST('error', 'alpha')).'
'; } @@ -190,7 +190,7 @@ if ($id > 0 || $ref) print ''; */ - if($object->date_trans <> 0) + if ($object->date_trans <> 0) { $muser = new User($db); $muser->fetch($object->user_trans); @@ -202,7 +202,7 @@ if ($id > 0 || $ref) print $object->methodes_trans[$object->method_trans]; print ''; } - if($object->date_credit <> 0) + if ($object->date_credit <> 0) { print ''; } // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').''.$langs->trans("TotalToPay").($q ? ', '.$langs->trans("Quadri").' '.$q : '').''.price(price2num($diff, 'MT'))."
'.$langs->trans('CreditDate').''; print dol_print_date($object->date_credit, 'day'); @@ -217,7 +217,7 @@ if ($id > 0 || $ref) print ''; $acc = new Account($db); - $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); print ''; @@ -2576,16 +2576,16 @@ else print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print ''; if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) - print ''; + print ''; print '
'; print $langs->trans("BankToReceiveWithdraw"); @@ -244,7 +244,7 @@ if ($id > 0 || $ref) // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Delete'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Delete'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); } // Call Hook formConfirm @@ -257,7 +257,7 @@ if ($id > 0 || $ref) print $formconfirm; - if (empty($object->date_trans) && $user->rights->prelevement->bons->send && $action=='settransmitted') + if (empty($object->date_trans) && $user->rights->prelevement->bons->send && $action == 'settransmitted') { print '
'; print ''; @@ -281,7 +281,7 @@ if ($id > 0 || $ref) print '
'; } - if (! empty($object->date_trans) && $object->date_credit == 0 && $user->rights->prelevement->bons->credit && $action=='setcredited') + if (!empty($object->date_trans) && $object->date_credit == 0 && $user->rights->prelevement->bons->credit && $action == 'setcredited') { print ''; print ''; @@ -310,7 +310,7 @@ if ($id > 0 || $ref) print "id."\">".$langs->trans("SetToStatusSent").""; } - if (! empty($object->date_trans) && $object->date_credit == 0) + if (!empty($object->date_trans) && $object->date_credit == 0) { print "id."\">".$langs->trans("ClassCredited").""; } @@ -321,22 +321,22 @@ if ($id > 0 || $ref) } - $ligne=new LignePrelevement($db, $user); + $ligne = new LignePrelevement($db, $user); /* * Lines into withdraw request */ $sql = "SELECT pl.rowid, pl.statut, pl.amount,"; - $sql.= " s.rowid as socid, s.nom as name"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; - $sql.= ", ".MAIN_DB_PREFIX."prelevement_bons as pb"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE pl.fk_prelevement_bons = ".$id; - $sql.= " AND pl.fk_prelevement_bons = pb.rowid"; - $sql.= " AND pb.entity = ".$conf->entity; - $sql.= " AND pl.fk_soc = s.rowid"; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= $db->order($sortfield, $sortorder); + $sql .= " s.rowid as socid, s.nom as name"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; + $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE pl.fk_prelevement_bons = ".$id; + $sql .= " AND pl.fk_prelevement_bons = pb.rowid"; + $sql .= " AND pb.entity = ".$conf->entity; + $sql .= " AND pl.fk_soc = s.rowid"; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -351,7 +351,7 @@ if ($id > 0 || $ref) } } - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); @@ -364,7 +364,7 @@ if ($id > 0 || $ref) print_barre_liste($langs->trans("Lines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print_liste_field_titre("Lines", $_SERVER["PHP_SELF"], "pl.rowid", '', $urladd); @@ -389,7 +389,7 @@ if ($id > 0 || $ref) print sprintf("%06s", $obj->rowid); print ''; - $thirdparty=new Societe($db); + $thirdparty = new Societe($db); $thirdparty->fetch($obj->socid); print ''; */ - if($object->date_trans <> 0) + if ($object->date_trans <> 0) { $muser = new User($db); $muser->fetch($object->user_trans); @@ -100,7 +100,7 @@ if ($prev_id > 0 || $ref) print $object->methodes_trans[$object->method_trans]; print ''; } - if($object->date_credit <> 0) + if ($object->date_credit <> 0) { print ''; // Ref supplier - print ''; + print ''; print ''; print ''; @@ -1997,37 +1997,37 @@ if ($action == 'create') // Payment term print ''; // Payment mode print ''; // Bank Account print ''; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; print ''; print ''; } // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); $langs->load('projects'); - print ''; } @@ -2037,7 +2037,7 @@ if ($action == 'create') print ''; print ''; print ''; } @@ -2045,8 +2045,8 @@ if ($action == 'create') print ''; print ''; // print ''; @@ -2056,9 +2056,9 @@ if ($action == 'create') print ''; print ''; // print ''; @@ -2079,10 +2079,10 @@ if ($action == 'create') print ''; print ''; - $txt=$langs->trans($classname); - if ($classname=='CommandeFournisseur') { + $txt = $langs->trans($classname); + if ($classname == 'CommandeFournisseur') { $langs->load('orders'); - $txt=$langs->trans("SupplierOrder"); + $txt = $langs->trans("SupplierOrder"); } print ''; print ''; print '"; - if ($mysoc->localtax1_assuj=="1" || $object->total_localtax1 != 0) //Localtax1 + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) //Localtax1 { print '"; } - if ($mysoc->localtax2_assuj=="1" || $object->total_localtax2 != 0) //Localtax2 + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) //Localtax2 { print '"; } @@ -2118,15 +2118,15 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled)) { - print ''; - print '"; - print '"; + print ''; + print '"; + print '"; } } // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Bouton "Create Draft" @@ -2137,7 +2137,7 @@ if ($action == 'create') print '
'; print ''; print '     '; - print ''; + print ''; print '
'; print "\n"; @@ -2148,7 +2148,7 @@ if ($action == 'create') { print '
'; - $title=$langs->trans('ProductsAndServices'); + $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); print '
'; print $thirdparty->getNomUrl(1); diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index ca5cb77432b..ebb7ab7fbb2 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array("banks","categories",'withdrawals','bills')); +$langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills')); // Securite acces client if ($user->socid > 0) accessforbidden(); @@ -42,7 +42,7 @@ $prev_id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -88,7 +88,7 @@ if ($prev_id > 0 || $ref) print '
'.$langs->trans('CreditDate').''; print dol_print_date($object->date_credit, 'day'); @@ -115,7 +115,7 @@ if ($prev_id > 0 || $ref) print ''; $acc = new Account($db); - $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); print ''; - print ''; + print ''; // Order date print ''; // Statut - print ''; + print ''; // Checkbox print ''; print ''; $total = $total + $objp->price; $subtotal = $subtotal + $objp->price; - $i ++; + $i++; } print '
'; print $langs->trans("BankToReceiveWithdraw"); @@ -148,20 +148,20 @@ $rej = new RejetPrelevement($db, $user); * List errors */ $sql = "SELECT pl.rowid, pl.amount, pl.statut"; -$sql.= " , s.rowid as socid, s.nom as name"; -$sql.= " , pr.motif, pr.afacturer, pr.fk_facture"; -$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; -$sql.= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; -$sql.= " , ".MAIN_DB_PREFIX."societe as s"; -$sql.= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr"; -$sql.= " WHERE p.rowid=".$object->id; -$sql.= " AND pl.fk_prelevement_bons = p.rowid"; -$sql.= " AND p.entity = ".$conf->entity; -$sql.= " AND pl.fk_soc = s.rowid"; -$sql.= " AND pl.statut = 3 "; -$sql.= " AND pr.fk_prelevement_lignes = pl.rowid"; -if ($socid) $sql.= " AND s.rowid = ".$socid; -$sql.= " ORDER BY pl.amount DESC"; +$sql .= " , s.rowid as socid, s.nom as name"; +$sql .= " , pr.motif, pr.afacturer, pr.fk_facture"; +$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; +$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; +$sql .= " , ".MAIN_DB_PREFIX."societe as s"; +$sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr"; +$sql .= " WHERE p.rowid=".$object->id; +$sql .= " AND pl.fk_prelevement_bons = p.rowid"; +$sql .= " AND p.entity = ".$conf->entity; +$sql .= " AND pl.fk_soc = s.rowid"; +$sql .= " AND pl.statut = 3 "; +$sql .= " AND pr.fk_prelevement_lignes = pl.rowid"; +if ($socid) $sql .= " AND s.rowid = ".$socid; +$sql .= " ORDER BY pl.amount DESC"; // Count total nb of records $nbtotalofrecords = ''; @@ -176,7 +176,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -186,7 +186,7 @@ if ($resql) print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); print"\n\n"; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 1b351371958..fa7b1758435 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array("banks","categories",'withdrawals','bills')); +$langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills')); // Security check if ($user->socid > 0) accessforbidden(); @@ -40,7 +40,7 @@ $prev_id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -85,7 +85,7 @@ if ($prev_id > 0 || $ref) print ''; */ - if($object->date_trans <> 0) + if ($object->date_trans <> 0) { $muser = new User($db); $muser->fetch($object->user_trans); @@ -97,7 +97,7 @@ if ($prev_id > 0 || $ref) print $object->methodes_trans[$object->method_trans]; print ''; } - if($object->date_credit <> 0) + if ($object->date_credit <> 0) { print ''; @@ -441,22 +441,22 @@ if (($action != 'create' && $action != 'add') && !$error) { $sql = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,'; $sql .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'societe as s'; - $sql .= ', ' . MAIN_DB_PREFIX . 'commande_fournisseur as c'; - if (! $user->rights->societe->client->voir && ! $socid) - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; - $sql .= ' WHERE c.entity = ' . $conf->entity; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; + $sql .= ', '.MAIN_DB_PREFIX.'commande_fournisseur as c'; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ' WHERE c.entity = '.$conf->entity; $sql .= ' AND c.fk_soc = s.rowid'; // Show orders we can bill if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) { - $sql.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; // Must match filter in htdocs/fourn/card.php + $sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; // Must match filter in htdocs/fourn/card.php } else { // CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY - $sql.= " AND c.fk_statut IN (".$db->escape($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).")"; + $sql .= " AND c.fk_statut IN (".$db->escape($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).")"; } $sql .= " AND c.billed = 0"; @@ -466,33 +466,33 @@ if (($action != 'create' && $action != 'add') && !$error) { //$sql .= " AND c.rowid NOT IN (SELECT fk_source FROM " . MAIN_DB_PREFIX . "element_element WHERE targettype='invoice_supplier')"; if ($socid) - $sql .= ' AND s.rowid = ' . $socid; - if (! $user->rights->societe->client->voir && ! $socid) - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; + $sql .= ' AND s.rowid = '.$socid; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($sref) { $sql .= natural_search("c.ref", $sref); } if ($sall) { - $sql .= natural_search(array("c.ref","c.note"), $sall); + $sql .= natural_search(array("c.ref", "c.note"), $sall); } // Date filter //$sql.= dolSqlDateFilter("c.date_commande", GETPOST("date_startday", 'int'), GETPOST("date_startmonth", 'int'), GETPOST("date_startyear", 'int')); //$sql.= dolSqlDateFilter("c.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); if ($date_start) - $sql .= " AND c.date_commande >= '" . $db->idate($date_start) . "'"; + $sql .= " AND c.date_commande >= '".$db->idate($date_start)."'"; if ($date_end) - $sql .= " AND c.date_commande <= '" . $db->idate($date_end) . "'"; + $sql .= " AND c.date_commande <= '".$db->idate($date_end)."'"; if ($date_starty) - $sql .= " AND c.date_livraison >= '" . $db->idate($date_starty) . "'"; + $sql .= " AND c.date_livraison >= '".$db->idate($date_starty)."'"; if ($date_endy) - $sql .= " AND c.date_livraison <= '" . $db->idate($date_endy) . "'"; + $sql .= " AND c.date_livraison <= '".$db->idate($date_endy)."'"; - if (! empty($sref_client)) { + if (!empty($sref_client)) { $sql .= natural_search('c.ref_supplier', $sref_client); } - $sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder; - dol_syslog('fourn/commande/ordertoinvoice.php sql=' . $sql); + $sql .= ' ORDER BY '.$sortfield.' '.$sortorder; + dol_syslog('fourn/commande/ordertoinvoice.php sql='.$sql); $resql = $db->query($sql); if ($resql) { @@ -501,28 +501,28 @@ if (($action != 'create' && $action != 'add') && !$error) { $soc->fetch($socid); } $title = $langs->trans('ListOfSupplierOrders'); - $title .= ' - ' . $langs->trans('StatusOrderReceivedAllShort'); - $title .= ' - ' . $soc->getNomUrl(1, 'supplier'); + $title .= ' - '.$langs->trans('StatusOrderReceivedAllShort'); + $title .= ' - '.$soc->getNomUrl(1, 'supplier'); $num = $db->num_rows($resql); print load_fiche_titre($title); $i = 0; - $period = $html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0) . ' - ' . $html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0); - $periodely = $html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0) . ' - ' . $html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0); + $period = $html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0); + $periodely = $html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0); print ''; - print ''; - print ''; + print ''; + print ''; print '
'.$langs->trans("Line").''.$langs->trans("ThirdParty").''.$langs->trans("Amount").'
'.$langs->trans('CreditDate').''; print dol_print_date($object->date_credit, 'day'); @@ -112,7 +112,7 @@ if ($prev_id > 0 || $ref) print ''; $acc = new Account($db); - $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); print ''; print "\n"; @@ -188,7 +188,7 @@ if ($prev_id > 0 || $ref) } else { - print $db->error() . ' ' . $sql; + print $db->error().' '.$sql; } } diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index b43ccbacb38..3416cd553a0 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -36,13 +36,13 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; // Load translation files required by the page -$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin","accountancy")); +$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin", "accountancy")); $modecompta = (GETPOST('modecompta', 'alpha') ? GETPOST('modecompta', 'alpha') : $conf->global->ACCOUNTING_MODE); // Date range -$year=GETPOST("year", 'int'); -$month=GETPOST("month", 'int'); +$year = GETPOST("year", 'int'); +$month = GETPOST("month", 'int'); if (empty($year)) { $year_current = strftime("%Y", dol_now()); @@ -53,44 +53,44 @@ if (empty($year)) $month_current = strftime("%m", dol_now()); $year_start = $year; } -$date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); -$date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); +$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); +$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q", "int"); + $q = GETPOST("q", "int"); if (empty($q)) { // We define date_start and date_end - $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); - $year_end=$year_start; - $month_end=$month_start; - if (! GETPOST("month")) // If month not forced + $month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); + $year_end = $year_start; + $month_end = $month_start; + if (!GETPOST("month")) // If month not forced { - if (! GETPOST('year') && $month_start > $month_current) + if (!GETPOST('year') && $month_start > $month_current) { $year_start--; $year_end--; } - $month_end=$month_start-1; - if ($month_end < 1) $month_end=12; + $month_end = $month_start - 1; + if ($month_end < 1) $month_end = 12; else $year_end++; } - $date_start=dol_get_first_day($year_start, $month_start, false); $date_end=dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); } else { - if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); } - if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); } - if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); } - if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); } + if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } + if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } + if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } + if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } } } // $date_start and $date_end are defined. We force $year_start and $nbofyear -$tmps=dol_getdate($date_start); +$tmps = dol_getdate($date_start); $year_start = $tmps['year']; -$tmpe=dol_getdate($date_end); +$tmpe = dol_getdate($date_end); $year_end = $tmpe['year']; $tmp_date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; @@ -102,12 +102,12 @@ if (empty($min)) $min = 0; // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax", 'int'); -if (empty($modetax)) $modetax=0; +if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int'); +if (empty($modetax)) $modetax = 0; // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); @@ -116,21 +116,21 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); * View */ -$form=new Form($db); -$company_static=new Societe($db); -$invoice_customer=new Facture($db); -$invoice_supplier=new FactureFournisseur($db); -$expensereport=new ExpenseReport($db); -$product_static=new Product($db); -$payment_static=new Paiement($db); -$paymentfourn_static=new PaiementFourn($db); -$paymentexpensereport_static=new PaymentExpenseReport($db); +$form = new Form($db); +$company_static = new Societe($db); +$invoice_customer = new Facture($db); +$invoice_supplier = new FactureFournisseur($db); +$expensereport = new ExpenseReport($db); +$product_static = new Product($db); +$payment_static = new Paiement($db); +$paymentfourn_static = new PaiementFourn($db); +$paymentexpensereport_static = new PaymentExpenseReport($db); -$morequerystring=''; -$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); +$morequerystring = ''; +$listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday'); foreach ($listofparams as $param) { - if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param); + if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); } llxHeader('', $langs->trans("TurnoverReport"), '', '', 0, 0, '', '', $morequerystring); @@ -139,103 +139,103 @@ llxHeader('', $langs->trans("TurnoverReport"), '', '', 0, 0, '', '', $morequerys //print load_fiche_titre($langs->trans("VAT"),""); //$fsearch.='
'; -$fsearch.=' '; -$fsearch.=' '; +$fsearch .= ' '; +$fsearch .= ' '; //$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': '; //$fsearch.=' '; // Show report header -$name=$langs->trans("xxx"); -$calcmode=''; -if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); -if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); -if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices'); -$calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; +$name = $langs->trans("xxx"); +$calcmode = ''; +if ($modetax == 0) $calcmode = $langs->trans('OptionVATDefault'); +if ($modetax == 1) $calcmode = $langs->trans('OptionVATDebitOption'); +if ($modetax == 2) $calcmode = $langs->trans('OptionPaymentForProductAndServices'); +$calcmode .= '
('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; // Set period -$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); -$prevyear=$year_start; $prevquarter=$q; +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +$prevyear = $year_start; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; } else { - $prevquarter=4; $prevyear--; + $prevquarter = 4; $prevyear--; } -$nextyear=$year_start; $nextquarter=$q; +$nextyear = $year_start; $nextquarter = $q; if ($nextquarter < 4) { $nextquarter++; } else { - $nextquarter=1; $nextyear++; + $nextquarter = 1; $nextyear++; } -$description.=$fsearch; -$builddate=dol_now(); +$description .= $fsearch; +$builddate = dol_now(); -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts"); -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts"); -if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='
'.$langs->trans("RulesVATDueServices"); -if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='
'.$langs->trans("RulesVATInServices"); -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $description.='
'.$langs->trans("DepositsAreNotIncluded"); +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description .= $langs->trans("RulesVATDueProducts"); +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description .= $langs->trans("RulesVATInProducts"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description .= '
'.$langs->trans("RulesVATDueServices"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description .= '
'.$langs->trans("RulesVATInServices"); +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description .= '
'.$langs->trans("DepositsAreNotIncluded"); } -if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); +if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '
'.$langs->trans("ThisIsAnEstimatedValue"); // Customers invoices -$elementcust=$langs->trans("CustomersInvoices"); -$productcust=$langs->trans("ProductOrService"); -$amountcust=$langs->trans("AmountHT"); +$elementcust = $langs->trans("CustomersInvoices"); +$productcust = $langs->trans("ProductOrService"); +$amountcust = $langs->trans("AmountHT"); // Suppliers invoices -$elementsup=$langs->trans("SuppliersInvoices"); -$productsup=$productcust; -$amountsup=$amountcust; -$namesup=$namecust; +$elementsup = $langs->trans("SuppliersInvoices"); +$productsup = $productcust; +$amountsup = $amountcust; +$namesup = $namecust; // TODO Report from bookkeeping not yet available, so we switch on report on business events -if ($modecompta=="BOOKKEEPING") $modecompta="CREANCES-DETTES"; -if ($modecompta=="BOOKKEEPINGCOLLECTED") $modecompta="RECETTES-DEPENSES"; +if ($modecompta == "BOOKKEEPING") $modecompta = "CREANCES-DETTES"; +if ($modecompta == "BOOKKEEPINGCOLLECTED") $modecompta = "RECETTES-DEPENSES"; // Show report header -if ($modecompta=="CREANCES-DETTES") { - $name=$langs->trans("Turnover").', '.$langs->trans("ByVatRate"); - $calcmode=$langs->trans("CalcModeDebt"); +if ($modecompta == "CREANCES-DETTES") { + $name = $langs->trans("Turnover").', '.$langs->trans("ByVatRate"); + $calcmode = $langs->trans("CalcModeDebt"); //$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; - $description=$langs->trans("RulesCADue"); - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $description.= $langs->trans("DepositsAreNotIncluded"); + $description = $langs->trans("RulesCADue"); + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description .= $langs->trans("DepositsAreNotIncluded"); } else { - $description.= $langs->trans("DepositsAreIncluded"); + $description .= $langs->trans("DepositsAreIncluded"); } - $builddate=dol_now(); + $builddate = dol_now(); } -elseif ($modecompta=="RECETTES-DEPENSES") +elseif ($modecompta == "RECETTES-DEPENSES") { - $name=$langs->trans("TurnoverCollected").', '.$langs->trans("ByVatRate"); - $calcmode=$langs->trans("CalcModeEngagement"); + $name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByVatRate"); + $calcmode = $langs->trans("CalcModeEngagement"); //$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; - $description=$langs->trans("RulesCAIn"); - $description.= $langs->trans("DepositsAreIncluded"); + $description = $langs->trans("RulesCAIn"); + $description .= $langs->trans("DepositsAreIncluded"); - $builddate=dol_now(); + $builddate = dol_now(); } -elseif ($modecompta=="BOOKKEEPING") +elseif ($modecompta == "BOOKKEEPING") { } -elseif ($modecompta=="BOOKKEEPINGCOLLECTED") +elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } -$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); -if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().''.img_next().''; +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink = ''.img_previous().''.img_next().''; else $periodlink = ''; -$description.=' '; +$description .= ' '; report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); -if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') +if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') { print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); } @@ -243,62 +243,62 @@ if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') if ($modecompta == 'CREANCES-DETTES') { print '
'; print $langs->trans("BankToReceiveWithdraw"); @@ -142,14 +142,14 @@ if ($prev_id > 0 || $ref) /* * Stats */ - $ligne=new LignePrelevement($db, $user); + $ligne = new LignePrelevement($db, $user); $sql = "SELECT sum(pl.amount), pl.statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; - $sql.= " WHERE pl.fk_prelevement_bons = ".$object->id; - $sql.= " GROUP BY pl.statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; + $sql .= " WHERE pl.fk_prelevement_bons = ".$object->id; + $sql .= " GROUP BY pl.statut"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -174,7 +174,7 @@ if ($prev_id > 0 || $ref) print price($row[0]); print ''; - if ($object->amount) print round($row[0]/$object->amount*100, 2)." %"; + if ($object->amount) print round($row[0] / $object->amount * 100, 2)." %"; print '
'; - print ''; - print ''; - print ''; - $i=0; - while($i < 12) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + print ''; + print ''; + print ''; + $i = 0; + while ($i < 12) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; - print ''; + print ''; $i++; } - print ''; + print ''; $sql = "SELECT fd.tva_tx AS vatrate,"; $sql .= " fd.product_type AS product_type,"; $sql .= " cc.label AS country,"; - for ($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + for ($i = 1; $i <= 12; $i++) { + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$i, 'fd.total_ht', '0').") AS month".str_pad($i, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(fd.total_ht) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = f.fk_soc"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; - $sql .= " WHERE f.datef >= '" . $db->idate($date_start) . "'"; - $sql .= " AND f.datef <= '" . $db->idate($date_end) . "'"; - $sql.= " AND f.fk_statut in (1,2)"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND f.type IN (0,1,2,5)"; + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as soc ON soc.rowid = f.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = soc.fk_pays"; + $sql .= " WHERE f.datef >= '".$db->idate($date_start)."'"; + $sql .= " AND f.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND f.fk_statut in (1,2)"; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (0,1,2,5)"; } else { - $sql.= " AND f.type IN (0,1,2,3,5)"; + $sql .= " AND f.type IN (0,1,2,3,5)"; } - $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; + $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; $sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label "; - dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); + dol_syslog("htdocs/compta/tva/index.php sql=".$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $totalpermonth = array(); - while ( $obj = $db->fetch_object($resql)) { - print ''; + while ($obj = $db->fetch_object($resql)) { + print ''; if ($obj->product_type == 0) { - print ''; + print ''; } else { - print ''; + print ''; } - print ''; - for($i = 0; $i < 12; $i++) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + print ''; + for ($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; - $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; + print ''; + $totalpermonth[$j] = (empty($totalpermonth[$j]) ? 0 : $totalpermonth[$j]) + $obj->$monthj; } - print ''; - $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; + print ''; + $totalpermonth['total'] = (empty($totalpermonth['total']) ? 0 : $totalpermonth['total']) + $obj->total; print ''; } $db->free($resql); @@ -307,77 +307,77 @@ if ($modecompta == 'CREANCES-DETTES') { print ''; print ''; print ''; - for($i = 0; $i < 12; $i++) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + for ($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; + print ''; } - print ''; + print ''; print ''; } else { print $db->lasterror(); // Show last sql error } - print ''; - print ''; - print ''; - $i=0; - while($i < 12) + print ''; + print ''; + print ''; + $i = 0; + while ($i < 12) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; - print ''; + print ''; $i++; } - print ''; + print ''; $sql2 = "SELECT ffd.tva_tx AS vatrate,"; $sql2 .= " ffd.product_type AS product_type,"; $sql2 .= " cc.label AS country,"; - for($i = 1; $i <= 12; $i ++) { - $sql2 .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + for ($i = 1; $i <= 12; $i++) { + $sql2 .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$i, 'ffd.total_ht', '0').") AS month".str_pad($i, 2, '0', STR_PAD_LEFT).","; } $sql2 .= " SUM(ffd.total_ht) as total"; - $sql2 .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; - $sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; - $sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = ff.fk_soc"; - $sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; - $sql2 .= " WHERE ff.datef >= '" . $db->idate($date_start) . "'"; - $sql2 .= " AND ff.datef <= '" . $db->idate($date_end) . "'"; - $sql.= " AND ff.fk_statut in (1,2)"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND ff.type IN (0,1,2,5)"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; + $sql2 .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; + $sql2 .= " INNER JOIN ".MAIN_DB_PREFIX."societe as soc ON soc.rowid = ff.fk_soc"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = soc.fk_pays"; + $sql2 .= " WHERE ff.datef >= '".$db->idate($date_start)."'"; + $sql2 .= " AND ff.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND ff.fk_statut in (1,2)"; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND ff.type IN (0,1,2,5)"; } else { - $sql.= " AND ff.type IN (0,1,2,3,5)"; + $sql .= " AND ff.type IN (0,1,2,3,5)"; } - $sql2 .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; + $sql2 .= " AND ff.entity IN (".getEntity("facture_fourn", 0).")"; $sql2 .= " GROUP BY ffd.tva_tx, ffd.product_type, cc.label"; //print $sql2; - dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); + dol_syslog("htdocs/compta/tva/index.php sql=".$sql, LOG_DEBUG); $resql2 = $db->query($sql2); if ($resql2) { $num = $db->num_rows($resql2); $totalpermonth = array(); - while ( $obj = $db->fetch_object($resql2)) { - print ''; + while ($obj = $db->fetch_object($resql2)) { + print ''; if ($obj->product_type == 0) { - print ''; + print ''; } else { - print ''; + print ''; } - print ''; - for($i = 0; $i < 12; $i++) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + print ''; + for ($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; - $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; + print ''; + $totalpermonth[$j] = (empty($totalpermonth[$j]) ? 0 : $totalpermonth[$j]) + $obj->$monthj; } - print ''; - $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; + print ''; + $totalpermonth['total'] = (empty($totalpermonth['total']) ? 0 : $totalpermonth['total']) + $obj->total; print ''; } $db->free($resql2); @@ -386,13 +386,13 @@ if ($modecompta == 'CREANCES-DETTES') { print ''; print ''; print ''; - for($i = 0; $i < 12; $i++) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + for ($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; + print ''; } - print ''; + print ''; print ''; } else { print $db->lasterror(); // Show last sql error @@ -403,7 +403,7 @@ if ($modecompta == 'CREANCES-DETTES') { // "Calculation of part of each product for accountancy in this mode is not possible. When a partial payment (for example 5 euros) is done on an // invoice with 2 product (product A for 10 euros and product B for 20 euros), what is part of paiment for product A and part of paiment for product B ? // Because there is no way to know this, this report is not relevant. - print '
'.$langs->trans("TurnoverPerSaleTaxRateInCommitmentAccountingNotRelevant") . '
'; + print '
'.$langs->trans("TurnoverPerSaleTaxRateInCommitmentAccountingNotRelevant").'
'; } // End of page diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index c5df8e7d743..7927af38786 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -30,21 +30,21 @@ * \brief Page to invoice multiple supplier orders */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_invoice/modules_facturefournisseur.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page $langs->loadLangs(array("orders", "companies", "deliveries")); -if (! $user->rights->fournisseur->facture->creer) +if (!$user->rights->fournisseur->facture->creer) accessforbidden(); $id = (GETPOST('id') ? GETPOST('id', 'int') : GETPOST("facid")); // For backward compatibility @@ -53,16 +53,16 @@ $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $sref = GETPOST('sref'); $sref_client = GETPOST('sref_client'); -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $socid = GETPOST('socid', 'int'); $selected = GETPOST('orders_to_invoice'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $viewstatut = GETPOST('viewstatut'); -if (! $sortfield) +if (!$sortfield) $sortfield = 'c.rowid'; -if (! $sortorder) +if (!$sortorder) $sortorder = 'DESC'; $now = dol_now(); @@ -80,13 +80,13 @@ $extrafields->fetch_name_optionals_label($object->table_element); if ($action == 'create') { - if (! GETPOST('createbill')) + if (!GETPOST('createbill')) { $action = ''; } else { - if (! is_array($selected)) + if (!is_array($selected)) { //$error++; setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors'); @@ -99,7 +99,7 @@ if ($action == 'create') } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); $hookmanager->initHooks(array('orderstoinvoicesupplier')); @@ -108,10 +108,10 @@ $hookmanager->initHooks(array('orderstoinvoicesupplier')); * Actions */ -if (($action == 'create' || $action == 'add') && ! $error) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/fourn.lib.php'; - if (! empty($conf->projet->enabled)) - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (($action == 'create' || $action == 'add') && !$error) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; + if (!empty($conf->projet->enabled)) + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array("bills", "main", "products")); @@ -157,7 +157,7 @@ if (($action == 'create' || $action == 'add') && ! $error) { if (empty($datefacture)) { $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y")); } - if (! $error) { + if (!$error) { $object->ref = GETPOST('ref', 'nohtml'); $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); $object->socid = GETPOST('socid', 'int'); @@ -181,18 +181,18 @@ if (($action == 'create' || $action == 'add') && ! $error) { if ($ret < 0) $error++; if ($_POST['origin'] && $_POST['originid']) { - $linked_orders_ids=array(); + $linked_orders_ids = array(); foreach ($orders_id as $origin => $origin_id) { - $origin_id = (! empty($origin_id) ? $origin_id : $orders_id[$ii]); - $linked_orders_ids[]=$origin_id; + $origin_id = (!empty($origin_id) ? $origin_id : $orders_id[$ii]); + $linked_orders_ids[] = $origin_id; } $object->linked_objects = array(GETPOST('origin')=>$linked_orders_ids); $id = $object->create($user); if ($id > 0) { - while ( $ii < $nn ) { + while ($ii < $nn) { $objectsrc = new CommandeFournisseur($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $objectsrc->fetch($orders_id[$ii]); if ($result > 0) { $lines = $objectsrc->lines; @@ -202,7 +202,7 @@ if (($action == 'create' || $action == 'add') && ! $error) { } $fk_parent_line = 0; $num = count($lines); - for($i = 0; $i < $num; $i ++) { + for ($i = 0; $i < $num; $i++) { $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); @@ -232,7 +232,7 @@ if (($action == 'create' || $action == 'add') && ! $error) { $lineid = $result; } else { $lineid = 0; - $error ++; + $error++; break; } // Defined the new fk_parent_line @@ -242,22 +242,22 @@ if (($action == 'create' || $action == 'add') && ! $error) { } } else { $mesgs[] = $objectsrc->error; - $error ++; + $error++; } - $ii ++; + $ii++; } } else { $mesgs[] = $object->error; - $error ++; + $error++; } } } // End of object creation, we show it - if ($id > 0 && ! $error) { - foreach($orders_id as $fk_supplier_order) { + if ($id > 0 && !$error) { + foreach ($orders_id as $fk_supplier_order) { $supplier_order = new CommandeFournisseur($db); - if ($supplier_order->fetch($fk_supplier_order)>0 && $supplier_order->statut == 5) + if ($supplier_order->fetch($fk_supplier_order) > 0 && $supplier_order->statut == 5) { if ($supplier_order->classifyBilled($user) < 0) { @@ -265,7 +265,7 @@ if (($action == 'create' || $action == 'add') && ! $error) { $action = 'create'; $_GET["origin"] = $_POST["origin"]; $_GET["originid"] = $_POST["originid"]; - $mesgs[] = '
' . $object->error . '
'; + $mesgs[] = '
'.$object->error.'
'; $error++; break; @@ -273,9 +273,9 @@ if (($action == 'create' || $action == 'add') && ! $error) { } } - if(!$error) { + if (!$error) { $db->commit(); - header('Location: ' . DOL_URL_ROOT . '/fourn/facture/card.php?facid=' . $id); + header('Location: '.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$id); exit(); } } else { @@ -283,7 +283,7 @@ if (($action == 'create' || $action == 'add') && ! $error) { $action = 'create'; $_GET["origin"] = $_POST["origin"]; $_GET["originid"] = $_POST["originid"]; - $mesgs[] = '
' . $object->error . '
'; + $mesgs[] = '
'.$object->error.'
'; } } } @@ -308,7 +308,7 @@ if ($action == 'create' && !$error) { $cond_reglement_id = $soc->cond_reglement_supplier_id; $mode_reglement_id = $soc->mode_reglement_supplier_id; } - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? - 1 : ''; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? -1 : ''; $objectsrc = new CommandeFournisseur($db); $listoforders = array(); @@ -322,50 +322,50 @@ if ($action == 'create' && !$error) { if (empty($mode_reglement_id)) $mode_reglement_id = $objectsrc->mode_reglement_id; } - print ''; - print ''; + print ''; + print ''; print ''; - print '' . "\n"; + print ''."\n"; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print '
' . $langs->trans("TurnoverbyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '
'.$langs->trans("TurnoverbyVatrate").''.$langs->trans("ProductOrService").''.$langs->trans("Country").'' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . ''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("TotalHT") . '
'.$langs->trans("TotalHT").'
' . vatrate($obj->vatrate) . '
'.vatrate($obj->vatrate).''. $langs->trans("Product") . ''.$langs->trans("Product").''. $langs->trans("Service") . ''.$langs->trans("Service").'' .$obj->country . ''.$obj->country.'' . price($obj->$monthj) . ''.price($obj->$monthj).'' . price($obj->total) . ''.price($obj->total).'
' . price($totalpermonth[$j]) . ''.price($totalpermonth[$j]).'' . price($totalpermonth['total']) . ''.price($totalpermonth['total']).'
' . $langs->trans("PurchasebyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '
'.$langs->trans("PurchasebyVatrate").''.$langs->trans("ProductOrService").''.$langs->trans("Country").'' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . ''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("TotalHT") . '
'.$langs->trans("TotalHT").'
' . vatrate($obj->vatrate) . '
'.vatrate($obj->vatrate).''. $langs->trans("Product") . ''.$langs->trans("Product").''. $langs->trans("Service") . ''.$langs->trans("Service").'' . $obj->country . ''.$obj->country.'' . price($obj->$monthj) . ''.price($obj->$monthj).'' . price($obj->total) . ''.price($obj->total).'
' . price($totalpermonth[$j]) . ''.price($totalpermonth[$j]).'' . price($totalpermonth['total']) . ''.price($totalpermonth['total']).'
'; // Ref - print ''; + print ''; // Ref supplier - print ''; + print ''; print ''; // Date invoice - print ''; // Payment term - print ''; // Payment mode - print ''; // Project - if (! empty($conf->projet->enabled)) { + if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); $langs->load('projects'); - print ''; } // Other attributes - $parameters = array ( + $parameters = array( 'objectsrc' => $objectsrc, 'idsrc' => $listoforders, 'colspan' => ' colspan="2"', @@ -376,12 +376,12 @@ if ($action == 'create' && !$error) { if (empty($reshook)) { - $object=new FactureFournisseur($db); + $object = new FactureFournisseur($db); print $object->showOptionals($extrafields, 'edit'); } // Modele PDF - print ''; + print ''; print ''; - print ''; + print ''; print ''; // Private note if (empty($user->socid)) { print ''; - print ''; + print ''; print ''; } @@ -410,13 +410,13 @@ if ($action == 'create' && !$error) { print '
' . $langs->trans('Ref') . '' . $langs->trans('Draft') . '
'.$langs->trans('Ref').''.$langs->trans('Draft').'
' . $langs->trans('RefSupplier') . '
'.$langs->trans('RefSupplier').'
' . $langs->trans('Date') . ''; + print '
'.$langs->trans('Date').''; print $html->selectDate('', '', '', '', '', "add", 1, 1); print '
' . $langs->trans('PaymentConditionsShort') . ''; + print '
'.$langs->trans('PaymentConditionsShort').''; $html->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); print '
' . $langs->trans('PaymentMode') . ''; + print '
'.$langs->trans('PaymentMode').''; $html->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); print '
' . $langs->trans('Project') . ''; + print '
'.$langs->trans('Project').''; $formproject->select_projects($soc->id, $projectid, 'projectid'); print '
' . $langs->trans('Model') . '
'.$langs->trans('Model').''; $liste = ModelePDFSuppliersInvoices::liste_modeles($db); print $html->selectarray('model', $liste, $conf->global->INVOICE_SUPPLIER_ADDON_PDF); @@ -389,20 +389,20 @@ if ($action == 'create' && !$error) { // Public note print '
' . $langs->trans('NotePublic') . ''.$langs->trans('NotePublic').''; - print '
' . $langs->trans('NotePrivate') . ''.$langs->trans('NotePrivate').''; - print '
'; while ($i < $n) { - print ''; + print ''; $i++; } // Button "Create Draft" - print '
'; + print '
'; print "\n"; print '
'; print ''; - print_liste_field_titre('Ref', 'orderstoinvoice.php', 'c.ref', '', '&socid=' . $socid, '', $sortfield, $sortorder); - print_liste_field_titre('RefSupplier', 'orderstoinvoice.php', 'c.ref_supplier', '', '&socid=' . $socid, '', $sortfield, $sortorder); - print_liste_field_titre('OrderDate', 'orderstoinvoice.php', 'c.date_commande', '', '&socid=' . $socid, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DeliveryDate', 'orderstoinvoice.php', 'c.date_livraison', '', '&socid=' . $socid, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Ref', 'orderstoinvoice.php', 'c.ref', '', '&socid='.$socid, '', $sortfield, $sortorder); + print_liste_field_titre('RefSupplier', 'orderstoinvoice.php', 'c.ref_supplier', '', '&socid='.$socid, '', $sortfield, $sortorder); + print_liste_field_titre('OrderDate', 'orderstoinvoice.php', 'c.date_commande', '', '&socid='.$socid, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DeliveryDate', 'orderstoinvoice.php', 'c.date_livraison', '', '&socid='.$socid, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('Status', '', '', '', '', '', '', '', 'right '); print_liste_field_titre('GenerateBill', '', '', '', '', '', '', '', 'center '); print "\n"; @@ -532,12 +532,12 @@ if (($action != 'create' && $action != 'add') && !$error) { print ''; // print ''; // DATE ORDER @@ -552,13 +552,13 @@ if (($action != 'create' && $action != 'add') && !$error) { // SEARCH BUTTON print ''; // ALL/NONE print ''; print ''; @@ -581,13 +581,13 @@ if (($action != 'create' && $action != 'add') && !$error) { print '
'; // REF - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; if ($conf->use_javascript_ajax) - print '' . $langs->trans("All") . ' / ' . $langs->trans("None") . ''; + print ''.$langs->trans("All").' / '.$langs->trans("None").''; print '
'; $filename = dol_sanitizeFileName($objp->ref); - $filedir = $conf->fournisseur->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref); - $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objp->rowid; + $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($objp->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objp->rowid; print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print '
'; print '
' . $objp->ref_supplier . ''.$objp->ref_supplier.''; @@ -600,18 +600,18 @@ if (($action != 'create' && $action != 'add') && !$error) { print '' . $generic_commande->LibStatut($objp->fk_statut, 5) . ''.$generic_commande->LibStatut($objp->fk_statut, 5).''; - print ''; + print ''; print '
'; @@ -620,11 +620,11 @@ if (($action != 'create' && $action != 'add') && !$error) { */ print '
'; print '
'; - print ''; + print ''; print ''; print '
'; // print ''.$langs->trans("GoBack").''; - print ''; + print ''; print '
'; print '
'; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 3dc6e0383b0..6a5e29892d2 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -53,82 +53,82 @@ if (!empty($conf->projet->enabled)) { if (!empty($conf->variants->enabled)) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; -$langs->loadLangs(array('bills','compta','suppliers','companies','products','banks')); +$langs->loadLangs(array('bills', 'compta', 'suppliers', 'companies', 'products', 'banks')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); -$id = (GETPOST('facid', 'int') ? GETPOST('facid', 'int') : GETPOST('id', 'int')); -$socid = GETPOST('socid', 'int'); +$id = (GETPOST('facid', 'int') ? GETPOST('facid', 'int') : GETPOST('id', 'int')); +$socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST("confirm"); -$ref = GETPOST('ref', 'alpha'); +$ref = GETPOST('ref', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $lineid = GETPOST('lineid', 'int'); -$projectid = GETPOST('projectid', 'int'); +$projectid = GETPOST('projectid', 'int'); $origin = GETPOST('origin', 'alpha'); -$originid = GETPOST('originid', 'int'); +$originid = GETPOST('originid', 'int'); // PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('invoicesuppliercard','globalcard')); +$hookmanager->initHooks(array('invoicesuppliercard', 'globalcard')); -$object=new FactureFournisseur($db); +$object = new FactureFournisseur($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); // Load object -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { - $ret=$object->fetch($id, $ref); + $ret = $object->fetch($id, $ref); if ($ret < 0) dol_print_error($db, $object->error); - $ret=$object->fetch_thirdparty(); + $ret = $object->fetch_thirdparty(); if ($ret < 0) dol_print_error($db, $object->error); } // Security check -$socid=''; -if (! empty($user->socid)) $socid=$user->socid; +$socid = ''; +if (!empty($user->socid)) $socid = $user->socid; $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', $isdraft); -$permissionnote=$user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php -$permissiontoadd=$user->rights->fournisseur->facture->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->rights->fournisseur->facture->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php /* * Actions */ -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action=''; + $action = ''; } - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Link invoice to order if (GETPOST('linkedOrder') && empty($cancel) && $id > 0) @@ -141,12 +141,12 @@ if (empty($reshook)) // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { - $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. + $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. if (GETPOST('newsupplierref', 'alphanohtml')) $objectutil->ref_supplier = GETPOST('newsupplierref', 'alphanohtml'); $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); - $result=$objectutil->createFromClone($user, $id); + $result = $objectutil->createFromClone($user, $id); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -156,49 +156,49 @@ if (empty($reshook)) { $langs->load("errors"); setEventMessages($objectutil->error, $objectutil->errors, 'errors'); - $action=''; + $action = ''; } } elseif ($action == 'confirm_valid' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate))) + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate))) ) { - $idwarehouse=GETPOST('idwarehouse'); + $idwarehouse = GETPOST('idwarehouse'); $object->fetch($id); $object->fetch_thirdparty(); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) { $langs->load("stocks"); - if (! $idwarehouse || $idwarehouse == -1) + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $action=''; + $action = ''; } } - if (! $error) + if (!$error) { $result = $object->validate($user, '', $idwarehouse); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); - }else{ + } else { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -206,14 +206,14 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } } @@ -225,12 +225,12 @@ if (empty($reshook)) $object->fetch($id); $object->fetch_thirdparty(); - $isErasable=$object->is_erasable(); + $isErasable = $object->is_erasable(); if (($user->rights->fournisseur->facture->supprimer && $isErasable > 0) || ($user->rights->fournisseur->facture->creer && $isErasable == 1)) { - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { header('Location: list.php?restore_lastsearch_values=1'); @@ -272,7 +272,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); /* Fix bug 1485 : Reset action to avoid asking again confirmation on failure */ - $action=''; + $action = ''; } } @@ -287,8 +287,8 @@ if (empty($reshook)) elseif ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); - $result=$object->set_paid($user); - if ($result<0) + $result = $object->set_paid($user); + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -313,7 +313,7 @@ if (empty($reshook)) if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -327,7 +327,7 @@ if (empty($reshook)) // payments conditions if ($action == 'setconditions' && $user->rights->fournisseur->facture->creer) { - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); } // Set incoterm @@ -354,21 +354,21 @@ if (empty($reshook)) // bank account elseif ($action == 'setbankaccount' && $user->rights->fournisseur->facture->creer) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } // Set label elseif ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); - $object->label=GETPOST('label'); - $result=$object->update($user); + $object->label = GETPOST('label'); + $result = $object->update($user); if ($result < 0) dol_print_error($db); } elseif ($action == 'setdatef' && $user->rights->fournisseur->facture->creer) { - $newdate=dol_mktime(0, 0, 0, $_POST['datefmonth'], $_POST['datefday'], $_POST['datefyear']); - if ($newdate > (dol_now() + (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE)?0:$conf->global->INVOICE_MAX_OFFSET_IN_FUTURE))) + $newdate = dol_mktime(0, 0, 0, $_POST['datefmonth'], $_POST['datefday'], $_POST['datefyear']); + if ($newdate > (dol_now() + (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE) ? 0 : $conf->global->INVOICE_MAX_OFFSET_IN_FUTURE))) { if (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE)) setEventMessages($langs->trans("WarningInvoiceDateInFuture"), null, 'warnings'); else setEventMessages($langs->trans("WarningInvoiceDateTooFarInFuture"), null, 'warnings'); @@ -376,30 +376,30 @@ if (empty($reshook)) $object->fetch($id); - $object->date=$newdate; - $date_echence_calc=$object->calculate_date_lim_reglement(); - if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc) + $object->date = $newdate; + $date_echence_calc = $object->calculate_date_lim_reglement(); + if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc) { $object->date_echeance = $date_echence_calc; } if ($object->date_echeance && $object->date_echeance < $object->date) { - $object->date_echeance=$object->date; + $object->date_echeance = $object->date; } - $result=$object->update($user); + $result = $object->update($user); if ($result < 0) dol_print_error($db, $object->error); } elseif ($action == 'setdate_lim_reglement' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); - $object->date_echeance=dol_mktime(12, 0, 0, $_POST['date_lim_reglementmonth'], $_POST['date_lim_reglementday'], $_POST['date_lim_reglementyear']); - if (! empty($object->date_echeance) && $object->date_echeance < $object->date) + $object->date_echeance = dol_mktime(12, 0, 0, $_POST['date_lim_reglementmonth'], $_POST['date_lim_reglementday'], $_POST['date_lim_reglementyear']); + if (!empty($object->date_echeance) && $object->date_echeance < $object->date) { - $object->date_echeance=$object->date; + $object->date_echeance = $object->date; setEventMessages($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"), null, 'warnings'); } - $result=$object->update($user); + $result = $object->update($user); if ($result < 0) dol_print_error($db, $object->error); } elseif ($action == "setabsolutediscount" && $user->rights->fournisseur->facture->creer) @@ -407,7 +407,7 @@ if (empty($reshook)) // POST[remise_id] or POST[remise_id_for_payment] // We use the credit to reduce amount of invoice - if (! empty($_POST["remise_id"])) { + if (!empty($_POST["remise_id"])) { $ret = $object->fetch($id); if ($ret > 0) { $result = $object->insert_discount($_POST["remise_id"]); @@ -419,9 +419,9 @@ if (empty($reshook)) } } // We use the credit to reduce remain to pay - if (! empty($_POST["remise_id_for_payment"])) + if (!empty($_POST["remise_id_for_payment"])) { - require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($db); $discount->fetch($_POST["remise_id_for_payment"]); @@ -434,7 +434,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorDiscountLargerThanRemainToPaySplitItBefore"), null, 'errors'); } - if (! $error) + if (!$error) { $result = $discount->link_to_invoice(0, $id); if ($result < 0) { @@ -449,7 +449,7 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -467,12 +467,12 @@ if (empty($reshook)) //$object->fetch_lines(); // Already done into fetch // Check if there is already a discount (protection to avoid duplicate creation when resubmit post) - $discountcheck=new DiscountAbsolute($db); - $result=$discountcheck->fetch(0, 0, $object->id); + $discountcheck = new DiscountAbsolute($db); + $result = $discountcheck->fetch(0, 0, $object->id); - $canconvert=0; - if ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) - if (($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) + $canconvert = 0; + if ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) + if (($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) if ($canconvert) { $db->begin(); @@ -488,7 +488,7 @@ if (empty($reshook)) $amount_ht[$line->tva_tx] += $line->total_ht; $amount_tva[$line->tva_tx] += $line->total_tva; $amount_ttc[$line->tva_tx] += $line->total_ttc; - $i ++; + $i++; } } @@ -514,14 +514,14 @@ if (empty($reshook)) // If we're on a standard invoice, we have to get excess paid to create a discount in TTC without VAT $sql = 'SELECT SUM(pf.amount) as total_paiements'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'paiementfourn as p'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN (' . getEntity('c_paiement') . ')'; - $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; - $sql.= ' AND pf.fk_paiementfourn = p.rowid'; - $sql.= ' AND p.entity IN (' . getEntity('invoice').')'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'paiementfourn as p'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.getEntity('c_paiement').')'; + $sql .= ' WHERE pf.fk_facturefourn = '.$object->id; + $sql .= ' AND pf.fk_paiementfourn = p.rowid'; + $sql .= ' AND p.entity IN ('.getEntity('invoice').')'; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); $res = $db->fetch_object($resql); $total_paiements = $res->total_paiements; @@ -556,7 +556,7 @@ if (empty($reshook)) if (empty($error)) { - if($object->type != FactureFournisseur::TYPE_DEPOSIT) { + if ($object->type != FactureFournisseur::TYPE_DEPOSIT) { // Classe facture $result = $object->set_paid($user); if ($result >= 0) @@ -588,9 +588,9 @@ if (empty($reshook)) if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0) { $paiementfourn = new PaiementFourn($db); - $result=$paiementfourn->fetch(GETPOST('paiement_id')); + $result = $paiementfourn->fetch(GETPOST('paiement_id')); if ($result > 0) { - $result=$paiementfourn->delete(); // If fetch ok and found + $result = $paiementfourn->delete(); // If fetch ok and found header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); } if ($result < 0) { @@ -612,8 +612,8 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - $datefacture=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $datedue=dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); + $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $datedue = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); // Replacement invoice if ($_POST['type'] == FactureFournisseur::TYPE_REPLACEMENT) @@ -621,36 +621,36 @@ if (empty($reshook)) if ($datefacture == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; $error++; } - if (! ($_POST['fac_replacement'] > 0)) { - $error ++; + if (!($_POST['fac_replacement'] > 0)) { + $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), null, 'errors'); } - if (! $error) { + if (!$error) { // This is a replacement invoice $result = $object->fetch(GETPOST('fac_replacement'), 'int'); $object->fetch_thirdparty(); - $object->ref = GETPOST('ref', 'nohtml'); - $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); - $object->socid = GETPOST('socid', 'int'); - $object->libelle = GETPOST('label', 'nohtml'); - $object->date = $datefacture; - $object->date_echeance = $datedue; - $object->note_public = GETPOST('note_public', 'none'); - $object->note_private = GETPOST('note_private', 'none'); + $object->ref = GETPOST('ref', 'nohtml'); + $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); + $object->socid = GETPOST('socid', 'int'); + $object->libelle = GETPOST('label', 'nohtml'); + $object->date = $datefacture; + $object->date_echeance = $datedue; + $object->note_public = GETPOST('note_public', 'none'); + $object->note_private = GETPOST('note_private', 'none'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); - $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); // Proprietes particulieres a facture de remplacement $object->fk_facture_source = GETPOST('fac_replacement'); @@ -668,73 +668,73 @@ if (empty($reshook)) if ($_POST['type'] == FactureFournisseur::TYPE_CREDIT_NOTE) { $sourceinvoice = GETPOST('fac_avoir', 'int'); - if (! ($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) + if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) { - $error ++; + $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), null, 'errors'); } - if (GETPOST('socid', 'int')<1) + if (GETPOST('socid', 'int') < 1) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } if ($datefacture == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; $error++; } - if (! GETPOST('ref_supplier')) + if (!GETPOST('ref_supplier')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('RefSupplier')), null, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; $error++; } - if (! $error) + if (!$error) { $tmpproject = GETPOST('projectid', 'int'); // Creation facture - $object->ref = GETPOST('ref', 'nohtml'); - $object->ref_supplier = GETPOST('ref_supplier', 'nohtml'); + $object->ref = GETPOST('ref', 'nohtml'); + $object->ref_supplier = GETPOST('ref_supplier', 'nohtml'); $object->socid = GETPOST('socid', 'int'); - $object->libelle = GETPOST('label', 'nohtml'); + $object->libelle = GETPOST('label', 'nohtml'); $object->label = GETPOST('label', 'nohtml'); - $object->date = $datefacture; - $object->date_echeance = $datedue; - $object->note_public = GETPOST('note_public', 'none'); - $object->note_private = GETPOST('note_private', 'none'); + $object->date = $datefacture; + $object->date_echeance = $datedue; + $object->note_public = GETPOST('note_public', 'none'); + $object->note_private = GETPOST('note_private', 'none'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); - $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); // Proprietes particulieres a facture avoir - $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; + $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; $object->type = FactureFournisseur::TYPE_CREDIT_NOTE; $id = $object->create($user); - if($id <= 0) { + if ($id <= 0) { $error++; } - if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) + if (GETPOST('invoiceAvoirWithLines', 'int') == 1 && $id > 0) { $facture_source = new FactureFournisseur($db); // fetch origin object - if ($facture_source->fetch($object->fk_facture_source)>0) + if ($facture_source->fetch($object->fk_facture_source) > 0) { $fk_parent_line = 0; - foreach($facture_source->lines as $line) + foreach ($facture_source->lines as $line) { // Reset fk_parent_line for no child products and special product if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { @@ -744,13 +744,13 @@ if (empty($reshook)) $line->fk_facture_fourn = $object->id; $line->fk_parent_line = $fk_parent_line; - $line->subprice =-$line->subprice; // invert price for object + $line->subprice = -$line->subprice; // invert price for object $line->pa_ht = -$line->pa_ht; - $line->total_ht=-$line->total_ht; - $line->total_tva=-$line->total_tva; - $line->total_ttc=-$line->total_ttc; - $line->total_localtax1=-$line->total_localtax1; - $line->total_localtax2=-$line->total_localtax2; + $line->total_ht = -$line->total_ht; + $line->total_tva = -$line->total_tva; + $line->total_ttc = -$line->total_ttc; + $line->total_localtax1 = -$line->total_localtax1; + $line->total_localtax2 = -$line->total_localtax2; $result = $line->insert(); @@ -766,10 +766,10 @@ if (empty($reshook)) } } - if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) + if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) { $facture_source = new FactureFournisseur($db); // fetch origin object if not previously defined - if ($facture_source->fetch($object->fk_facture_source)>0) + if ($facture_source->fetch($object->fk_facture_source) > 0) { $totalpaye = $facture_source->getSommePaiement(); $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); @@ -785,29 +785,29 @@ if (empty($reshook)) // Standard or deposit if ($_POST['type'] == FactureFournisseur::TYPE_STANDARD || $_POST['type'] == FactureFournisseur::TYPE_DEPOSIT) { - if (GETPOST('socid', 'int')<1) + if (GETPOST('socid', 'int') < 1) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } if ($datefacture == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; $error++; } - if (! GETPOST('ref_supplier')) + if (!GETPOST('ref_supplier')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('RefSupplier')), null, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; $error++; } - if (! $error) + if (!$error) { $tmpproject = GETPOST('projectid', 'int'); @@ -823,19 +823,19 @@ if (empty($reshook)) $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; + $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); // Auto calculation of date due if not filled by user - if(empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement(); + if (empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement(); $object->fetch_thirdparty(); // If creation from another object of another module - if (! $error && $_POST['origin'] && $_POST['originid']) + if (!$error && $_POST['origin'] && $_POST['originid']) { // Parse element/subelement (ex: project_task) $element = $subelement = GETPOST('origin'); @@ -846,10 +846,10 @@ if (empty($reshook)) }*/ // For compatibility - if ($element == 'order') { + if ($element == 'order') { $element = $subelement = 'commande'; } - if ($element == 'propal') { + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } if ($element == 'contract') { @@ -868,7 +868,7 @@ if (empty($reshook)) require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; + if ($classname == 'Fournisseur.commande') $classname = 'CommandeFournisseur'; $objectsrc = new $classname($db); $objectsrc->fetch($originid); $objectsrc->fetch_thirdparty(); @@ -893,10 +893,10 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; + if ($classname == 'Fournisseur.commande') $classname = 'CommandeFournisseur'; $srcobject = new $classname($db); - $result=$srcobject->fetch(GETPOST('originid', 'int')); + $result = $srcobject->fetch(GETPOST('originid', 'int')); if ($result > 0) { $lines = $srcobject->lines; @@ -906,11 +906,11 @@ if (empty($reshook)) $lines = $srcobject->lines; } - $num=count($lines); + $num = count($lines); for ($i = 0; $i < $num; $i++) // TODO handle subprice < 0 { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { @@ -919,12 +919,12 @@ if (empty($reshook)) // Dates // TODO mutualiser - $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; - $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; + $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; // FIXME Missing special_code into addline and updateline methods $object->special_code = $lines[$i]->special_code; @@ -975,7 +975,7 @@ if (empty($reshook)) $error++; } } - elseif (! $error) + elseif (!$error) { $id = $object->create($user); if ($id < 0) @@ -992,8 +992,8 @@ if (empty($reshook)) $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; } else { @@ -1002,7 +1002,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) + if ($result < 0) { dol_print_error($db, $object->error, $object->errors); exit; @@ -1038,9 +1038,9 @@ if (empty($reshook)) if (GETPOST('productid') > 0) { $productsupplier = new ProductFournisseur($db); - if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) + if (!empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) { - if (GETPOST('productid') > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), GETPOST('productid'), 'none', GETPOST('socid', 'int')) < 0 ) + if (GETPOST('productid') > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), GETPOST('productid'), 'none', GETPOST('socid', 'int')) < 0) { setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); } @@ -1049,18 +1049,18 @@ if (empty($reshook)) $prod = new Product($db); $prod->fetch(GETPOST('productid')); $label = $prod->description; - if (trim($_POST['product_desc']) != trim($label)) $label=$_POST['product_desc']; + if (trim($_POST['product_desc']) != trim($label)) $label = $_POST['product_desc']; $type = $prod->type; } else { $label = $_POST['product_desc']; - $type = $_POST["type"]?$_POST["type"]:0; + $type = $_POST["type"] ? $_POST["type"] : 0; } - $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); // Define info_bits $info_bits = 0; @@ -1069,10 +1069,10 @@ if (empty($reshook)) // Define vat_rate $tva_tx = str_replace('*', '', $tva_tx); - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); + $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - $remise_percent=GETPOST('remise_percent'); + $remise_percent = GETPOST('remise_percent'); $pu_ht_devise = GETPOST('multicurrency_subprice'); // Extrafields Lines @@ -1081,11 +1081,11 @@ if (empty($reshook)) // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } - $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise, GETPOST('fourn_ref', 'alpha')); + $result = $object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise, GETPOST('fourn_ref', 'alpha')); if ($result >= 0) { unset($_POST['label']); @@ -1116,39 +1116,39 @@ if (empty($reshook)) { $db->begin(); - $ret=$object->fetch($id); + $ret = $object->fetch($id); if ($ret < 0) { dol_print_error($db, $object->error); exit; } - $ret=$object->fetch_thirdparty(); + $ret = $object->fetch_thirdparty(); $langs->load('errors'); - $error=0; + $error = 0; // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + $predef = ''; + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { - $idprod=0; + $idprod = 0; $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $price_ht = ''; $tva_tx = ''; } $qty = GETPOST('qty'.$predef); - $remise_percent=GETPOST('remise_percent'.$predef); + $remise_percent = GETPOST('remise_percent'.$predef); $price_ht_devise = GETPOST('multicurrency_price_ht'); // Extrafields @@ -1158,31 +1158,31 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } - if ($prod_entry_mode =='free' && GETPOST('price_ht') < 0 && $qty < 0) + if ($prod_entry_mode == 'free' && GETPOST('price_ht') < 0 && $qty < 0) { setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } - if ($prod_entry_mode =='free' && ! GETPOST('idprodfournprice') && GETPOST('type') < 0) + if ($prod_entry_mode == 'free' && !GETPOST('idprodfournprice') && GETPOST('type') < 0) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if ($prod_entry_mode =='free' && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='' && $price_ht_devise==='') // Unit price can be 0 but not '' + if ($prod_entry_mode == 'free' && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') // Unit price can be 0 but not '' { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice')), null, 'errors'); $error++; } - if ($prod_entry_mode =='free' && ! GETPOST('dp_desc')) + if ($prod_entry_mode == 'free' && !GETPOST('dp_desc')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); $error++; } - if (! GETPOST('qty')) + if (!GETPOST('qty')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; @@ -1197,28 +1197,28 @@ if (empty($reshook)) $idprod = $res->fk_product_child; } else { setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors'); - $error ++; + $error++; } } } if ($prod_entry_mode != 'free' && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' { - $productsupplier=new ProductFournisseur($db); + $productsupplier = new ProductFournisseur($db); - $idprod=0; - if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + $idprod = 0; + if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { - $idprod=$reg[1]; - $res=$productsupplier->fetch($idprod); // Load product from its id + $idprod = $reg[1]; + $res = $productsupplier->fetch($idprod); // Load product from its id // Call to init some price properties of $productsupplier // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price - if (! empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) + if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) { $fksoctosearch = 0; - $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist + $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist if ($productsupplier->fourn_socid != $socid) // The price we found is for another supplier, so we clear supplier price { $productsupplier->ref_supplier = ''; @@ -1227,15 +1227,15 @@ if (empty($reshook)) else { $fksoctosearch = $object->thirdparty->id; - $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist + $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist } } elseif (GETPOST('idprodfournprice', 'alpha') > 0) { - $qtytosearch=$qty; // Just to see if a price exists for the quantity. Not used to found vat. + $qtytosearch = $qty; // Just to see if a price exists for the quantity. Not used to found vat. //$qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist - $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); - $res=$productsupplier->fetch($idprod); + $idprod = $productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); + $res = $productsupplier->fetch($idprod); } if ($idprod > 0) @@ -1243,27 +1243,27 @@ if (empty($reshook)) $label = $productsupplier->label; // if we use supplier description of the products - if(!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { + if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { $desc = $productsupplier->desc_supplier; } else $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $type = $productsupplier->type; - $price_base_type = ($productsupplier->fourn_price_base_type?$productsupplier->fourn_price_base_type:'HT'); + $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); $ref_supplier = $productsupplier->ref_supplier; - $tva_tx=get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); - if (empty($tva_tx)) $tva_npr=0; - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); + if (empty($tva_tx)) $tva_npr = 0; + $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); $pu = $productsupplier->fourn_pu; - if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value + if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value - $result=$object->addline( + $result = $object->addline( $desc, $pu, $tva_tx, @@ -1311,13 +1311,13 @@ if (empty($reshook)) $type = GETPOST('type'); $ref_supplier = GETPOST('fourn_ref', 'alpha'); - $fk_unit= GETPOST('units', 'alpha'); + $fk_unit = GETPOST('units', 'alpha'); - $tva_tx = price2num($tva_tx); // When vat is text input field + $tva_tx = price2num($tva_tx); // When vat is text input field // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); + $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); if ($price_ht !== '') { @@ -1335,7 +1335,7 @@ if (empty($reshook)) } //print "xx".$tva_tx; exit; - if (! $error && $result > 0) + if (!$error && $result > 0) { $db->commit(); @@ -1346,14 +1346,14 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } @@ -1402,7 +1402,7 @@ if (empty($reshook)) elseif ($action == 'classin' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); - $result=$object->setProject($projectid); + $result = $object->setProject($projectid); } @@ -1417,7 +1417,7 @@ if (empty($reshook)) // We check that lines of invoices are exported in accountancy $ventilExportCompta = $object->getVentilExportCompta(); - if (! $ventilExportCompta) + if (!$ventilExportCompta) { // On verifie si aucun paiement n'a ete effectue if ($resteapayer == price2num($object->total_ttc, 'MT', 1) && $object->statut == FactureFournisseur::STATUS_VALIDATED) @@ -1426,25 +1426,25 @@ if (empty($reshook)) $object->fetch_thirdparty(); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) { $langs->load("stocks"); - if (! $idwarehouse || $idwarehouse == -1) + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $action=''; + $action = ''; } } @@ -1457,18 +1457,18 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } - $action=''; + $action = ''; } } } @@ -1497,10 +1497,10 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='BILL_SUPPLIER_SENTBYMAIL'; - $paramname='id'; - $autocopy='MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO'; - $trackid='sin'.$object->id; + $trigger_name = 'BILL_SUPPLIER_SENTBYMAIL'; + $paramname = 'id'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO'; + $trackid = 'sin'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc @@ -1511,12 +1511,12 @@ if (empty($reshook)) // Make calculation according to calculationrule if ($action == 'calculate') { - $calculationrule=GETPOST('calculationrule'); + $calculationrule = GETPOST('calculationrule'); $object->fetch($id); $object->fetch_thirdparty(); - $result=$object->update_price(0, (($calculationrule=='totalofround')?'0':'1'), 0, $object->thirdparty); - if ($result <= 0) + $result = $object->update_price(0, (($calculationrule == 'totalofround') ? '0' : '1'), 0, $object->thirdparty); + if ($result <= 0) { dol_print_error($db, $result); exit; @@ -1530,12 +1530,12 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$object->insertExtraFields('BILL_SUPPLIER_MODIFY'); + $result = $object->insertExtraFields('BILL_SUPPLIER_MODIFY'); if ($result < 0) { $error++; @@ -1547,7 +1547,7 @@ if (empty($reshook)) $action = 'edit_extras'; } - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->facture->creer) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->facture->creer) { if ($action == 'addcontact') { @@ -1583,7 +1583,7 @@ if (empty($reshook)) { if ($object->fetch($id)) { - $result=$object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } else { @@ -1616,13 +1616,13 @@ if (empty($reshook)) $form = new Form($db); $formfile = new FormFile($db); -$bankaccountstatic=new Account($db); -$paymentstatic=new PaiementFourn($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +$bankaccountstatic = new Account($db); +$paymentstatic = new PaiementFourn($db); +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $now = dol_now(); -$title = $langs->trans('SupplierInvoice') . " - " . $langs->trans('Card'); +$title = $langs->trans('SupplierInvoice')." - ".$langs->trans('Card'); $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; llxHeader('', $title, $helpurl); @@ -1637,15 +1637,15 @@ if ($action == 'create') $currency_code = $conf->currency; - $societe=''; + $societe = ''; if (GETPOST('socid') > 0) { - $societe=new Societe($db); + $societe = new Societe($db); $societe->fetch(GETPOST('socid', 'int')); if (!empty($conf->multicurrency->enabled) && !empty($societe->multicurrency_code)) $currency_code = $societe->multicurrency_code; } - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; @@ -1657,10 +1657,10 @@ if ($action == 'create') } // For compatibility - if ($element == 'order') { + if ($element == 'order') { $element = $subelement = 'commande'; } - if ($element == 'propal') { + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } if ($element == 'contract') { @@ -1672,21 +1672,21 @@ if ($action == 'create') require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; + if ($classname == 'Fournisseur.commande') $classname = 'CommandeFournisseur'; $objectsrc = new $classname($db); $objectsrc->fetch($originid); $objectsrc->fetch_thirdparty(); - $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); + $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); //$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); $soc = $objectsrc->thirdparty; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_supplier_id)?$soc->cond_reglement_supplier_id:0)); // TODO maybe add default value option - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_supplier_id)?$soc->mode_reglement_supplier_id:0)); - $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0)); - $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_supplier_id) ? $soc->cond_reglement_supplier_id : 0)); // TODO maybe add default value option + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_supplier_id) ? $soc->mode_reglement_supplier_id : 0)); + $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); + $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0)); + $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; if (!empty($conf->multicurrency->enabled)) { @@ -1694,10 +1694,10 @@ if ($action == 'create') if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; } - $datetmp=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); - $datetmp=dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); - $datedue=($datetmp==''?-1:$datetmp); + $datetmp = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp); + $datetmp = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); + $datedue = ($datetmp == '' ?-1 : $datetmp); // Replicate extrafields $objectsrc->fetch_optionals($originid); @@ -1708,10 +1708,10 @@ if ($action == 'create') $cond_reglement_id = $societe->cond_reglement_supplier_id; $mode_reglement_id = $societe->mode_reglement_supplier_id; $fk_account = $societe->fk_account; - $datetmp=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); - $datetmp=dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); - $datedue=($datetmp==''?-1:$datetmp); + $datetmp = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp); + $datetmp = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); + $datedue = ($datetmp == '' ?-1 : $datetmp); if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; } @@ -1719,10 +1719,10 @@ if ($action == 'create') print ''; print ''; print ''; - if ($societe->id > 0) print '' . "\n"; + if ($societe->id > 0) print ''."\n"; print ''; print ''; - if (!empty($currency_tx)) print ''; + if (!empty($currency_tx)) print ''; dol_fiche_head(); @@ -1762,16 +1762,16 @@ if ($action == 'create') print '
'.$langs->trans('RefSupplier').'
'.$langs->trans('RefSupplier').'
'.$langs->trans('Type').''; - print '
' . "\n"; + print '
'."\n"; // Standard invoice print '
'; - $tmp=' '; + $tmp = ' '; $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; @@ -1883,7 +1883,7 @@ if ($action == 'create') if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) { // Show link for credit note - $facids=$facturestatic->list_qualified_avoir_supplier_invoices($societe->id); + $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id); if ($facids < 0) { dol_print_error($db, $facturestatic); @@ -1899,19 +1899,19 @@ if ($action == 'create') $newinvoice_static->type = $valarray ['type']; $newinvoice_static->paye = $valarray ['paye']; - $optionsav .= ''; } print '
'; - $tmp=' jQuery(document).ready(function() { @@ -1927,26 +1927,26 @@ if ($action == 'create') }); }); '; - $text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' '; + $text = $tmp.$langs->transnoentities("InvoiceAvoirAsk").' '; // $text.=''; $text .= ''; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; - print '    0 ? 'checked':'').' /> '; + print '    0 ? 'checked' : '').' /> '; print '"; - print '
    0 ? 'checked':'').' /> '; + print '
    0 ? 'checked' : '').' /> '; print '"; print '
'; @@ -1956,12 +1956,12 @@ if ($action == 'create') else { print '
'; - $tmp=' '; - $text = $tmp.$langs->trans("InvoiceAvoir") . ' '; - $text.= '('.$langs->trans("YouMustCreateInvoiceFromSupplierThird").') '; + $tmp = ' '; + $text = $tmp.$langs->trans("InvoiceAvoir").' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromSupplierThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; - print '
' . "\n"; + print '
'."\n"; } } @@ -1972,11 +1972,11 @@ if ($action == 'create') if ($societe->id > 0) { // Discounts for third party - print '
' . $langs->trans('Discounts') . ''; + print '
'.$langs->trans('Discounts').''; $thirdparty = $societe; $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$societe->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '
'.$langs->trans('PaymentConditionsShort').''; - $form->select_conditions_paiements(GETPOSTISSET('cond_reglement_id')?GETPOST('cond_reglement_id', 'int'):$cond_reglement_id, 'cond_reglement_id'); + $form->select_conditions_paiements(GETPOSTISSET('cond_reglement_id') ?GETPOST('cond_reglement_id', 'int') : $cond_reglement_id, 'cond_reglement_id'); print '
'.$langs->trans('PaymentMode').''; - $form->select_types_paiements(GETPOSTISSET('mode_reglement_id')?GETPOST('mode_reglement_id', 'int'):$mode_reglement_id, 'mode_reglement_id', 'DBIT'); + $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ?GETPOST('mode_reglement_id', 'int') : $mode_reglement_id, 'mode_reglement_id', 'DBIT'); print '
'.$langs->trans('BankAccount').''; - $form->select_comptes((GETPOSTISSET('fk_account')?GETPOST('fk_account', 'alpha'):$fk_account), 'fk_account', 0, '', 1); + $form->select_comptes((GETPOSTISSET('fk_account') ?GETPOST('fk_account', 'alpha') : $fk_account), 'fk_account', 0, '', 1); print '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; - print $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code')?GETPOST('multicurrency_code', 'alpha'):$currency_code), 'multicurrency_code'); + print $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ?GETPOST('multicurrency_code', 'alpha') : $currency_code), 'multicurrency_code'); print '
' . $langs->trans('Project') . ''; - $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1); + print '
'.$langs->trans('Project').''; + $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1); print '
'; - print $form->select_incoterms(GETPOSTISSET('incoterm_id') ? GETPOST('incoterm_id', 'alphanohtml') : (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), GETPOSTISSET('location_incoterms') ? GETPOST('location_incoterms', 'alphanohtml') : (!empty($objectsrc->location_incoterms)?$objectsrc->location_incoterms:'')); + print $form->select_incoterms(GETPOSTISSET('incoterm_id') ? GETPOST('incoterm_id', 'alphanohtml') : (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), GETPOSTISSET('location_incoterms') ? GETPOST('location_incoterms', 'alphanohtml') : (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : '')); print '
'.$langs->trans('NotePublic').''; $note_public = $object->getDefaultCreateValueFor('note_public'); - if(empty($note_public))$note_public = $objectsrc->note_public; - $doleditor = new DolEditor('note_public', (GETPOSTISSET('note_public')?GETPOST('note_public', 'none'):$note_public), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + if (empty($note_public))$note_public = $objectsrc->note_public; + $doleditor = new DolEditor('note_public', (GETPOSTISSET('note_public') ?GETPOST('note_public', 'none') : $note_public), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print '
'.$langs->trans('NotePrivate').''; $note_private = $object->getDefaultCreateValueFor('note_private'); - if(empty($note_private))$note_private = $objectsrc->note_private; + if (empty($note_private))$note_private = $objectsrc->note_private; - $doleditor = new DolEditor('note_private', (GETPOSTISSET('note_private')?GETPOST('note_private', 'none'):$note_private), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', (GETPOSTISSET('note_private') ?GETPOST('note_private', 'none') : $note_private), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print '
'.$txt.''.$objectsrc->getNomUrl(1); // We check if Origin document (id and type is known) has already at least one invoice attached to it @@ -2091,7 +2091,7 @@ if ($action == 'create') $invoice_supplier = $objectsrc->linkedObjects['invoice_supplier']; // count function need a array as argument (Note: the array must implement Countable too) - if(is_array($invoice_supplier)) + if (is_array($invoice_supplier)) { $cntinvoice = count($invoice_supplier); @@ -2105,12 +2105,12 @@ if ($action == 'create') echo '
'.$langs->trans('AmountHT').''.price($objectsrc->total_ht).'
'.$langs->trans('AmountVAT').''.price($objectsrc->total_tva)."
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($objectsrc->total_localtax1)."
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($objectsrc->total_localtax2)."
' . $langs->trans('MulticurrencyAmountHT') . '' . price($objectsrc->multicurrency_total_ht) . '
' . $langs->trans('MulticurrencyAmountVAT') . '' . price($objectsrc->multicurrency_total_tva) . "
' . $langs->trans('MulticurrencyAmountTTC') . '' . price($objectsrc->multicurrency_total_ttc) . "
'.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).'
'.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva)."
'.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc)."
'; @@ -2160,7 +2160,7 @@ if ($action == 'create') } else { - if ($id > 0 || ! empty($ref)) + if ($id > 0 || !empty($ref)) { /* *************************************************************************** */ /* */ @@ -2168,16 +2168,16 @@ else /* */ /* *************************************************************************** */ - $now=dol_now(); + $now = dol_now(); $productstatic = new Product($db); $object->fetch($id, $ref); - $result=$object->fetch_thirdparty(); + $result = $object->fetch_thirdparty(); if ($result < 0) dol_print_error($db); $societe = new Fournisseur($db); - $result=$societe->fetch($object->socid); + $result = $societe->fetch($object->socid); if ($result < 0) dol_print_error($db); $totalpaye = $object->getSommePaiement(); @@ -2198,7 +2198,7 @@ else } $resteapayeraffiche = $resteapayer; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this $filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { @@ -2215,7 +2215,7 @@ else * View card */ $head = facturefourn_prepare_head($object); - $titre=$langs->trans('SupplierInvoice'); + $titre = $langs->trans('SupplierInvoice'); dol_fiche_head($head, 'card', $titre, -1, 'bill'); @@ -2223,19 +2223,19 @@ else // Confirmation de la conversion de l'avoir en reduc if ($action == 'converttoreduc') { - if($object->type == FactureFournisseur::TYPE_STANDARD) $type_fac = 'ExcessPaid'; - elseif($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $type_fac = 'CreditNote'; - elseif($object->type == FactureFournisseur::TYPE_DEPOSIT) $type_fac = 'Deposit'; + if ($object->type == FactureFournisseur::TYPE_STANDARD) $type_fac = 'ExcessPaid'; + elseif ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $type_fac = 'CreditNote'; + elseif ($object->type == FactureFournisseur::TYPE_DEPOSIT) $type_fac = 'Deposit'; $text = $langs->trans('ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac))); $text .= '
'.$langs->trans('ConfirmConvertToReducSupplier2'); - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2); } // Clone confirmation if ($action == 'clone') { // Create an array for form - $formquestion=array( + $formquestion = array( array('type' => 'text', 'name' => 'newsupplierref', 'label' => $langs->trans("RefSupplier"), 'value' => $langs->trans("CopyOf").' '.$object->ref_supplier), array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now()) ); @@ -2250,7 +2250,7 @@ else $objectref = substr($object->ref, 1, 4); if ($objectref == 'PROV') { - $savdate=$object->date; + $savdate = $object->date; $numref = $object->getNextNumRef($societe); } else @@ -2258,7 +2258,7 @@ else $numref = $object->ref; } - $text=$langs->trans('ConfirmValidateBill', $numref); + $text = $langs->trans('ConfirmValidateBill', $numref); /*if (! empty($conf->notification->enabled)) { require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; @@ -2266,34 +2266,34 @@ else $text.='
'; $text.=$notify->confirmMessage('BILL_SUPPLIER_VALIDATE',$object->socid, $object); }*/ - $formquestion=array(); + $formquestion = array(); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) { $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct=new FormProduct($db); + $formproduct = new FormProduct($db); $warehouse = new Entrepot($db); $warehouse_array = $warehouse->list_array(); if (count($warehouse_array) == 1) { $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockDecrease", current($warehouse_array)) : $langs->trans("WarehouseForStockIncrease", current($warehouse_array)); - $value = ''; + $value = ''; } else { $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease"); - $value = $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1); + $value = $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1); } $formquestion = array( - array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $value) ); } @@ -2314,7 +2314,7 @@ else { $qualified_for_stock_change = $object->hasProductsOrServices(1); } - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) { $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; @@ -2323,13 +2323,13 @@ else $warehouse_array = $warehouse->list_array(); if (count($warehouse_array) == 1) { $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockIncrease", current($warehouse_array)) : $langs->trans("WarehouseForStockDecrease", current($warehouse_array)); - $value = ''; + $value = ''; } else { $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockIncrease") : $langs->trans("SelectWarehouseForStockDecrease"); - $value = $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1); + $value = $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1); } $formquestion = array( - array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $value) ); } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnvalidateBill'), $langs->trans('ConfirmUnvalidateBill', $object->ref), 'confirm_edit', $formquestion, 1, 1); @@ -2355,15 +2355,15 @@ else // Confirmation to delete line if ($action == 'ask_deleteline') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } if (!$formconfirm) { - $parameters=array('lineid'=>$lineid); + $parameters = array('lineid'=>$lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; } // Print form confirm @@ -2371,51 +2371,51 @@ else // Supplier invoice card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; // Ref supplier - $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->facture->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->facture->creer, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->facture->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->facture->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherBills").')'; + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherBills").')'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->fournisseur->facture->creer) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
'; + $morehtmlref .= '
'; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -2430,27 +2430,27 @@ else print $object->getLibType(); if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) { - $facreplaced=new FactureFournisseur($db); + $facreplaced = new FactureFournisseur($db); $facreplaced->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; } if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { - $facusing=new FactureFournisseur($db); + $facusing = new FactureFournisseur($db); $facusing->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } - $facidavoir=$object->getListIdAvoirFromInvoice(); + $facidavoir = $object->getListIdAvoirFromInvoice(); if (count($facidavoir) > 0) { print ' ('.$langs->transnoentities("InvoiceHasAvoir"); - $i=0; - foreach($facidavoir as $id) + $i = 0; + foreach ($facidavoir as $id) { - if ($i==0) print ' '; + if ($i == 0) print ' '; else print ','; - $facavoir=new FactureFournisseur($db); + $facavoir = new FactureFournisseur($db); $facavoir->fetch($id); print $facavoir->getNomUrl(1); } @@ -2458,14 +2458,14 @@ else } if (isset($facidnext) && $facidnext > 0) { - $facthatreplace=new FactureFournisseur($db); + $facthatreplace = new FactureFournisseur($db); $facthatreplace->fetch($facidnext); print ' ('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')'; } if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) { $discount = new DiscountAbsolute($db); $result = $discount->fetch(0, 0, $object->id); - if ($result > 0){ + if ($result > 0) { print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).'
'; } } @@ -2473,12 +2473,12 @@ else // Relative and absolute discounts - print ''; @@ -2548,7 +2548,7 @@ else print ''; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { // Multicurrency code print ''; @@ -2557,13 +2557,13 @@ else print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print ''; if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT) - print ''; + print ''; print '
' . $langs->trans('Discounts'); + print '
'.$langs->trans('Discounts'); print ''; $thirdparty = $societe; $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?facid=' . $object->id); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?facid='.$object->id); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '
id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; print '
'; if ($action == 'editmulticurrencycode') { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); } print '
id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; print '
'; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print '
        '; print ''.$langs->trans("ActualizeCurrency").''; @@ -2631,14 +2631,14 @@ else } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print '
'; @@ -2652,44 +2652,44 @@ else if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT - print '
' . $form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0) . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
' . $form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0) . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
' . $form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0) . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$langs->trans('AmountHT').''.price($object->total_ht, 1, $langs, 0, -1, -1, $conf->currency).'
'.$langs->trans('AmountVAT').''.price($object->total_tva, 1, $langs, 0, -1, -1, $conf->currency).'
        '; - if (GETPOST('calculationrule')) $calculationrule=GETPOST('calculationrule', 'alpha'); - else $calculationrule=(empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)?'totalofround':'roundoftotal'); - if ($calculationrule == 'totalofround') $calculationrulenum=1; - else $calculationrulenum=2; - $s=$langs->trans("ReCalculate").' '; - $s.=''.$langs->trans("Mode1").''; - $s.=' / '; - $s.=''.$langs->trans("Mode2").''; + if (GETPOST('calculationrule')) $calculationrule = GETPOST('calculationrule', 'alpha'); + else $calculationrule = (empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND) ? 'totalofround' : 'roundoftotal'); + if ($calculationrule == 'totalofround') $calculationrulenum = 1; + else $calculationrulenum = 2; + $s = $langs->trans("ReCalculate").' '; + $s .= ''.$langs->trans("Mode1").''; + $s .= ' / '; + $s .= ''.$langs->trans("Mode2").''; print $form->textwithtooltip($s, $langs->trans("CalculationRuleDesc", $calculationrulenum).'
'.$langs->trans("CalculationRuleDescSupplier"), 2, 1, img_picto('', 'help')); print '
'.$langs->transcountry("AmountLT1", $societe->country_code).''.price($object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency).'
'.$langs->transcountry("AmountLT2", $societe->country_code).''.price($object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency).'
'; print ''; - print ''; + print ''; print ''; print ''; - if (! empty($conf->banque->enabled)) print ''; + if (!empty($conf->banque->enabled)) print ''; print ''; print ''; print ''; @@ -2753,28 +2753,28 @@ else { $objp = $db->fetch_object($result); - $paymentstatic->id=$objp->rowid; - $paymentstatic->datepaye=$db->jdate($objp->dp); - $paymentstatic->ref=($objp->ref ? $objp->ref : $objp->rowid); - $paymentstatic->num_paiement=$objp->num_paiement; - $paymentstatic->payment_code=$objp->payment_code; + $paymentstatic->id = $objp->rowid; + $paymentstatic->datepaye = $db->jdate($objp->dp); + $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid); + $paymentstatic->num_paiement = $objp->num_paiement; + $paymentstatic->payment_code = $objp->payment_code; print ''; print ''; - print ''; + print ''; print ''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { - $bankaccountstatic->id=$objp->baid; - $bankaccountstatic->ref=$objp->baref; - $bankaccountstatic->label=$objp->baref; + $bankaccountstatic->id = $objp->baid; + $bankaccountstatic->ref = $objp->baref; + $bankaccountstatic->label = $objp->baref; $bankaccountstatic->number = $objp->banumber; - if (! empty($conf->accounting->enabled)) { + if (!empty($conf->accounting->enabled)) { $bankaccountstatic->account_number = $objp->account_number; $accountingjournal = new AccountingJournal($db); @@ -2786,7 +2786,7 @@ else if ($objp->baid > 0) print $bankaccountstatic->getNomUrl(1, 'transactions'); print ''; } - print ''; + print ''; print ''; + print ' :'; //$resteapayer = $object->total_ttc - $totalpaye; $resteapayeraffiche = $resteapayer; @@ -2847,8 +2847,8 @@ else $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql .= " re.description, re.fk_invoice_supplier_source"; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; - $sql .= " WHERE fk_invoice_supplier = " . $object->id; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " WHERE fk_invoice_supplier = ".$object->id; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -2857,18 +2857,18 @@ else while ($i < $num) { $obj = $db->fetch_object($resql); $invoice->fetch($obj->fk_invoice_supplier_source); - print ''; - print ''; + print ''; print ''; - $i ++; + $i++; if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) $creditnoteamount += $obj->amount_ttc; if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT) @@ -2880,73 +2880,73 @@ else // Paye partiellement 'escompte' if (($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED) && $object->close_code == 'discount_vat') { - print ''; + print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Paye partiellement ou Abandon 'badsupplier' if (($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED) && $object->close_code == 'badsupplier') { - print ''; + print ''; // $resteapayeraffiche=0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Paye partiellement ou Abandon 'product_returned' if (($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED) && $object->close_code == 'product_returned') { - print ''; + print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Paye partiellement ou Abandon 'abandon' if (($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED) && $object->close_code == 'abandon') { - print ''; + $text .= '

'.$langs->trans("Reason").':'.$object->close_note; + print $form->textwithpicto($langs->trans("Abandoned").':', $text, - 1); + print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Billed - print ''; + print ''; // Remainder to pay - print ''; - print ''; + print ''; print ''; } else // Credit note { - $cssforamountpaymentcomplete='amountpaymentneutral'; + $cssforamountpaymentcomplete = 'amountpaymentneutral'; // Total already paid back - print ''; + print ' :'; // Billed - print ''; + print ''; // Remainder to pay back - print ''; - print ''; + print ''; print ''; // Sold credit note @@ -2964,16 +2964,16 @@ else print '

'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $colwidth=20; + $colwidth = 20; $blocname = 'notes'; $title = $langs->trans('Notes'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; @@ -2983,31 +2983,31 @@ else /* * Lines */ - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - if (! empty($conf->use_javascript_ajax) && $object->statut == FactureFournisseur::STATUS_DRAFT) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + if (!empty($conf->use_javascript_ajax) && $object->statut == FactureFournisseur::STATUS_DRAFT) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '
'; print '
' . ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')) . ''.($object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).''.$langs->trans('Date').''.$langs->trans('Type').''.$langs->trans('BankAccount').''.$langs->trans('BankAccount').''.$langs->trans('Amount').' 
'; print $paymentstatic->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->dp), 'day') . ''.dol_print_date($db->jdate($objp->dp), 'day').''; print $form->form_modes_reglement(null, $objp->paiement_type, 'none').' '.$objp->num_paiement; print '' . price($sign * $objp->amount) . ''.price($sign * $objp->amount).''; if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { @@ -2828,12 +2828,12 @@ else if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE) { // Total already paid - print '
'; + print '
'; if ($object->type != FactureFournisseur::TYPE_DEPOSIT) print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); else print $langs->trans('AlreadyPaid'); - print ' : 0)?' class="amountalreadypaid"':'').'>' . price($totalpaye) . ' 
0) ? ' class="amountalreadypaid"' : '').'>'.price($totalpaye).' 
'; + print '
'; if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) - print $langs->trans("CreditNote") . ' '; + print $langs->trans("CreditNote").' '; if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT) - print $langs->trans("Deposit") . ' '; + print $langs->trans("Deposit").' '; print $invoice->getNomUrl(0); print ' :' . price($obj->amount_ttc) . ''.price($obj->amount_ttc).''; - print 'rowid . '">' . img_delete() . ''; + print 'rowid.'">'.img_delete().''; print '
'; - print $form->textwithpicto($langs->trans("Discount") . ':', $langs->trans("HelpEscompte"), - 1); - print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; + print $form->textwithpicto($langs->trans("Discount").':', $langs->trans("HelpEscompte"), - 1); + print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' 
'; - print $form->textwithpicto($langs->trans("Abandoned") . ':', $langs->trans("HelpAbandonBadCustomer"), - 1); - print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; + print $form->textwithpicto($langs->trans("Abandoned").':', $langs->trans("HelpAbandonBadCustomer"), - 1); + print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' 
'; - print $form->textwithpicto($langs->trans("ProductReturned") . ':', $langs->trans("HelpAbandonProductReturned"), - 1); - print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; + print $form->textwithpicto($langs->trans("ProductReturned").':', $langs->trans("HelpAbandonProductReturned"), - 1); + print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' 
'; + print '
'; $text = $langs->trans("HelpAbandonOther"); if ($object->close_note) - $text .= '

' . $langs->trans("Reason") . ':' . $object->close_note; - print $form->textwithpicto($langs->trans("Abandoned") . ':', $text, - 1); - print '
' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' 
' . $langs->trans("Billed") . ' :' . price($object->total_ttc) . ' 
'.$langs->trans("Billed").' :'.price($object->total_ttc).' 
'; + print '
'; if ($resteapayeraffiche >= 0) print $langs->trans('RemainderToPay'); else print $langs->trans('ExcessPaid'); print ' :' . price($resteapayeraffiche) . ''.price($resteapayeraffiche).' 
'; + print '
'; print $langs->trans('AlreadyPaidBack'); - print ' :' . price($sign * $totalpaye) . ' 
'.price($sign * $totalpaye).' 
' . $langs->trans("Billed") . ' :' . price($sign * $object->total_ttc) . ' 
'.$langs->trans("Billed").' :'.price($sign * $object->total_ttc).' 
'; + print '
'; if ($resteapayeraffiche <= 0) print $langs->trans('RemainderToPayBack'); else print $langs->trans('ExcessPaid'); print ' :' . price($sign * $resteapayeraffiche) . ''.price($sign * $resteapayeraffiche).' 
'; global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; - $forceall=1; $dateSelector=0; $inputalsopricewithtax=1; - $senderissupplier=2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. + $forceall = 1; $dateSelector = 0; $inputalsopricewithtax = 1; + $senderissupplier = 2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. //if (! empty($conf->global->SUPPLIER_INVOICE_WITH_NOPRICEDEFINED)) $senderissupplier=2; - if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier=1; + if (!empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier = 1; // Show object lines - if (! empty($object->lines)) + if (!empty($object->lines)) $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); - $num=count($object->lines); + $num = count($object->lines); // Form to add new line if ($object->statut == FactureFournisseur::STATUS_DRAFT && $user->rights->fournisseur->facture->creer) @@ -3046,7 +3046,7 @@ else if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'confirm_edit' && $object->getSommePaiement() == 0 && $user->rights->fournisseur->facture->creer) { // We check if lines of invoice are not already transfered into accountancy - $ventilExportCompta = $object->getVentilExportCompta(); // Should be 0 since the sum of payments are zero. But we keep the protection. + $ventilExportCompta = $object->getVentilExportCompta(); // Should be 0 since the sum of payments are zero. But we keep the protection. if ($ventilExportCompta == 0) { @@ -3054,7 +3054,7 @@ else } else { - print '
' . $langs->trans('Modify') . '
'; + print '
'.$langs->trans('Modify').'
'; } } @@ -3066,7 +3066,7 @@ else || ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && empty($discount->id))) && ($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED)) // A paid invoice (partially or completely) { - if (! $facidnext && $object->close_code != 'replaced' && $user->rights->fournisseur->facture->creer) // Not replaced by another invoice + if (!$facidnext && $object->close_code != 'replaced' && $user->rights->fournisseur->facture->creer) // Not replaced by another invoice { print ''; } @@ -3091,13 +3091,13 @@ else } // Make payments - if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) + if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { - print ''; // must use facid because id is for payment id not invoice + print ''; // must use facid because id is for payment id not invoice } // Classify paid - if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) + if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { print ''; @@ -3127,7 +3127,7 @@ else } // For credit note if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() == 0) { - print ''; + print ''; } // For deposit invoice if ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->paye == 1 && $resteapayer == 0 && $user->rights->fournisseur->facture->creer && empty($discount->id)) @@ -3141,8 +3141,8 @@ else { if (count($object->lines)) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate))) + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate))) { print ''; @@ -3170,32 +3170,32 @@ else // Create a credit note if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_DEPOSIT) && $object->statut > 0 && $user->rights->fournisseur->facture->creer) { - if (! $objectidnext) + if (!$objectidnext) { - print ''; + print ''; } } // Delete - $isErasable=$object->is_erasable(); + $isErasable = $object->is_erasable(); if ($action != 'confirm_edit' && ($user->rights->fournisseur->facture->supprimer || ($user->rights->fournisseur->facture->creer && $isErasable == 1))) // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) { //var_dump($isErasable); if ($isErasable == -4) { - print ''; + print ''; } elseif ($isErasable == -3) { // Should never happen with supplier invoice - print ''; + print ''; } elseif ($isErasable == -2) { // Should never happen with supplier invoice - print ''; + print ''; } elseif ($isErasable == -1) { - print ''; + print ''; } elseif ($isErasable <= 0) // Any other cases { - print ''; + print ''; } else { @@ -3211,16 +3211,16 @@ else /* * Documents generes */ - $ref=dol_sanitizeFileName($object->ref); + $ref = dol_sanitizeFileName($object->ref); $subdir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$ref; $filedir = $conf->fournisseur->facture->dir_output.'/'.$subdir; - $urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id; - $genallowed=$user->rights->fournisseur->facture->lire; - $delallowed=$user->rights->fournisseur->facture->creer; - $modelpdf=(! empty($object->modelpdf)?$object->modelpdf:(empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)?'':$conf->global->INVOICE_SUPPLIER_ADDON_PDF)); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id; + $genallowed = $user->rights->fournisseur->facture->lire; + $delallowed = $user->rights->fournisseur->facture->creer; + $modelpdf = (!empty($object->modelpdf) ? $object->modelpdf : (empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF) ? '' : $conf->global->INVOICE_SUPPLIER_ADDON_PDF)); print $formfile->showdocuments('facture_fournisseur', $subdir, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0, '', '', '', $societe->default_lang); - $somethingshown=$formfile->numoffiles; + $somethingshown = $formfile->numoffiles; // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice_supplier')); @@ -3232,8 +3232,8 @@ else // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); - $somethingshown = $formactions->showactions($object, 'invoice_supplier', $socid, 1, 'listaction'.($genallowed?'largetitle':'')); + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'invoice_supplier', $socid, 1, 'listaction'.($genallowed ? 'largetitle' : '')); print ''; //print '
'; @@ -3247,10 +3247,10 @@ else } // Presend form - $modelmail='invoice_supplier_send'; - $defaulttopic='SendBillRef'; + $modelmail = 'invoice_supplier_send'; + $defaulttopic = 'SendBillRef'; $diroutput = $conf->fournisseur->facture->dir_output; - $autocopy='MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO'; $trackid = 'sin'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 133fa4fd3d6..cfa12648377 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -$langs->loadLangs(array("products","suppliers")); +$langs->loadLangs(array("products", "suppliers")); if (!$user->rights->produit->lire && !$user->rights->service->lire) accessforbidden(); @@ -42,7 +42,7 @@ $type = GETPOST('type'); $optioncss = GETPOST('optioncss', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -50,11 +50,11 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="p.ref"; // Set here default search field -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "p.ref"; // Set here default search field +if (!$sortorder) $sortorder = "ASC"; $fourn_id = GETPOST('fourn_id', 'intcomma'); -if ($user->socid) $fourn_id=$user->socid; +if ($user->socid) $fourn_id = $user->socid; $catid = GETPOST('catid', 'intcomma'); @@ -71,12 +71,12 @@ $extrafields = new ExtraFields($db); * Put here all code to do according to value of "action" parameter */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array(); +$parameters = array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -85,17 +85,17 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { $sref = ''; $sRefSupplier = ''; $snom = ''; - $search_field1=''; - $search_field2=''; - $search_date_creation=''; - $search_date_update=''; - $toselect=''; - $search_array_options=array(); + $search_field1 = ''; + $search_field2 = ''; + $search_date_creation = ''; + $search_date_update = ''; + $toselect = ''; + $search_array_options = array(); } } @@ -107,7 +107,7 @@ $form = new Form($db); $productstatic = new Product($db); $companystatic = new Societe($db); -$title=$langs->trans("ProductsAndServices"); +$title = $langs->trans("ProductsAndServices"); if ($fourn_id) { @@ -117,36 +117,36 @@ if ($fourn_id) -$arrayofmassactions = array( +$arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); -if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); $sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type, p.entity,"; -$sql.= " ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,"; -$sql.= " s.rowid as socid, s.nom as name"; +$sql .= " ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,"; +$sql .= " s.rowid as socid, s.nom as name"; // Add fields to SELECT from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $sql .= $hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."product as p"; -if ($catid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON p.rowid = ppf.fk_product"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ppf.fk_soc = s.rowid"; -$sql.= " WHERE p.entity IN (".getEntity('product').")"; +$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; +if ($catid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON p.rowid = ppf.fk_product"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ppf.fk_soc = s.rowid"; +$sql .= " WHERE p.entity IN (".getEntity('product').")"; if ($sRefSupplier) { $sql .= natural_search('ppf.ref_fourn', $sRefSupplier); } if (GETPOST('type')) { - $sql .= " AND p.fk_product_type = " . GETPOST('type', 'int'); + $sql .= " AND p.fk_product_type = ".GETPOST('type', 'int'); } if ($sref) { @@ -156,7 +156,7 @@ if ($snom) { $sql .= natural_search('p.label', $snom); } -if($catid) +if ($catid) { $sql .= " AND cp.fk_categorie = ".$catid; } @@ -203,18 +203,18 @@ if ($resql) exit; } - if (! empty($supplier->id)) $texte = $langs->trans("ListOfSupplierProductForSupplier", $supplier->name); + if (!empty($supplier->id)) $texte = $langs->trans("ListOfSupplierProductForSupplier", $supplier->name); else $texte = $langs->trans("List"); llxHeader("", "", $texte); - $param="&tobuy=".$tobuy."&sref=".$sref."&snom=".$snom."&fourn_id=".$fourn_id.(isset($type)?"&type=".$type:"").(empty($sRefSupplier)?"":"&srefsupplier=".$sRefSupplier); - if ($optioncss != '') $param.='&optioncss='.$optioncss; + $param = "&tobuy=".$tobuy."&sref=".$sref."&snom=".$snom."&fourn_id=".$fourn_id.(isset($type) ? "&type=".$type : "").(empty($sRefSupplier) ? "" : "&srefsupplier=".$sRefSupplier); + if ($optioncss != '') $param .= '&optioncss='.$optioncss; print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); - if (! empty($catid)) + if (!empty($catid)) { print "
"; $c = new Categorie($db); @@ -232,10 +232,10 @@ if ($resql) print ''; print ''; - $topicmail="Information"; - $modelmail="product"; - $objecttmp=new Product($db); - $trackid='prod'.$object->id; + $topicmail = "Information"; + $modelmail = "product"; + $objecttmp = new Product($db); + $trackid = 'prod'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; print ''; @@ -261,7 +261,7 @@ if ($resql) if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); print $hookmanager->resPrint; print ''; print ''; @@ -292,10 +292,10 @@ if ($resql) print ''; print ''; @@ -303,8 +303,8 @@ if ($resql) print ''."\n"; - $companystatic->name=$objp->name; - $companystatic->id=$objp->socid; + $companystatic->name = $objp->name; + $companystatic->id = $objp->socid; print ''; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 777c467ad67..b10f409e9a1 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -39,26 +39,26 @@ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_expression.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; -if(!empty($conf->barcode->enabled)) dol_include_once('/core/class/html.formbarcode.class.php'); +if (!empty($conf->barcode->enabled)) dol_include_once('/core/class/html.formbarcode.class.php'); // Load translation files required by the page $langs->loadLangs(array('products', 'suppliers', 'bills', 'margins')); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$rowid=GETPOST('rowid', 'int'); -$action=GETPOST('action', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'pricesuppliercard'; +$rowid = GETPOST('rowid', 'int'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'pricesuppliercard'; -$socid=GETPOST('socid', 'int'); -$cost_price=GETPOST('cost_price', 'alpha'); -$backtopage=GETPOST('backtopage', 'alpha'); -$error=0; +$socid = GETPOST('socid', 'int'); +$cost_price = GETPOST('cost_price', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); +$error = 0; $extrafields = new ExtraFields($db); // If socid provided by ajax company selector -if (! empty($_REQUEST['search_fourn_id'])) +if (!empty($_REQUEST['search_fourn_id'])) { $_GET['id_fourn'] = $_GET['search_fourn_id']; $_POST['id_fourn'] = $_POST['search_fourn_id']; @@ -66,26 +66,26 @@ if (! empty($_REQUEST['search_fourn_id'])) } // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); if (empty($user->rights->fournisseur->lire)) accessforbidden(); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = (GETPOST("page", 'int')?GETPOST("page", 'int'):0); +$page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="s.nom"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "s.nom"; +if (!$sortorder) $sortorder = "ASC"; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('pricesuppliercard','globalcard')); +$hookmanager->initHooks(array('pricesuppliercard', 'globalcard')); $object = new ProductFournisseur($db); if ($id > 0 || $ref) @@ -96,21 +96,21 @@ if ($id > 0 || $ref) $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (! $sortfield) $sortfield="s.nom"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "s.nom"; +if (!$sortorder) $sortorder = "ASC"; /* * Actions */ -if ($cancel) $action=''; +if ($cancel) $action = ''; $usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); $usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); -$parameters=array('socid'=>$socid, 'id_prod'=>$id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid, 'id_prod'=>$id); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -119,13 +119,13 @@ if (empty($reshook)) { if ($id) { - $result=$object->fetch($id); + $result = $object->fetch($id); $object->cost_price = price2num($cost_price); - $result=$object->update($object->id, $user); + $result = $object->update($object->id, $user); if ($result > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $action=''; + $action = ''; } else { @@ -140,11 +140,11 @@ if (empty($reshook)) if ($rowid) // id of product supplier price to remove { $action = ''; - $result=$object->remove_product_fournisseur_price($rowid); - if($result > 0){ - $db->query("DELETE FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = $rowid"); + $result = $object->remove_product_fournisseur_price($rowid); + if ($result > 0) { + $db->query("DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = $rowid"); setEventMessages($langs->trans("PriceRemoved"), null, 'mesgs'); - }else{ + } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); } @@ -153,23 +153,23 @@ if (empty($reshook)) if ($action == 'save_price') { - $id_fourn=GETPOST("id_fourn"); - if (empty($id_fourn)) $id_fourn=GETPOST("search_id_fourn"); - $ref_fourn=GETPOST("ref_fourn"); - if (empty($ref_fourn)) $ref_fourn=GETPOST("search_ref_fourn"); - $ref_fourn_old=GETPOST("ref_fourn_old"); + $id_fourn = GETPOST("id_fourn"); + if (empty($id_fourn)) $id_fourn = GETPOST("search_id_fourn"); + $ref_fourn = GETPOST("ref_fourn"); + if (empty($ref_fourn)) $ref_fourn = GETPOST("search_ref_fourn"); + $ref_fourn_old = GETPOST("ref_fourn_old"); if (empty($ref_fourn_old)) $ref_fourn_old = $ref_fourn; - $quantity=price2num(GETPOST("qty", 'nohtml'), 'MS'); - $remise_percent=price2num(GETPOST('remise_percent', 'alpha')); - $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0 ; + $quantity = price2num(GETPOST("qty", 'nohtml'), 'MS'); + $remise_percent = price2num(GETPOST('remise_percent', 'alpha')); + $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0; $tva_tx = str_replace('*', '', GETPOST('tva_tx', 'alpha')); $tva_tx = price2num($tva_tx); $price_expression = GETPOST('eid', 'int') ? GETPOST('eid', 'int') : ''; // Discard expression if not in expression mode $delivery_time_days = GETPOST('delivery_time_days', 'int') ? GETPOST('delivery_time_days', 'int') : ''; $supplier_reputation = GETPOST('supplier_reputation'); $supplier_description = GETPOST('supplier_description', 'alpha'); - $barcode=GETPOST('barcode', 'alpha'); - $fk_barcode_type=GETPOST('fk_barcode_type', 'int'); + $barcode = GETPOST('barcode', 'alpha'); + $fk_barcode_type = GETPOST('fk_barcode_type', 'int'); if ($tva_tx == '') { @@ -177,7 +177,7 @@ if (empty($reshook)) $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("VATRateForSupplierProduct")), null, 'errors'); } - if (! is_numeric($tva_tx)) + if (!is_numeric($tva_tx)) { $error++; $langs->load("errors"); @@ -232,13 +232,13 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $db->begin(); - if (! $error) + if (!$error) { - $ret=$object->add_fournisseur($user, $id_fourn, $ref_fourn_old, $quantity); // This insert record with no value for price. Values are update later with update_buyprice + $ret = $object->add_fournisseur($user, $id_fourn, $ref_fourn_old, $quantity); // This insert record with no value for price. Values are update later with update_buyprice if ($ret == -3) { $error++; @@ -255,37 +255,37 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { - $supplier=new Fournisseur($db); - $result=$supplier->fetch($id_fourn); + $supplier = new Fournisseur($db); + $result = $supplier->fetch($id_fourn); if (isset($_POST['ref_fourn_price_id'])) $object->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']); - $extralabels=$extrafields->fetch_name_optionals_label("product_fournisseur_price"); + $extralabels = $extrafields->fetch_name_optionals_label("product_fournisseur_price"); $extrafield_values = $extrafields->getOptionalsFromPost("product_fournisseur_price"); $sql = ""; - $resql = $db->query("SELECT * FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = " . $object->product_fourn_price_id); + $resql = $db->query("SELECT * FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = ".$object->product_fourn_price_id); // Insert a new extrafields row, if none exists if ($db->num_rows($resql) != 1) { - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields (fk_object, "; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields (fk_object, "; foreach ($extrafield_values as $key => $value) { - $sql .= str_replace('options_', '', $key) . ', '; + $sql .= str_replace('options_', '', $key).', '; } - $sql = substr($sql, 0, strlen($sql)-2) . ") VALUES (" . $object->product_fourn_price_id . ", "; + $sql = substr($sql, 0, strlen($sql) - 2).") VALUES (".$object->product_fourn_price_id.", "; foreach ($extrafield_values as $key => $value) { - $sql .= '"' . $value . '", '; + $sql .= '"'.$value.'", '; } - $sql = substr($sql, 0, strlen($sql)-2) . ')'; + $sql = substr($sql, 0, strlen($sql) - 2).')'; } // else update the existing one else { - $sql = "UPDATE " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields SET "; + $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields SET "; foreach ($extrafield_values as $key => $value) { - $sql .= str_replace('options_', '', $key) . ' = "' . $value . '", '; + $sql .= str_replace('options_', '', $key).' = "'.$value.'", '; } - $sql = substr($sql, 0, strlen($sql)-2) . ' WHERE fk_object = ' . $object->product_fourn_price_id; + $sql = substr($sql, 0, strlen($sql) - 2).' WHERE fk_object = '.$object->product_fourn_price_id; } // Execute the sql command from above @@ -321,10 +321,10 @@ if (empty($reshook)) setEventMessages($priceparser->translatedError(), null, 'errors'); } } - if (! $error && ! empty($conf->dynamicprices->enabled)) + if (!$error && !empty($conf->dynamicprices->enabled)) { //Set the price expression for this supplier price - $ret=$object->setSupplierPriceExpression($price_expression); + $ret = $object->setSupplierPriceExpression($price_expression); if ($ret < 0) { $error++; @@ -334,10 +334,10 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $db->commit(); - $action=''; + $action = ''; } else { @@ -361,13 +361,13 @@ $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('BuyingPrices'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('BuyingPrices'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('BuyingPrices'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('BuyingPrices'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); @@ -380,23 +380,23 @@ if ($id > 0 || $ref) { if ($action == 'ask_remove_pf') { $form = new Form($db); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id . '&rowid=' . $rowid, $langs->trans('DeleteProductBuyPrice'), $langs->trans('ConfirmDeleteProductBuyPrice'), 'confirm_remove_pf', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&rowid='.$rowid, $langs->trans('DeleteProductBuyPrice'), $langs->trans('ConfirmDeleteProductBuyPrice'), 'confirm_remove_pf', '', 0, 1); echo $formconfirm; } if ($action <> 'edit' && $action <> 're-edit') { - $head=product_prepare_head($object); - $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); + $head = product_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'suppliers', $titre, -1, $picto); $linkback = ''.$langs->trans("BackToList").''; - $object->next_prev_filter=" fk_product_type = ".$object->type; + $object->next_prev_filter = " fk_product_type = ".$object->type; $shownav = 1; - if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -419,9 +419,9 @@ if ($id > 0 || $ref) // Cost price. Can be used for margin module for option "calculate margin on explicit cost price // Accountancy sell code print ''; print ''; // Availability - if (! empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) + if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) { $langs->load("propal"); print ''; // Vat rate - $default_vat=''; + $default_vat = ''; // We don't have supplier, so we try to guess. // For this we build a fictive supplier with same properties than user but using vat) $mysoc2 = clone $mysoc; - $mysoc2->name='Fictive seller with same country'; - $mysoc2->tva_assuj=1; - $default_vat=get_default_tva($mysoc2, $mysoc, $object->id, 0); - $default_npr=get_default_npr($mysoc2, $mysoc, $object->id, 0); - if (empty($default_vat)) $default_npr=$default_vat; + $mysoc2->name = 'Fictive seller with same country'; + $mysoc2->tva_assuj = 1; + $default_vat = get_default_tva($mysoc2, $mysoc, $object->id, 0); + $default_npr = get_default_npr($mysoc2, $mysoc, $object->id, 0); + if (empty($default_vat)) $default_npr = $default_vat; print ''; print ''; - if (! empty($conf->dynamicprices->enabled)) //Only show price mode and expression selector if module is enabled + if (!empty($conf->dynamicprices->enabled)) //Only show price mode and expression selector if module is enabled { // Price mode selector print ''; print ''; print ''; // Currency tx print ''; - print ''; print ''; // Currency price qty min print ''; - $pricesupplierincurrencytouse=(GETPOST('multicurrency_price')?GETPOST('multicurrency_price'):(isset($object->fourn_multicurrency_price)?$object->fourn_multicurrency_price:'')); + $pricesupplierincurrencytouse = (GETPOST('multicurrency_price') ?GETPOST('multicurrency_price') : (isset($object->fourn_multicurrency_price) ? $object->fourn_multicurrency_price : '')); print ''; // Price qty min - print ''; + print ''; print ''; - print ''; + print ''; } // Discount qty min print ''; - print ''; print ''; @@ -712,22 +712,22 @@ SCRIPT; // Reputation print ''; // Barcode - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { // Option to define a transport cost on supplier price print ''; - print ''; + print ''; print ''; print ''; $formbarcode = new FormBarCode($db); // Barcode type print ''; - print ''; + print ''; print ''; @@ -737,18 +737,18 @@ SCRIPT; // Option to define a transport cost on supplier price if ($conf->global->PRODUCT_CHARGES) { - if (! empty($conf->margin->enabled)) + if (!empty($conf->margin->enabled)) { print ''; print ''; - print ''; print ''; } } // Product description of the supplier - if (! empty($conf->global->PRODUIT_FOURN_TEXTS)) + if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -765,21 +765,21 @@ SCRIPT; } $extrafields->fetch_name_optionals_label("product_fournisseur_price"); - $extralabels=$extrafields->attributes["product_fournisseur_price"]['label']; + $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; // Extrafields - $resql = $db->query("SELECT * FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = " . $rowid); + $resql = $db->query("SELECT * FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = ".$rowid); if (!empty($extralabels)) { if ($db->num_rows($resql) != 1) { foreach ($extralabels as $key => $value) { - if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) { - print 'attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '') . '>' . $langs->trans($value) . ''; + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) { + print 'attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>'.$langs->trans($value).''; } } } else { $resql = $db->fetch_object($resql); foreach ($extralabels as $key => $value) { - if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) { - print 'attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '') . '>' . $langs->trans($value) . ''; + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) { + print 'attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>'.$langs->trans($value).''; } } } @@ -787,8 +787,8 @@ SCRIPT; if (is_object($hookmanager)) { - $parameters=array('id_fourn'=>$id_fourn,'prod_id'=>$object->id); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); + $parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); print $hookmanager->resPrint; } @@ -811,8 +811,8 @@ SCRIPT; if ($action != 'add_price' && $action != 'update_price') { - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { if ($usercancreate) @@ -828,10 +828,10 @@ SCRIPT; if ($user->rights->fournisseur->lire) // Duplicate ? this check is already in the head of this file { - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - $param.='&ref='.urlencode($object->ref); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + $param .= '&ref='.urlencode($object->ref); $product_fourn = new ProductFournisseur($db); $product_fourn_list = $product_fourn->list_product_fournisseur_price($object->id, $sortfield, $sortorder, $limit, $offset); @@ -846,7 +846,7 @@ SCRIPT; print '
'; print '
'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; - $productstatic->id=$objp->rowid; - $productstatic->ref=$objp->ref; - $productstatic->type=$objp->fk_product_type; - $productstatic->entity=$objp->entity; + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->ref; + $productstatic->type = $objp->fk_product_type; + $productstatic->entity = $objp->entity; print $productstatic->getNomUrl(1, 'supplier'); print ''.$objp->label.''; if ($companystatic->id > 0) print $companystatic->getNomUrl(1, 'supplier'); print '
'; - $textdesc =$langs->trans("CostPriceDescription"); - $textdesc.="
".$langs->trans("CostPriceUsage"); - $text=$form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', ''); + $textdesc = $langs->trans("CostPriceDescription"); + $textdesc .= "
".$langs->trans("CostPriceUsage"); + $text = $form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', ''); print $form->editfieldkey($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); print '
'; print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); @@ -436,7 +436,7 @@ if ($id > 0 || $ref) // Form to add or update a price - if (($action == 'add_price' || $action == 'update_price' ) && $usercancreate) + if (($action == 'add_price' || $action == 'update_price') && $usercancreate) { $langs->load("suppliers"); @@ -462,7 +462,7 @@ if ($id > 0 || $ref) print '
'.$langs->trans("Supplier").''; if ($rowid) { - $supplier=new Fournisseur($db); + $supplier = new Fournisseur($db); $supplier->fetch($socid); print $supplier->getNomUrl(1); print ''; @@ -472,12 +472,12 @@ if ($id > 0 || $ref) } else { - $events=array(); - $events[]=array('method' => 'getVatRates', 'url' => dol_buildpath('/core/ajax/vatrates.php', 1), 'htmlname' => 'tva_tx', 'params' => array()); + $events = array(); + $events[] = array('method' => 'getVatRates', 'url' => dol_buildpath('/core/ajax/vatrates.php', 1), 'htmlname' => 'tva_tx', 'params' => array()); print $form->select_company(GETPOST("id_fourn", 'alpha'), 'id_fourn', 'fournisseur=1', 'SelectThirdParty', 0, 0, $events); - $parameters=array('filtre'=>"fournisseur=1",'html_name'=>'id_fourn','selected'=>GETPOST("id_fourn"),'showempty'=>1,'prod_id'=>$object->id); - $reshook=$hookmanager->executeHooks('formCreateThirdpartyOptions', $parameters, $object, $action); + $parameters = array('filtre'=>"fournisseur=1", 'html_name'=>'id_fourn', 'selected'=>GETPOST("id_fourn"), 'showempty'=>1, 'prod_id'=>$object->id); + $reshook = $hookmanager->executeHooks('formCreateThirdpartyOptions', $parameters, $object, $action); if (empty($reshook)) { if (empty($form->result)) @@ -497,13 +497,13 @@ if ($id > 0 || $ref) } else { - print ''; + print ''; } print '
'.$langs->trans("Availability").''; @@ -529,46 +529,46 @@ if ($id > 0 || $ref) if ($conf->global->PRODUCT_USE_UNITS) { $unit = $object->getLabelOfUnit(); if ($unit !== '') { - print '  ' . $langs->trans($unit); + print '  '.$langs->trans($unit); } } print '
'.$langs->trans("VATRateForSupplierProduct").''; //print $form->load_tva('tva_tx',$object->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country - if (! empty($rowid)) // If we have a supplier, it is an update, we must show the vat of current supplier price + if (!empty($rowid)) // If we have a supplier, it is an update, we must show the vat of current supplier price { - $tmpproductsupplier=new ProductFournisseur($db); + $tmpproductsupplier = new ProductFournisseur($db); $tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1); - $default_vat=$tmpproductsupplier->fourn_tva_tx; - $default_npr=$tmpproductsupplier->fourn_tva_npr; + $default_vat = $tmpproductsupplier->fourn_tva_tx; + $default_npr = $tmpproductsupplier->fourn_tva_npr; } else { if (empty($default_vat)) { - $default_vat=$object->tva_tx; + $default_vat = $object->tva_tx; } } - $vattosuggest=(GETPOST("tva_tx")?vatrate(GETPOST("tva_tx")):($default_vat!=''?vatrate($default_vat):'')); - $vattosuggest=preg_replace('/\s*\(.*\)$/', '', $vattosuggest); + $vattosuggest = (GETPOST("tva_tx") ?vatrate(GETPOST("tva_tx")) : ($default_vat != '' ?vatrate($default_vat) : '')); + $vattosuggest = preg_replace('/\s*\(.*\)$/', '', $vattosuggest); print ''; print '
'.$langs->trans("PriceMode").''; @@ -606,28 +606,28 @@ if ($id > 0 || $ref) // Currency print '
'.$langs->trans("Currency").''; - $currencycodetouse = GETPOST('multicurrency_code')?GETPOST('multicurrency_code'):(isset($object->fourn_multicurrency_code)?$object->fourn_multicurrency_code:''); - if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) $currencycodetouse=$conf->currency; + $currencycodetouse = GETPOST('multicurrency_code') ?GETPOST('multicurrency_code') : (isset($object->fourn_multicurrency_code) ? $object->fourn_multicurrency_code : ''); + if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) $currencycodetouse = $conf->currency; print $form->selectMultiCurrency($currencycodetouse, "multicurrency_code", 1); print '
'.$langs->trans("CurrencyRate").''; + print ''; print '
'.$langs->trans("PriceQtyMinCurrency").''; print ' '; - print $form->selectPriceBaseType((GETPOST('multicurrency_price_base_type')?GETPOST('multicurrency_price_base_type'):'HT'), "multicurrency_price_base_type"); // We keep 'HT' here, multicurrency_price_base_type is not yet supported for supplier prices + print $form->selectPriceBaseType((GETPOST('multicurrency_price_base_type') ?GETPOST('multicurrency_price_base_type') : 'HT'), "multicurrency_price_base_type"); // We keep 'HT' here, multicurrency_price_base_type is not yet supported for supplier prices print '
' . $langs->trans("PriceQtyMin") . '
'.$langs->trans("PriceQtyMin").''; print ''; print ''; @@ -690,17 +690,17 @@ if ($id > 0 || $ref) SCRIPT; } else { // Price qty min - print '
' . $langs->trans("PriceQtyMin") . ''; + print '
'.$langs->trans("PriceQtyMin").''; print ' '; - print $form->selectPriceBaseType((GETPOST('price_base_type') ? GETPOST('price_base_type') : 'HT'), "price_base_type"); // We keep 'HT' here, price_base_type is not yet supported for supplier prices + print $form->selectPriceBaseType((GETPOST('price_base_type') ? GETPOST('price_base_type') : 'HT'), "price_base_type"); // We keep 'HT' here, price_base_type is not yet supported for supplier prices print '
'.$langs->trans("DiscountQtyMin").' %'; + print ' %'; print '
'.$langs->trans("SupplierReputation").''; - echo $form->selectarray('supplier_reputation', $object->reputations, $supplier_reputation?$supplier_reputation:$object->supplier_reputation); + echo $form->selectarray('supplier_reputation', $object->reputations, $supplier_reputation ? $supplier_reputation : $object->supplier_reputation); print '
' . $langs->trans('BarcodeValue') . ''.$langs->trans('BarcodeValue').'
' . $langs->trans('BarcodeType') . ''.$langs->trans('BarcodeType').''; print $formbarcode->selectBarcodeType(($rowid ? $object->fourn_fk_barcode_type : $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE), 'fk_barcode_type', 1); print '
'.$langs->trans("Charges").''; + print ''; print '
' . $extrafields->showInputField($key, '', '', '', '', '', 0, 'product_fournisseur_price') . '
'.$extrafields->showInputField($key, '', '', '', '', '', 0, 'product_fournisseur_price').'
' . $extrafields->showInputField($key, $resql->{$key}, '', '', '', '', 0, 'product_fournisseur_price') . '
'.$extrafields->showInputField($key, $resql->{$key}, '', '', '', '', 0, 'product_fournisseur_price').'
'; - $param="&id=".$object->id; + $param = "&id=".$object->id; print ''; print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder); @@ -875,11 +875,11 @@ SCRIPT; // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label("product_fournisseur_price"); - $extralabels=$extrafields->attributes["product_fournisseur_price"]['label']; + $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; if (!empty($extralabels)) { foreach ($extralabels as $key => $value) { // Show field if not hidden - if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { print_liste_field_titre($value, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); } } @@ -887,20 +887,20 @@ SCRIPT; if (is_object($hookmanager)) { - $parameters=array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); + $parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); } print_liste_field_titre(''); print "\n"; if (is_array($product_fourn_list)) { - foreach($product_fourn_list as $productfourn) + foreach ($product_fourn_list as $productfourn) { print ''; // Date from - print ''; + print ''; // Supplier print ''; @@ -916,10 +916,10 @@ SCRIPT; } // Availability - if(!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) + if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) { $form->load_cache_availability(); - $availability= $form->cache_availability[$productfourn->fk_availability]['label']; + $availability = $form->cache_availability[$productfourn->fk_availability]['label']; print ''; } @@ -930,7 +930,7 @@ SCRIPT; if ($conf->global->PRODUCT_USE_UNITS) { $unit = $object->getLabelOfUnit(); if ($unit !== '') { - print '  ' . $langs->trans($unit); + print '  '.$langs->trans($unit); } } print ''; @@ -942,7 +942,7 @@ SCRIPT; // Price for the quantity print ''; if ($conf->multicurrency->enabled) { @@ -995,9 +995,9 @@ SCRIPT; // Barcode type print ''; } @@ -1007,19 +1007,19 @@ SCRIPT; print ''; // Extrafields - $resql = $db->query("SELECT * FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = " . $productfourn->product_fourn_price_id); - if (! empty($extralabels)) { + $resql = $db->query("SELECT * FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = ".$productfourn->product_fourn_price_id); + if (!empty($extralabels)) { if ($db->num_rows($resql) != 1) { foreach ($extralabels as $key => $value) { - if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { print ""; } } } else { $resql = $db->fetch_object($resql); foreach ($extralabels as $key => $value) { - if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { - print '"; + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + print '"; } } } @@ -1027,8 +1027,8 @@ SCRIPT; if (is_object($hookmanager)) { - $parameters=array('id_pfp'=>$productfourn->product_fourn_price_id,'id_fourn'=>$id_fourn,'prod_id'=>$object->id); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); + $parameters = array('id_pfp'=>$productfourn->product_fourn_price_id, 'id_fourn'=>$id_fourn, 'prod_id'=>$object->id); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); } // Modify-Remove diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index f5604cbacdb..e2d954b2847 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -26,7 +26,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -48,7 +48,7 @@ class Productlot extends CommonObject /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='barcode'; + public $picto = 'barcode'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -59,14 +59,14 @@ class Productlot extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'batch' =>array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>1, 'notnull'=>0, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'comment'=>'Batch'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), - 'fk_user_creat'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511) + 'batch' =>array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>1, 'notnull'=>0, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'comment'=>'Batch'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + 'fk_user_creat'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511) ); /** @@ -150,56 +150,56 @@ class Productlot extends CommonObject // Put here code to add control on parameters values // Insert request - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - $sql.= 'entity,'; - $sql.= 'fk_product,'; - $sql.= 'batch,'; - $sql.= 'eatby,'; - $sql.= 'sellby,'; - $sql.= 'datec,'; - $sql.= 'fk_user_creat,'; - $sql.= 'fk_user_modif,'; - $sql.= 'import_key'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'('; + $sql .= 'entity,'; + $sql .= 'fk_product,'; + $sql .= 'batch,'; + $sql .= 'eatby,'; + $sql .= 'sellby,'; + $sql .= 'datec,'; + $sql .= 'fk_user_creat,'; + $sql .= 'fk_user_modif,'; + $sql .= 'import_key'; $sql .= ') VALUES ('; - $sql .= ' '.(! isset($this->entity)?$conf->entity:$this->entity).','; - $sql .= ' '.(! isset($this->fk_product)?'NULL':$this->fk_product).','; - $sql .= ' '.(! isset($this->batch)?'NULL':"'".$this->db->escape($this->batch)."'").','; - $sql .= ' '.(! isset($this->eatby) || dol_strlen($this->eatby)==0?'NULL':"'".$this->db->idate($this->eatby)."'").','; - $sql .= ' '.(! isset($this->sellby) || dol_strlen($this->sellby)==0?'NULL':"'".$this->db->idate($this->sellby)."'").','; + $sql .= ' '.(!isset($this->entity) ? $conf->entity : $this->entity).','; + $sql .= ' '.(!isset($this->fk_product) ? 'NULL' : $this->fk_product).','; + $sql .= ' '.(!isset($this->batch) ? 'NULL' : "'".$this->db->escape($this->batch)."'").','; + $sql .= ' '.(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : "'".$this->db->idate($this->eatby)."'").','; + $sql .= ' '.(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : "'".$this->db->idate($this->sellby)."'").','; $sql .= ' '."'".$this->db->idate(dol_now())."'".','; - $sql .= ' '.(! isset($this->fk_user_creat)?'NULL':$this->fk_user_creat).','; - $sql .= ' '.(! isset($this->fk_user_modif)?'NULL':$this->fk_user_modif).','; - $sql .= ' '.(! isset($this->import_key)?'NULL':$this->import_key); + $sql .= ' '.(!isset($this->fk_user_creat) ? 'NULL' : $this->fk_user_creat).','; + $sql .= ' '.(!isset($this->fk_user_modif) ? 'NULL' : $this->fk_user_modif).','; + $sql .= ' '.(!isset($this->import_key) ? 'NULL' : $this->import_key); $sql .= ')'; $this->db->begin(); $resql = $this->db->query($sql); if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) { + if (!$error && !$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. // Call triggers - $result=$this->call_trigger('PRODUCTLOT_CREATE', $user); + $result = $this->call_trigger('PRODUCTLOT_CREATE', $user); if ($result < 0) $error++; // End call triggers } @@ -209,7 +209,7 @@ class Productlot extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -243,11 +243,11 @@ class Productlot extends CommonObject $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif,"; $sql .= " t.import_key"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($product_id > 0 && $batch != '') { - $sql .= " WHERE t.batch = '". $this->db->escape($batch) . "' AND t.fk_product = " . $product_id; + $sql .= " WHERE t.batch = '".$this->db->escape($batch)."' AND t.fk_product = ".$product_id; } else { - $sql .= ' WHERE t.rowid = ' . $id; + $sql .= ' WHERE t.rowid = '.$id; } $resql = $this->db->query($sql); @@ -261,7 +261,7 @@ class Productlot extends CommonObject //$this->ref = $obj->fk_product.'_'.$obj->batch; $this->batch = $obj->batch; - $this->entity = (!empty($obj->entity)?$obj->entity:$conf->entity); // Prevent "null" entity + $this->entity = (!empty($obj->entity) ? $obj->entity : $conf->entity); // Prevent "null" entity $this->fk_product = $obj->fk_product; $this->eatby = $this->db->jdate($obj->eatby); $this->sellby = $this->db->jdate($obj->sellby); @@ -283,10 +283,10 @@ class Productlot extends CommonObject return 0; } } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -330,38 +330,38 @@ class Productlot extends CommonObject if (empty($this->oldcopy)) { - $org=new self($this->db); + $org = new self($this->db); $org->fetch($this->id); - $this->oldcopy=$org; + $this->oldcopy = $org; } // Update request - $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - $sql .= ' entity = '.(isset($this->entity)?$this->entity:"null").','; - $sql .= ' fk_product = '.(isset($this->fk_product)?$this->fk_product:"null").','; - $sql .= ' batch = '.(isset($this->batch)?"'".$this->db->escape($this->batch)."'":"null").','; - $sql .= ' eatby = '.(! isset($this->eatby) || dol_strlen($this->eatby) != 0 ? "'".$this->db->idate($this->eatby)."'" : 'null').','; - $sql .= ' sellby = '.(! isset($this->sellby) || dol_strlen($this->sellby) != 0 ? "'".$this->db->idate($this->sellby)."'" : 'null').','; - $sql .= ' datec = '.(! isset($this->datec) || dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').','; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; + $sql .= ' entity = '.(isset($this->entity) ? $this->entity : "null").','; + $sql .= ' fk_product = '.(isset($this->fk_product) ? $this->fk_product : "null").','; + $sql .= ' batch = '.(isset($this->batch) ? "'".$this->db->escape($this->batch)."'" : "null").','; + $sql .= ' eatby = '.(!isset($this->eatby) || dol_strlen($this->eatby) != 0 ? "'".$this->db->idate($this->eatby)."'" : 'null').','; + $sql .= ' sellby = '.(!isset($this->sellby) || dol_strlen($this->sellby) != 0 ? "'".$this->db->idate($this->sellby)."'" : 'null').','; + $sql .= ' datec = '.(!isset($this->datec) || dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; - $sql .= ' fk_user_creat = '.(isset($this->fk_user_creat)?$this->fk_user_creat:"null").','; - $sql .= ' fk_user_modif = '.(isset($this->fk_user_modif)?$this->fk_user_modif:"null").','; - $sql .= ' import_key = '.(isset($this->import_key)?$this->import_key:"null"); - $sql .= ' WHERE rowid=' . $this->id; + $sql .= ' fk_user_creat = '.(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").','; + $sql .= ' fk_user_modif = '.(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").','; + $sql .= ' import_key = '.(isset($this->import_key) ? $this->import_key : "null"); + $sql .= ' WHERE rowid='.$this->id; $this->db->begin(); $resql = $this->db->query($sql); if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -370,7 +370,7 @@ class Productlot extends CommonObject if (!$error && !$notrigger) { // Call triggers - $result=$this->call_trigger('PRODUCTLOT_MODIFY', $user); + $result = $this->call_trigger('PRODUCTLOT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } @@ -379,7 +379,7 @@ class Productlot extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -416,14 +416,14 @@ class Productlot extends CommonObject //} if (!$error) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; - $sql .= ' WHERE rowid=' . $this->id; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' WHERE rowid='.$this->id; $resql = $this->db->query($sql); if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } } @@ -431,7 +431,7 @@ class Productlot extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -469,9 +469,9 @@ class Productlot extends CommonObject // Other options if ($result < 0) { - $error ++; + $error++; $this->errors = $object->errors; - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } unset($object->context['createfromclone']); @@ -484,7 +484,7 @@ class Productlot extends CommonObject } else { $this->db->rollback(); - return - 1; + return -1; } } @@ -539,16 +539,16 @@ class Productlot extends CommonObject $result = ''; - $label = '' . $langs->trans("Batch") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Batch') . ': ' . $this->batch; + $label = ''.$langs->trans("Batch").''; + $label .= '
'; + $label .= ''.$langs->trans('Batch').': '.$this->batch; if ($this->eatby) { - $label.= '
' . $langs->trans('EatByDate') . ': ' . dol_print_date($this->eatby, 'day'); + $label .= '
'.$langs->trans('EatByDate').': '.dol_print_date($this->eatby, 'day'); } if ($this->sellby) { - $label.= '
' . $langs->trans('SellByDate') . ': ' . dol_print_date($this->sellby, 'day'); + $label .= '
'.$langs->trans('SellByDate').': '.dol_print_date($this->sellby, 'day'); } $url = DOL_URL_ROOT.'/product/stock/productlot_card.php?id='.$this->id; @@ -556,31 +556,31 @@ class Productlot extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowMyObject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->batch; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->batch; $result .= $linkend; return $result; diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 81fbd774111..22c8787348a 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -38,7 +38,7 @@ $langs->loadLangs(array('products', 'stocks', 'orders', 'productbatch')); if ($user->socid) { $socid = $user->socid; } -$result=restrictedArea($user, 'produit|service'); +$result = restrictedArea($user, 'produit|service'); //checks if a product has been ordered @@ -62,11 +62,11 @@ if (!$sortfield) { if (!$sortorder) { $sortorder = 'ASC'; } -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; -$offset = $limit * $page ; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$offset = $limit * $page; -$listofdata=array(); -if (! empty($_SESSION['massstockmove'])) $listofdata=json_decode($_SESSION['massstockmove'], true); +$listofdata = array(); +if (!empty($_SESSION['massstockmove'])) $listofdata = json_decode($_SESSION['massstockmove'], true); /* @@ -75,17 +75,17 @@ if (! empty($_SESSION['massstockmove'])) $listofdata=json_decode($_SESSION['mass if ($action == 'addline') { - if (! ($id_product > 0)) + if (!($id_product > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); } - if (! ($id_sw > 0)) + if (!($id_sw > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); } - if (! ($id_tw > 0)) + if (!($id_tw > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); @@ -96,16 +96,16 @@ if ($action == 'addline') $langs->load("errors"); setEventMessages($langs->trans("ErrorWarehouseMustDiffers"), null, 'errors'); } - if (! $qty) + if (!$qty) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); } // Check a batch number is provided if product need it - if (! $error) + if (!$error) { - $producttmp=new Product($db); + $producttmp = new Product($db); $producttmp->fetch($id_product); if ($producttmp->hasbatch()) { @@ -120,7 +120,7 @@ if ($action == 'addline') // TODO Check qty is ok for stock move. Note qty may not be enough yet, but we make a check now to report a warning. // What is important is to have qty when doing action 'createmovements' - if (! $error) + if (!$error) { // Warning, don't forget lines already added into the $_SESSION['massstockmove'] if ($producttmp->hasbatch()) @@ -131,12 +131,12 @@ if ($action == 'addline') } } - if (! $error) + if (!$error) { - if (count(array_keys($listofdata)) > 0) $id=max(array_keys($listofdata)) + 1; - else $id=1; - $listofdata[$id]=array('id'=>$id, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw, 'batch'=>$batch); - $_SESSION['massstockmove']=json_encode($listofdata); + if (count(array_keys($listofdata)) > 0) $id = max(array_keys($listofdata)) + 1; + else $id = 1; + $listofdata[$id] = array('id'=>$id, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw, 'batch'=>$batch); + $_SESSION['massstockmove'] = json_encode($listofdata); unset($id_product); //unset($id_sw); @@ -147,16 +147,16 @@ if ($action == 'addline') if ($action == 'delline' && $idline != '') { - if (! empty($listofdata[$idline])) unset($listofdata[$idline]); - if (count($listofdata) > 0) $_SESSION['massstockmove']=json_encode($listofdata); + if (!empty($listofdata[$idline])) unset($listofdata[$idline]); + if (count($listofdata) > 0) $_SESSION['massstockmove'] = json_encode($listofdata); else unset($_SESSION['massstockmove']); } if ($action == 'createmovements') { - $error=0; + $error = 0; - if (! GETPOST("label")) + if (!GETPOST("label")) { $error++; setEventMessages($langs->trans("ErrorFieldRequired"), $langs->transnoentitiesnoconv("MovementLabel"), null, 'errors'); @@ -164,38 +164,38 @@ if ($action == 'createmovements') $db->begin(); - if (! $error) + if (!$error) { $product = new Product($db); - foreach($listofdata as $key => $val) // Loop on each movement to do + foreach ($listofdata as $key => $val) // Loop on each movement to do { - $id=$val['id']; - $id_product=$val['id_product']; - $id_sw=$val['id_sw']; - $id_tw=$val['id_tw']; - $qty=price2num($val['qty']); - $batch=$val['batch']; - $dlc=-1; // They are loaded later from serial - $dluo=-1; // They are loaded later from serial + $id = $val['id']; + $id_product = $val['id_product']; + $id_sw = $val['id_sw']; + $id_tw = $val['id_tw']; + $qty = price2num($val['qty']); + $batch = $val['batch']; + $dlc = -1; // They are loaded later from serial + $dluo = -1; // They are loaded later from serial - if (! $error && $id_sw <> $id_tw && is_numeric($qty) && $id_product) + if (!$error && $id_sw <> $id_tw && is_numeric($qty) && $id_product) { - $result=$product->fetch($id_product); + $result = $product->fetch($id_product); - $product->load_stock('novirtual'); // Load array product->stock_warehouse + $product->load_stock('novirtual'); // Load array product->stock_warehouse // Define value of products moved - $pricesrc=0; - if (! empty($product->pmp)) $pricesrc=$product->pmp; - $pricedest=$pricesrc; + $pricesrc = 0; + if (!empty($product->pmp)) $pricesrc = $product->pmp; + $pricedest = $pricesrc; //print 'price src='.$pricesrc.', price dest='.$pricedest;exit; - if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) // If product does not need lot/serial + if (empty($conf->productbatch->enabled) || !$product->hasbatch()) // If product does not need lot/serial { // Remove stock - $result1=$product->correct_stock( + $result1 = $product->correct_stock( $user, $id_sw, $qty, @@ -211,7 +211,7 @@ if ($action == 'createmovements') } // Add stock - $result2=$product->correct_stock( + $result2 = $product->correct_stock( $user, $id_tw, $qty, @@ -228,22 +228,22 @@ if ($action == 'createmovements') } else { - $arraybatchinfo=$product->loadBatchInfo($batch); + $arraybatchinfo = $product->loadBatchInfo($batch); if (count($arraybatchinfo) > 0) { $firstrecord = array_shift($arraybatchinfo); - $dlc=$firstrecord['eatby']; - $dluo=$firstrecord['sellby']; + $dlc = $firstrecord['eatby']; + $dluo = $firstrecord['sellby']; //var_dump($batch); var_dump($arraybatchinfo); var_dump($firstrecord); var_dump($dlc); var_dump($dluo); exit; } else { - $dlc=''; - $dluo=''; + $dlc = ''; + $dluo = ''; } // Remove stock - $result1=$product->correct_stock_batch( + $result1 = $product->correct_stock_batch( $user, $id_sw, $qty, @@ -262,7 +262,7 @@ if ($action == 'createmovements') } // Add stock - $result2=$product->correct_stock_batch( + $result2 = $product->correct_stock_batch( $user, $id_tw, $qty, @@ -289,13 +289,13 @@ if ($action == 'createmovements') } } - if (! $error) + if (!$error) { unset($_SESSION['massstockmove']); $db->commit(); setEventMessages($langs->trans("StockMovementRecorded"), null, 'mesgs'); - header("Location: ".DOL_URL_ROOT.'/product/stock/index.php'); // Redirect to avoid pb when using back + header("Location: ".DOL_URL_ROOT.'/product/stock/index.php'); // Redirect to avoid pb when using back exit; } else @@ -311,10 +311,10 @@ if ($action == 'createmovements') * View */ -$now=dol_now(); +$now = dol_now(); -$form=new Form($db); -$formproduct=new FormProduct($db); +$form = new Form($db); +$formproduct = new FormProduct($db); $productstatic = new Product($db); $warehousestatics = new Entrepot($db); $warehousestatict = new Entrepot($db); @@ -325,16 +325,16 @@ llxHeader('', $title); print load_fiche_titre($langs->trans("MassStockTransferShort")); -$titletoadd=$langs->trans("Select"); -$buttonrecord=$langs->trans("RecordMovement"); -$titletoaddnoent=$langs->transnoentitiesnoconv("Select"); -$buttonrecordnoent=$langs->transnoentitiesnoconv("RecordMovement"); +$titletoadd = $langs->trans("Select"); +$buttonrecord = $langs->trans("RecordMovement"); +$titletoaddnoent = $langs->transnoentitiesnoconv("Select"); +$buttonrecordnoent = $langs->transnoentitiesnoconv("RecordMovement"); print ''.$langs->trans("SelectProductInAndOutWareHouse", $titletoaddnoent, $buttonrecordnoent).'
'; print '
'."\n"; // Form to add a line print ''; -print ''; +print ''; print ''; @@ -342,7 +342,7 @@ print '
'; print '
'.dol_print_date(($productfourn->fourn_date_creation ? $productfourn->fourn_date_creation: $productfourn->date_creation), 'dayhour').''.dol_print_date(($productfourn->fourn_date_creation ? $productfourn->fourn_date_creation : $productfourn->date_creation), 'dayhour').''.$productfourn->getSocNomUrl(1, 'supplier').''.$availability.''; - print $productfourn->fourn_price?price($productfourn->fourn_price):""; + print $productfourn->fourn_price ?price($productfourn->fourn_price) : ""; print ''; - $productfourn->barcode_type = !empty($productfourn->fk_barcode_type) ? $productfourn->fk_barcode_type:0; + $productfourn->barcode_type = !empty($productfourn->fk_barcode_type) ? $productfourn->fk_barcode_type : 0; $productfourn->fetch_barcode(); - print $productfourn->barcode_type_label?$productfourn->barcode_type_label:($productfourn->barcode?'
'.$langs->trans("SetDefaultBarcodeType").'
':''); + print $productfourn->barcode_type_label ? $productfourn->barcode_type_label : ($productfourn->barcode ? '
'.$langs->trans("SetDefaultBarcodeType").'
' : ''); print '
' . $extrafields->showOutputField($key, $resql->{$key}) . "'.$extrafields->showOutputField($key, $resql->{$key})."
'; //print '
'; -$param=''; +$param = ''; print '
'; print getTitleFieldOfList($langs->trans('ProductRef'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); @@ -359,10 +359,10 @@ print ''; print ''; // Product print '
'; -$filtertype=0; -if (! empty($conf->global->STOCK_SUPPORTS_SERVICES)) $filtertype=''; +$filtertype = 0; +if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) $filtertype = ''; if ($conf->global->PRODUIT_LIMIT_SIZE <= 0) { - $limit=''; + $limit = ''; } else { @@ -394,7 +394,7 @@ print ''; -foreach($listofdata as $key => $val) +foreach ($listofdata as $key => $val) { $productstatic->fetch($val['id_product']); $warehousestatics->fetch($val['id_sw']); @@ -432,12 +432,12 @@ print '
'; print ''; -print ''; +print ''; print ''; // Button to record mass movement -$codemove=(isset($_POST["codemove"])?GETPOST("codemove", 'alpha'):dol_print_date(dol_now(), '%Y%m%d%H%M%S')); -$labelmovement=GETPOST("label")?GETPOST('label'):$langs->trans("StockTransfer").' '.dol_print_date($now, '%Y-%m-%d %H:%M'); +$codemove = (isset($_POST["codemove"]) ?GETPOST("codemove", 'alpha') : dol_print_date(dol_now(), '%Y%m%d%H%M%S')); +$labelmovement = GETPOST("label") ?GETPOST('label') : $langs->trans("StockTransfer").' '.dol_print_date($now, '%Y-%m-%d %H:%M'); print ''; print ''; diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 2932ba43d5b..d1c81ff7251 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -38,46 +38,46 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productstockentrepot.class.php'; -if (! empty($conf->productbatch->enabled)) { +if (!empty($conf->productbatch->enabled)) { require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; } -if (! empty($conf->projet->enabled)) { +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } -if (! empty($conf->variants->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/variants/class/ProductAttribute.class.php'; - require_once DOL_DOCUMENT_ROOT . '/variants/class/ProductAttributeValue.class.php'; - require_once DOL_DOCUMENT_ROOT . '/variants/class/ProductCombination.class.php'; - require_once DOL_DOCUMENT_ROOT . '/variants/class/ProductCombination2ValuePair.class.php'; +if (!empty($conf->variants->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php'; + require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php'; + require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; + require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php'; } // Load translation files required by the page $langs->loadlangs(array('products', 'orders', 'bills', 'stocks', 'sendings')); -if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); -$backtopage=GETPOST('backtopage', 'alpha'); -$action=GETPOST('action', 'aZ09'); -$cancel=GETPOST('cancel', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); -$id=GETPOST('id', 'int'); -$ref=GETPOST('ref', 'alpha'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $stocklimit = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); $cancel = GETPOST('cancel', 'alpha'); -$fieldid = isset($_GET["ref"])?'ref':'rowid'; -$d_eatby=dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); -$d_sellby=dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); -$pdluoid=GETPOST('pdluoid', 'int'); -$batchnumber=GETPOST('batch_number', 'san_alpha'); +$fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid'; +$d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); +$d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); +$pdluoid = GETPOST('pdluoid', 'int'); +$batchnumber = GETPOST('batch_number', 'san_alpha'); if (!empty($batchnumber)) { - $batchnumber=trim($batchnumber); + $batchnumber = trim($batchnumber); } // Security check -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'produit&stock', $id, 'product&product', '', '', $fieldid); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit&stock', $id, 'product&product', '', '', $fieldid); $object = new Product($db); @@ -86,19 +86,19 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); } -if(empty($id) && !empty($object->id)) $id = $object->id; +if (empty($id) && !empty($object->id)) $id = $object->id; -$modulepart='product'; +$modulepart = 'product'; // Get object canvas (By default, this is not defined, so standard usage of dolibarr) -$canvas = !empty($object->canvas)?$object->canvas:GETPOST("canvas"); -$objcanvas=null; -if (! empty($canvas)) +$canvas = !empty($object->canvas) ? $object->canvas : GETPOST("canvas"); +$objcanvas = null; +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); @@ -106,17 +106,17 @@ if (! empty($canvas)) } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('stockproductcard','globalcard')); +$hookmanager->initHooks(array('stockproductcard', 'globalcard')); /* * Actions */ -if ($cancel) $action=''; +if ($cancel) $action = ''; -$parameters=array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer)) @@ -125,29 +125,29 @@ if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer) $desiredstock = GETPOST('desiredstock'); $maj_ok = true; - if($seuil_stock_alerte == '') { + if ($seuil_stock_alerte == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("StockLimit")), null, 'errors'); $maj_ok = false; } - if($desiredstock == '') { + if ($desiredstock == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DesiredStock")), null, 'errors'); $maj_ok = false; } - if($maj_ok) { + if ($maj_ok) { $pse = new ProductStockEntrepot($db); if ($pse->fetch(0, $id, GETPOST('fk_entrepot', 'int')) > 0) { // Update $pse->seuil_stock_alerte = $seuil_stock_alerte; - $pse->desiredstock = $desiredstock; - if($pse->update($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseUpdated'), null, 'mesgs'); + $pse->desiredstock = $desiredstock; + if ($pse->update($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseUpdated'), null, 'mesgs'); } else { // Create - $pse->fk_entrepot = GETPOST('fk_entrepot'); + $pse->fk_entrepot = GETPOST('fk_entrepot'); $pse->fk_product = $id; $pse->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $pse->desiredstock = GETPOST('desiredstock'); - if($pse->create($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseCreated'), null, 'mesgs'); + if ($pse->create($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseCreated'), null, 'mesgs'); } } @@ -155,7 +155,7 @@ if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer) exit; } -if($action == 'delete_productstockwarehouse' && !empty($user->rights->produit->creer)) +if ($action == 'delete_productstockwarehouse' && !empty($user->rights->produit->creer)) { $pse = new ProductStockEntrepot($db); @@ -169,61 +169,61 @@ if($action == 'delete_productstockwarehouse' && !empty($user->rights->produit->c if ($action == 'setseuil_stock_alerte' && !empty($user->rights->produit->creer)) { $object = new Product($db); - $result=$object->fetch($id); - $object->seuil_stock_alerte=$stocklimit; - $result=$object->update($object->id, $user, 0, 'update'); + $result = $object->fetch($id); + $object->seuil_stock_alerte = $stocklimit; + $result = $object->update($object->id, $user, 0, 'update'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); //else // setEventMessages($lans->trans("SavedRecordSuccessfully"), null, 'mesgs'); - $action=''; + $action = ''; } // Set desired stock if ($action == 'setdesiredstock' && !empty($user->rights->produit->creer)) { $object = new Product($db); - $result=$object->fetch($id); - $object->desiredstock=$desiredstock; - $result=$object->update($object->id, $user, 0, 'update'); + $result = $object->fetch($id); + $object->desiredstock = $desiredstock; + $result = $object->update($object->id, $user, 0, 'update'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } // Correct stock -if ($action == "correct_stock" && ! $cancel) +if ($action == "correct_stock" && !$cancel) { - if (! (GETPOST("id_entrepot") > 0)) + if (!(GETPOST("id_entrepot") > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; - $action='correction'; + $action = 'correction'; } - if (! GETPOST("nbpiece")) + if (!GETPOST("nbpiece")) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; - $action='correction'; + $action = 'correction'; } - if (! empty($conf->productbatch->enabled)) + if (!empty($conf->productbatch->enabled)) { $object = new Product($db); - $result=$object->fetch($id); + $result = $object->fetch($id); - if ($object->hasbatch() && ! $batchnumber) + if ($object->hasbatch() && !$batchnumber) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); $error++; - $action='correction'; + $action = 'correction'; } } - if (! $error) + if (!$error) { - $priceunit=price2num(GETPOST("unitprice")); + $priceunit = price2num(GETPOST("unitprice")); if (is_numeric(GETPOST("nbpiece")) && $id) { $origin_element = ''; @@ -237,16 +237,16 @@ if ($action == "correct_stock" && ! $cancel) if (empty($object)) { $object = new Product($db); - $result=$object->fetch($id); + $result = $object->fetch($id); } if ($object->hasbatch()) { - $result=$object->correct_stock_batch( + $result = $object->correct_stock_batch( $user, GETPOST("id_entrepot"), GETPOST("nbpiece"), GETPOST("mouvement"), - GETPOST("label"), // label movement + GETPOST("label"), // label movement $priceunit, $d_eatby, $d_sellby, @@ -254,11 +254,11 @@ if ($action == "correct_stock" && ! $cancel) GETPOST('inventorycode'), $origin_element, $origin_id - ); // We do not change value of stock for a correction + ); // We do not change value of stock for a correction } else { - $result=$object->correct_stock( + $result = $object->correct_stock( $user, GETPOST("id_entrepot"), GETPOST("nbpiece"), @@ -268,7 +268,7 @@ if ($action == "correct_stock" && ! $cancel) GETPOST('inventorycode'), $origin_element, $origin_id - ); // We do not change value of stock for a correction + ); // We do not change value of stock for a correction } if ($result > 0) @@ -287,61 +287,61 @@ if ($action == "correct_stock" && ! $cancel) else { setEventMessages($object->error, $object->errors, 'errors'); - $action='correction'; + $action = 'correction'; } } } } // Transfer stock from a warehouse to another warehouse -if ($action == "transfert_stock" && ! $cancel) +if ($action == "transfert_stock" && !$cancel) { - if (! (GETPOST("id_entrepot", 'int') > 0) || ! (GETPOST("id_entrepot_destination", 'int') > 0)) + if (!(GETPOST("id_entrepot", 'int') > 0) || !(GETPOST("id_entrepot_destination", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } - if (! GETPOST("nbpiece", 'int')) + if (!GETPOST("nbpiece", 'int')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } if (GETPOST("id_entrepot", 'int') == GETPOST("id_entrepot_destination", 'int')) { setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } - if (! empty($conf->productbatch->enabled)) + if (!empty($conf->productbatch->enabled)) { $object = new Product($db); - $result=$object->fetch($id); + $result = $object->fetch($id); - if ($object->hasbatch() && ! $batchnumber) + if ($object->hasbatch() && !$batchnumber) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } } - if (! $error) + if (!$error) { if ($id) { $object = new Product($db); - $result=$object->fetch($id); + $result = $object->fetch($id); $db->begin(); - $object->load_stock('novirtual'); // Load array product->stock_warehouse + $object->load_stock('novirtual'); // Load array product->stock_warehouse // Define value of products moved - $pricesrc=0; - if (isset($object->pmp)) $pricesrc=$object->pmp; - $pricedest=$pricesrc; + $pricesrc = 0; + if (isset($object->pmp)) $pricesrc = $object->pmp; + $pricedest = $pricesrc; if ($object->hasbatch()) { @@ -349,13 +349,13 @@ if ($action == "transfert_stock" && ! $cancel) if ($pdluoid > 0) { - $result=$pdluo->fetch($pdluoid); + $result = $pdluo->fetch($pdluoid); if ($result) { - $srcwarehouseid=$pdluo->warehouseid; - $batch=$pdluo->batch; - $eatby=$pdluo->eatby; - $sellby=$pdluo->sellby; + $srcwarehouseid = $pdluo->warehouseid; + $batch = $pdluo->batch; + $eatby = $pdluo->eatby; + $sellby = $pdluo->sellby; } else { @@ -365,16 +365,16 @@ if ($action == "transfert_stock" && ! $cancel) } else { - $srcwarehouseid=GETPOST('id_entrepot', 'int'); - $batch=$batchnumber; - $eatby=$d_eatby; - $sellby=$d_sellby; + $srcwarehouseid = GETPOST('id_entrepot', 'int'); + $batch = $batchnumber; + $eatby = $d_eatby; + $sellby = $d_sellby; } - if (! $error) + if (!$error) { // Remove stock - $result1=$object->correct_stock_batch( + $result1 = $object->correct_stock_batch( $user, $srcwarehouseid, GETPOST("nbpiece", 'int'), @@ -386,10 +386,10 @@ if ($action == "transfert_stock" && ! $cancel) ); if ($result1 < 0) $error++; } - if (! $error) + if (!$error) { // Add stock - $result2=$object->correct_stock_batch( + $result2 = $object->correct_stock_batch( $user, GETPOST("id_entrepot_destination", 'int'), GETPOST("nbpiece", 'int'), @@ -404,10 +404,10 @@ if ($action == "transfert_stock" && ! $cancel) } else { - if (! $error) + if (!$error) { // Remove stock - $result1=$object->correct_stock( + $result1 = $object->correct_stock( $user, GETPOST("id_entrepot"), GETPOST("nbpiece"), @@ -418,10 +418,10 @@ if ($action == "transfert_stock" && ! $cancel) ); if ($result1 < 0) $error++; } - if (! $error) + if (!$error) { // Add stock - $result2=$object->correct_stock( + $result2 = $object->correct_stock( $user, GETPOST("id_entrepot_destination"), GETPOST("nbpiece"), @@ -435,7 +435,7 @@ if ($action == "transfert_stock" && ! $cancel) } - if (! $error && $result1 >= 0 && $result2 >= 0) + if (!$error && $result1 >= 0 && $result2 >= 0) { $db->commit(); @@ -454,7 +454,7 @@ if ($action == "transfert_stock" && ! $cancel) { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); - $action='transfert'; + $action = 'transfert'; } } } @@ -464,24 +464,24 @@ if ($action == "transfert_stock" && ! $cancel) if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save')) { $pdluo = new Productbatch($db); - $result=$pdluo->fetch(GETPOST('pdluoid', 'int')); + $result = $pdluo->fetch(GETPOST('pdluoid', 'int')); - if ($result>0) + if ($result > 0) { if ($pdluo->id) { - if ((! GETPOST("sellby")) && (! GETPOST("eatby")) && (! $batchnumber)) { + if ((!GETPOST("sellby")) && (!GETPOST("eatby")) && (!$batchnumber)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); } else { - $d_eatby=dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); - $d_sellby=dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); - $pdluo->batch=$batchnumber; - $pdluo->eatby=$d_eatby; - $pdluo->sellby=$d_sellby; - $result=$pdluo->update($user); - if ($result<0) + $d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); + $d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); + $pdluo->batch = $batchnumber; + $pdluo->eatby = $d_eatby; + $pdluo->sellby = $d_sellby; + $result = $pdluo->update($user); + if ($result < 0) { setEventMessages($pdluo->error, $pdluo->errors, 'errors'); } @@ -507,8 +507,8 @@ if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save')) */ $form = new Form($db); -$formproduct=new FormProduct($db); -if (! empty($conf->projet->enabled)) $formproject=new FormProjets($db); +$formproduct = new FormProduct($db); +if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); if ($id > 0 || $ref) { @@ -524,22 +524,22 @@ if ($id > 0 || $ref) $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Stock'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Stock'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Stock'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Stock'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); if ($result > 0) { - $head=product_prepare_head($object); - $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type==Product::TYPE_SERVICE?'service':'product'); + $head = product_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'stock', $titre, -1, $picto); @@ -548,7 +548,7 @@ if ($id > 0 || $ref) $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->socid && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -557,22 +557,22 @@ if ($id > 0 || $ref) print '
'; print '
'; - if (! $variants) { + if (!$variants) { if ($conf->productbatch->enabled) { - print ''; } // PMP - print ''; + print ''; print ''; print ''; // Minimum Price - print ''; + print ''; print ''; // Price minimum - print ''; } else { // Price - print ''; // Price minimum - print ''; } // Stock alert threshold - print ''; // Hook formObject $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Desired stock - print ''; // Real stock - $text_stock_options = $langs->trans("RealStockDesc") . '
'; - $text_stock_options .= $langs->trans("RealStockWillAutomaticallyWhen") . '
'; - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) ? $langs->trans("DeStockOnShipment") . '
' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) ? $langs->trans("DeStockOnValidateOrder") . '
' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_BILL) ? $langs->trans("DeStockOnBill") . '
' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? $langs->trans("ReStockOnBill") . '
' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? $langs->trans("ReStockOnValidateOrder") . '
' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? $langs->trans("ReStockOnDispatchOrder") . '
' : ''); - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)?$langs->trans("StockOnReception").'
':''); + $text_stock_options = $langs->trans("RealStockDesc").'
'; + $text_stock_options .= $langs->trans("RealStockWillAutomaticallyWhen").'
'; + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) ? $langs->trans("DeStockOnShipment").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) ? $langs->trans("DeStockOnValidateOrder").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_BILL) ? $langs->trans("DeStockOnBill").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? $langs->trans("ReStockOnBill").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? $langs->trans("ReStockOnValidateOrder").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? $langs->trans("ReStockOnDispatchOrder").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? $langs->trans("StockOnReception").'
' : ''); print ''; - print ''; print ''; $stocktheo = price2num($object->stock_theorique, 'MS'); $found = 0; - $helpondiff = '' . $langs->trans("StockDiffPhysicTeoric") . ':
'; + $helpondiff = ''.$langs->trans("StockDiffPhysicTeoric").':
'; // Number of customer orders running if (!empty($conf->commande->enabled)) { if ($found) $helpondiff .= '
'; else $found = 1; - $helpondiff .= $langs->trans("ProductQtyInCustomersOrdersRunning") . ': ' . $object->stats_commande['qty']; + $helpondiff .= $langs->trans("ProductQtyInCustomersOrdersRunning").': '.$object->stats_commande['qty']; $result = $object->load_stats_commande(0, '0', 1); if ($result < 0) dol_print_error($db, $object->error); - $helpondiff .= ' (' . $langs->trans("ProductQtyInDraft") . ': ' . $object->stats_commande['qty'] . ')'; + $helpondiff .= ' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; } // Number of product from customer order already sent (partial shipping) if (!empty($conf->expedition->enabled)) { if ($found) $helpondiff .= '
'; else $found = 1; $result = $object->load_stats_sending(0, '2', 1); - $helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent") . ': ' . $object->stats_expedition['qty']; + $helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty']; } // Number of supplier order running if (!empty($conf->fournisseur->enabled)) { if ($found) $helpondiff .= '
'; else $found = 1; $result = $object->load_stats_commande_fournisseur(0, '3,4', 1); - $helpondiff .= $langs->trans("ProductQtyInSuppliersOrdersRunning") . ': ' . $object->stats_commande_fournisseur['qty']; + $helpondiff .= $langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$object->stats_commande_fournisseur['qty']; $result = $object->load_stats_commande_fournisseur(0, '0,1,2', 1); if ($result < 0) dol_print_error($db, $object->error); - $helpondiff .= ' (' . $langs->trans("ProductQtyInDraftOrWaitingApproved") . ': ' . $object->stats_commande_fournisseur['qty'] . ')'; + $helpondiff .= ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; } // Number of product from supplier order already received (partial receipt) if (!empty($conf->fournisseur->enabled)) { if ($found) $helpondiff .= '
'; else $found = 1; - $helpondiff .= $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied") . ': ' . $object->stats_reception['qty']; + $helpondiff .= $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty']; } // Calculating a theorical value @@ -689,7 +689,7 @@ if ($id > 0 || $ref) print "'; print ''; @@ -697,8 +697,8 @@ if ($id > 0 || $ref) if (!empty($user->rights->stock->mouvement->lire)) { $sql = "SELECT max(m.datem) as datem"; - $sql .= " FROM " . MAIN_DB_PREFIX . "stock_mouvement as m"; - $sql .= " WHERE m.fk_product = '" . $object->id . "'"; + $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; + $sql .= " WHERE m.fk_product = '".$object->id."'"; $resqlbis = $db->query($sql); if ($resqlbis) { $obj = $db->fetch_object($resqlbis); @@ -706,12 +706,12 @@ if ($id > 0 || $ref) } else { dol_print_error($db); } - print '"; } @@ -750,9 +750,9 @@ else /* */ /* ************************************************************************** */ -$parameters=array(); +$parameters = array(); -$reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { if (empty($action) && $object->id) @@ -761,33 +761,33 @@ if (empty($reshook)) if ($user->rights->stock->mouvement->creer) { - if (! $variants || ! empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { - print '' . $langs->trans("CorrectStock") . ''; + if (!$variants || !empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { + print ''.$langs->trans("CorrectStock").''; } else { - print '' . $langs->trans("CorrectStock") . ''; + print ''.$langs->trans("CorrectStock").''; } } else { - print '' . $langs->trans("CorrectStock") . ''; + print ''.$langs->trans("CorrectStock").''; } //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) if ($user->rights->stock->mouvement->creer) { - if (! $variants || ! empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { - print '' . $langs->trans("TransferStock") . ''; + if (!$variants || !empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { + print ''.$langs->trans("TransferStock").''; } else { - print '' . $langs->trans("TransferStock") . ''; + print ''.$langs->trans("TransferStock").''; } } else { - print '' . $langs->trans("CorrectStock") . ''; + print ''.$langs->trans("CorrectStock").''; } print ''; @@ -795,7 +795,7 @@ if (empty($reshook)) } -if (! $variants) { +if (!$variants) { /* * Stock detail (by warehouse). May go down into batch details. */ @@ -804,18 +804,18 @@ if (! $variants) { print '
' . $langs->trans("ManageLotSerial") . ''; + print '
'.$langs->trans("ManageLotSerial").''; print $object->getLibStatut(0, 2); print '
' . $langs->trans("AverageUnitPricePMP") . '
'.$langs->trans("AverageUnitPricePMP").''; - if ($object->pmp > 0) print price($object->pmp) . ' ' . $langs->trans("HT"); + if ($object->pmp > 0) print price($object->pmp).' '.$langs->trans("HT"); print '
' . $langs->trans("BuyingPriceMin") . '
'.$langs->trans("BuyingPriceMin").''; $product_fourn = new ProductFournisseur($db); if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) { @@ -583,103 +583,103 @@ if ($id > 0 || $ref) if (empty($conf->global->PRODUIT_MULTIPRICES)) { // Price - print '
' . $langs->trans("SellingPrice") . ''; + print '
'.$langs->trans("SellingPrice").''; if ($object->price_base_type == 'TTC') { - print price($object->price_ttc) . ' ' . $langs->trans($object->price_base_type); + print price($object->price_ttc).' '.$langs->trans($object->price_base_type); } else { - print price($object->price) . ' ' . $langs->trans($object->price_base_type); + print price($object->price).' '.$langs->trans($object->price_base_type); } print '
' . $langs->trans("MinPrice") . ''; + print '
'.$langs->trans("MinPrice").''; if ($object->price_base_type == 'TTC') { - print price($object->price_min_ttc) . ' ' . $langs->trans($object->price_base_type); + print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type); } else { - print price($object->price_min) . ' ' . $langs->trans($object->price_base_type); + print price($object->price_min).' '.$langs->trans($object->price_base_type); } print '
' . $langs->trans("SellingPrice") . ''; + print '
'.$langs->trans("SellingPrice").''; print $langs->trans("Variable"); print '
' . $langs->trans("MinPrice") . ''; + print '
'.$langs->trans("MinPrice").''; print $langs->trans("Variable"); print '
' . $form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer) . ''; + print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer).''; print $form->editfieldval("StockLimit", 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer, 'string'); print '
' . $form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1), 'desiredstock', $object->desiredstock, $object, $user->rights->produit->creer); + print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1), 'desiredstock', $object->desiredstock, $object, $user->rights->produit->creer); print ''; print $form->editfieldval("DesiredStock", 'desiredstock', $object->desiredstock, $object, $user->rights->produit->creer, 'string'); print '
'; print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1); print '' . price2num($object->stock_reel, 'MS'); - if ($object->seuil_stock_alerte != '' && ($object->stock_reel < $object->seuil_stock_alerte)) print ' ' . img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); + print ''.price2num($object->stock_reel, 'MS'); + if ($object->seuil_stock_alerte != '' && ($object->stock_reel < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); print '
"; //print (empty($stocktheo)?0:$stocktheo); print $form->textwithpicto((empty($stocktheo) ? 0 : $stocktheo), $helpondiff); - if ($object->seuil_stock_alerte != '' && ($object->stock_theorique < $object->seuil_stock_alerte)) print ' ' . img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); + if ($object->seuil_stock_alerte != '' && ($object->stock_theorique < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); print '
' . $langs->trans("LastMovement") . ''; + print '
'.$langs->trans("LastMovement").''; if ($lastmovementdate) { - print dol_print_date($lastmovementdate, 'dayhour') . ' '; - print '(' . $langs->trans("FullList") . ')'; + print dol_print_date($lastmovementdate, 'dayhour').' '; + print '('.$langs->trans("FullList").')'; } else { - print '' . $langs->trans("None") . ''; + print ''.$langs->trans("None").''; } print "
'; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) { print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -825,13 +825,13 @@ if (! $variants) { } $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp"; - $sql .= " FROM " . MAIN_DB_PREFIX . "entrepot as e,"; - $sql .= " " . MAIN_DB_PREFIX . "product_stock as ps"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = ps.fk_product"; + $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; + $sql .= " ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; $sql .= " WHERE ps.reel != 0"; $sql .= " AND ps.fk_entrepot = e.rowid"; - $sql .= " AND e.entity IN (" . getEntity('stock') . ")"; - $sql .= " AND ps.fk_product = " . $object->id; + $sql .= " AND e.entity IN (".getEntity('stock').")"; + $sql .= " AND ps.fk_product = ".$object->id; $sql .= " ORDER BY e.ref"; $entrepotstatic = new Entrepot($db); @@ -859,12 +859,12 @@ if (! $variants) { $stock_real = price2num($obj->reel, 'MS'); print ''; - print ''; - print ''; + print ''; + print ''; // PMP - print ''; + print ''; // Value purchase - print ''; + print ''; // Sell price print ''; // Value sell print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price * $obj->reel, 'MT'), 1).''; else print $langs->trans("Variable"); print ''; $total += $obj->reel; @@ -890,27 +890,27 @@ if (! $variants) { $product_lot_static->sellby = $pdluo->sellby; if ($action == 'editline' && GETPOST('lineid', 'int') == $pdluo->id) { //Current line edit - print "\n" . ''; + print "\n".''; print ''; } else { - print "\n" . ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; } @@ -931,10 +931,10 @@ if (! $variants) { } else dol_print_error($db); // Total line - print ''; - print ''; + print ''; + print ''; print ''; // Value purchase print ''; print '
' . $langs->trans("Warehouse") . '' . $langs->trans("NumberOfUnit") . '' . $langs->trans("AverageUnitPricePMPShort") . '' . $langs->trans("EstimatedStockValueShort") . '' . $langs->trans("SellPriceMin") . '' . $langs->trans("EstimatedStockValueSellShort") . ''.$langs->trans("Warehouse").''.$langs->trans("NumberOfUnit").''.$langs->trans("AverageUnitPricePMPShort").''.$langs->trans("EstimatedStockValueShort").''.$langs->trans("SellPriceMin").''.$langs->trans("EstimatedStockValueSellShort").'
' . $langs->trans("batch_number") . '' . $langs->trans("EatByDate") . '' . $langs->trans("SellByDate") . ''.$langs->trans("batch_number").''.$langs->trans("EatByDate").''.$langs->trans("SellByDate").'
' . $entrepotstatic->getNomUrl(1) . '' . $stock_real . ($stock_real < 0 ? ' ' . img_warning() : '') . ''.$entrepotstatic->getNomUrl(1).''.$stock_real.($stock_real < 0 ? ' '.img_warning() : '').'' . (price2num($object->pmp) ? price2num($object->pmp, 'MU') : '') . ''.(price2num($object->pmp) ? price2num($object->pmp, 'MU') : '').'' . (price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '') . ''.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').''; if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price, 'MU'), 1); @@ -872,7 +872,7 @@ if (! $variants) { print ''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price * $obj->reel, 'MT'), 1) . '
'; - print ''; - print ''; - print ''; + print ''; + print '
'; + print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print '
'; print $form->selectDate($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0); print ''; print $form->selectDate($pdluo->sellby, 'sellby', '', '', 1, '', 1, 0); print '' . $pdluo->qty . ($pdluo->qty < 0 ? ' ' . img_warning() : '') . ''; - print '
'.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; + print '
'; print ''; print '
'; - print img_picto($langs->trans("Tranfer"), 'uparrow', 'class="hideonsmartphone"') . ' '; - print 'id . '">' . $langs->trans("TransferStock") . ''; + print "\n".'
'; + print img_picto($langs->trans("Tranfer"), 'uparrow', 'class="hideonsmartphone"').' '; + print 'id.'">'.$langs->trans("TransferStock").''; // Disabled, because edition of stock content must use the "Correct stock menu". // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... //print 'id.'#'.$pdluo->id.'">'; @@ -918,9 +918,9 @@ if (! $variants) { print ''; print $product_lot_static->getNomUrl(1); print '' . dol_print_date($pdluo->eatby, 'day') . '' . dol_print_date($pdluo->sellby, 'day') . '' . $pdluo->qty . ($pdluo->qty < 0 ? ' ' . img_warning() : '') . ''.dol_print_date($pdluo->eatby, 'day').''.dol_print_date($pdluo->sellby, 'day').''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').'
' . $langs->trans("Total") . ':' . price2num($total, 'MS') . '
'.$langs->trans("Total").':'.price2num($total, 'MS').''; - print ($totalwithpmp ? price(price2num($totalvalue / $totalwithpmp, 'MU')) : ' '); // This value may have rounding errors + print ($totalwithpmp ? price(price2num($totalvalue / $totalwithpmp, 'MU')) : ' '); // This value may have rounding errors print ''; @@ -959,21 +959,21 @@ if (! $variants) { print load_fiche_titre($langs->trans('AddNewProductStockWarehouse')); if (!empty($user->rights->produit->creer)) { - print '
'; + print ''; print ''; - print ''; + print ''; } print ''; if (!empty($user->rights->produit->creer)) { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; } else { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; } @@ -985,11 +985,11 @@ if (! $variants) { foreach ($lines as $line) { $ent = new Entrepot($db); $ent->fetch($line['fk_entrepot']); - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (!empty($user->rights->produit->creer)) { - print ''; + print ''; } print ''; } @@ -1035,12 +1035,12 @@ if (! $variants) { if (count($productCombinations)) { - $stock_total= 0; + $stock_total = 0; foreach ($productCombinations as $currcomb) { $prodstatic->fetch($currcomb->fk_product_child); $prodstatic->load_stock(); - $stock_total+=$prodstatic->stock_reel; + $stock_total += $prodstatic->stock_reel; ?> diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index dbab10c0bf4..1d8b709f662 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -41,7 +41,7 @@ $langs->loadLangs(array('products', 'stocks', 'orders')); if ($user->socid) { $socid = $user->socid; } -$result=restrictedArea($user, 'produit|service'); +$result = restrictedArea($user, 'produit|service'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('stockreplenishlist')); @@ -51,7 +51,7 @@ $hookmanager->initHooks(array('stockreplenishlist')); $action = GETPOST('action', 'alpha'); $sref = GETPOST('sref', 'alpha'); $snom = GETPOST('snom', 'alpha'); -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $type = GETPOST('type', 'int'); $tobuy = GETPOST('tobuy', 'int'); $salert = GETPOST('salert', 'alpha'); @@ -68,8 +68,8 @@ $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; -$offset = $limit * $page ; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$offset = $limit * $page; if (!$sortfield) { $sortfield = 'p.ref'; @@ -80,20 +80,20 @@ if (!$sortorder) { } // Define virtualdiffersfromphysical -$virtualdiffersfromphysical=0; -if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) -|| ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) -|| ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) +$virtualdiffersfromphysical = 0; +if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) +|| !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) +|| !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { - $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. + $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } -$usevirtualstock=0; -if ($mode == 'virtual') $usevirtualstock=1; +$usevirtualstock = 0; +if ($mode == 'virtual') $usevirtualstock = 1; -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); /* @@ -106,9 +106,9 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $snom = ''; $sal = ''; $salert = ''; - $draftorder=''; + $draftorder = ''; } -if($draftorder == 'on') $draftchecked = "checked"; +if ($draftorder == 'on') $draftchecked = "checked"; // Create orders if ($action == 'order' && isset($_POST['valid'])) @@ -122,19 +122,19 @@ if ($action == 'order' && isset($_POST['valid'])) $db->begin(); $suppliers = array(); - require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $productsupplier = new ProductFournisseur($db); for ($i = 0; $i < $linecount; $i++) { - if (GETPOST('choose' . $i, 'alpha') === 'on' && GETPOST('fourn' . $i, 'int') > 0) + if (GETPOST('choose'.$i, 'alpha') === 'on' && GETPOST('fourn'.$i, 'int') > 0) { //one line $box = $i; $supplierpriceid = GETPOST('fourn'.$i, 'int'); //get all the parameters needed to create a line $qty = GETPOST('tobuy'.$i, 'int'); - $idprod=$productsupplier->get_buyprice($supplierpriceid, $qty); - $res=$productsupplier->fetch($idprod); + $idprod = $productsupplier->get_buyprice($supplierpriceid, $qty); + $res = $productsupplier->fetch($idprod); if ($res && $idprod > 0) { if ($qty) @@ -146,12 +146,12 @@ if ($action == 'order' && isset($_POST['valid'])) //$product = new Product($db); //$product->fetch($obj->fk_product); - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { $productsupplier->getMultiLangs(); } $line->desc = $productsupplier->description; - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { // TODO Get desc in language of thirdparty } @@ -175,11 +175,11 @@ if ($action == 'order' && isset($_POST['valid'])) } else { - $error=$db->lasterror(); + $error = $db->lasterror(); dol_print_error($db); } - unset($_POST['fourn' . $i]); + unset($_POST['fourn'.$i]); } unset($_POST[$i]); } @@ -193,12 +193,12 @@ if ($action == 'order' && isset($_POST['valid'])) $order = new CommandeFournisseur($db); // Check if an order for the supplier exists $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql.= " WHERE fk_soc = ".$suppliersid[$i]; - $sql.= " AND source = 42 AND fk_statut = 0"; - $sql.= " AND entity IN (".getEntity('commande_fournisseur').")"; - $sql.= " ORDER BY date_creation DESC"; + $sql .= " WHERE fk_soc = ".$suppliersid[$i]; + $sql .= " AND source = 42 AND fk_statut = 0"; + $sql .= " AND entity IN (".getEntity('commande_fournisseur').")"; + $sql .= " ORDER BY date_creation DESC"; $resql = $db->query($sql); - if($resql && $db->num_rows($resql) > 0) { + if ($resql && $db->num_rows($resql) > 0) { $obj = $db->fetch_object($resql); $order->fetch($obj->rowid); foreach ($supplier['lines'] as $line) { @@ -226,7 +226,7 @@ if ($action == 'order' && isset($_POST['valid'])) } if ($result < 0) { $fail++; - $msg = $langs->trans('OrderFail') . " : "; + $msg = $langs->trans('OrderFail')." : "; $msg .= $order->error; setEventMessages($msg, null, 'errors'); } else { @@ -245,7 +245,7 @@ if ($action == 'order' && isset($_POST['valid'])) $id = $order->create($user); if ($id < 0) { $fail++; - $msg = $langs->trans('OrderFail') . " : "; + $msg = $langs->trans('OrderFail')." : "; $msg .= $order->error; setEventMessages($msg, null, 'errors'); } @@ -253,9 +253,9 @@ if ($action == 'order' && isset($_POST['valid'])) } } - if($errorQty) setEventMessages($langs->trans('ErrorOrdersNotCreatedQtyTooLow'), null, 'warnings'); + if ($errorQty) setEventMessages($langs->trans('ErrorOrdersNotCreatedQtyTooLow'), null, 'warnings'); - if (! $fail && $id) + if (!$fail && $id) { $db->commit(); @@ -286,45 +286,45 @@ $prod = new Product($db); $title = $langs->trans('Status'); if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $sqldesiredtock=$db->ifsql("pse.desiredstock IS NULL", "p.desiredstock", "pse.desiredstock"); - $sqlalertstock=$db->ifsql("pse.seuil_stock_alerte IS NULL", "p.seuil_stock_alerte", "pse.seuil_stock_alerte"); + $sqldesiredtock = $db->ifsql("pse.desiredstock IS NULL", "p.desiredstock", "pse.desiredstock"); + $sqlalertstock = $db->ifsql("pse.seuil_stock_alerte IS NULL", "p.seuil_stock_alerte", "pse.seuil_stock_alerte"); } else { - $sqldesiredtock='p.desiredstock'; - $sqlalertstock='p.seuil_stock_alerte'; + $sqldesiredtock = 'p.desiredstock'; + $sqlalertstock = 'p.seuil_stock_alerte'; } $sql = 'SELECT p.rowid, p.ref, p.label, p.description, p.price,'; -$sql.= ' p.price_ttc, p.price_base_type,p.fk_product_type,'; -$sql.= ' p.tms as datem, p.duration, p.tobuy,'; -$sql.= ' p.desiredstock, p.seuil_stock_alerte,'; +$sql .= ' p.price_ttc, p.price_base_type,p.fk_product_type,'; +$sql .= ' p.tms as datem, p.duration, p.tobuy,'; +$sql .= ' p.desiredstock, p.seuil_stock_alerte,'; if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $sql.= ' pse.desiredstock as desiredstockpse, pse.seuil_stock_alerte as seuil_stock_alertepse,'; + $sql .= ' pse.desiredstock as desiredstockpse, pse.seuil_stock_alerte as seuil_stock_alertepse,'; } -$sql.= ' '.$sqldesiredtock.' as desiredstockcombined, '.$sqlalertstock.' as seuil_stock_alertecombined,'; -$sql.= ' SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique'; +$sql .= ' '.$sqldesiredtock.' as desiredstockcombined, '.$sqlalertstock.' as seuil_stock_alertecombined,'; +$sql .= ' SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique'; // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= ' FROM ' . MAIN_DB_PREFIX . 'product as p'; -$sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s'; -$sql.= ' ON (p.rowid = s.fk_product AND s.fk_entrepot IN (SELECT ent.rowid FROM '.MAIN_DB_PREFIX.'entrepot AS ent WHERE ent.entity IN('.getEntity('stock').')))'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s'; +$sql .= ' ON (p.rowid = s.fk_product AND s.fk_entrepot IN (SELECT ent.rowid FROM '.MAIN_DB_PREFIX.'entrepot AS ent WHERE ent.entity IN('.getEntity('stock').')))'; if ($fk_supplier > 0) { - $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid AND pfp.fk_soc = '.$fk_supplier.')'; + $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid AND pfp.fk_soc = '.$fk_supplier.')'; } if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.$fk_entrepot.')'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.$fk_entrepot.')'; } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListJoin', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= ' WHERE p.entity IN (' . getEntity('product') . ')'; +$sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($sall) $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($type)) { @@ -334,83 +334,83 @@ if (dol_strlen($type)) { $sql .= ' AND p.fk_product_type <> 1'; } } -if ($sref) $sql.=natural_search('p.ref', $sref); -if ($snom) $sql.=natural_search('p.label', $snom); -$sql.= ' AND p.tobuy = 1'; -if (!empty($canvas)) $sql .= ' AND p.canvas = "' . $db->escape($canvas) . '"'; -$sql.= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price'; -$sql.= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms'; -$sql.= ', p.duration, p.tobuy'; -$sql.= ', p.desiredstock'; -$sql.= ', p.seuil_stock_alerte'; +if ($sref) $sql .= natural_search('p.ref', $sref); +if ($snom) $sql .= natural_search('p.label', $snom); +$sql .= ' AND p.tobuy = 1'; +if (!empty($canvas)) $sql .= ' AND p.canvas = "'.$db->escape($canvas).'"'; +$sql .= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price'; +$sql .= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms'; +$sql .= ', p.duration, p.tobuy'; +$sql .= ', p.desiredstock'; +$sql .= ', p.seuil_stock_alerte'; if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $sql.= ', pse.desiredstock' ; - $sql.= ', pse.seuil_stock_alerte' ; + $sql .= ', pse.desiredstock'; + $sql .= ', pse.seuil_stock_alerte'; } -$sql.= ', s.fk_product'; +$sql .= ', s.fk_product'; if ($usevirtualstock) { $sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty"; - $sqlCommandesCli.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; - $sqlCommandesCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; - $sqlCommandesCli.= " WHERE c.entity IN (".getEntity('commande').")"; - $sqlCommandesCli.= " AND cd.fk_product = p.rowid"; - $sqlCommandesCli.= " AND c.fk_statut IN (1,2))"; + $sqlCommandesCli .= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; + $sqlCommandesCli .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; + $sqlCommandesCli .= " WHERE c.entity IN (".getEntity('commande').")"; + $sqlCommandesCli .= " AND cd.fk_product = p.rowid"; + $sqlCommandesCli .= " AND c.fk_statut IN (1,2))"; $sqlExpeditionsCli = "(SELECT ".$db->ifsql("SUM(ed.qty) IS NULL", "0", "SUM(ed.qty)")." as qty"; - $sqlExpeditionsCli.= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet as ed ON (ed.fk_expedition = e.rowid)"; - $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commandedet as cd ON (cd.rowid = ed.fk_origin_line)"; - $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; - $sqlExpeditionsCli.= " WHERE e.entity IN (".getEntity('expedition').")"; - $sqlExpeditionsCli.= " AND cd.fk_product = p.rowid"; - $sqlExpeditionsCli.= " AND c.fk_statut IN (1,2))"; + $sqlExpeditionsCli .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sqlExpeditionsCli .= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet as ed ON (ed.fk_expedition = e.rowid)"; + $sqlExpeditionsCli .= " LEFT JOIN ".MAIN_DB_PREFIX."commandedet as cd ON (cd.rowid = ed.fk_origin_line)"; + $sqlExpeditionsCli .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; + $sqlExpeditionsCli .= " WHERE e.entity IN (".getEntity('expedition').")"; + $sqlExpeditionsCli .= " AND cd.fk_product = p.rowid"; + $sqlExpeditionsCli .= " AND c.fk_statut IN (1,2))"; $sqlCommandesFourn = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty"; - $sqlCommandesFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; - $sqlCommandesFourn.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - $sqlCommandesFourn.= " WHERE c.rowid = cd.fk_commande"; - $sqlCommandesFourn.= " AND c.entity IN (".getEntity('supplier_order').")"; - $sqlCommandesFourn.= " AND cd.fk_product = p.rowid"; - $sqlCommandesFourn.= " AND c.fk_statut IN (3,4))"; + $sqlCommandesFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; + $sqlCommandesFourn .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + $sqlCommandesFourn .= " WHERE c.rowid = cd.fk_commande"; + $sqlCommandesFourn .= " AND c.entity IN (".getEntity('supplier_order').")"; + $sqlCommandesFourn .= " AND cd.fk_product = p.rowid"; + $sqlCommandesFourn .= " AND c.fk_statut IN (3,4))"; $sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd.qty) IS NULL", "0", "SUM(fd.qty)")." as qty"; - $sqlReceptionFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sqlReceptionFourn.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd ON (fd.fk_commande = cf.rowid)"; - $sqlReceptionFourn.= " WHERE cf.entity IN (".getEntity('supplier_order').")"; - $sqlReceptionFourn.= " AND fd.fk_product = p.rowid"; - $sqlReceptionFourn.= " AND cf.fk_statut IN (3,4))"; + $sqlReceptionFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sqlReceptionFourn .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd ON (fd.fk_commande = cf.rowid)"; + $sqlReceptionFourn .= " WHERE cf.entity IN (".getEntity('supplier_order').")"; + $sqlReceptionFourn .= " AND fd.fk_product = p.rowid"; + $sqlReceptionFourn .= " AND cf.fk_statut IN (3,4))"; - $sql.= ' HAVING (('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))'; - $sql.= ' OR ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.'))))'; + $sql .= ' HAVING (('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))'; + $sql .= ' OR ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.'))))'; if ($salert == 'on') // Option to see when stock is lower than alert { - $sql.= ' AND ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))'; + $sql .= ' AND ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))'; $alertchecked = 'checked'; } } else { - $sql.= ' HAVING (('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; - $sql.= ' OR ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; + $sql .= ' HAVING (('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + $sql .= ' OR ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; if ($salert == 'on') // Option to see when stock is lower than alert { - $sql.= ' AND ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + $sql .= ' AND ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; $alertchecked = 'checked'; } } // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->order($sortfield, $sortorder); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); @@ -473,8 +473,8 @@ print '
'; print $langs->trans('Supplier').' '.$form->select_company($fk_supplier, 'fk_supplier', 'fournisseur=1', 1); print '
'; -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) print $hookmanager->resPrint; print '
'; @@ -484,13 +484,13 @@ print '
'; print ''; if ($sref || $snom || $sall || $salert || $draftorder || GETPOST('search', 'alpha')) { - $filters = '&sref=' . $sref . '&snom=' . $snom; - $filters .= '&sall=' . $sall; - $filters .= '&salert=' . $salert; - $filters .= '&draftorder=' . $draftorder; - $filters .= '&mode=' . $mode; - $filters .= '&fk_supplier=' . $fk_supplier; - $filters .= '&fk_entrepot=' . $fk_entrepot; + $filters = '&sref='.$sref.'&snom='.$snom; + $filters .= '&sall='.$sall; + $filters .= '&salert='.$salert; + $filters .= '&draftorder='.$draftorder; + $filters .= '&mode='.$mode; + $filters .= '&fk_supplier='.$fk_supplier; + $filters .= '&fk_entrepot='.$fk_entrepot; print_barre_liste( $texte, $page, @@ -502,14 +502,14 @@ if ($sref || $snom || $sall || $salert || $draftorder || GETPOST('search', 'alph $num ); } else { - $filters = '&sref=' . $sref . '&snom=' . $snom; - $filters .= '&fourn_id=' . $fourn_id; - $filters .= (isset($type)?'&type=' . $type:''); - $filters .= '&=' . $salert; - $filters .= '&draftorder=' . $draftorder; - $filters .= '&mode=' . $mode; - $filters .= '&fk_supplier=' . $fk_supplier; - $filters .= '&fk_entrepot=' . $fk_entrepot; + $filters = '&sref='.$sref.'&snom='.$snom; + $filters .= '&fourn_id='.$fourn_id; + $filters .= (isset($type) ? '&type='.$type : ''); + $filters .= '&='.$salert; + $filters .= '&draftorder='.$draftorder; + $filters .= '&mode='.$mode; + $filters .= '&fk_supplier='.$fk_supplier; + $filters .= '&fk_entrepot='.$fk_entrepot; print_barre_liste( $texte, $page, @@ -522,33 +522,33 @@ if ($sref || $snom || $sall || $salert || $draftorder || GETPOST('search', 'alph ); } -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
' . $formproduct->selectWarehouses('', 'fk_entrepot') . '
'.$formproduct->selectWarehouses('', 'fk_entrepot').'
' . $langs->trans("Warehouse") . '' . $langs->trans("StockLimit") . '' . $langs->trans("DesiredStock") . '
'.$langs->trans("Warehouse").''.$langs->trans("StockLimit").''.$langs->trans("DesiredStock").'
' . $ent->getNomUrl(3) . '' . $line['seuil_stock_alerte'] . '' . $line['desiredstock'] . '
'.$ent->getNomUrl(3).''.$line['seuil_stock_alerte'].''.$line['desiredstock'].'' . img_delete() . ''.img_delete().'
getNomUrl(1) ?>
'; -$param = (isset($type)? '&type=' . $type : ''); -$param .= '&fourn_id=' . $fourn_id . '&snom='. $snom . '&salert=' . $salert . '&draftorder='.$draftorder; -$param .= '&sref=' . $sref; -$param .= '&mode=' . $mode; -$param .= '&fk_supplier=' . $fk_supplier; -$param .= '&fk_entrepot=' . $fk_entrepot; +$param = (isset($type) ? '&type='.$type : ''); +$param .= '&fourn_id='.$fourn_id.'&snom='.$snom.'&salert='.$salert.'&draftorder='.$draftorder; +$param .= '&sref='.$sref; +$param .= '&mode='.$mode; +$param .= '&fk_supplier='.$fk_supplier; +$param .= '&fk_entrepot='.$fk_entrepot; $stocklabel = $langs->trans('Stock'); if ($usevirtualstock == 1) $stocklabel = $langs->trans('VirtualStock'); if ($usevirtualstock == 0) $stocklabel = $langs->trans('PhysicalStock'); if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $stocklabel.=' ('.$langs->trans("AllWarehouses").')'; + $stocklabel .= ' ('.$langs->trans("AllWarehouses").')'; } print ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. ''. - ''; + ''; // Fields title search print ''; @@ -558,16 +558,16 @@ print ''; print ''; print ''; -print ''; -print ''; +print ''; +print ''; print ''; // Fields from hook -$parameters=array('param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ''; print ''; @@ -586,8 +586,8 @@ print_liste_field_titre('StockToBuy', $_SERVER["PHP_SELF"], '', $param, '', '', print_liste_field_titre('SupplierRef', $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'right '); // Hook fields -$parameters=array('param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "\n"; @@ -596,18 +596,18 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $objp = $db->fetch_object($resql); - if (! empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0) + if (!empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0) { $prod->fetch($objp->rowid); $prod->load_stock('warehouseopen, warehouseinternal'); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { $sql = 'SELECT label,description'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'product_lang'; - $sql .= ' WHERE fk_product = ' . $objp->rowid; - $sql .= ' AND lang = "' . $langs->getDefaultLang() . '"'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang'; + $sql .= ' WHERE fk_product = '.$objp->rowid; + $sql .= ' AND lang = "'.$langs->getDefaultLang().'"'; $sql .= ' LIMIT 1'; $resqlm = $db->query($sql); @@ -630,25 +630,25 @@ while ($i < ($limit ? min($num, $limit) : $num)) } // Force call prod->load_stats_xxx to choose status to count (otherwise it is loaded by load_stock function) - if(isset($draftchecked)){ - $result=$prod->load_stats_commande_fournisseur(0, '0,1,2,3,4'); - }else { - $result=$prod->load_stats_commande_fournisseur(0, '1,2,3,4'); + if (isset($draftchecked)) { + $result = $prod->load_stats_commande_fournisseur(0, '0,1,2,3,4'); + } else { + $result = $prod->load_stats_commande_fournisseur(0, '1,2,3,4'); } - $result=$prod->load_stats_reception(0, '4'); + $result = $prod->load_stats_reception(0, '4'); //print $prod->stats_commande_fournisseur['qty'].'
'."\n"; //print $prod->stats_reception['qty']; $ordered = $prod->stats_commande_fournisseur['qty'] - $prod->stats_reception['qty']; - $desiredstock=($objp->desiredstockpse ? $objp->desiredstockpse : $objp->desiredstock); - $alertstock=($objp->seuil_stock_alertepse ? $objp->seuil_stock_alertepse : $objp->seuil_stock_alerte); + $desiredstock = ($objp->desiredstockpse ? $objp->desiredstockpse : $objp->desiredstock); + $alertstock = ($objp->seuil_stock_alertepse ? $objp->seuil_stock_alertepse : $objp->seuil_stock_alerte); - $warning=''; + $warning = ''; if ($alertstock && ($stock < $alertstock)) { - $warning = img_warning($langs->trans('StockTooLow')) . ' '; + $warning = img_warning($langs->trans('StockTooLow')).' '; } //depending on conf, use either physical stock or @@ -679,18 +679,18 @@ while ($i < ($limit ? min($num, $limit) : $num)) print ''; - print ''; if (!empty($conf->service->enabled) && $type == 1) { if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) { - $duration = $regs[1] . ' ' . $langs->trans('DurationYear'); + $duration = $regs[1].' '.$langs->trans('DurationYear'); } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) { - $duration = $regs[1] . ' ' . $langs->trans('DurationMonth'); + $duration = $regs[1].' '.$langs->trans('DurationMonth'); } elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) { - $duration = $regs[1] . ' ' . $langs->trans('DurationDay'); + $duration = $regs[1].' '.$langs->trans('DurationDay'); } else { $duration = $objp->duration; } @@ -698,27 +698,27 @@ while ($i < ($limit ? min($num, $limit) : $num)) } // Desired stock - print ''; + print ''; // Limit stock for alert - print ''; + print ''; // Current stock (all warehouses) - print ''; + print ''; // Already ordered - print ''; + print ''; // To order //print ''; print ''; // Supplier - print ''; + print ''; // Fields from hook - $parameters=array( 'objp'=>$objp); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('objp'=>$objp); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ''; @@ -726,8 +726,8 @@ while ($i < ($limit ? min($num, $limit) : $num)) $i++; } -$parameters=array('sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
service->enabled) && $type == 1) print '   ' . $langs->trans('AlertOnly') . ' ' . $langs->trans('IncludeAlsoDraftOrders') . ' '.$langs->trans('AlertOnly').' '.$langs->trans('IncludeAlsoDraftOrders').'  '; -$searchpicto=$form->showFilterAndCheckAddButtons(0); +$searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
'.$prod->getNomUrl(1, '').''.$objp->label ; - print ''; // TODO Remove this and make a fetch to get description when creating order instead of a GETPOST + print ''.$objp->label; + print ''; // TODO Remove this and make a fetch to get description when creating order instead of a GETPOST print '' . $desiredstock . ''.$desiredstock.'' . $alertstock . ''.$alertstock.''. $warning . $stock. ''.$warning.$stock.''. $ordered . ' ' . $picto. ''.$ordered.' '.$picto.''. $form->select_product_fourn_price($prod->id, 'fourn'.$i, $fk_supplier).''.$form->select_product_fourn_price($prod->id, 'fourn'.$i, $fk_supplier).'
'; @@ -738,7 +738,7 @@ $db->free($resql); dol_fiche_end(); -$value=$langs->trans("CreateOrders"); +$value = $langs->trans("CreateOrders"); print '
'; diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 989339590b3..beadddc6397 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -36,45 +36,45 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $langs->loadLangs(array("sendings", "receptions", "deliveries", 'companies', 'bills')); -$socid=GETPOST('socid', 'int'); -$massaction=GETPOST('massaction', 'alpha'); +$socid = GETPOST('socid', 'int'); +$massaction = GETPOST('massaction', 'alpha'); $toselect = GETPOST('toselect', 'array'); // Security check $receptionid = GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'reception', $receptionid, ''); -$diroutputmassaction=$conf->reception->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->reception->dir_output.'/temp/massgeneration/'.$user->id; $search_ref_rcp = GETPOST("search_ref_rcp"); $search_ref_liv = GETPOST('search_ref_liv'); $search_ref_supplier = GETPOST('search_ref_supplier'); $search_company = GETPOST("search_company"); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state")); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$search_billed=GETPOST("search_billed", 'int'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$search_billed = GETPOST("search_billed", 'int'); $sall = GETPOST('sall', 'alphanohtml'); $optioncss = GETPOST('optioncss', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if (! $sortfield) $sortfield="e.ref"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "e.ref"; +if (!$sortorder) $sortorder = "DESC"; if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage='receptionlist'; +$contextpage = 'receptionlist'; -$viewstatut=GETPOST('viewstatut'); +$viewstatut = GETPOST('viewstatut'); $object = new Reception($db); @@ -92,10 +92,10 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'e.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["e.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["e.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'e.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), @@ -113,10 +113,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -127,11 +127,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction') && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction') && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -139,18 +139,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { - $search_ref_supplier=''; - $search_ref_rcp=''; - $search_ref_liv=''; - $search_company=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_country=''; - $search_type_thirdparty=''; - $search_billed=''; - $viewstatut=''; - $search_array_options=array(); + $search_ref_supplier = ''; + $search_ref_rcp = ''; + $search_ref_liv = ''; + $search_company = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_country = ''; + $search_type_thirdparty = ''; + $search_billed = ''; + $viewstatut = ''; + $search_array_options = array(); } if (empty($reshook)) @@ -166,29 +166,29 @@ if (empty($reshook)) $nb_bills_created = 0; $db->begin(); - $errors =array(); - foreach($receptions as $id_reception) + $errors = array(); + foreach ($receptions as $id_reception) { $rcp = new Reception($db); // On ne facture que les réceptions validées - if ($rcp->fetch($id_reception) <= 0 || $rcp->statut != 1){ - $errors[]=$langs->trans('StatusMustBeValidate', $rcp->ref); + if ($rcp->fetch($id_reception) <= 0 || $rcp->statut != 1) { + $errors[] = $langs->trans('StatusMustBeValidate', $rcp->ref); $error++; continue; } $object = new FactureFournisseur($db); - if (!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])){ + if (!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])) { $object = $TFactThird[$rcp->socid]; // If option "one bill per third" is set, we use already created reception. - if(empty($object->rowid)&&$object->id != null)$object->rowid = $object->id; - if(!empty($object->rowid))$object->fetchObjectLinked(); + if (empty($object->rowid) && $object->id != null)$object->rowid = $object->id; + if (!empty($object->rowid))$object->fetchObjectLinked(); $rcp->fetchObjectLinked(); if (count($rcp->linkedObjectsIds['order_supplier']) > 0) { foreach ($rcp->linkedObjectsIds['order_supplier'] as $key => $value) { - if(empty($object->linkedObjectsIds['order_supplier']) || !in_array($value, $object->linkedObjectsIds['order_supplier']))//Dont try to link if already linked + if (empty($object->linkedObjectsIds['order_supplier']) || !in_array($value, $object->linkedObjectsIds['order_supplier']))//Dont try to link if already linked $object->add_object_linked('order_supplier', $value); // add supplier order linked object } } @@ -198,12 +198,12 @@ if (empty($reshook)) $object->type = FactureFournisseur::TYPE_STANDARD; $object->cond_reglement_id = $rcp->thirdparty->cond_reglement_supplier_id; $object->mode_reglement_id = $rcp->thirdparty->mode_reglement_supplier_id; - $object->fk_account = !empty($rcp->thirdparty->fk_account)?$rcp->thirdparty->fk_account:0; - $object->remise_percent = !empty($rcp->thirdparty->remise_percent)?$rcp->thirdparty->remise_percent:0; - $object->remise_absolue = !empty($rcp->thirdparty->remise_absolue)?$rcp->thirdparty->remise_absolue:0; + $object->fk_account = !empty($rcp->thirdparty->fk_account) ? $rcp->thirdparty->fk_account : 0; + $object->remise_percent = !empty($rcp->thirdparty->remise_percent) ? $rcp->thirdparty->remise_percent : 0; + $object->remise_absolue = !empty($rcp->thirdparty->remise_absolue) ? $rcp->thirdparty->remise_absolue : 0; $object->fk_project = $rcp->fk_project; - $object->ref_supplier = $rcp->ref_supplier; + $object->ref_supplier = $rcp->ref_supplier; $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); if (empty($datefacture)) @@ -226,28 +226,28 @@ if (empty($reshook)) $res = $object->create($user); //var_dump($object->error);exit; - if($res > 0){ + if ($res > 0) { $nb_bills_created++; $object->id = $res; - }else { - $errors[]=$rcp->ref.' : '.$langs->trans($object->error); + } else { + $errors[] = $rcp->ref.' : '.$langs->trans($object->error); $error++; } } if ($object->id > 0) { - if(!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])){ //cause function create already add object linked for facturefournisseur + if (!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])) { //cause function create already add object linked for facturefournisseur $res = $object->add_object_linked($object->origin, $id_reception); - if ($res==0) + if ($res == 0) { - $errors[]=$object->error; + $errors[] = $object->error; $error++; } } - if (! $error) + if (!$error) { $lines = $rcp->lines; if (empty($lines) && method_exists($rcp, 'fetch_lines')) @@ -256,27 +256,27 @@ if (empty($reshook)) $lines = $rcp->lines; } - $fk_parent_line=0; - $num=count($lines); + $fk_parent_line = 0; + $num = count($lines); - for ($i=0;$i<$num;$i++) + for ($i = 0; $i < $num; $i++) { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); if ($lines[$i]->subprice < 0) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); - $discount->fk_soc=$object->socid; - $discount->amount_ht=abs($lines[$i]->total_ht); - $discount->amount_tva=abs($lines[$i]->total_tva); - $discount->amount_ttc=abs($lines[$i]->total_ttc); - $discount->tva_tx=$lines[$i]->tva_tx; - $discount->fk_user=$user->id; - $discount->description=$desc; - $discountid=$discount->create($user); + $discount->fk_soc = $object->socid; + $discount->amount_ht = abs($lines[$i]->total_ht); + $discount->amount_tva = abs($lines[$i]->total_tva); + $discount->amount_ttc = abs($lines[$i]->total_ttc); + $discount->tva_tx = $lines[$i]->tva_tx; + $discount->fk_user = $user->id; + $discount->description = $desc; + $discountid = $discount->create($user); if ($discountid > 0) { - $result=$object->insert_discount($discountid); + $result = $object->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); } else @@ -289,17 +289,17 @@ if (empty($reshook)) else { // Positive line - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Date start - $date_start=false; - if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + $date_start = false; + if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; //Date end - $date_end=false; - if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + $date_end = false; + if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { @@ -333,11 +333,11 @@ if (empty($reshook)) if ($result > 0) { - $lineid=$result; + $lineid = $result; } else { - $lineid=0; + $lineid = 0; $error++; break; } @@ -353,7 +353,7 @@ if (empty($reshook)) //$rcp->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. - if(!empty($createbills_onebythird) && empty($TFactThird[$rcp->socid])) $TFactThird[$rcp->socid] = $object; + if (!empty($createbills_onebythird) && empty($TFactThird[$rcp->socid])) $TFactThird[$rcp->socid] = $object; else $TFact[$object->id] = $object; } @@ -361,10 +361,10 @@ if (empty($reshook)) $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; $toselect = array(); - if (! $error && $validate_invoices) + if (!$error && $validate_invoices) { $massaction = $action = 'builddoc'; - foreach($TAllFact as &$object) + foreach ($TAllFact as &$object) { $result = $object->validate($user); if ($result <= 0) @@ -379,14 +379,14 @@ if (empty($reshook)) // Fac builddoc $donotredirect = 1; $upload_dir = $conf->fournisseur->facture->dir_output; - $permissiontoadd=$user->rights->fournisseur->facture->creer; + $permissiontoadd = $user->rights->fournisseur->facture->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } $massaction = $action = 'confirm_createbills'; } - if (! $error) + if (!$error) { $db->commit(); setEventMessage($langs->trans('BillCreated', $nb_bills_created)); @@ -394,9 +394,9 @@ if (empty($reshook)) else { $db->rollback(); - $action='create'; - $_GET["origin"]=$_POST["origin"]; - $_GET["originid"]=$_POST["originid"]; + $action = 'create'; + $_GET["origin"] = $_POST["origin"]; + $_GET["originid"] = $_POST["originid"]; setEventMessages($object->error, $errors, 'errors'); $error++; } @@ -408,58 +408,58 @@ if (empty($reshook)) * View */ -$form=new Form($db); -$companystatic=new Societe($db); -$reception=new Reception($db); -$formcompany=new FormCompany($db); +$form = new Form($db); +$companystatic = new Societe($db); +$reception = new Reception($db); +$formcompany = new FormCompany($db); $formfile = new FormFile($db); -$helpurl='EN:Module_Receptions|FR:Module_Receptions|ES:Módulo_Receptiones'; +$helpurl = 'EN:Module_Receptions|FR:Module_Receptions|ES:Módulo_Receptiones'; llxHeader('', $langs->trans('ListOfReceptions'), $helpurl); $sql = "SELECT e.rowid, e.ref, e.ref_supplier, e.date_reception as date_reception, e.date_delivery as date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed,"; -$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' e.date_creation as date_creation, e.tms as date_update'; +$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= ' e.date_creation as date_creation, e.tms as date_update'; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."reception as e"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'reception' AND ee.targettype = 'delivery'"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."reception as e"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'reception' AND ee.targettype = 'delivery'"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target"; if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } -$sql.= " WHERE e.entity IN (".getEntity('reception').")"; +$sql .= " WHERE e.entity IN (".getEntity('reception').")"; if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all { - $sql.= " AND e.fk_soc = sc.fk_soc"; - $sql.= " AND sc.fk_user = " .$user->id; + $sql .= " AND e.fk_soc = sc.fk_soc"; + $sql .= " AND sc.fk_user = ".$user->id; } if ($socid) { - $sql.= " AND e.fk_soc = ".$socid; + $sql .= " AND e.fk_soc = ".$socid; } if ($viewstatut <> '' && $viewstatut >= 0) { - $sql.= " AND e.fk_statut = ".$viewstatut; + $sql .= " AND e.fk_statut = ".$viewstatut; } -if ($search_billed != '' && $search_billed >= 0) $sql.=' AND e.billed = '.$search_billed; -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +if ($search_billed != '' && $search_billed >= 0) $sql .= ' AND e.billed = '.$search_billed; +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_ref_rcp) $sql .= natural_search('e.ref', $search_ref_rcp); @@ -471,21 +471,21 @@ if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); // Add where from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/', '', $key); - $typ=$extrafields->attributes[$object->table_element]['type'][$tmpkey]; - $mode=0; - if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric - if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int - if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) + $crit = $val; + $tmpkey = preg_replace('/search_options_/', '', $key); + $typ = $extrafields->attributes[$object->table_element]['type'][$tmpkey]; + $mode = 0; + if (in_array($typ, array('int', 'double', 'real'))) $mode = 1; // Search on a numeric + if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode = 2; // Search on a foreign key int + if ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0')) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); } } // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -494,51 +494,51 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->order($sortfield, $sortorder); -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->order($sortfield, $sortorder); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $reception = new Reception($db); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($sall) $param.= "&sall=".$sall; - if ($search_ref_rcp) $param.= "&search_ref_rcp=".$search_ref_rcp; - if ($search_ref_liv) $param.= "&search_ref_liv=".$search_ref_liv; - if ($search_company) $param.= "&search_company=".$search_company; - if ($optioncss != '') $param.='&optioncss='.$optioncss; - if ($search_billed != '' && $search_billed >= 0)$param.= "&search_billed=".$search_billed; - if ($search_town) $param.= "&search_town=".$search_town; - if ($search_zip) $param.= "&search_zip=".$search_zip; - if ($search_state) $param.= "&search_state=".$search_state; - if ($viewstatut) $param.= "&viewstatut=".$viewstatut; - if ($search_country) $param.= "&search_country=".$search_country; - if ($search_type_thirdparty) $param.= "&search_type_thirdparty=".$search_type_thirdparty; - if ($search_ref_supplier) $param.= "&search_ref_supplier=".$search_ref_supplier; + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($sall) $param .= "&sall=".$sall; + if ($search_ref_rcp) $param .= "&search_ref_rcp=".$search_ref_rcp; + if ($search_ref_liv) $param .= "&search_ref_liv=".$search_ref_liv; + if ($search_company) $param .= "&search_company=".$search_company; + if ($optioncss != '') $param .= '&optioncss='.$optioncss; + if ($search_billed != '' && $search_billed >= 0)$param .= "&search_billed=".$search_billed; + if ($search_town) $param .= "&search_town=".$search_town; + if ($search_zip) $param .= "&search_zip=".$search_zip; + if ($search_state) $param .= "&search_state=".$search_state; + if ($viewstatut) $param .= "&viewstatut=".$viewstatut; + if ($search_country) $param .= "&search_country=".$search_country; + if ($search_type_thirdparty) $param .= "&search_type_thirdparty=".$search_type_thirdparty; + if ($search_ref_supplier) $param .= "&search_ref_supplier=".$search_ref_supplier; // Add $param from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/', '', $key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + $crit = $val; + $tmpkey = preg_replace('/search_options_/', '', $key); + if ($val != '') $param .= '&search_options_'.$tmpkey.'='.urlencode($val); } - $arrayofmassactions = array( + $arrayofmassactions = array( // 'presend'=>$langs->trans("SendByMail"), ); - if($user->rights->fournisseur->facture->creer)$arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisSupplier"); - if($massaction == 'createbills') $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->fournisseur->facture->creer)$arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier"); + if ($massaction == 'createbills') $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); //$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); $i = 0; @@ -581,7 +581,7 @@ if ($resql) print $langs->trans('ValidateInvoices'); print '
'; - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { print $form->selectyesno('validate_invoices', 0, 1, 1); print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; @@ -604,91 +604,91 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall); + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print $langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall); } - $moreforfilter=''; - if (! empty($moreforfilter)) + $moreforfilter = ''; + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters=array('type'=>$type); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('type'=>$type); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; - print ''."\n"; + print '
'."\n"; // Fields title search // -------------------------------------------------------------------- print ''; // Ref - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print ''; } // Ref customer - if (! empty($arrayfields['e.ref_supplier']['checked'])) + if (!empty($arrayfields['e.ref_supplier']['checked'])) { print ''; } // Thirdparty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } // Town - if (! empty($arrayfields['s.town']['checked'])) print ''; + if (!empty($arrayfields['s.town']['checked'])) print ''; // Zip - if (! empty($arrayfields['s.zip']['checked'])) print ''; + if (!empty($arrayfields['s.zip']['checked'])) print ''; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; } // Date delivery planned - if (! empty($arrayfields['e.date_delivery']['checked'])) + if (!empty($arrayfields['e.date_delivery']['checked'])) { print ''; } - if (! empty($arrayfields['l.ref']['checked'])) + if (!empty($arrayfields['l.ref']['checked'])) { // Delivery ref print ''; @@ -697,30 +697,30 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['e.datec']['checked'])) + if (!empty($arrayfields['e.datec']['checked'])) { print ''; } // Date modification - if (! empty($arrayfields['e.tms']['checked'])) + if (!empty($arrayfields['e.tms']['checked'])) { print ''; } // Status - if (! empty($arrayfields['e.fk_statut']['checked'])) + if (!empty($arrayfields['e.fk_statut']['checked'])) { print ''; } // Status billed - if (! empty($arrayfields['e.billed']['checked'])) + if (!empty($arrayfields['e.billed']['checked'])) { print ''; print "\n"; print ''; - if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['e.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['e.ref_supplier']['label'], $_SERVER["PHP_SELF"], "e.ref_supplier", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['e.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['e.ref_supplier']['label'], $_SERVER["PHP_SELF"], "e.ref_supplier", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $reception->id=$obj->rowid; - $reception->ref=$obj->ref; + $reception->id = $obj->rowid; + $reception->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->ref=$obj->name; - $companystatic->name=$obj->name; + $companystatic->id = $obj->socid; + $companystatic->ref = $obj->name; + $companystatic->name = $obj->name; print ''; // Ref - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Ref customer - if (! empty($arrayfields['e.ref_supplier']['checked'])) + if (!empty($arrayfields['e.ref_supplier']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Third party - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['s.town']['checked'])) + if (!empty($arrayfields['s.town']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['s.zip']['checked'])) + if (!empty($arrayfields['s.zip']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type ent - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date delivery planed - if (! empty($arrayfields['e.date_delivery']['checked'])) + if (!empty($arrayfields['e.date_delivery']['checked'])) { print '\n"; } - if (! empty($arrayfields['l.ref']['checked']) || ! empty($arrayfields['l.date_delivery']['checked'])) + if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { $reception->fetchObjectLinked($reception->id, $reception->element); - $receiving=''; - if (count($reception->linkedObjects['delivery']) > 0) $receiving=reset($reception->linkedObjects['delivery']); + $receiving = ''; + if (count($reception->linkedObjects['delivery']) > 0) $receiving = reset($reception->linkedObjects['delivery']); - if (! empty($arrayfields['l.ref']['checked'])) + if (!empty($arrayfields['l.ref']['checked'])) { // Ref print ''; } - if (! empty($arrayfields['l.date_delivery']['checked'])) + if (!empty($arrayfields['l.date_delivery']['checked'])) { // Date received print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['e.tms']['checked'])) + if (!empty($arrayfields['e.tms']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['e.fk_statut']['checked'])) + if (!empty($arrayfields['e.fk_statut']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Billed - if (! empty($arrayfields['e.billed']['checked'])) + if (!empty($arrayfields['e.billed']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 1ad5c03ef98..d2b16926a1a 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -40,7 +40,7 @@ $cancel = GETPOST('cancel', 'alpha'); $ref = GETPOST('ref', 'alpha'); $description = GETPOST('description'); $confirm = GETPOST('confirm'); -$fk_code_type_resource = GETPOST('fk_code_type_resource', 'alpha'); +$fk_code_type_resource = GETPOST('fk_code_type_resource', 'alpha'); $country_id = GETPOST('country_id', 'int'); // Protection if external user @@ -49,7 +49,7 @@ if ($user->socid > 0) accessforbidden(); } -if( ! $user->rights->resource->read) +if (!$user->rights->resource->read) { accessforbidden(); } @@ -67,16 +67,16 @@ $extrafields->fetch_name_optionals_label($object->table_element); * Actions */ -$hookmanager->initHooks(array('resource', 'resource_card','globalcard')); -$parameters=array('resource_id'=>$id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$hookmanager->initHooks(array('resource', 'resource_card', 'globalcard')); +$parameters = array('resource_id'=>$id); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -86,14 +86,14 @@ if (empty($reshook)) header("Location: ".DOL_URL_ROOT.'/resource/list.php'); exit; } - $action=''; + $action = ''; } if ($action == 'add' && $user->rights->resource->write) { - if (! $cancel) + if (!$cancel) { - $error=''; + $error = ''; if (empty($ref)) { @@ -111,7 +111,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - $result=$object->create($user); + $result = $object->create($user); if ($result > 0) { // Creation OK @@ -134,9 +134,9 @@ if (empty($reshook)) } } - if ($action == 'update' && ! $cancel && $user->rights->resource->write) + if ($action == 'update' && !$cancel && $user->rights->resource->write) { - $error=0; + $error = 0; if (empty($ref)) { @@ -144,10 +144,10 @@ if (empty($reshook)) $error++; } - if (! $error) + if (!$error) { $res = $object->fetch($id); - if ( $res > 0 ) + if ($res > 0) { $object->ref = $ref; $object->description = $description; @@ -157,10 +157,10 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { - $error ++; + $error++; } - $result=$object->update($user); + $result = $object->update($user); if ($result > 0) { Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -181,14 +181,14 @@ if (empty($reshook)) if ($error) { - $action='edit'; + $action = 'edit'; } } if ($action == 'confirm_delete_resource' && $user->rights->resource->delete && $confirm === 'yes') { $res = $object->fetch($id); - if($res > 0) + if ($res > 0) { $result = $object->delete($id); @@ -236,13 +236,13 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) if ($action == 'create' || $action == 'edit') { - if (! $user->rights->resource->write) accessforbidden('', 0, 1); + if (!$user->rights->resource->write) accessforbidden('', 0, 1); // Create/Edit object print ''; print ''; - print ''; + print ''; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print ' '; print ''; } - if (! empty($arrayfields['l.date_delivery']['checked'])) + if (!empty($arrayfields['l.date_delivery']['checked'])) { // Date received print ' '; print ''; print ''; - print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusReceptionDraftShort'),'1'=>$langs->trans('StatusReceptionValidatedShort'),'2'=>$langs->trans('StatusReceptionProcessedShort')), $viewstatut, 1); + print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusReceptionDraftShort'), '1'=>$langs->trans('StatusReceptionValidatedShort'), '2'=>$langs->trans('StatusReceptionProcessedShort')), $viewstatut, 1); print ''; print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); @@ -728,126 +728,126 @@ if ($resql) } // Action column print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
"; print $reception->getNomUrl(1); - $filename=dol_sanitizeFileName($reception->ref); - $filedir=$conf->reception->dir_output . '/' . dol_sanitizeFileName($reception->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$reception->rowid; + $filename = dol_sanitizeFileName($reception->ref); + $filedir = $conf->reception->dir_output.'/'.dol_sanitizeFileName($reception->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$reception->rowid; print $formfile->getDocumentsLink($reception->element, $filename, $filedir); print ""; print $obj->ref_supplier; print "'; print $companystatic->getNomUrl(1); print ''; print $obj->town; print ''; print $obj->zip; print '".$obj->state_name."'; - $tmparray=getCountry($obj->fk_pays, 'all'); + $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print ''; - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print ''; print dol_print_date($db->jdate($obj->date_livraison), "day"); @@ -858,13 +858,13 @@ if ($resql) print "'; @@ -872,7 +872,7 @@ if ($resql) print ''; @@ -885,48 +885,48 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['e.datec']['checked'])) + if (!empty($arrayfields['e.datec']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour'); print ''.$reception->LibStatut($obj->fk_statut, 5).''.yn($obj->billed).''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'; @@ -271,8 +271,8 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) print ''; // Other attributes - $parameters=array('objectsrc' => $objectsrc); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('objectsrc' => $objectsrc); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -284,9 +284,9 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print ''; @@ -306,11 +306,11 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) print $formconfirm; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; - $morehtmlref.='
'; + $morehtmlref = '
'; + $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -326,7 +326,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) // Resource type print ''; - print ''; + print ''; print ''; @@ -334,13 +334,13 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) // Description print ''; - print ''; + print ''; print ''; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; @@ -371,10 +371,10 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) // modified by hook if (empty($reshook)) { - if ($action != "create" && $action != "edit" ) + if ($action != "create" && $action != "edit") { // Edit resource - if($user->rights->resource->write) + if ($user->rights->resource->write) { print '
'; print ''.$langs->trans('Modify').''; @@ -384,7 +384,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) if ($action != "delete" && $action != "create" && $action != "edit") { // Delete resource - if($user->rights->resource->delete) + if ($user->rights->resource->delete) { print '
'; print ''.$langs->trans('Delete').''; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 62fc5ca9a9c..81e79aea228 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -28,12 +28,12 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; +if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; } // Load translation files required by the page @@ -45,19 +45,19 @@ $sortfield = GETPOST('sortfield','alpha'); $page = GETPOST('page','int'); */ -if( ! $user->rights->resource->read) +if (!$user->rights->resource->read) accessforbidden(); -$object=new Dolresource($db); +$object = new Dolresource($db); $hookmanager->initHooks(array('element_resource')); $object->available_resources = array('dolresource'); // Get parameters -$id = GETPOST('id', 'int'); // resource id -$element_id = GETPOST('element_id', 'int'); // element_id -$element_ref = GETPOST('ref', 'alpha'); // element ref -$element = GETPOST('element', 'alpha'); // element_type +$id = GETPOST('id', 'int'); // resource id +$element_id = GETPOST('element_id', 'int'); // element_id +$element_ref = GETPOST('ref', 'alpha'); // element ref +$element = GETPOST('element', 'alpha'); // element_type $action = GETPOST('action', 'alpha'); $mode = GETPOST('mode', 'alpha'); $lineid = GETPOST('lineid', 'int'); @@ -89,14 +89,14 @@ if (empty($reshook)) { $error = 0; - if ($action == 'add_element_resource' && ! $cancel) + if ($action == 'add_element_resource' && !$cancel) { $res = 0; - if (! ($resource_id > 0)) + if (!($resource_id > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Resource")), null, 'errors'); - $action=''; + $action = ''; } else { @@ -105,7 +105,7 @@ if (empty($reshook)) // TODO : add this check at update_linked_resource and when modifying event start or end date // check if an event resource is already in use - if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $objstat->element=='action' && $resource_type=='dolresource' && intval($busy)==1) { + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $objstat->element == 'action' && $resource_type == 'dolresource' && intval($busy) == 1) { $eventDateStart = $objstat->datep; $eventDateEnd = $objstat->datef; $isFullDayEvent = intval($objstat->fulldayevent); @@ -118,24 +118,24 @@ if (empty($reshook)) } $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "element_resources as er"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($resource_type) . "'"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($objstat->element) . "'"; - $sql .= " WHERE er.resource_id = " . $resource_id; + $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = '".$db->escape($resource_type)."'"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($objstat->element)."'"; + $sql .= " WHERE er.resource_id = ".$resource_id; $sql .= " AND er.busy = 1"; $sql .= " AND ("; // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) - $sql .= " (ac.datep <= '" . $db->idate($eventDateStart) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) . "'))"; + $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; // event date end between ac.datep and ac.datep2 if (!empty($eventDateEnd)) { - $sql .= " OR (ac.datep <= '" . $db->idate($eventDateEnd) . "' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) . "'))"; + $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; } // event date start before ac.datep and event date end after ac.datep2 $sql .= " OR ("; - $sql .= "ac.datep >= '" . $db->idate($eventDateStart) . "'"; + $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; if (!empty($eventDateEnd)) { - $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) . "')"; + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; } $sql .= ")"; @@ -146,12 +146,12 @@ if (empty($reshook)) $objstat->error = $db->lasterror(); $objstat->errors[] = $objstat->error; } else { - if ($db->num_rows($resql)>0) { + if ($db->num_rows($resql) > 0) { // already in use $error++; - $objstat->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; + $objstat->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; while ($obj = $db->fetch_object($resql)) { - $objstat->error .= '
- ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + $objstat->error .= '
- '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); } $objstat->errors[] = $objstat->error; } @@ -164,7 +164,7 @@ if (empty($reshook)) } } - if (! $error && $res > 0) + if (!$error && $res > 0) { setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$objstat->id); @@ -177,15 +177,15 @@ if (empty($reshook)) } // Update ressource - if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel', 'alpha') ) + if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel', 'alpha')) { $res = $object->fetch_element_resource($lineid); - if($res) + if ($res) { $object->busy = $busy; $object->mandatory = $mandatory; - if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element_type=='action' && $object->resource_type=='dolresource' && intval($object->busy)==1) { + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element_type == 'action' && $object->resource_type == 'dolresource' && intval($object->busy) == 1) { $eventDateStart = $object->objelement->datep; $eventDateEnd = $object->objelement->datef; $isFullDayEvent = intval($objstat->fulldayevent); @@ -198,25 +198,25 @@ if (empty($reshook)) } $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "element_resources as er"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($object->resource_type) . "'"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($object->element_type) . "'"; - $sql .= " WHERE er.resource_id = " . $object->resource_id; - $sql .= " AND ac.id != " . $object->element_id; + $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = '".$db->escape($object->resource_type)."'"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element_type)."'"; + $sql .= " WHERE er.resource_id = ".$object->resource_id; + $sql .= " AND ac.id != ".$object->element_id; $sql .= " AND er.busy = 1"; $sql .= " AND ("; // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) - $sql .= " (ac.datep <= '" . $db->idate($eventDateStart) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) . "'))"; + $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; // event date end between ac.datep and ac.datep2 if (!empty($eventDateEnd)) { - $sql .= " OR (ac.datep <= '" . $db->idate($eventDateEnd) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateEnd) . "'))"; + $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; } // event date start before ac.datep and event date end after ac.datep2 $sql .= " OR ("; - $sql .= "ac.datep >= '" . $db->idate($eventDateStart) . "'"; + $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; if (!empty($eventDateEnd)) { - $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) . "')"; + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; } $sql .= ")"; @@ -227,12 +227,12 @@ if (empty($reshook)) $object->error = $db->lasterror(); $object->errors[] = $object->error; } else { - if ($db->num_rows($resql)>0) { + if ($db->num_rows($resql) > 0) { // already in use $error++; - $object->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; + $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; while ($obj = $db->fetch_object($resql)) { - $object->error .= '
- ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + $object->error .= '
- '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); } $object->errors[] = $objstat->error; } @@ -273,8 +273,8 @@ if (empty($reshook)) } } -$parameters=array('resource_id'=>$resource_id); -$reshook=$hookmanager->executeHooks('getElementResources', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('resource_id'=>$resource_id); +$reshook = $hookmanager->executeHooks('getElementResources', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -283,15 +283,15 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e * View */ -$form=new Form($db); +$form = new Form($db); -$pagetitle=$langs->trans('ResourceElementPage'); +$pagetitle = $langs->trans('ResourceElementPage'); llxHeader('', $pagetitle, ''); // Load available resource, declared by modules $ret = count($object->available_resources); -if($ret == -1) { +if ($ret == -1) { dol_print_error($db, $object->error); exit; } @@ -315,49 +315,49 @@ else $act = fetchObjectByElement($element_id, $element, $element_ref); if (is_object($act)) { - $head=actions_prepare_head($act); + $head = actions_prepare_head($act); dol_fiche_head($head, 'resources', $langs->trans("Action"), -1, 'action'); - $linkback =img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); - $linkback.= ''.$langs->trans("BackToList").''; + $linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); + $linkback .= ''.$langs->trans("BackToList").''; // Link to other agenda views - $out=''; - $out.='
  • '.img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"'); - $out.=''.$langs->trans("ViewPerUser").''; - $out.='
  • '.img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="hideonsmartphone pictoactionview"'); - $out.=''.$langs->trans("ViewCal").''; - $out.='
  • '.img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"'); - $out.=''.$langs->trans("ViewWeek").''; - $out.='
  • '.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); - $out.=''.$langs->trans("ViewDay").''; + $out = ''; + $out .= '
  • '.img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"'); + $out .= ''.$langs->trans("ViewPerUser").''; + $out .= '
  • '.img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="hideonsmartphone pictoactionview"'); + $out .= ''.$langs->trans("ViewCal").''; + $out .= '
  • '.img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"'); + $out .= ''.$langs->trans("ViewWeek").''; + $out .= '
  • '.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); + $out .= ''.$langs->trans("ViewDay").''; - $linkback.=$out; + $linkback .= $out; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Thirdparty //$morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); //$morehtmlref.='
    '.$langs->trans('Project') . ' '; - $morehtmlref.=$langs->trans('Project') . ': '; - if (! empty($act->fk_project)) { + $morehtmlref .= $langs->trans('Project').': '; + if (!empty($act->fk_project)) { $proj = new Project($db); $proj->fetch($act->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - if ($proj->title) $morehtmlref.=' - '.$proj->title; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + if ($proj->title) $morehtmlref .= ' - '.$proj->title; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; - dol_banner_tab($act, 'element_id', $linkback, ($user->socid?0:1), 'id', 'ref', $morehtmlref, '&element='.$element, 0, '', ''); + dol_banner_tab($act, 'element_id', $linkback, ($user->socid ? 0 : 1), 'id', 'ref', $morehtmlref, '&element='.$element, 0, '', ''); print '
    '; @@ -366,7 +366,7 @@ else print '
  • ' . $langs->trans("ResourceType") . ''.$langs->trans("ResourceType").''; print $object->type_label; print '
    ' . $langs->trans("ResourceFormLabel_description") . ''.$langs->trans("ResourceFormLabel_description").''; print $object->description; print '
    '; // Type - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''; } @@ -376,7 +376,7 @@ else // Date start print ''; @@ -384,9 +384,9 @@ else // Date end print ''; // Location @@ -397,32 +397,32 @@ else // Assigned to print ''; print ''; print ''; print ''; print ''; - $generated_password=''; + $generated_password = ''; if (empty($ldap_sid)) // ldap_sid is for activedirectory { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $generated_password=getRandomPassword(false); + $generated_password = getRandomPassword(false); } - $password=$generated_password; + $password = $generated_password; // Password print ''; print ''; - if (! empty($conf->api->enabled)) + if (!empty($conf->api->enabled)) { // API key $generated_api_key = ''; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $generated_password=getRandomPassword(false); + $generated_password = getRandomPassword(false); print ''; print ''; } @@ -905,20 +905,20 @@ if ($action == 'create' || $action == 'adduserldap') { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; // PARTIAL WORKAROUND - $generated_fake_api_key=getRandomPassword(false); + $generated_fake_api_key = getRandomPassword(false); print ''; } // Administrator - if (! empty($user->admin)) + if (!empty($user->admin)) { print ''; print '\n"; @@ -962,15 +962,15 @@ if ($action == 'create' || $action == 'adduserldap') // Gender print ''; print ''; // Employee - $defaultemployee=1; + $defaultemployee = 1; print ''; print ''; // Hierarchy @@ -981,7 +981,7 @@ if ($action == 'create' || $action == 'adduserldap') print "\n"; // Expense report validator - if(!empty($conf->expensereport->enabled)) + if (!empty($conf->expensereport->enabled)) { print ''; // Town print ''; // Country print ''; @@ -1043,7 +1043,7 @@ if ($action == 'create' || $action == 'adduserldap') // Tel print ''; print ''; print ''; print ''; // EMail - print 'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.img_picto('', 'object_email').' '.$langs->trans("EMail").''; + print 'global->USER_MAIL_REQUIRED) ? ' class="fieldrequired"' : '').'>'.img_picto('', 'object_email').' '.$langs->trans("EMail").''; print ''; - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { print ''; print ''; } else { // if social network is not active but value exist we do not want to loose it - if (! empty($ldap_social[$key])) { + if (!empty($ldap_social[$key])) { print ''; } else { print ''; @@ -1196,30 +1196,30 @@ if ($action == 'create' || $action == 'adduserldap') } // User color - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { print ''; print ''; } // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print '"; } // Multicompany - if (! empty($conf->multicompany->enabled) && is_object($mc)) + if (!empty($conf->multicompany->enabled) && is_object($mc)) { // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module - if (! method_exists($mc, 'formObjectOptions')) + if (!method_exists($mc, 'formObjectOptions')) { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) // condition must be same for create and edit mode + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) // condition must be same for create and edit mode { print "".''; print "\n"; @@ -1254,7 +1254,7 @@ if ($action == 'create' || $action == 'adduserldap') print ''; print ''; @@ -1265,7 +1265,7 @@ if ($action == 'create' || $action == 'adduserldap') // TODO Move this into tab RH (HierarchicalResponsible must be on both tab) // Default warehouse - if (! empty($conf->stock->enabled) && ! empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? + if (!empty($conf->stock->enabled) && !empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? { print ''; - if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) - || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) + || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { $langs->load("salaries"); // THM print ''; print ''; print ''; - if (! empty($object->ldap_sid) && $object->statut==0) + if (!empty($object->ldap_sid) && $object->statut == 0) { print ''; } @@ -1506,68 +1506,68 @@ else print ''; print '"; print ''."\n"; // API key - if (! empty($conf->api->enabled) && $user->admin) { + if (!empty($conf->api->enabled) && $user->admin) { print ''; print ''; } // Administrator print ''."\n"; @@ -1618,7 +1618,7 @@ else print ''; print ''; print '\n"; // Default warehouse - if (! empty($conf->stock->enabled) && ! empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? + if (!empty($conf->stock->enabled) && !empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? { - require_once DOL_DOCUMENT_ROOT .'/product/stock/class/entrepot.class.php'; - $warehousestatic=new Entrepot($db); + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + $warehousestatic = new Entrepot($db); $warehousestatic->fetch($object->fk_warehouse); print ''; print ''; print "\n"; // TJM print ''; print ''; print "\n"; // Salary print ''; print ''; print "\n"; } @@ -1750,7 +1750,7 @@ else print '
    '.$langs->trans("Type").''.$act->type.'
    '.$langs->trans("DateActionStart").''; - if (! $act->fulldayevent) print dol_print_date($act->datep, 'dayhour'); + if (!$act->fulldayevent) print dol_print_date($act->datep, 'dayhour'); else print dol_print_date($act->datep, 'day'); if ($act->percentage == 0 && $act->datep && $act->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print '
    '.$langs->trans("DateActionEnd").''; - if (! $act->fulldayevent) print dol_print_date($act->datef, 'dayhour'); + if (!$act->fulldayevent) print dol_print_date($act->datef, 'dayhour'); else print dol_print_date($act->datef, 'day'); - if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); + if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print '
    '.$langs->trans("ActionAffectedTo").''; - $listofuserid=array(); + $listofuserid = array(); if (empty($donotclearsession)) { - if ($act->userownerid > 0) $listofuserid[$act->userownerid]=array('id'=>$act->userownerid,'transparency'=>$act->transparency); // Owner first - if (! empty($act->userassigned)) // Now concat assigned users + if ($act->userownerid > 0) $listofuserid[$act->userownerid] = array('id'=>$act->userownerid, 'transparency'=>$act->transparency); // Owner first + if (!empty($act->userassigned)) // Now concat assigned users { // Restore array with key with same value than param 'id' - $tmplist1=$act->userassigned; $tmplist2=array(); - foreach($tmplist1 as $key => $val) + $tmplist1 = $act->userassigned; $tmplist2 = array(); + foreach ($tmplist1 as $key => $val) { - if ($val['id'] && $val['id'] != $act->userownerid) $listofuserid[$val['id']]=$val; + if ($val['id'] && $val['id'] != $act->userownerid) $listofuserid[$val['id']] = $val; } } - $_SESSION['assignedtouser']=json_encode($listofuserid); + $_SESSION['assignedtouser'] = json_encode($listofuserid); } else { if (!empty($_SESSION['assignedtouser'])) { - $listofuserid=json_decode($_SESSION['assignedtouser'], true); + $listofuserid = json_decode($_SESSION['assignedtouser'], true); } } - $listofcontactid=array(); // not used yet - $listofotherid=array(); // not used yet + $listofcontactid = array(); // not used yet + $listofotherid = array(); // not used yet print '
    '; - print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($act->datep != $act->datef)?1:0, $listofuserid, $listofcontactid, $listofotherid); + print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($act->datep != $act->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid); print '
    '; /*if (in_array($user->id,array_keys($listofuserid))) { @@ -448,7 +448,7 @@ else $savobject = $object; $object = $socstatic; - require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $head = societe_prepare_head($socstatic); dol_fiche_head($head, 'resources', $langs->trans("ThirdParty"), -1, 'company'); @@ -461,7 +461,7 @@ else print ''; // Alias name (commercial, trademark or alias name) - print '"; @@ -486,53 +486,53 @@ else if (is_object($fichinter)) { - $head=fichinter_prepare_head($fichinter); + $head = fichinter_prepare_head($fichinter); dol_fiche_head($head, 'resource', $langs->trans("InterventionCard"), -1, 'intervention'); // Intervention card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Ref customer //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $fichinter->thirdparty->getNomUrl(1); + $morehtmlref .= $langs->trans('ThirdParty').' : '.$fichinter->thirdparty->getNomUrl(1); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
    '.$langs->trans('Project') . ' '; + $morehtmlref .= '
    '.$langs->trans('Project').' '; if ($user->rights->commande->creer) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; + $morehtmlref .= ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $fichinter->id, $fichinter->socid, $fichinter->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($fichinter->socid, $fichinter->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($fichinter->socid, $fichinter->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $fichinter->id, $fichinter->socid, $fichinter->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($fichinter->fk_project)) { + if (!empty($fichinter->fk_project)) { $proj = new Project($db); $proj->fetch($fichinter->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; dol_banner_tab($fichinter, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '&element='.$element, 0, '', '', 1); @@ -551,13 +551,13 @@ else if (is_object($product)) { $head = product_prepare_head($product); - $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==Product::TYPE_SERVICE?'service':'product'); + $titre = $langs->trans("CardProduct".$product->type); + $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'resources', $titre, -1, $picto); $shownav = 1; - if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($product, 'ref', '', $shownav, 'ref', 'ref', '', '&element='.$element); dol_fiche_end(); @@ -566,8 +566,8 @@ else // hook for other elements linked - $parameters=array('element'=>$element, 'element_id'=>$element_id, 'element_ref'=>$element_ref); - $reshook=$hookmanager->executeHooks('printElementTab', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('element'=>$element, 'element_id'=>$element_id, 'element_ref'=>$element_ref); + $reshook = $hookmanager->executeHooks('printElementTab', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -578,26 +578,26 @@ else foreach ($object->available_resources as $modresources => $resources) { - $resources=(array) $resources; // To be sure $resources is an array - foreach($resources as $resource_obj) + $resources = (array) $resources; // To be sure $resources is an array + foreach ($resources as $resource_obj) { $element_prop = getElementProperties($resource_obj); //print '/'.$modresources.'/class/'.$resource_obj.'.class.php
    '; $path = ''; - if(strpos($resource_obj, '@')) + if (strpos($resource_obj, '@')) $path .= '/'.$element_prop['module']; $linked_resources = $object->getElementResources($element, $element_id, $resource_obj); // Output template part (modules that overwrite templates must declare this into descriptor) - $defaulttpldir='/core/tpl'; - $dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir), array($path.$defaulttpldir)); + $defaulttpldir = '/core/tpl'; + $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir), array($path.$defaulttpldir)); - foreach($dirtpls as $module => $reldir) + foreach ($dirtpls as $module => $reldir) { - if(file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php'))) + if (file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php'))) { $tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php'); } @@ -606,18 +606,18 @@ else $tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_add.tpl.php'; } if (empty($conf->file->strict_mode)) { - $res=@include $tpl; + $res = @include $tpl; } else { - $res=include $tpl; // for debug + $res = include $tpl; // for debug } if ($res) break; } if ($mode != 'add' || $resource_obj != $resource_type) { - foreach($dirtpls as $module => $reldir) + foreach ($dirtpls as $module => $reldir) { - if(file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php'))) + if (file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php'))) { $tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php'); } @@ -626,9 +626,9 @@ else $tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_view.tpl.php'; } if (empty($conf->file->strict_mode)) { - $res=@include $tpl; + $res = @include $tpl; } else { - $res=include $tpl; // for debug + $res = include $tpl; // for debug } if ($res) break; } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 7c4c3bc0ef1..7886c0ef728 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -45,50 +45,50 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -if (! empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; -if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +if (!empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; +if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +if (!empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); -$mode = GETPOST('mode', 'alpha'); +$mode = GETPOST('mode', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$group = GETPOST("group", "int", 3); +$group = GETPOST("group", "int", 3); $cancel = GETPOST('cancel', 'alpha'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'useracard'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useracard'; // To manage different context of search // Define value to know what current user can do on users -$canadduser=(! empty($user->admin) || $user->rights->user->user->creer); -$canreaduser=(! empty($user->admin) || $user->rights->user->user->lire); -$canedituser=(! empty($user->admin) || $user->rights->user->user->creer); -$candisableuser=(! empty($user->admin) || $user->rights->user->user->supprimer); -$canreadgroup=$canreaduser; -$caneditgroup=$canedituser; -if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) +$canadduser = (!empty($user->admin) || $user->rights->user->user->creer); +$canreaduser = (!empty($user->admin) || $user->rights->user->user->lire); +$canedituser = (!empty($user->admin) || $user->rights->user->user->creer); +$candisableuser = (!empty($user->admin) || $user->rights->user->user->supprimer); +$canreadgroup = $canreaduser; +$caneditgroup = $canedituser; +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { - $canreadgroup=(! empty($user->admin) || $user->rights->user->group_advance->read); - $caneditgroup=(! empty($user->admin) || $user->rights->user->group_advance->write); + $canreadgroup = (!empty($user->admin) || $user->rights->user->group_advance->read); + $caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write); } // Define value to know what current user can do on properties of edited user if ($id) { // $user est le user qui edite, $id est l'id de l'utilisateur edite - $caneditfield=((($user->id == $id) && $user->rights->user->self->creer) + $caneditfield = ((($user->id == $id) && $user->rights->user->self->creer) || (($user->id != $id) && $user->rights->user->user->creer)); - $caneditpassword=((($user->id == $id) && $user->rights->user->self->password) + $caneditpassword = ((($user->id == $id) && $user->rights->user->self->password) || (($user->id != $id) && $user->rights->user->user->password)); } // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) $socid = $user->socid; -$feature2='user'; +$feature2 = 'user'; $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); -if ($user->id <> $id && ! $canreaduser) accessforbidden(); +if ($user->id <> $id && !$canreaduser) accessforbidden(); // Load translation files required by page $langs->loadLangs(array('users', 'companies', 'ldap', 'admin', 'hrm', 'stocks')); @@ -109,8 +109,8 @@ $hookmanager->initHooks(array('usercard', 'globalcard')); /** * Actions */ -$parameters=array('id' => $id, 'socid' => $socid, 'group' => $group, 'caneditgroup' => $caneditgroup); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id' => $id, 'socid' => $socid, 'group' => $group, 'caneditgroup' => $caneditgroup); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { @@ -131,7 +131,7 @@ if (empty($reshook)) { if (!empty($conf->file->main_limit_users)) { $nb = $object->getNbOfUsers("active"); if ($nb >= $conf->file->main_limit_users) { - $error ++; + $error++; setEventMessages($langs->trans("YourQuotaOfUsersIsReached"), null, 'errors'); } } @@ -148,7 +148,7 @@ if (empty($reshook)) { { if ($id <> $user->id) { - if (! GETPOSTISSET('token')) + if (!GETPOSTISSET('token')) { print 'Error, token required for this critical operation'; exit; @@ -175,22 +175,22 @@ if (empty($reshook)) { $error = 0; if (!$_POST["lastname"]) { - $error ++; + $error++; setEventMessages($langs->trans("NameNotDefined"), null, 'errors'); - $action = "create"; // Go back to create page + $action = "create"; // Go back to create page } if (!$_POST["login"]) { - $error ++; + $error++; setEventMessages($langs->trans("LoginNotDefined"), null, 'errors'); - $action = "create"; // Go back to create page + $action = "create"; // Go back to create page } if (!empty($conf->file->main_limit_users)) { // If option to limit users is set $nb = $object->getNbOfUsers("active"); if ($nb >= $conf->file->main_limit_users) { - $error ++; + $error++; setEventMessages($langs->trans("YourQuotaOfUsersIsReached"), null, 'errors'); - $action = "create"; // Go back to create page + $action = "create"; // Go back to create page } } @@ -217,7 +217,7 @@ if (empty($reshook)) { //$object->facebook = GETPOST("facebook", 'alphanohtml'); //$object->linkedin = GETPOST("linkedin", 'alphanohtml'); $object->socialnetworks = array(); - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } @@ -252,16 +252,16 @@ if (empty($reshook)) { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { - $error ++; + $error++; } // Set entity property $entity = GETPOST('entity', 'int'); - if (! empty($conf->multicompany->enabled)) { + if (!empty($conf->multicompany->enabled)) { if (GETPOST('superadmin', 'int')) { $object->entity = 0; } else { - if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $object->entity = 1; // all users are forced into master entity } else { $object->entity = ($entity == '' ? 1 : $entity); @@ -281,7 +281,7 @@ if (empty($reshook)) { if (GETPOST('password')) { $object->setPassword($user, GETPOST('password')); } - if (! empty($conf->categorie->enabled)) { + if (!empty($conf->categorie->enabled)) { // Categories association $usercats = GETPOST('usercats', 'array'); $object->setCategories($usercats); @@ -296,7 +296,7 @@ if (empty($reshook)) { $langs->load("errors"); $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); - $action = "create"; // Go back to create page + $action = "create"; // Go back to create page } } } @@ -308,7 +308,7 @@ if (empty($reshook)) { { $editgroup = new UserGroup($db); $editgroup->fetch($group); - $editgroup->oldcopy=clone $editgroup; + $editgroup->oldcopy = clone $editgroup; $object->fetch($id); if ($action == 'addgroup') { @@ -329,7 +329,7 @@ if (empty($reshook)) { } } - if ($action == 'update' && ! $cancel) + if ($action == 'update' && !$cancel) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -337,15 +337,15 @@ if (empty($reshook)) { { $error = 0; - if (! GETPOST("lastname", 'alpha')) { + if (!GETPOST("lastname", 'alpha')) { setEventMessages($langs->trans("NameNotDefined"), null, 'errors'); - $action = "edit"; // Go back to create page - $error ++; + $action = "edit"; // Go back to create page + $error++; } - if (! GETPOST("login", 'alpha')) { + if (!GETPOST("login", 'alpha')) { setEventMessages($langs->trans("LoginNotDefined"), null, 'errors'); - $action = "edit"; // Go back to create page - $error ++; + $action = "edit"; // Go back to create page + $error++; } if (!$error) @@ -364,7 +364,7 @@ if (empty($reshook)) { $object->birth = $birth; $object->pass = GETPOST("password", 'none'); $object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key; - if (! empty($user->admin)) $object->admin = GETPOST("admin", "int"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request + if (!empty($user->admin)) $object->admin = GETPOST("admin", "int"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request $object->address = GETPOST('address', 'alphanohtml'); $object->zip = GETPOST('zipcode', 'alphanohtml'); $object->town = GETPOST('town', 'alphanohtml'); @@ -378,7 +378,7 @@ if (empty($reshook)) { //$object->facebook = GETPOST("facebook", 'alphanohtml'); //$object->linkedin = GETPOST("linkedin", 'alphanohtml'); $object->socialnetworks = array(); - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } @@ -405,35 +405,35 @@ if (empty($reshook)) { $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth', 'int'), GETPOST('dateemploymentendday', 'int'), GETPOST('dateemploymentendyear', 'int')); $object->dateemploymentend = $dateemploymentend; - if (! empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { $object->fk_warehouse = GETPOST('fk_warehouse', 'int'); } - if (! empty($conf->multicompany->enabled)) + if (!empty($conf->multicompany->enabled)) { - if (! empty($_POST["superadmin"])) + if (!empty($_POST["superadmin"])) { $object->entity = 0; } - elseif (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + elseif (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $object->entity = 1; // all users in master entity } else { - $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); + $object->entity = (!GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); } } else { - $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); + $object->entity = (!GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); } // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { - $error ++; + $error++; } if (GETPOST('deletephoto')) { @@ -441,7 +441,7 @@ if (empty($reshook)) { } if (!empty($_FILES['photo']['name'])) { - $isimage=image_format_supported($_FILES['photo']['name']); + $isimage = image_format_supported($_FILES['photo']['name']); if ($isimage > 0) { $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); @@ -491,7 +491,7 @@ if (empty($reshook)) { dol_syslog("usercard::update", LOG_DEBUG); $resql = $db->query($sql); if (!$resql) { - $error ++; + $error++; setEventMessages($db->lasterror(), null, 'errors'); } } @@ -520,14 +520,14 @@ if (empty($reshook)) { $object->addThumbs($newfile); } } else { - $error ++; + $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors'); } } } - if (! $error && ! count($object->errors)) + if (!$error && !count($object->errors)) { // Then we add the associated categories $categories = GETPOST('usercats', 'array'); @@ -657,15 +657,15 @@ if (empty($reshook)) { } // Actions to send emails - $trigger_name='USER_SENTBYMAIL'; - $paramname='id'; // Name of param key to open the card - $mode='emailfromuser'; - $trackid='use'.$id; + $trigger_name = 'USER_SENTBYMAIL'; + $paramname = 'id'; // Name of param key to open the card + $mode = 'emailfromuser'; + $trackid = 'use'.$id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc $upload_dir = $conf->user->dir_output; - $permissiontoadd=$user->rights->user->user->creer; + $permissiontoadd = $user->rights->user->user->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -675,10 +675,10 @@ if (empty($reshook)) { */ $form = new Form($db); -$formother=new FormOther($db); +$formother = new FormOther($db); $formcompany = new FormCompany($db); $formfile = new FormFile($db); -if (! empty($conf->stock->enabled)) $formproduct = new FormProduct($db); +if (!empty($conf->stock->enabled)) $formproduct = new FormProduct($db); llxHeader('', $langs->trans("UserCard")); @@ -696,7 +696,7 @@ if ($action == 'create' || $action == 'adduserldap') print "
    "; - if (! empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')) + if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')) { /* * Affiche formulaire d'ajout d'un compte depuis LDAP @@ -707,7 +707,7 @@ if ($action == 'create' || $action == 'adduserldap') $result = $ldap->connect_bind(); if ($result >= 0) { - $required_fields=array( + $required_fields = array( $conf->global->LDAP_KEY_USERS, $conf->global->LDAP_FIELD_FULLNAME, $conf->global->LDAP_FIELD_NAME, @@ -727,23 +727,23 @@ if ($action == 'create' || $action == 'adduserldap') ); // Remove from required_fields all entries not configured in LDAP (empty) and duplicated - $required_fields=array_unique(array_values(array_filter($required_fields, "dol_validElement"))); + $required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement"))); // Get from LDAP database an array of results $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1); if (is_array($ldapusers)) { - $liste=array(); + $liste = array(); foreach ($ldapusers as $key => $ldapuser) { // Define the label string for this user - $label=''; + $label = ''; foreach ($required_fields as $value) { if ($value) { - $label.=$value."=".$ldapuser[$value]." "; + $label .= $value."=".$ldapuser[$value]." "; } } $liste[$key] = $label; @@ -776,7 +776,7 @@ if ($action == 'create' || $action == 'adduserldap') print ajax_combobox('users'); } print '
    ' . $langs->trans('AliasNames') . ''; + print '
    '.$langs->trans('AliasNames').''; print $socstatic->name_alias; print "
    '; - print ''; + print ''; print '
    '; print ''; @@ -788,7 +788,7 @@ if ($action == 'create' || $action == 'adduserldap') print '
    '; print ''; print ''; - if (! empty($ldap_sid)) print ''; + if (!empty($ldap_sid)) print ''; print ''; dol_fiche_head('', '', '', 0, ''); @@ -801,7 +801,7 @@ if ($action == 'create' || $action == 'adduserldap') print '
    '.$langs->trans("Lastname").''; - if (! empty($ldap_lastname)) + if (!empty($ldap_lastname)) { print ''; print $ldap_lastname; @@ -815,7 +815,7 @@ if ($action == 'create' || $action == 'adduserldap') // Firstname print '
    '.$langs->trans("Firstname").''; - if (! empty($ldap_firstname)) + if (!empty($ldap_firstname)) { print ''; print $ldap_firstname; @@ -829,12 +829,12 @@ if ($action == 'create' || $action == 'adduserldap') // Login print '
    '.$langs->trans("Login").''; - if (! empty($ldap_login)) + if (!empty($ldap_login)) { print ''; print $ldap_login; } - elseif (! empty($ldap_loginsmb)) + elseif (!empty($ldap_loginsmb)) { print ''; print $ldap_loginsmb; @@ -845,59 +845,59 @@ if ($action == 'create' || $action == 'adduserldap') } print '
    '.$langs->trans("Password").''; - $valuetoshow=''; + $valuetoshow = ''; if (preg_match('/ldap/', $dolibarr_main_authentication)) { - $valuetoshow.=($valuetoshow?', ':'').$langs->trans("PasswordOfUserInLDAP"); + $valuetoshow .= ($valuetoshow ? ', ' : '').$langs->trans("PasswordOfUserInLDAP"); } if (preg_match('/http/', $dolibarr_main_authentication)) { - $valuetoshow.=($valuetoshow?', ':'').$langs->trans("HTTPBasicPassword"); + $valuetoshow .= ($valuetoshow ? ', ' : '').$langs->trans("HTTPBasicPassword"); } if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { - if (! empty($ldap_pass)) // For very old system comaptibilty. Now clear password can't be viewed from LDAP read + if (!empty($ldap_pass)) // For very old system comaptibilty. Now clear password can't be viewed from LDAP read { - $valuetoshow.= ($valuetoshow?', ':'').''; // Dolibarr password is preffiled with LDAP known password - $valuetoshow.= preg_replace('/./i', '*', $ldap_pass); + $valuetoshow .= ($valuetoshow ? ', ' : '').''; // Dolibarr password is preffiled with LDAP known password + $valuetoshow .= preg_replace('/./i', '*', $ldap_pass); } else { // We do not use a field password but a field text to show new password to use. - $valuetoshow.= ($valuetoshow?', ':'').''; + $valuetoshow .= ($valuetoshow ? ', ' : '').''; } } // Other form for user password - $parameters=array('valuetoshow' => $valuetoshow, 'password' => $password); - $reshook=$hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) $valuetoshow=$hookmanager->resPrint; // to replace - else $valuetoshow.=$hookmanager->resPrint; // to add + $parameters = array('valuetoshow' => $valuetoshow, 'password' => $password); + $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook > 0) $valuetoshow = $hookmanager->resPrint; // to replace + else $valuetoshow .= $hookmanager->resPrint; // to add print $valuetoshow; print '
    '.$langs->trans("ApiKey").''; print ''; - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); print '
    '.$langs->trans("Administrator").''; print $form->selectyesno('admin', GETPOST('admin'), 1); - if (! empty($conf->multicompany->enabled) && ! $user->entity) + if (!empty($conf->multicompany->enabled) && !$user->entity) { - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print ''; } - $checked=(GETPOST('superadmin', 'int')?' checked':''); - $disabled=(GETPOST('superadmin', 'int')?'':' disabled'); + $checked = (GETPOST('superadmin', 'int') ? ' checked' : ''); + $disabled = (GETPOST('superadmin', 'int') ? '' : ' disabled'); print ' '.$langs->trans("SuperAdministrator"); } print "
    '.$langs->trans("Gender").''; - $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); print $form->selectarray('gender', $arraygender, GETPOST('gender'), 1); print '
    '.$langs->trans('Employee').''; - print $form->selectyesno("employee", (GETPOST('employee')!=''?GETPOST('employee'):$defaultemployee), 1); + print $form->selectyesno("employee", (GETPOST('employee') != '' ?GETPOST('employee') : $defaultemployee), 1); print '
    '; $text = $langs->trans("ForceUserExpenseValidator"); @@ -994,7 +994,7 @@ if ($action == 'create' || $action == 'adduserldap') } // Holiday request validator - if(!empty($conf->holiday->enabled)) + if (!empty($conf->holiday->enabled)) { print '
    '; $text = $langs->trans("ForceUserHolidayValidator"); @@ -1018,17 +1018,17 @@ if ($action == 'create' || $action == 'adduserldap') // Zip print '
    '.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).''; - print $formcompany->select_ziptown($object->zip, 'zipcode', array('town','selectcountry_id','state_id'), 6); + print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print '
    '.$form->editfieldkey('Town', 'town', '', $object, 0).''; - print $formcompany->select_ziptown($object->town, 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
    '.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).''; - print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id)); + print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id)); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
    '.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").''; - if (! empty($ldap_phone)) + if (!empty($ldap_phone)) { print ''; print $ldap_phone; @@ -1057,7 +1057,7 @@ if ($action == 'create' || $action == 'adduserldap') // Tel portable print '
    '.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").''; - if (! empty($ldap_mobile)) + if (!empty($ldap_mobile)) { print ''; print $ldap_mobile; @@ -1071,7 +1071,7 @@ if ($action == 'create' || $action == 'adduserldap') // Fax print '
    '.img_picto('', 'object_phoning_fax').' '.$langs->trans("Fax").''; - if (! empty($ldap_fax)) + if (!empty($ldap_fax)) { print ''; print $ldap_fax; @@ -1083,9 +1083,9 @@ if ($action == 'create' || $action == 'adduserldap') print '
    '; - if (! empty($ldap_mail)) + if (!empty($ldap_mail)) { print ''; print $ldap_mail; @@ -1096,12 +1096,12 @@ if ($action == 'create' || $action == 'adduserldap') } print '
    '.$langs->trans($value['label']).''; - if (! empty($ldap_social[$key])) { + if (!empty($ldap_social[$key])) { print ''; print $ldap_social[$key]; } else { @@ -1110,7 +1110,7 @@ if ($action == 'create' || $action == 'adduserldap') print '
    '.$langs->trans("ColorUser").''; - print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); + print $formother->selectColor(GETPOST('color') ?GETPOST('color') : $object->color, 'color', null, 1, '', 'hideifnotset'); print '
    ' . $form->editfieldkey('Categories', 'usercats', '', $object, 0) . ''; + print '
    '.$form->editfieldkey('Categories', 'usercats', '', $object, 0).''; $cate_arbo = $form->select_all_categories('user', null, 'parent', null, null, 1); print $form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), null, null, null, null, '90%'); print "
    '.$langs->trans("Entity").'".$mc->select_entities($conf->entity); @@ -1233,8 +1233,8 @@ if ($action == 'create' || $action == 'adduserldap') } // Other attributes - $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -1246,7 +1246,7 @@ if ($action == 'create' || $action == 'adduserldap') print $langs->trans("Note"); print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note', '', '', 120, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_3, '90%'); + $doleditor = new DolEditor('note', '', '', 120, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_3, '90%'); $doleditor->Create(); print "
    '.$langs->trans("Signature").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('signature', GETPOST('signature'), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1, ROWS_4, '90%'); + $doleditor = new DolEditor('signature', GETPOST('signature'), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%'); print $doleditor->Create(1); print '
    '.$langs->trans("DefaultWarehouse").''; print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); @@ -1278,14 +1278,14 @@ if ($action == 'create' || $action == 'adduserldap') print ''; print '
    '; - $text=$langs->trans("THM"); + $text = $langs->trans("THM"); print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm'); print ''; @@ -1295,7 +1295,7 @@ if ($action == 'create' || $action == 'adduserldap') // TJM print '
    '; - $text=$langs->trans("TJM"); + $text = $langs->trans("TJM"); print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm'); print ''; @@ -1363,7 +1363,7 @@ else { $object->fetch($id, '', '', 1); if ($res < 0) { dol_print_error($db, $object->error); exit; } - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); // Check if user has rights if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) @@ -1374,15 +1374,15 @@ else // Connexion ldap // pour recuperer passDoNotExpire et userChangePassNextLogon - if (! empty($conf->ldap->enabled) && ! empty($object->ldap_sid)) + if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) { $ldap = new Ldap(); - $result=$ldap->connect_bind(); + $result = $ldap->connect_bind(); if ($result > 0) { $userSearchFilter = '('.$conf->global->LDAP_FILTER_CONNECTION.'('.$ldap->getUserIdentifier().'='.$object->login.'))'; $entries = $ldap->fetch($object->login, $userSearchFilter); - if (! $entries) + if (!$entries) { setEventMessages($ldap->error, $ldap->errors, 'errors'); } @@ -1492,7 +1492,7 @@ else // Login print '
    '.$langs->trans("Login").''.$langs->trans("LoginAccountDisableInDolibarr").'
    '.$langs->trans("Password").''; - $valuetoshow=''; + $valuetoshow = ''; if (preg_match('/ldap/', $dolibarr_main_authentication)) { - if (! empty($object->ldap_sid)) + if (!empty($object->ldap_sid)) { if ($passDoNotExpire) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("LdapUacf_".$statutUACF); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("LdapUacf_".$statutUACF); } - elseif($userChangePassNextLogon) + elseif ($userChangePassNextLogon) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').''.$langs->trans("UserMustChangePassNextLogon", $ldap->domainFQDN).''; + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''.$langs->trans("UserMustChangePassNextLogon", $ldap->domainFQDN).''; } - elseif($userDisabled) + elseif ($userDisabled) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').''.$langs->trans("LdapUacf_".$statutUACF, $ldap->domainFQDN).''; + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''.$langs->trans("LdapUacf_".$statutUACF, $ldap->domainFQDN).''; } else { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("PasswordOfUserInLDAP"); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); } } else { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("PasswordOfUserInLDAP"); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); } } if (preg_match('/http/', $dolibarr_main_authentication)) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("HTTPBasicPassword"); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("HTTPBasicPassword"); } if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { - if ($object->pass) $valuetoshow.= ($valuetoshow?(' '.$langs->trans("or").' '):'').preg_replace('/./i', '*', $object->pass); + if ($object->pass) $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass); else { - if ($user->admin) $valuetoshow.= ($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("Crypted").': '.$object->pass_indatabase_crypted; - else $valuetoshow.= ($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("Hidden"); + if ($user->admin) $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("Crypted").': '.$object->pass_indatabase_crypted; + else $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("Hidden"); } } // Other form for user password - $parameters=array('valuetoshow' => $valuetoshow); - $reshook=$hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) $valuetoshow=$hookmanager->resPrint; // to replace - else $valuetoshow.=$hookmanager->resPrint; // to add + $parameters = array('valuetoshow' => $valuetoshow); + $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook > 0) $valuetoshow = $hookmanager->resPrint; // to replace + else $valuetoshow .= $hookmanager->resPrint; // to add print $valuetoshow; print "
    '.$langs->trans("ApiKey").''; - if (! empty($object->api_key)) print preg_replace('/./', '*', $object->api_key); + if (!empty($object->api_key)) print preg_replace('/./', '*', $object->api_key); print '
    '.$langs->trans("Administrator").''; - if (! empty($conf->multicompany->enabled) && $object->admin && ! $object->entity) + if (!empty($conf->multicompany->enabled) && $object->admin && !$object->entity) { print $form->textwithpicto(yn($object->admin), $langs->trans("SuperAdministratorDesc"), 1, "superadmin"); } @@ -1583,11 +1583,11 @@ else // Type print '
    '; - $text=$langs->trans("Type"); + $text = $langs->trans("Type"); print $form->textwithpicto($text, $langs->trans("InternalExternalDesc")); print ''; - $type=$langs->trans("Internal"); - if ($object->societe_id > 0) $type=$langs->trans("External"); + $type = $langs->trans("Internal"); + if ($object->societe_id > 0) $type = $langs->trans("External"); print $type; if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; print '
    '; if (empty($object->fk_user)) print $langs->trans("None"); else { - $huser=new User($db); + $huser = new User($db); $huser->fetch($object->fk_user); print $huser->getNomUrl(1); } @@ -1631,8 +1631,8 @@ else print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); print ''; - if (! empty($object->fk_user_expense_validator)) { - $evuser=new User($db); + if (!empty($object->fk_user_expense_validator)) { + $evuser = new User($db); $evuser->fetch($object->fk_user_expense_validator); print $evuser->getNomUrl(1); } @@ -1645,8 +1645,8 @@ else print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); print ''; - if (! empty($object->fk_user_holiday_validator)) { - $hvuser=new User($db); + if (!empty($object->fk_user_holiday_validator)) { + $hvuser = new User($db); $hvuser->fetch($object->fk_user_holiday_validator); print $hvuser->getNomUrl(1); } @@ -1654,10 +1654,10 @@ else print "
    '.$langs->trans("DefaultWarehouse").''; print $warehousestatic->getNomUrl(); @@ -1671,8 +1671,8 @@ else //$childids = $user->getAllChildIds(1); - if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) - || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) + || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { // Even a superior can't see this info of its subordinates wihtout $user->rights->salaries->read and $user->rights->hrm->employee->read (setting/viewing is reserverd to HR people). // However, he can see the valuation of timesheet of its subordinates even without these permissions. @@ -1680,28 +1680,28 @@ else // THM print '
    '; - $text=$langs->trans("THM"); + $text = $langs->trans("THM"); print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm'); print ''; - print ($object->thm!=''?price($object->thm, '', $langs, 1, -1, -1, $conf->currency):''); + print ($object->thm != '' ?price($object->thm, '', $langs, 1, -1, -1, $conf->currency) : ''); print '
    '; - $text=$langs->trans("TJM"); + $text = $langs->trans("TJM"); print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm'); print ''; - print ($object->tjm!=''?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency):''); + print ($object->tjm != '' ?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency) : ''); print '
    '.$langs->trans("Salary").''; - print ($object->salary!=''?price($object->salary, '', $langs, 1, -1, -1, $conf->currency):''); + print ($object->salary != '' ?price($object->salary, '', $langs, 1, -1, -1, $conf->currency) : ''); print '
    '; // Color user - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { print ''; print ''; + print ''; print ''; } - if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) + if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) { print ''; print ''; @@ -1784,14 +1784,14 @@ else print "\n"; // Multicompany - if (! empty($conf->multicompany->enabled) && is_object($mc)) + if (!empty($conf->multicompany->enabled) && is_object($mc)) { // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module - if (! method_exists($mc, 'formObjectOptions')) + if (!method_exists($mc, 'formObjectOptions')) { - if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) { - print ''; print ''; print '
    '.$langs->trans("ColorUser").''; @@ -1760,15 +1760,15 @@ else } // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print '
    ' . $langs->trans("Categories") . '
    '.$langs->trans("Categories").''; print $form->showCategories($object->id, 'user', 1); print '
    '.$langs->trans("OpenIDURL").''.$object->openid.'
    ' . $langs->trans("Entity") . ''; + print '
    '.$langs->trans("Entity").''; if (empty($object->entity)) { print $langs->trans("AllEntities"); } else { @@ -1804,10 +1804,10 @@ else } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; // Company / Contact - if (! empty($conf->societe->enabled)) + if (!empty($conf->societe->enabled)) { print '
    '.$langs->trans("LinkToCompanyContact").''; @@ -1821,7 +1821,7 @@ else { print $langs->trans("ThisUserIsNot"); } - if (! empty($object->contactid)) + if (!empty($object->contactid)) { $contact = new Contact($db); $contact->fetch($object->contactid); @@ -1834,16 +1834,16 @@ else } // Module Adherent - if (! empty($conf->adherent->enabled)) + if (!empty($conf->adherent->enabled)) { $langs->load("members"); print '
    '.$langs->trans("LinkedToDolibarrMember").''; if ($object->fk_member) { - $adh=new Adherent($db); + $adh = new Adherent($db); $adh->fetch($object->fk_member); - $adh->ref=$adh->getFullname($langs); // Force to show login instead of id + $adh->ref = $adh->getFullname($langs); // Force to show login instead of id print $adh->getNomUrl(1); } else @@ -1875,11 +1875,11 @@ else print '
    '; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - if (! empty($object->email)) + if (!empty($object->email)) { $langs->load("mails"); print ''; @@ -1890,9 +1890,9 @@ else print ''; } - if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { - if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) + if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { print ''; } @@ -1901,8 +1901,8 @@ else print ''; } } - elseif ($caneditpassword && ! $object->ldap_sid && - (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + elseif ($caneditpassword && !$object->ldap_sid && + (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print ''; } @@ -1915,7 +1915,7 @@ else print ''; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print ''; } @@ -1925,7 +1925,7 @@ else print ''; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { if ($object->email) print ''; else print ''; @@ -1934,13 +1934,13 @@ else // Enable user if ($user->id <> $id && $candisableuser && $object->statut == 0 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print ''; } // Disable user if ($user->id <> $id && $candisableuser && $object->statut == 1 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print ''; } @@ -1953,9 +1953,9 @@ else } // Delete if ($user->id <> $id && $candisableuser && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { - if ($user->admin || ! $object->admin) // If user edited is admin, delete is possible on for an admin + if ($user->admin || !$object->admin) // If user edited is admin, delete is possible on for an admin { print ''; } @@ -1974,8 +1974,8 @@ else if (GETPOST('modelselected')) $action = 'presend'; // Presend form - $modelmail='user'; - $defaulttopic='Information'; + $modelmail = 'user'; + $defaulttopic = 'Information'; $diroutput = $conf->user->dir_output; $trackid = 'use'.$object->id; @@ -1994,14 +1994,14 @@ else // On selectionne les groupes auquel fait parti le user $exclude = array(); - $usergroup=new UserGroup($db); + $usergroup = new UserGroup($db); $groupslist = $usergroup->listGroupsForUser($object->id); - if (! empty($groupslist)) + if (!empty($groupslist)) { - foreach($groupslist as $groupforuser) + foreach ($groupslist as $groupforuser) { - $exclude[]=$groupforuser->id; + $exclude[] = $groupforuser->id; } } @@ -2015,8 +2015,8 @@ else print ''."\n"; // Other form for add user to group - $parameters=array('caneditgroup' => $caneditgroup, 'groupslist' => $groupslist, 'exclude' => $exclude); - $reshook=$hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('caneditgroup' => $caneditgroup, 'groupslist' => $groupslist, 'exclude' => $exclude); + $reshook = $hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) @@ -2035,9 +2035,9 @@ else /* * Groups assigned to user */ - if (! empty($groupslist)) + if (!empty($groupslist)) { - foreach($groupslist as $group) + foreach ($groupslist as $group) { print ''; print '
    '; @@ -2096,7 +2096,7 @@ else print ''; // Ref/ID - if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print ''; print '".''; print ''; print '\n"; // API key - if(! empty($conf->api->enabled) && $user->admin) + if (!empty($conf->api->enabled) && $user->admin) { print ''; print ''; } @@ -2215,13 +2215,13 @@ else && ($user->id != $object->id) // Don't downgrade ourself && ( (empty($conf->multicompany->enabled) && $nbAdmin >= 1) - || (! empty($conf->multicompany->enabled) && (($object->entity > 0 || ($user->entity == 0 && $object->entity == 0)) || $nbSuperAdmin > 1)) // Don't downgrade a superadmin if alone + || (!empty($conf->multicompany->enabled) && (($object->entity > 0 || ($user->entity == 0 && $object->entity == 0)) || $nbSuperAdmin > 1)) // Don't downgrade a superadmin if alone ) ) { print $form->selectyesno('admin', $object->admin, 1); - if (! empty($conf->multicompany->enabled) && ! $user->entity) + if (!empty($conf->multicompany->enabled) && !$user->entity) { if ($conf->use_javascript_ajax) { @@ -2262,7 +2262,7 @@ else '; } - $checked=(($object->admin && ! $object->entity) ? ' checked' : ''); + $checked = (($object->admin && !$object->entity) ? ' checked' : ''); print ' '.$langs->trans("SuperAdministrator"); } } @@ -2271,7 +2271,7 @@ else $yn = yn($object->admin); print ''; print ''; - if (! empty($conf->multicompany->enabled) && empty($object->entity)) print $form->textwithpicto($yn, $langs->trans("DontDowngradeSuperAdmin"), 1, 'warning'); + if (!empty($conf->multicompany->enabled) && empty($object->entity)) print $form->textwithpicto($yn, $langs->trans("DontDowngradeSuperAdmin"), 1, 'warning'); else print $yn; } print ''; @@ -2280,17 +2280,17 @@ else // Type print ''; print ''; print ''; // Employee @@ -2309,7 +2309,7 @@ else if ($caneditfield) { print $form->selectyesno("employee", $object->employee, 1); } else { - if ($object->employee){ + if ($object->employee) { print $langs->trans("Yes"); } else { print $langs->trans("No"); @@ -2327,7 +2327,7 @@ else else { print ''; - $huser=new User($db); + $huser = new User($db); $huser->fetch($object->fk_user); print $huser->getNomUrl(1); } @@ -2347,7 +2347,7 @@ else else { print ''; - $evuser=new User($db); + $evuser = new User($db); $evuser->fetch($object->fk_user_expense_validator); print $evuser->getNomUrl(1); } @@ -2367,7 +2367,7 @@ else else { print ''; - $hvuser=new User($db); + $hvuser = new User($db); $hvuser->fetch($object->fk_user_holiday_validator); print $hvuser->getNomUrl(1); } @@ -2396,7 +2396,7 @@ else // Country print ''; @@ -2411,7 +2411,7 @@ else // Tel pro print "".''; print '".''; print ''; // EMail - print "".'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.img_picto('', 'object_email').' '.$langs->trans("EMail").''; + print "".'global->USER_MAIL_REQUIRED) ? ' class="fieldrequired"' : '').'>'.img_picto('', 'object_email').' '.$langs->trans("EMail").''; print ''; - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { print ''; print '".''; print ''; print ''; @@ -2614,7 +2614,7 @@ else // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print ''; + print ''; print '"; @@ -2638,7 +2638,7 @@ else print ''; // Company / Contact - if (! empty($conf->societe->enabled)) + if (!empty($conf->societe->enabled)) { print ''; print ''; print '".''; - print "\n"; } else @@ -2705,15 +2705,15 @@ else } // Other attributes - $parameters=array('colspan' => ' colspan="2"'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('colspan' => ' colspan="2"'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { if ($caneditfield) { print $object->showOptionals($extrafields, 'edit'); - }else{ + } else { print $object->showOptionals($extrafields, 'view'); } } @@ -2724,7 +2724,7 @@ else if ($caneditfield) { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('signature', $object->signature, '', 138, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1, ROWS_4, '90%'); + $doleditor = new DolEditor('signature', $object->signature, '', 138, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%'); print $doleditor->Create(1); } else @@ -2740,7 +2740,7 @@ else // TODO Move this into tab RH (HierarchicalResponsible must be on both tab) // Default warehouse - if (! empty($conf->stock->enabled) && ! empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? + if (!empty($conf->stock->enabled) && !empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? { print ''; - if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) - || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) + || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { $langs->load("salaries"); // THM print ''; print ''; print "\n"; // TJM print ''; print ''; print "\n"; @@ -2799,7 +2799,7 @@ else // Salary print ''; print ''; print "\n"; } @@ -2807,10 +2807,10 @@ else // Weeklyhours print ''; print ''; @@ -2819,10 +2819,10 @@ else // Date employment print ''; print ''; @@ -2831,10 +2831,10 @@ else // Date employmentEnd print ''; print ''; @@ -2844,10 +2844,10 @@ else // Date birth print ''; print ''; @@ -2873,8 +2873,8 @@ else * Documents generes */ $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->user->dir_output . "/" . dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $filedir = $conf->user->dir_output."/".dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $user->rights->user->user->lire; $delallowed = $user->rights->user->user->creer; @@ -2888,7 +2888,7 @@ else print '
    '; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'user', $socid, 1); @@ -2896,11 +2896,11 @@ else print '
    '; } - if (! empty($conf->ldap->enabled) && ! empty($object->ldap_sid)) $ldap->close(); + if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) $ldap->close(); } } -if (! empty($conf->api->enabled) && ! empty($conf->use_javascript_ajax)) +if (!empty($conf->api->enabled) && !empty($conf->use_javascript_ajax)) { print "\n".'
    '.$langs->trans("Ref").''; @@ -2138,7 +2138,7 @@ else // Login print "
    '.$langs->trans("Login").''; - if ($user->admin && !$object->ldap_sid) + if ($user->admin && !$object->ldap_sid) { print ''; } @@ -2153,43 +2153,43 @@ else // Pass print '
    '.$langs->trans("Password").''; - $valuetoshow=''; + $valuetoshow = ''; if (preg_match('/ldap/', $dolibarr_main_authentication)) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("PasswordOfUserInLDAP"); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); } if (preg_match('/http/', $dolibarr_main_authentication)) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$form->textwithpicto($text, $langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1, 'warning'); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$form->textwithpicto($text, $langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1, 'warning'); } if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { if ($caneditpassword) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').''; + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''; } else { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').preg_replace('/./i', '*', $object->pass); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass); } } // Other form for user password - $parameters=array('valuetoshow' => $valuetoshow, 'caneditpassword' => $caneditpassword); - $reshook=$hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) $valuetoshow=$hookmanager->resPrint; // to replace - else $valuetoshow.=$hookmanager->resPrint; // to add + $parameters = array('valuetoshow' => $valuetoshow, 'caneditpassword' => $caneditpassword); + $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook > 0) $valuetoshow = $hookmanager->resPrint; // to replace + else $valuetoshow .= $hookmanager->resPrint; // to add print $valuetoshow; print "
    '.$langs->trans("ApiKey").''; print ''; - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); print '
    '.$langs->trans("Type").''; - if ($user->id == $object->id || ! $user->admin) + if ($user->id == $object->id || !$user->admin) { - $type=$langs->trans("Internal"); - if ($object->socid) $type=$langs->trans("External"); + $type = $langs->trans("Internal"); + if ($object->socid) $type = $langs->trans("External"); print $form->textwithpicto($type, $langs->trans("InternalExternalDesc")); if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; } else { - $type=0; - if ($object->contactid) $type=$object->contactid; + $type = 0; + if ($object->contactid) $type = $object->contactid; print $form->selectcontacts(0, $type, 'contactid', 2, '', '', 1, '', false, 1); if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; } @@ -2299,8 +2299,8 @@ else // Gender print '
    '.$langs->trans("Gender").''; - $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); - print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1); + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); print '
    '.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).''; - print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id), 'country_id'); + print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id), 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
    '.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").''; - if ($caneditfield && empty($object->ldap_sid)) + if ($caneditfield && empty($object->ldap_sid)) { print ''; } @@ -2439,7 +2439,7 @@ else // Fax print "
    '.img_picto('', 'object_phoning_fax').' '.$langs->trans("Fax").''; - if ($caneditfield && empty($object->ldap_sid)) + if ($caneditfield && empty($object->ldap_sid)) { print ''; } @@ -2451,9 +2451,9 @@ else print '
    '; - if ($caneditfield && empty($object->ldap_sid)) + if ($caneditfield && empty($object->ldap_sid)) { print ''; } @@ -2464,12 +2464,12 @@ else } print '
    '.$langs->trans($value['label']).''; - if ($caneditfield && empty($object->ldap_sid)) { + if ($caneditfield && empty($object->ldap_sid)) { print ''; } else { print ''; @@ -2552,7 +2552,7 @@ else // } // OpenID url - if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) + if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) { print "
    '.$langs->trans("OpenIDURL").''; @@ -2590,14 +2590,14 @@ else } // User color - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { print '
    '.$langs->trans("ColorUser").''; if ($caneditfield) { - print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); - }else{ + print $formother->selectColor(GETPOST('color') ?GETPOST('color') : $object->color, 'color', null, 1, '', 'hideifnotset'); + } else { print $formother->showColor($object->color, ''); } print '
    ' . $form->editfieldkey('Categories', 'usercats', '', $object, 0) . '
    '.$form->editfieldkey('Categories', 'usercats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_USER, null, null, null, null, 1); $c = new Categorie($db); @@ -2625,7 +2625,7 @@ else if ($caneditfield) { print $form->multiselectarray('usercats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); - }else{ + } else { print $form->showCategories($object->id, 'user', 1); } print "
    '.$langs->trans("LinkToCompanyContact").''; @@ -2664,16 +2664,16 @@ else } // Module Adherent - if (! empty($conf->adherent->enabled)) + if (!empty($conf->adherent->enabled)) { $langs->load("members"); print '
    '.$langs->trans("LinkedToDolibarrMember").''; if ($object->fk_member) { - $adh=new Adherent($db); + $adh = new Adherent($db); $adh->fetch($object->fk_member); - $adh->ref=$adh->login; // Force to show login instead of id + $adh->ref = $adh->login; // Force to show login instead of id print $adh->getNomUrl(1); } else @@ -2686,15 +2686,15 @@ else // Multicompany // TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !! - if (! empty($conf->multicompany->enabled) && is_object($mc)) + if (!empty($conf->multicompany->enabled) && is_object($mc)) { // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module - if (! method_exists($mc, 'formObjectOptions')) + if (!method_exists($mc, 'formObjectOptions')) { - if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && !$user->entity) { print "
    '.$langs->trans("Entity").'".$mc->select_entities($object->entity, 'entity', '', 0, 1, false, false, 1); // last parameter 1 means, show also a choice 0=>'all entities' + print "".$mc->select_entities($object->entity, 'entity', '', 0, 1, false, false, 1); // last parameter 1 means, show also a choice 0=>'all entities' print "
    '.$langs->trans("DefaultWarehouse").''; print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); @@ -2762,36 +2762,36 @@ else } print '
    '; - $text=$langs->trans("THM"); + $text = $langs->trans("THM"); print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm'); print ''; - if($caneditfield){ - print ''; - }else{ - print ($object->thm!=''?price($object->thm, '', $langs, 1, -1, -1, $conf->currency):''); + if ($caneditfield) { + print ''; + } else { + print ($object->thm != '' ?price($object->thm, '', $langs, 1, -1, -1, $conf->currency) : ''); } print '
    '; - $text=$langs->trans("TJM"); + $text = $langs->trans("TJM"); print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm'); print ''; - if($caneditfield) + if ($caneditfield) { - print ''; - }else{ - print ($object->tjm!=''?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency):''); + print ''; + } else { + print ($object->tjm != '' ?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency) : ''); } print '
    '.$langs->trans("Salary").''; - print ''; + print ''; print '
    '.$langs->trans("WeeklyHours").''; - if($caneditfield) + if ($caneditfield) { - print ''; - }else{ + print ''; + } else { print price2num($object->weeklyhours); } print '
    '.$langs->trans("DateEmployment").''; - if($caneditfield) + if ($caneditfield) { - print $form->selectDate(GETPOST('dateemployment')?GETPOST('dateemployment'):$object->dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 0); - }else{ + print $form->selectDate(GETPOST('dateemployment') ?GETPOST('dateemployment') : $object->dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 0); + } else { print dol_print_date($object->dateemployment, 'day'); } print '
    '.$langs->trans("DateEmploymentEnd").''; - if($caneditfield) + if ($caneditfield) { - print $form->selectDate(GETPOST('dateemploymentend')?GETPOST('dateemploymentend'):$object->dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0); - }else{ + print $form->selectDate(GETPOST('dateemploymentend') ?GETPOST('dateemploymentend') : $object->dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0); + } else { print dol_print_date($object->dateemploymentend, 'day'); } print '
    '.$langs->trans("DateToBirth").''; - if($caneditfield) + if ($caneditfield) { - echo $form->selectDate(GETPOST('birth')?GETPOST('birth'):$object->birth, 'birth', 0, 0, 1, 'updateuser', 1, 0); - }else{ + echo $form->selectDate(GETPOST('birth') ?GETPOST('birth') : $object->birth, 'birth', 0, 0, 1, 'updateuser', 1, 0); + } else { print dol_print_date($object->birth, 'day'); } print '