Merge pull request #8326 from atm-florian/dev_fixscrunitiz

fix scrunitizer
This commit is contained in:
Laurent Destailleur 2018-03-10 12:57:51 +01:00 committed by GitHub
commit 96aaeb2fd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 48 deletions

View File

@ -1602,8 +1602,9 @@ class Adherent extends CommonObject
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang = ''; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $lang_id=GETPOST('lang_id');
$newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($lang_id))
$newlang = $lang_id;
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $customer->default_lang; $newlang = $customer->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {

View File

@ -509,6 +509,8 @@ class Account extends CommonObject
{ {
global $langs,$conf, $hookmanager; global $langs,$conf, $hookmanager;
$error=0;
// Clean parameters // Clean parameters
if (! $this->min_allowed) $this->min_allowed=0; if (! $this->min_allowed) $this->min_allowed=0;
if (! $this->min_desired) $this->min_desired=0; if (! $this->min_desired) $this->min_desired=0;
@ -668,7 +670,7 @@ class Account extends CommonObject
* @param int $notrigger 1=Disable triggers * @param int $notrigger 1=Disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update(User $user = null, $notrigger = 0) function update(User $user, $notrigger = 0)
{ {
global $langs,$conf, $hookmanager; global $langs,$conf, $hookmanager;
@ -1135,6 +1137,8 @@ class Account extends CommonObject
*/ */
function solde($option=0) function solde($option=0)
{ {
$solde=0;
$sql = "SELECT sum(amount) as amount"; $sql = "SELECT sum(amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."bank"; $sql.= " FROM ".MAIN_DB_PREFIX."bank";
$sql.= " WHERE fk_account = ".$this->id; $sql.= " WHERE fk_account = ".$this->id;
@ -1149,8 +1153,13 @@ class Account extends CommonObject
$solde = $obj->amount; $solde = $obj->amount;
} }
$this->db->free($resql); $this->db->free($resql);
return $solde; } else {
$this->errors[]=$this->db->lasterror;
return -1;
} }
return $solde;
} }
/** /**
@ -1593,7 +1602,7 @@ class Account extends CommonObject
$this->code_banque = '123'; $this->code_banque = '123';
$this->code_guichet = '456'; $this->code_guichet = '456';
$this->number = 'ABC12345'; $this->number = 'ABC12345';
$this->cle_rib = 50; $this->cle_rib = '50';
$this->bic = 'AA12'; $this->bic = 'AA12';
$this->iban = 'FR999999999'; $this->iban = 'FR999999999';
$this->domiciliation = 'My bank address'; $this->domiciliation = 'My bank address';
@ -1904,7 +1913,7 @@ class AccountLine extends CommonObject
*/ */
function update_conciliation(User $user, $cat) function update_conciliation(User $user, $cat)
{ {
global $conf; global $conf,$langs;
$this->db->begin(); $this->db->begin();
@ -2132,9 +2141,10 @@ class AccountLine extends CommonObject
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param int $maxlen Longueur max libelle * @param int $maxlen Longueur max libelle
* @param string $option Option ('showall') * @param string $option Option ('showall')
* @param int $notooltip 1=Disable tooltip
* @return string Chaine avec URL * @return string Chaine avec URL
*/ */
function getNomUrl($withpicto=0,$maxlen=0,$option='') function getNomUrl($withpicto=0,$maxlen=0,$option='',$notooltip=0)
{ {
global $langs; global $langs;

View File

@ -140,7 +140,7 @@ class Facture extends CommonInvoice
public $situation_counter; public $situation_counter;
/** /**
* @var bool Final situation flag * @var int Final situation flag
*/ */
public $situation_final; public $situation_final;
@ -303,13 +303,13 @@ class Facture extends CommonInvoice
$this->entity = $_facrec->entity; // Invoice created in same entity than template $this->entity = $_facrec->entity; // Invoice created in same entity than template
// Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI
$this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project; $this->fk_project = (int)GETPOST('projectid','int') > 0 ? (int)GETPOST('projectid','int') : $_facrec->fk_project;
$this->note_public = GETPOST('note_public','none') ? GETPOST('note_public','none') : $_facrec->note_public; $this->note_public = GETPOST('note_public','none') ? GETPOST('note_public','none') : $_facrec->note_public;
$this->note_private = GETPOST('note_private','none') ? GETPOST('note_private','none') : $_facrec->note_private; $this->note_private = GETPOST('note_private','none') ? GETPOST('note_private','none') : $_facrec->note_private;
$this->modelpdf = GETPOST('model') ? GETPOST('model') : $_facrec->modelpdf; $this->modelpdf = GETPOST('model') ? GETPOST('model') : $_facrec->modelpdf;
$this->cond_reglement_id = GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $_facrec->cond_reglement_id; $this->cond_reglement_id = (int)GETPOST('cond_reglement_id') > 0 ? (int)GETPOST('cond_reglement_id') : $_facrec->cond_reglement_id;
$this->mode_reglement_id = GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id; $this->mode_reglement_id = (int)GETPOST('mode_reglement_id') > 0 ? (int)GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id;
$this->fk_account = GETPOST('fk_account') > 0 ? GETPOST('fk_account') : $_facrec->fk_account; $this->fk_account = (int)GETPOST('fk_account') > 0 ? (int)GETPOST('fk_account') : $_facrec->fk_account;
// Set here to have this defined for substitution into notes, should be recalculated after adding lines to get same result // Set here to have this defined for substitution into notes, should be recalculated after adding lines to get same result
$this->total_ht = $_facrec->total_ht; $this->total_ht = $_facrec->total_ht;
@ -860,7 +860,7 @@ class Facture extends CommonInvoice
} }
elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION))
{ {
$this->fetchObjectLinked('', '', $object->id, 'facture'); $this->fetchObjectLinked('', '', $facture->id, 'facture');
foreach ($this->linkedObjectsIds as $typeObject => $Tfk_object) foreach ($this->linkedObjectsIds as $typeObject => $Tfk_object)
{ {
@ -1519,7 +1519,7 @@ class Facture extends CommonInvoice
* @param int $notrigger 0=launch triggers after, 1=disable triggers * @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update($user=null, $notrigger=0) function update(User $user, $notrigger=0)
{ {
$error=0; $error=0;
@ -1535,17 +1535,6 @@ class Facture extends CommonInvoice
if (isset($this->note_public)) $this->note_public=trim($this->note_public); if (isset($this->note_public)) $this->note_public=trim($this->note_public);
if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf);
if (isset($this->import_key)) $this->import_key=trim($this->import_key); if (isset($this->import_key)) $this->import_key=trim($this->import_key);
if (empty($this->situation_cycle_ref)) {
$this->situation_cycle_ref = 'null';
}
if (empty($this->situation_counter)) {
$this->situation_counter = 'null';
}
if (empty($this->situation_final)) {
$this->situation_final = '0';
}
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
@ -1585,9 +1574,9 @@ class Facture extends CommonInvoice
$sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"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.= " 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.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null");
$sql.= ", situation_cycle_ref=".$this->situation_cycle_ref; $sql.= ", situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->situation_cycle_ref);
$sql.= ", situation_counter=".$this->situation_counter; $sql.= ", situation_counter=".(empty($this->situation_counter)?"null":$this->situation_counter);
$sql.= ", situation_final=".$this->situation_final; $sql.= ", situation_final=".(empty($this->situation_counter)?"0":$this->situation_counter);
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
@ -1810,9 +1799,9 @@ class Facture extends CommonInvoice
dol_syslog(get_class($this)."::delete rowid=".$rowid.", ref=".$this->ref.", thirdparty=".$this->thirdparty->name, LOG_DEBUG); dol_syslog(get_class($this)."::delete rowid=".$rowid.", ref=".$this->ref.", thirdparty=".$this->thirdparty->name, LOG_DEBUG);
// Test to avoid invoice deletion (allowed if draft) // Test to avoid invoice deletion (allowed if draft)
$test = $this->is_erasable(); $result = $this->is_erasable();
if ($test <= 0) return 0; if ($result <= 0) return 0;
$error=0; $error=0;
@ -2556,7 +2545,7 @@ class Facture extends CommonInvoice
* @param double $pu_ht_devise Unit price in currency * @param double $pu_ht_devise Unit price in currency
* @return int <0 if KO, Id of line if OK * @return int <0 if KO, Id of line if OK
*/ */
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id='', $fk_unit = null, $pu_ht_devise = 0) function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id=0, $fk_unit = null, $pu_ht_devise = 0)
{ {
// Deprecation warning // Deprecation warning
if ($label) { if ($label) {
@ -3061,7 +3050,7 @@ class Facture extends CommonInvoice
// For triggers // For triggers
$result = $line->fetch($rowid); $result = $line->fetch($rowid);
if (! ($result > 0)) dol_print_error($db, $line->error, $line->errors); if (! ($result > 0)) dol_print_error($this->db, $line->error, $line->errors);
if ($line->delete($user) > 0) if ($line->delete($user) > 0)
{ {
@ -4379,7 +4368,7 @@ class FactureLigne extends CommonInvoiceLine
if (empty($this->subprice)) $this->subprice=0; if (empty($this->subprice)) $this->subprice=0;
if (empty($this->special_code)) $this->special_code=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_parent_line)) $this->fk_parent_line=0;
if (empty($this->fk_prev_id)) $this->fk_prev_id = 'null'; 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->pa_ht)) $this->pa_ht=0;
@ -4462,7 +4451,7 @@ class FactureLigne extends CommonInvoiceLine
$sql.= " ".price2num($this->total_localtax1).","; $sql.= " ".price2num($this->total_localtax1).",";
$sql.= " ".price2num($this->total_localtax2); $sql.= " ".price2num($this->total_localtax2);
$sql.= ", " . $this->situation_percent; $sql.= ", " . $this->situation_percent;
$sql.= ", " . $this->fk_prev_id; $sql.= ", " . (!empty($this->fk_prev_id)?$this->fk_prev_id:"null");
$sql.= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); $sql.= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= ", ".$user->id; $sql.= ", ".$user->id;
$sql.= ", ".$user->id; $sql.= ", ".$user->id;

View File

@ -57,7 +57,6 @@ class PaymentTerm // extends CommonObject
function __construct($db) function __construct($db)
{ {
$this->db = $db; $this->db = $db;
return 1;
} }
@ -332,11 +331,11 @@ class PaymentTerm // extends CommonObject
} }
/** /**
* Delete object in database * Delete object in database
* *
* @param User $user User that delete * @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers * @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function delete($user, $notrigger=0) function delete($user, $notrigger=0)

View File

@ -899,17 +899,20 @@ class Contrat extends CommonObject
if ($result > 0) if ($result > 0)
{ {
$modCodeContract = new $module(); $modCodeContract = new $module();
}
if (!empty($modCodeContract->code_auto)) { if (!empty($modCodeContract->code_auto)) {
// Mise a jour ref // Mise a jour ref
$sql = 'UPDATE '.MAIN_DB_PREFIX."contrat SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; $sql = 'UPDATE '.MAIN_DB_PREFIX."contrat SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{
if ($this->id)
{ {
$this->ref="(PROV".$this->id.")"; if ($this->id)
{
$this->ref="(PROV".$this->id.")";
}
} }
} else {
$error++;
$this->error='Failed to get PROV number';
} }
} }
@ -1336,6 +1339,7 @@ class Contrat extends CommonObject
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0, $fk_unit = null, $rang=0) function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0, $fk_unit = null, $rang=0)
{ {
global $user, $langs, $conf, $mysoc; global $user, $langs, $conf, $mysoc;
$error=0;
dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type, $pu_ttc, $info_bits, $rang"); dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type, $pu_ttc, $info_bits, $rang");
@ -1544,6 +1548,8 @@ class Contrat extends CommonObject
{ {
global $user, $conf, $langs, $mysoc; global $user, $conf, $langs, $mysoc;
$error=0;
// Clean parameters // Clean parameters
$qty=trim($qty); $qty=trim($qty);
$desc=trim($desc); $desc=trim($desc);

View File

@ -44,7 +44,6 @@ abstract class CommonDocGenerator
*/ */
public function __construct($db) { public function __construct($db) {
$this->db = $db; $this->db = $db;
return 1;
} }

View File

@ -676,7 +676,7 @@ abstract class CommonInvoiceLine extends CommonObjectLine
{ {
/** /**
* Quantity * Quantity
* @var int * @var double
*/ */
public $qty; public $qty;