Merge #8008 manually

This commit is contained in:
Laurent Destailleur 2018-01-04 21:14:45 +01:00
parent 6b8c7239cd
commit 24dc144cc4
3 changed files with 53 additions and 9 deletions

View File

@ -196,6 +196,20 @@ class Documents extends DolibarrApi
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
{
throw new RestException(403, 'Generation not available for this modulepart');

View File

@ -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
*
@ -538,7 +569,7 @@ class Proposals extends DolibarrApi
* {
* "notrigger": 0
* }
*
*
* @param int $id Commercial proposal ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
*
@ -548,13 +579,13 @@ class Proposals extends DolibarrApi
* @throws 401
* @throws 404
* @throws 500
*
*
* @return array
*/
function validate($id, $notrigger=0)
{
var_dump($notrigger);exit;
if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
@ -656,7 +687,7 @@ class Proposals extends DolibarrApi
if ($result < 0) {
throw new RestException(500, 'Error : '.$this->propal->error);
}
return array(
'success' => array(
'code' => 200,
@ -664,8 +695,8 @@ class Proposals extends DolibarrApi
)
);
}
/**
* Validate fields before create or update object
*

View File

@ -573,9 +573,8 @@ class Orders extends DolibarrApi
return $result;
}
/**
* Classify the order as invoiced
* Classify the order as invoiced. Could be also called setbilled
*
* @param int $id Id of the order
*
@ -605,7 +604,7 @@ class Orders extends DolibarrApi
if( $result < 0) {
throw new RestException(400, $this->commande->error);
}
return $result;
}