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
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
$newlang = $_REQUEST['lang_id'];
$lang_id=GETPOST('lang_id');
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($lang_id))
$newlang = $lang_id;
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $customer->default_lang;
if (! empty($newlang)) {

View File

@ -509,6 +509,8 @@ class Account extends CommonObject
{
global $langs,$conf, $hookmanager;
$error=0;
// Clean parameters
if (! $this->min_allowed) $this->min_allowed=0;
if (! $this->min_desired) $this->min_desired=0;
@ -668,7 +670,7 @@ class Account extends CommonObject
* @param int $notrigger 1=Disable triggers
* @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;
@ -1135,6 +1137,8 @@ class Account extends CommonObject
*/
function solde($option=0)
{
$solde=0;
$sql = "SELECT sum(amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."bank";
$sql.= " WHERE fk_account = ".$this->id;
@ -1149,8 +1153,13 @@ class Account extends CommonObject
$solde = $obj->amount;
}
$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_guichet = '456';
$this->number = 'ABC12345';
$this->cle_rib = 50;
$this->cle_rib = '50';
$this->bic = 'AA12';
$this->iban = 'FR999999999';
$this->domiciliation = 'My bank address';
@ -1904,7 +1913,7 @@ class AccountLine extends CommonObject
*/
function update_conciliation(User $user, $cat)
{
global $conf;
global $conf,$langs;
$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 $maxlen Longueur max libelle
* @param string $option Option ('showall')
* @param int $notooltip 1=Disable tooltip
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$maxlen=0,$option='')
function getNomUrl($withpicto=0,$maxlen=0,$option='',$notooltip=0)
{
global $langs;

View File

@ -140,7 +140,7 @@ class Facture extends CommonInvoice
public $situation_counter;
/**
* @var bool Final situation flag
* @var int Final situation flag
*/
public $situation_final;
@ -303,13 +303,13 @@ class Facture extends CommonInvoice
$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
$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_private = GETPOST('note_private','none') ? GETPOST('note_private','none') : $_facrec->note_private;
$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->mode_reglement_id = GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id;
$this->fk_account = GETPOST('fk_account') > 0 ? GETPOST('fk_account') : $_facrec->fk_account;
$this->cond_reglement_id = (int)GETPOST('cond_reglement_id') > 0 ? (int)GETPOST('cond_reglement_id') : $_facrec->cond_reglement_id;
$this->mode_reglement_id = (int)GETPOST('mode_reglement_id') > 0 ? (int)GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id;
$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
$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))
{
$this->fetchObjectLinked('', '', $object->id, 'facture');
$this->fetchObjectLinked('', '', $facture->id, 'facture');
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
* @return int <0 if KO, >0 if OK
*/
function update($user=null, $notrigger=0)
function update(User $user, $notrigger=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->modelpdf)) $this->modelpdf=trim($this->modelpdf);
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
// 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.= " 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=".$this->situation_cycle_ref;
$sql.= ", situation_counter=".$this->situation_counter;
$sql.= ", situation_final=".$this->situation_final;
$sql.= ", situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->situation_cycle_ref);
$sql.= ", situation_counter=".(empty($this->situation_counter)?"null":$this->situation_counter);
$sql.= ", situation_final=".(empty($this->situation_counter)?"0":$this->situation_counter);
$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);
// 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;
@ -2556,7 +2545,7 @@ class Facture extends CommonInvoice
* @param double $pu_ht_devise Unit price in currency
* @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
if ($label) {
@ -3061,7 +3050,7 @@ class Facture extends CommonInvoice
// For triggers
$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)
{
@ -4379,7 +4368,7 @@ class FactureLigne extends CommonInvoiceLine
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 = '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 (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_localtax2);
$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.= ", ".$user->id;
$sql.= ", ".$user->id;

View File

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

View File

@ -899,17 +899,20 @@ class Contrat extends CommonObject
if ($result > 0)
{
$modCodeContract = new $module();
}
if (!empty($modCodeContract->code_auto)) {
// Mise a jour ref
$sql = 'UPDATE '.MAIN_DB_PREFIX."contrat SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
if ($this->db->query($sql))
{
if ($this->id)
if (!empty($modCodeContract->code_auto)) {
// Mise a jour ref
$sql = 'UPDATE '.MAIN_DB_PREFIX."contrat SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
if ($this->db->query($sql))
{
$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)
{
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");
@ -1544,6 +1548,8 @@ class Contrat extends CommonObject
{
global $user, $conf, $langs, $mysoc;
$error=0;
// Clean parameters
$qty=trim($qty);
$desc=trim($desc);

View File

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

View File

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