Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
develop Conflicts: htdocs/fourn/class/fournisseur.commande.class.php
This commit is contained in:
commit
66978a3bb4
@ -306,6 +306,56 @@ class Invoices extends DolibarrApi
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a line of a given invoice
|
||||||
|
*
|
||||||
|
* @param int $id Id of invoice
|
||||||
|
* @param int $lineid Id of the line to delete
|
||||||
|
*
|
||||||
|
* @url DELETE {id}/deleteline/{lineid}
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @throws 304
|
||||||
|
* @throws 400
|
||||||
|
* @throws 401
|
||||||
|
* @throws 404
|
||||||
|
*/
|
||||||
|
function deleteLine($id, $lineid) {
|
||||||
|
|
||||||
|
if(! DolibarrApiAccess::$user->rights->facture->creer) {
|
||||||
|
throw new RestException(401);
|
||||||
|
}
|
||||||
|
if(empty($lineid)) {
|
||||||
|
throw new RestException(400, 'Line ID is mandatory');
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ! DolibarrApi::_checkAccessToResource('facture',$id)) {
|
||||||
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->invoice->fetch($id);
|
||||||
|
if( ! $result ) {
|
||||||
|
throw new RestException(404, 'Invoice not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->invoice->deleteline($lineid);
|
||||||
|
if( $result < 0) {
|
||||||
|
throw new RestException(304);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->invoice->fetch($id);
|
||||||
|
|
||||||
|
$this->invoice->getLinesArray();
|
||||||
|
$result = array();
|
||||||
|
foreach ($this->invoice->lines as $line) {
|
||||||
|
array_push($result,$this->_cleanObjectDatas($line));
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a line to a given invoice
|
* Add a line to a given invoice
|
||||||
*
|
*
|
||||||
@ -314,7 +364,7 @@ class Invoices extends DolibarrApi
|
|||||||
* @param int $id Id of invoice
|
* @param int $id Id of invoice
|
||||||
* @param array $request_data Invoiceline data
|
* @param array $request_data Invoiceline data
|
||||||
*
|
*
|
||||||
* @url POST {id}/lines
|
* @url POST {id}/addline
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -327,7 +327,7 @@ if (empty($reshook))
|
|||||||
$label = $lines[$i]->product_label;
|
$label = $lines[$i]->product_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
$desc .= ($lines[$i]->desc && $lines[$i]->desc!=$lines[$i]->libelle)?dol_htmlentitiesbr($lines[$i]->desc):'';
|
$desc = ($lines[$i]->desc && $lines[$i]->desc!=$lines[$i]->libelle)?dol_htmlentitiesbr($lines[$i]->desc):'';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$desc = dol_htmlentitiesbr($lines[$i]->desc);
|
$desc = dol_htmlentitiesbr($lines[$i]->desc);
|
||||||
@ -440,6 +440,14 @@ if (empty($reshook))
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year'));
|
||||||
|
$date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year'));
|
||||||
|
if (!empty($date_start) && !empty($date_end) && $date_start > $date_end)
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
@ -638,6 +646,15 @@ if (empty($reshook))
|
|||||||
|
|
||||||
else if ($action == 'updateline' && $user->rights->contrat->creer && ! GETPOST('cancel','alpha'))
|
else if ($action == 'updateline' && $user->rights->contrat->creer && ! GETPOST('cancel','alpha'))
|
||||||
{
|
{
|
||||||
|
if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update)
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors');
|
||||||
|
$action = 'editline';
|
||||||
|
$_GET['rowid'] = GETPOST('elrowid');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
$objectline = new ContratLigne($db);
|
$objectline = new ContratLigne($db);
|
||||||
if ($objectline->fetch(GETPOST('elrowid')))
|
if ($objectline->fetch(GETPOST('elrowid')))
|
||||||
{
|
{
|
||||||
@ -722,6 +739,7 @@ if (empty($reshook))
|
|||||||
{
|
{
|
||||||
setEventMessages($objectline->error, $objectline->errors, 'errors');
|
setEventMessages($objectline->error, $objectline->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer)
|
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user