Merge #8008 manually
This commit is contained in:
parent
6b8c7239cd
commit
f19fb90ab0
@ -196,6 +196,20 @@ class Documents extends DolibarrApi
|
|||||||
throw new RestException(500, 'Error generating document');
|
throw new RestException(500, 'Error generating document');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elseif ($module_part == 'propal' || $module_part == 'proposal')
|
||||||
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||||
|
$this->propal = new Propal($this->db);
|
||||||
|
$result = $this->propal->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
|
||||||
|
if( ! $result ) {
|
||||||
|
throw new RestException(404, 'Proposal not found');
|
||||||
|
}
|
||||||
|
$templateused = $doctemplate?$doctemplate:$this->propal->modelpdf;
|
||||||
|
$result = $this->propal->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
|
if( $result <= 0 ) {
|
||||||
|
throw new RestException(500, 'Error generating document');
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new RestException(403, 'Generation not available for this modulepart');
|
throw new RestException(403, 'Generation not available for this modulepart');
|
||||||
|
|||||||
@ -531,6 +531,37 @@ class Proposals extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a commercial proposal billed. Could be also called setbilled
|
||||||
|
*
|
||||||
|
* @param int $id Commercial proposal ID
|
||||||
|
*
|
||||||
|
* @url POST {id}/setbilled
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function setinvoiced($id)
|
||||||
|
{
|
||||||
|
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||||
|
throw new RestException(401);
|
||||||
|
}
|
||||||
|
$result = $this->propal->fetch($id);
|
||||||
|
if( ! $result ) {
|
||||||
|
throw new RestException(404, 'Commercial Proposal not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
|
||||||
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->propal->classifyBilled(DolibarrApiAccess::$user);
|
||||||
|
if( $result < 0) {
|
||||||
|
throw new RestException(400, $this->propal->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate a commercial proposal
|
* Validate a commercial proposal
|
||||||
*
|
*
|
||||||
@ -538,7 +569,7 @@ class Proposals extends DolibarrApi
|
|||||||
* {
|
* {
|
||||||
* "notrigger": 0
|
* "notrigger": 0
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* @param int $id Commercial proposal ID
|
* @param int $id Commercial proposal ID
|
||||||
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
||||||
*
|
*
|
||||||
@ -548,13 +579,13 @@ class Proposals extends DolibarrApi
|
|||||||
* @throws 401
|
* @throws 401
|
||||||
* @throws 404
|
* @throws 404
|
||||||
* @throws 500
|
* @throws 500
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function validate($id, $notrigger=0)
|
function validate($id, $notrigger=0)
|
||||||
{
|
{
|
||||||
var_dump($notrigger);exit;
|
var_dump($notrigger);exit;
|
||||||
|
|
||||||
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
@ -656,7 +687,7 @@ class Proposals extends DolibarrApi
|
|||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
throw new RestException(500, 'Error : '.$this->propal->error);
|
throw new RestException(500, 'Error : '.$this->propal->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'success' => array(
|
'success' => array(
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
@ -664,8 +695,8 @@ class Proposals extends DolibarrApi
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate fields before create or update object
|
* Validate fields before create or update object
|
||||||
*
|
*
|
||||||
|
|||||||
@ -573,9 +573,8 @@ class Orders extends DolibarrApi
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classify the order as invoiced
|
* Classify the order as invoiced. Could be also called setbilled
|
||||||
*
|
*
|
||||||
* @param int $id Id of the order
|
* @param int $id Id of the order
|
||||||
*
|
*
|
||||||
@ -605,7 +604,7 @@ class Orders extends DolibarrApi
|
|||||||
if( $result < 0) {
|
if( $result < 0) {
|
||||||
throw new RestException(400, $this->commande->error);
|
throw new RestException(400, $this->commande->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -147,7 +147,8 @@ class Invoices extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql.= $db->order($sortfield, $sortorder);
|
$sql.= $db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit)
|
||||||
|
{
|
||||||
if ($page < 0)
|
if ($page < 0)
|
||||||
{
|
{
|
||||||
$page = 0;
|
$page = 0;
|
||||||
@ -167,8 +168,15 @@ class Invoices extends DolibarrApi
|
|||||||
{
|
{
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
$invoice_static = new Facture($db);
|
$invoice_static = new Facture($db);
|
||||||
if($invoice_static->fetch($obj->rowid)) {
|
if ($invoice_static->fetch($obj->rowid))
|
||||||
$obj_ret[] = $this->_cleanObjectDatas($invoice_static);
|
{
|
||||||
|
// Get payment details
|
||||||
|
$invoice_static->totalpaid = $invoice_static->getSommePaiement();
|
||||||
|
$invoice_static->totalcreditnotes = $invoice_static->getSumCreditNotesUsed();
|
||||||
|
$invoice_static->totaldeposits = $invoice_static->getSumDepositsUsed();
|
||||||
|
$invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT');
|
||||||
|
|
||||||
|
$obj_ret[] = $this->_cleanObjectDatas($invoice_static);
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -752,7 +760,7 @@ class Invoices extends DolibarrApi
|
|||||||
|
|
||||||
return $this->_cleanObjectDatas($this->invoice);
|
return $this->_cleanObjectDatas($this->invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a discount line into an invoice (as an invoice line) using an existing absolute discount
|
* Add a discount line into an invoice (as an invoice line) using an existing absolute discount
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user