Merge branch '4.0' of git@github.com:Dolibarr/dolibarr.git into 5.0
Conflicts: htdocs/compta/facture/class/facture.class.php htdocs/compta/prelevement/class/bonprelevement.class.php htdocs/filefunc.inc.php
This commit is contained in:
commit
3555bd2bd7
@ -54,7 +54,7 @@ class Facture extends CommonInvoice
|
|||||||
public $fk_element = 'fk_facture';
|
public $fk_element = 'fk_facture';
|
||||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||||
public $picto='bill';
|
public $picto='bill';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -243,7 +243,7 @@ class Facture extends CommonInvoice
|
|||||||
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
|
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
|
||||||
$this->brouillon = 1;
|
$this->brouillon = 1;
|
||||||
if (empty($this->entity)) $this->entity = $conf->entity;
|
if (empty($this->entity)) $this->entity = $conf->entity;
|
||||||
|
|
||||||
// Multicurrency (test on $this->multicurrency_tx because we sould take the default rate only if not using origin rate)
|
// Multicurrency (test on $this->multicurrency_tx because we sould 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);
|
else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
|
||||||
@ -286,7 +286,7 @@ class Facture extends CommonInvoice
|
|||||||
|
|
||||||
$this->socid = $_facrec->socid; // Invoice created on same thirdparty than template
|
$this->socid = $_facrec->socid; // Invoice created on same thirdparty than template
|
||||||
$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 = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project;
|
||||||
$this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public;
|
$this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public;
|
||||||
@ -299,7 +299,7 @@ class Facture extends CommonInvoice
|
|||||||
// 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;
|
||||||
$this->total_ttc = $_facrec->total_ttc;
|
$this->total_ttc = $_facrec->total_ttc;
|
||||||
|
|
||||||
// Fields always coming from template
|
// Fields always coming from template
|
||||||
$this->remise_absolue = $_facrec->remise_absolue;
|
$this->remise_absolue = $_facrec->remise_absolue;
|
||||||
$this->remise_percent = $_facrec->remise_percent;
|
$this->remise_percent = $_facrec->remise_percent;
|
||||||
@ -358,10 +358,10 @@ class Facture extends CommonInvoice
|
|||||||
'__INVOICE_YEAR__' => dol_print_date($this->date, '%Y'),
|
'__INVOICE_YEAR__' => dol_print_date($this->date, '%Y'),
|
||||||
'__INVOICE_NEXT_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'),
|
'__INVOICE_NEXT_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$substitutionisok=true;
|
$substitutionisok=true;
|
||||||
complete_substitutions_array($substitutionarray, $outputlangs);
|
complete_substitutions_array($substitutionarray, $outputlangs);
|
||||||
|
|
||||||
$this->note_public=make_substitutions($this->note_public,$substitutionarray);
|
$this->note_public=make_substitutions($this->note_public,$substitutionarray);
|
||||||
$this->note_private=make_substitutions($this->note_private,$substitutionarray);
|
$this->note_private=make_substitutions($this->note_private,$substitutionarray);
|
||||||
}
|
}
|
||||||
@ -470,7 +470,7 @@ class Facture extends CommonInvoice
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
$originforcontact = $this->origin;
|
||||||
@ -481,7 +481,7 @@ class Facture extends CommonInvoice
|
|||||||
$exp = new Expedition($this->db);
|
$exp = new Expedition($this->db);
|
||||||
$exp->fetch($this->origin_id);
|
$exp->fetch($this->origin_id);
|
||||||
$exp->fetchObjectLinked();
|
$exp->fetchObjectLinked();
|
||||||
if (count($exp->linkedObjectsIds['commande']) > 0)
|
if (count($exp->linkedObjectsIds['commande']) > 0)
|
||||||
{
|
{
|
||||||
foreach ($exp->linkedObjectsIds['commande'] as $key => $value)
|
foreach ($exp->linkedObjectsIds['commande'] as $key => $value)
|
||||||
{
|
{
|
||||||
@ -491,10 +491,10 @@ 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 = "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);
|
$resqlcontact = $this->db->query($sqlcontact);
|
||||||
if ($resqlcontact)
|
if ($resqlcontact)
|
||||||
{
|
{
|
||||||
@ -553,11 +553,11 @@ class Facture extends CommonInvoice
|
|||||||
foreach ($this->lines as $i => $val)
|
foreach ($this->lines as $i => $val)
|
||||||
{
|
{
|
||||||
$line = $this->lines[$i];
|
$line = $this->lines[$i];
|
||||||
|
|
||||||
// Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array
|
// 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=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 (($line->info_bits & 0x01) == 0) // We keep only lines with first bit = 0
|
if (($line->info_bits & 0x01) == 0) // We keep only lines with first bit = 0
|
||||||
{
|
{
|
||||||
// Reset fk_parent_line for no child products and special product
|
// Reset fk_parent_line for no child products and special product
|
||||||
@ -1058,7 +1058,7 @@ class Facture extends CommonInvoice
|
|||||||
if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note
|
if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note
|
||||||
if ($this->type == self::TYPE_DEPOSIT) $picto.='d'; // Deposit invoice
|
if ($this->type == self::TYPE_DEPOSIT) $picto.='d'; // Deposit invoice
|
||||||
$label='';
|
$label='';
|
||||||
|
|
||||||
if ($user->rights->facture->lire) {
|
if ($user->rights->facture->lire) {
|
||||||
$label = '<u>' . $langs->trans("ShowInvoice") . '</u>';
|
$label = '<u>' . $langs->trans("ShowInvoice") . '</u>';
|
||||||
if (! empty($this->ref))
|
if (! empty($this->ref))
|
||||||
@ -1077,7 +1077,7 @@ class Facture extends CommonInvoice
|
|||||||
if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref;
|
if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref;
|
||||||
if ($moretitle) $label.=' - '.$moretitle;
|
if ($moretitle) $label.=' - '.$moretitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
$linkclose='';
|
$linkclose='';
|
||||||
if (empty($notooltip) && $user->rights->facture->lire)
|
if (empty($notooltip) && $user->rights->facture->lire)
|
||||||
{
|
{
|
||||||
@ -1111,7 +1111,7 @@ class Facture extends CommonInvoice
|
|||||||
$result.='</span>';
|
$result.='</span>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1319,7 +1319,7 @@ class Facture extends CommonInvoice
|
|||||||
$line->qty = $objp->qty;
|
$line->qty = $objp->qty;
|
||||||
$line->subprice = $objp->subprice;
|
$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->tva_tx = $objp->tva_tx;
|
||||||
$line->localtax1_tx = $objp->localtax1_tx;
|
$line->localtax1_tx = $objp->localtax1_tx;
|
||||||
$line->localtax2_tx = $objp->localtax2_tx;
|
$line->localtax2_tx = $objp->localtax2_tx;
|
||||||
@ -1572,7 +1572,7 @@ class Facture extends CommonInvoice
|
|||||||
$arraytmp=$formmargin->getMarginInfosArray($srcinvoice, false);
|
$arraytmp=$formmargin->getMarginInfosArray($srcinvoice, false);
|
||||||
$facligne->pa_ht = $arraytmp['pa_total'];
|
$facligne->pa_ht = $arraytmp['pa_total'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$facligne->total_ht = -$remise->amount_ht;
|
$facligne->total_ht = -$remise->amount_ht;
|
||||||
$facligne->total_tva = -$remise->amount_tva;
|
$facligne->total_tva = -$remise->amount_tva;
|
||||||
$facligne->total_ttc = -$remise->amount_ttc;
|
$facligne->total_ttc = -$remise->amount_ttc;
|
||||||
@ -1626,7 +1626,7 @@ class Facture extends CommonInvoice
|
|||||||
function set_ref_client($ref_client, $notrigger=0)
|
function set_ref_client($ref_client, $notrigger=0)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
@ -2455,7 +2455,7 @@ class Facture extends CommonInvoice
|
|||||||
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;
|
||||||
|
|
||||||
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
|
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
|
||||||
|
|
||||||
// Clean vat code
|
// Clean vat code
|
||||||
$vat_src_code='';
|
$vat_src_code='';
|
||||||
if (preg_match('/\((.*)\)/', $txtva, $reg))
|
if (preg_match('/\((.*)\)/', $txtva, $reg))
|
||||||
@ -2463,7 +2463,7 @@ class Facture extends CommonInvoice
|
|||||||
$vat_src_code = $reg[1];
|
$vat_src_code = $reg[1];
|
||||||
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
|
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
|
||||||
}
|
}
|
||||||
|
|
||||||
$remise_percent=price2num($remise_percent);
|
$remise_percent=price2num($remise_percent);
|
||||||
$qty=price2num($qty);
|
$qty=price2num($qty);
|
||||||
$pu_ht=price2num($pu_ht);
|
$pu_ht=price2num($pu_ht);
|
||||||
@ -2648,7 +2648,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, > 0 if OK
|
* @return int < 0 if KO, > 0 if OK
|
||||||
*/
|
*/
|
||||||
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=0, $fk_unit = null, $pu_ht_devise = 0)
|
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)
|
||||||
{
|
{
|
||||||
global $conf,$user;
|
global $conf,$user;
|
||||||
// Deprecation warning
|
// Deprecation warning
|
||||||
@ -2768,14 +2768,14 @@ class Facture extends CommonInvoice
|
|||||||
$this->line->label = $label;
|
$this->line->label = $label;
|
||||||
$this->line->desc = $desc;
|
$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->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->vat_src_code = $vat_src_code;
|
||||||
$this->line->tva_tx = $txtva;
|
$this->line->tva_tx = $txtva;
|
||||||
$this->line->localtax1_tx = $txlocaltax1;
|
$this->line->localtax1_tx = $txlocaltax1;
|
||||||
$this->line->localtax2_tx = $txlocaltax2;
|
$this->line->localtax2_tx = $txlocaltax2;
|
||||||
$this->line->localtax1_type = $localtaxes_type[0];
|
$this->line->localtax1_type = $localtaxes_type[0];
|
||||||
$this->line->localtax2_type = $localtaxes_type[2];
|
$this->line->localtax2_type = $localtaxes_type[2];
|
||||||
|
|
||||||
$this->line->remise_percent = $remise_percent;
|
$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->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_start = $date_start;
|
||||||
@ -2894,7 +2894,7 @@ class Facture extends CommonInvoice
|
|||||||
function deleteline($rowid)
|
function deleteline($rowid)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG);
|
dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG);
|
||||||
|
|
||||||
if (! $this->brouillon)
|
if (! $this->brouillon)
|
||||||
@ -2920,13 +2920,13 @@ class Facture extends CommonInvoice
|
|||||||
}
|
}
|
||||||
|
|
||||||
$line=new FactureLigne($this->db);
|
$line=new FactureLigne($this->db);
|
||||||
|
|
||||||
$line->context = $this->context;
|
$line->context = $this->context;
|
||||||
|
|
||||||
// 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($db, $line->error, $line->errors);
|
||||||
|
|
||||||
if ($line->delete($user) > 0)
|
if ($line->delete($user) > 0)
|
||||||
{
|
{
|
||||||
$result=$this->update_price(1);
|
$result=$this->update_price(1);
|
||||||
@ -4340,7 +4340,7 @@ class FactureLigne extends CommonInvoiceLine
|
|||||||
$this->fk_unit = $objp->fk_unit;
|
$this->fk_unit = $objp->fk_unit;
|
||||||
$this->fk_user_modif = $objp->fk_user_modif;
|
$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->situation_percent = $objp->situation_percent;
|
||||||
$this->fk_prev_id = $objp->fk_prev_id;
|
$this->fk_prev_id = $objp->fk_prev_id;
|
||||||
|
|
||||||
|
|||||||
@ -252,7 +252,7 @@ class BonPrelevement extends CommonObject
|
|||||||
function getErrorString($error)
|
function getErrorString($error)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
||||||
$errors[1027] = $langs->trans("DateInvalid");
|
$errors[1027] = $langs->trans("DateInvalid");
|
||||||
@ -813,7 +813,7 @@ class BonPrelevement extends CommonObject
|
|||||||
dol_syslog(__METHOD__."::Read invoices error ".$this->db->error(), LOG_ERR);
|
dol_syslog(__METHOD__."::Read invoices error ".$this->db->error(), LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
|
||||||
@ -834,7 +834,7 @@ class BonPrelevement extends CommonObject
|
|||||||
{
|
{
|
||||||
$bac = new CompanyBankAccount($this->db);
|
$bac = new CompanyBankAccount($this->db);
|
||||||
$bac->fetch(0,$soc->id);
|
$bac->fetch(0,$soc->id);
|
||||||
|
|
||||||
if ($bac->verif() >= 1)
|
if ($bac->verif() >= 1)
|
||||||
//if (true)
|
//if (true)
|
||||||
{
|
{
|
||||||
@ -867,7 +867,7 @@ class BonPrelevement extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$ok=0;
|
$ok=0;
|
||||||
|
|
||||||
// Withdraw invoices in factures_prev array
|
// Withdraw invoices in factures_prev array
|
||||||
$out=count($factures_prev)." invoices will be withdrawn.";
|
$out=count($factures_prev)." invoices will be withdrawn.";
|
||||||
//print $out."\n";
|
//print $out."\n";
|
||||||
@ -920,7 +920,7 @@ class BonPrelevement extends CommonObject
|
|||||||
|
|
||||||
$dir=$conf->prelevement->dir_output.'/receipts';
|
$dir=$conf->prelevement->dir_output.'/receipts';
|
||||||
if (! is_dir($dir)) dol_mkdir($dir);
|
if (! is_dir($dir)) dol_mkdir($dir);
|
||||||
|
|
||||||
$this->filename = $dir.'/'.$ref.'.xml';
|
$this->filename = $dir.'/'.$ref.'.xml';
|
||||||
|
|
||||||
// Create withdraw receipt in database
|
// Create withdraw receipt in database
|
||||||
@ -1028,7 +1028,7 @@ class BonPrelevement extends CommonObject
|
|||||||
$this->emetteur_bic = $account->bic;
|
$this->emetteur_bic = $account->bic;
|
||||||
|
|
||||||
$this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
|
$this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
|
||||||
|
|
||||||
$this->raison_sociale = $account->proprio;
|
$this->raison_sociale = $account->proprio;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1272,16 +1272,6 @@ class BonPrelevement extends CommonObject
|
|||||||
* section Debiteur (sepa Debiteurs bloc lines)
|
* section Debiteur (sepa Debiteurs bloc lines)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*$tmp_invoices = array();
|
|
||||||
|
|
||||||
$sql = "SELECT f.facnumber as fac FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."prelevement_facture as pf, ".MAIN_DB_PREFIX."societe as soc, ".MAIN_DB_PREFIX."c_country as p, ".MAIN_DB_PREFIX."societe_rib as rib WHERE pl.fk_prelevement_bons = ".$this->id." AND pl.rowid = pf.fk_prelevement_lignes AND pf.fk_facture = f.rowid AND soc.fk_pays = p.rowid AND soc.rowid = f.fk_soc AND rib.fk_soc = f.fk_soc AND rib.default_rib = 1";
|
|
||||||
$resql=$this->db->query($sql);
|
|
||||||
if ($resql) {
|
|
||||||
while ($objfac = $this->db->fetch_object($resql)) {
|
|
||||||
$tmp_invoices[] = $objfac->fac;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
$sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
|
$sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
|
||||||
$sql.= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
|
$sql.= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
|
||||||
$sql.= " f.facnumber as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum";
|
$sql.= " f.facnumber as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum";
|
||||||
@ -1365,35 +1355,6 @@ class BonPrelevement extends CommonObject
|
|||||||
fputs($this->file, ' </PmtInf>'.$CrLf);
|
fputs($this->file, ' </PmtInf>'.$CrLf);
|
||||||
fputs($this->file, ' </CstmrDrctDbtInitn>'.$CrLf);
|
fputs($this->file, ' </CstmrDrctDbtInitn>'.$CrLf);
|
||||||
fputs($this->file, '</Document>'.$CrLf);
|
fputs($this->file, '</Document>'.$CrLf);
|
||||||
|
|
||||||
/*$sql = "SELECT pl.amount";
|
|
||||||
$sql.= " FROM";
|
|
||||||
$sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
|
|
||||||
$sql.= " ".MAIN_DB_PREFIX."facture as f,";
|
|
||||||
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture as pf";
|
|
||||||
$sql.= " WHERE pl.fk_prelevement_bons = ".$this->id;
|
|
||||||
$sql.= " AND pl.rowid = pf.fk_prelevement_lignes";
|
|
||||||
$sql.= " AND pf.fk_facture = f.rowid";
|
|
||||||
|
|
||||||
//Lines
|
|
||||||
$i = 0;
|
|
||||||
$resql=$this->db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$num = $this->db->num_rows($resql);
|
|
||||||
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
|
||||||
$this->total = $this->total + $obj->amount;
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$result = -2;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build file for Other Countries with unknow format
|
// Build file for Other Countries with unknow format
|
||||||
@ -1580,11 +1541,11 @@ class BonPrelevement extends CommonObject
|
|||||||
$XML_DEBITOR .=' </FinInstnId>'.$CrLf;
|
$XML_DEBITOR .=' </FinInstnId>'.$CrLf;
|
||||||
$XML_DEBITOR .=' </DbtrAgt>'.$CrLf;
|
$XML_DEBITOR .=' </DbtrAgt>'.$CrLf;
|
||||||
$XML_DEBITOR .=' <Dbtr>'.$CrLf;
|
$XML_DEBITOR .=' <Dbtr>'.$CrLf;
|
||||||
$XML_DEBITOR .=' <Nm>'.strtoupper(dol_string_unaccent($row_nom)).'</Nm>'.$CrLf;
|
$XML_DEBITOR .=' <Nm>'.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).'</Nm>'.$CrLf;
|
||||||
$XML_DEBITOR .=' <PstlAdr>'.$CrLf;
|
$XML_DEBITOR .=' <PstlAdr>'.$CrLf;
|
||||||
$XML_DEBITOR .=' <Ctry>'.$row_country_code.'</Ctry>'.$CrLf;
|
$XML_DEBITOR .=' <Ctry>'.$row_country_code.'</Ctry>'.$CrLf;
|
||||||
$XML_DEBITOR .=' <AdrLine>'.dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))).'</AdrLine>'.$CrLf;
|
$XML_DEBITOR .=' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))),70,'right','UTF-8',true)).'</AdrLine>'.$CrLf;
|
||||||
$XML_DEBITOR .=' <AdrLine>'.dol_string_unaccent($row_zip.' '.$row_town).'</AdrLine>'.$CrLf;
|
$XML_DEBITOR .=' <AdrLine>'.dolEscapeXML(dol_string_unaccent($row_zip.' '.$row_town)).'</AdrLine>'.$CrLf;
|
||||||
$XML_DEBITOR .=' </PstlAdr>'.$CrLf;
|
$XML_DEBITOR .=' </PstlAdr>'.$CrLf;
|
||||||
$XML_DEBITOR .=' </Dbtr>'.$CrLf;
|
$XML_DEBITOR .=' </Dbtr>'.$CrLf;
|
||||||
$XML_DEBITOR .=' <DbtrAcct>'.$CrLf;
|
$XML_DEBITOR .=' <DbtrAcct>'.$CrLf;
|
||||||
@ -1679,7 +1640,7 @@ class BonPrelevement extends CommonObject
|
|||||||
* @return string String with SEPA Sender
|
* @return string String with SEPA Sender
|
||||||
*/
|
*/
|
||||||
function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n')
|
function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n')
|
||||||
{
|
{
|
||||||
// SEPA INITIALISATION
|
// SEPA INITIALISATION
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@ -1698,12 +1659,12 @@ class BonPrelevement extends CommonObject
|
|||||||
$this->emetteur_number_key = $account->cle_rib;
|
$this->emetteur_number_key = $account->cle_rib;
|
||||||
$this->emetteur_iban = $account->iban;
|
$this->emetteur_iban = $account->iban;
|
||||||
$this->emetteur_bic = $account->bic;
|
$this->emetteur_bic = $account->bic;
|
||||||
|
|
||||||
$this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
|
$this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
|
||||||
|
|
||||||
$this->raison_sociale = $account->proprio;
|
$this->raison_sociale = $account->proprio;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Récupération info demandeur
|
// Récupération info demandeur
|
||||||
$sql = "SELECT rowid, ref";
|
$sql = "SELECT rowid, ref";
|
||||||
$sql.= " FROM";
|
$sql.= " FROM";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user