Merge remote-tracking branch 'upstream/develop' into new_branch_20_09_2018
This commit is contained in:
commit
ef95be1ed7
@ -1184,6 +1184,8 @@ class Thirdparties extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
public function generateBankAccountDocument($id, $companybankid = null, $model = 'sepamandate')
|
public function generateBankAccountDocument($id, $companybankid = null, $model = 'sepamandate')
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$this->langs->load("database");
|
$this->langs->load("database");
|
||||||
$this->langs->load("main");
|
$this->langs->load("main");
|
||||||
$this->langs->load("dict");
|
$this->langs->load("dict");
|
||||||
@ -1199,20 +1201,18 @@ class Thirdparties extends DolibarrApi
|
|||||||
$this->langs->load("withdrawals");
|
$this->langs->load("withdrawals");
|
||||||
|
|
||||||
$this->company->fetch($id);
|
$this->company->fetch($id);
|
||||||
|
|
||||||
$action = 'builddoc';
|
$action = 'builddoc';
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->creer)
|
if(! DolibarrApiAccess::$user->rights->societe->creer)
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
|
|
||||||
// Reload to get all modified line records and be ready for hooks
|
$this->company->setDocModel(DolibarrApiAccess::$user, $model);
|
||||||
|
|
||||||
$this->company->setDocModel($user, $model);
|
|
||||||
|
|
||||||
$this->company->fk_bank = $this->company->fk_account;
|
$this->company->fk_bank = $this->company->fk_account;
|
||||||
|
|
||||||
$outputlangs = $this->langs;
|
$outputlangs = $this->langs;
|
||||||
$newlang='';
|
$newlang='';
|
||||||
|
|
||||||
if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
|
if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
|
||||||
if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang=$this->company->thirdparty->default_lang; // for proposal, order, invoice, ...
|
if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang=$this->company->thirdparty->default_lang; // for proposal, order, invoice, ...
|
||||||
if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang=$this->company->default_lang; // for thirdparty
|
if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang=$this->company->default_lang; // for thirdparty
|
||||||
@ -1220,37 +1220,38 @@ class Thirdparties extends DolibarrApi
|
|||||||
$outputlangs = new Translate("",$conf);
|
$outputlangs = new Translate("",$conf);
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
}
|
}
|
||||||
|
|
||||||
// To be sure vars is defined
|
// To be sure vars is defined
|
||||||
|
$hidedetails = $hidedesc = $hideref = 0;
|
||||||
|
$moreparams=null;
|
||||||
if (empty($hidedetails)) $hidedetails=0;
|
if (empty($hidedetails)) $hidedetails=0;
|
||||||
if (empty($hidedesc)) $hidedesc=0;
|
if (empty($hidedesc)) $hidedesc=0;
|
||||||
if (empty($hideref)) $hideref=0;
|
if (empty($hideref)) $hideref=0;
|
||||||
if (empty($moreparams)) $moreparams=null;
|
if (empty($moreparams)) $moreparams=null;
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT rowid";
|
$sql = "SELECT rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||||
if ($id) $sql.= " WHERE fk_soc = ".$id." ";
|
if ($id) $sql.= " WHERE fk_soc = ".$id." ";
|
||||||
if ($companybankid) $sql.= " AND id = ".$companybankid."";
|
if ($companybankid) $sql.= " AND id = ".$companybankid."";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
|
||||||
|
|
||||||
if($result->num_rows == 0 ){
|
|
||||||
throw new RestException(404, 'Account not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
|
$accounts=array();
|
||||||
$accounts =[];
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
|
if ($result->num_rows == 0) {
|
||||||
|
throw new RestException(404, 'Bank account not found');
|
||||||
|
}
|
||||||
|
|
||||||
$num = $this->db->num_rows($result);
|
$num = $this->db->num_rows($result);
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
|
|
||||||
$account = new CompanyBankAccount($this->db);
|
$account = new CompanyBankAccount($this->db);
|
||||||
if($account->fetchFromApi($obj->rowid)) {
|
if ($account->fetch($obj->rowid)) {
|
||||||
$accounts[] = $account;
|
$accounts[] = $account;
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
@ -1258,19 +1259,18 @@ class Thirdparties extends DolibarrApi
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new RestException(404, 'Account not found');
|
throw new RestException(404, 'Bank account not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$moreparams = array(
|
$moreparams = array(
|
||||||
'use_companybankid'=>$accounts[0]->id,
|
'use_companybankid'=>$accounts[0]->id,
|
||||||
'force_dir_output'=>$this->conf->societe->multidir_output[$this->company->entity].'/'.dol_sanitizeFileName($this->company->id)
|
'force_dir_output'=>$this->conf->societe->multidir_output[$this->company->entity].'/'.dol_sanitizeFileName($this->company->id)
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = 0;
|
$result = 0;
|
||||||
|
|
||||||
$result = $this->company->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
|
$result = $this->company->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
return array("success" => $result);
|
return array("success" => $result);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user