Merge branch '7.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
f51d6a2e50
@ -773,7 +773,7 @@ if ($object->id > 0)
|
||||
}
|
||||
|
||||
/*
|
||||
* Last sendings
|
||||
* Last shipments
|
||||
*/
|
||||
if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire) {
|
||||
$sendingstatic = new Expedition($db);
|
||||
|
||||
@ -153,6 +153,7 @@ class Orders extends DolibarrApi
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
$i=0;
|
||||
while ($i < $min)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
@ -276,7 +277,7 @@ class Orders extends DolibarrApi
|
||||
$request_data->product_type,
|
||||
$request_data->rang,
|
||||
$request_data->special_code,
|
||||
$fk_parent_line,
|
||||
$request_data->fk_parent_line,
|
||||
$request_data->fk_fournprice,
|
||||
$request_data->pa_ht,
|
||||
$request_data->label,
|
||||
|
||||
@ -60,30 +60,30 @@ class Invoices extends DolibarrApi
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function get($id)
|
||||
{
|
||||
function get($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->facture->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->invoice->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
$result = $this->invoice->fetch($id);
|
||||
if (! $result) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
|
||||
// Get payment details
|
||||
$this->invoice->totalpaye = $this->invoice->getSommePaiement();
|
||||
$this->invoice->totalcreditnotes = $this->invoice->getSumCreditNotesUsed();
|
||||
$this->invoice->totaldeposits = $this->invoice->getSumDepositsUsed();
|
||||
$this->invoice->resteapayer = price2num($this->invoice->total_ttc - $this->invoice->totalpaye - $this->invoice->totalcreditnotes - $this->invoice->totaldeposits, 'MT');
|
||||
// Get payment details
|
||||
$this->invoice->totalpaye = $this->invoice->getSommePaiement();
|
||||
$this->invoice->totalcreditnotes = $this->invoice->getSumCreditNotesUsed();
|
||||
$this->invoice->totaldeposits = $this->invoice->getSumDepositsUsed();
|
||||
$this->invoice->resteapayer = price2num($this->invoice->total_ttc - $this->invoice->totalpaye - $this->invoice->totalcreditnotes - $this->invoice->totaldeposits, 'MT');
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
|
||||
if (! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$this->invoice->fetchObjectLinked();
|
||||
return $this->_cleanObjectDatas($this->invoice);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List invoices
|
||||
|
||||
@ -1163,9 +1163,9 @@ class Facture extends CommonInvoice
|
||||
$label.= '<br><b>' . $langs->trans('AmountHT') . ':</b> ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
|
||||
if (! empty($this->total_tva))
|
||||
$label.= '<br><b>' . $langs->trans('VAT') . ':</b> ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
|
||||
if (! empty($this->total_tva))
|
||||
if (! empty($this->total_localtax1))
|
||||
$label.= '<br><b>' . $langs->trans('LT1') . ':</b> ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency);
|
||||
if (! empty($this->total_tva))
|
||||
if (! empty($this->total_localtax2))
|
||||
$label.= '<br><b>' . $langs->trans('LT2') . ':</b> ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency);
|
||||
if (! empty($this->total_ttc))
|
||||
$label.= '<br><b>' . $langs->trans('AmountTTC') . ':</b> ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
|
||||
|
||||
@ -78,7 +78,7 @@ abstract class CommonObject
|
||||
*/
|
||||
public $array_options=array();
|
||||
/**
|
||||
* @var int[] Array of linked objects ids. Loaded by ->fetchObjectLinked
|
||||
* @var int[][] Array of linked objects ids. Loaded by ->fetchObjectLinked
|
||||
*/
|
||||
public $linkedObjectsIds;
|
||||
/**
|
||||
@ -4391,7 +4391,7 @@ abstract class CommonObject
|
||||
* @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label(). Deprecated. Function must be called without parameters.
|
||||
* @return int <0 if error, 0 if no values of extrafield to find nor found, 1 if an attribute is found and value loaded
|
||||
*/
|
||||
function fetch_optionals($rowid=null,$optionsArray=null)
|
||||
function fetch_optionals($rowid=null, $optionsArray=null)
|
||||
{
|
||||
if (empty($rowid)) $rowid=$this->id;
|
||||
|
||||
@ -4536,16 +4536,30 @@ abstract class CommonObject
|
||||
|
||||
foreach($new_array_options as $key => $value)
|
||||
{
|
||||
$attributeKey = substr($key,8); // Remove 'options_' prefix
|
||||
$attributeType = $extrafields->attribute_type[$attributeKey];
|
||||
$attributeLabel = $extrafields->attribute_label[$attributeKey];
|
||||
$attributeParam = $extrafields->attribute_param[$attributeKey];
|
||||
$attributeKey = substr($key,8); // Remove 'options_' prefix
|
||||
$attributeType = $extrafields->attribute_type[$attributeKey];
|
||||
$attributeLabel = $extrafields->attribute_label[$attributeKey];
|
||||
$attributeParam = $extrafields->attribute_param[$attributeKey];
|
||||
$attributeRequired = $extrafields->attribute_required[$attributeKey];
|
||||
|
||||
if ($attributeRequired)
|
||||
{
|
||||
$mandatorypb=false;
|
||||
if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb=true;
|
||||
if ($this->array_options[$key] === '') $mandatorypb=true;
|
||||
if ($mandatorypb)
|
||||
{
|
||||
$this->errors[]=$langs->trans('ErrorFieldRequired', $attributeLabel);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($attributeType)
|
||||
{
|
||||
case 'int':
|
||||
if (!is_numeric($value) && $value!='')
|
||||
{
|
||||
$this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel);
|
||||
$this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
|
||||
return -1;
|
||||
}
|
||||
elseif ($value=='')
|
||||
@ -4569,23 +4583,27 @@ abstract class CommonObject
|
||||
$new_array_options[$key] = $this->db->idate($this->array_options[$key]);
|
||||
break;
|
||||
case 'link':
|
||||
$param_list=array_keys($attributeParam ['options']);
|
||||
$param_list=array_keys($attributeParam['options']);
|
||||
// 0 : ObjectName
|
||||
// 1 : classPath
|
||||
$InfoFieldList = explode(":", $param_list[0]);
|
||||
dol_include_once($InfoFieldList[1]);
|
||||
if ($InfoFieldList[0] && class_exists($InfoFieldList[0]))
|
||||
{
|
||||
$object = new $InfoFieldList[0]($this->db);
|
||||
if ($value)
|
||||
if ($value == '-1') // -1 is key for no defined in combo list of objects
|
||||
{
|
||||
$new_array_options[$key]='';
|
||||
}
|
||||
elseif ($value)
|
||||
{
|
||||
$object = new $InfoFieldList[0]($this->db);
|
||||
if (is_numeric($value)) $res=$object->fetch($value);
|
||||
else $res=$object->fetch('',$value);
|
||||
|
||||
if ($res > 0) $new_array_options[$key]=$object->id;
|
||||
else
|
||||
{
|
||||
$this->error="Ref '".$value."' for object '".$object->element."' not found";
|
||||
$this->error="Id/Ref '".$value."' for object '".$object->element."' not found";
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@ -4598,6 +4616,7 @@ abstract class CommonObject
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$table_element = $this->table_element;
|
||||
@ -4730,9 +4749,9 @@ abstract class CommonObject
|
||||
// 1 : classPath
|
||||
$InfoFieldList = explode(":", $param_list[0]);
|
||||
dol_include_once($InfoFieldList[1]);
|
||||
$object = new $InfoFieldList[0]($this->db);
|
||||
if ($value)
|
||||
{
|
||||
$object = new $InfoFieldList[0]($this->db);
|
||||
$object->fetch(0,$value);
|
||||
$this->array_options["options_".$key]=$object->id;
|
||||
}
|
||||
@ -6254,12 +6273,14 @@ abstract class CommonObject
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
|
||||
}
|
||||
|
||||
// Create extrafields
|
||||
if (! $error)
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0) $error++;
|
||||
}
|
||||
|
||||
// Triggers
|
||||
if (! $error && ! $notrigger)
|
||||
{
|
||||
// Call triggers
|
||||
@ -6321,13 +6342,13 @@ abstract class CommonObject
|
||||
/**
|
||||
* Update object into database
|
||||
*
|
||||
* @param User $user User that modifies
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param User $user User that modifies
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function updateCommon(User $user, $notrigger = false)
|
||||
{
|
||||
global $langs;
|
||||
global $conf, $langs;
|
||||
|
||||
$error = 0;
|
||||
|
||||
@ -6375,7 +6396,22 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error && ! $notrigger) {
|
||||
// Update extrafield
|
||||
if (! $error)
|
||||
{
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Triggers
|
||||
if (! $error && ! $notrigger)
|
||||
{
|
||||
// Call triggers
|
||||
$result=$this->call_trigger(strtoupper(get_class($this)).'_MODIFY',$user);
|
||||
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
|
||||
@ -6414,6 +6450,19 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . $this->table_element."_extrafields";
|
||||
$sql.= " WHERE fk_object=" . $this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id;
|
||||
|
||||
@ -1621,8 +1621,8 @@ class ExtraFields
|
||||
{
|
||||
$out='';
|
||||
|
||||
// only if something to display (perf)
|
||||
if ($value)
|
||||
// Only if something to display (perf)
|
||||
if ($value) // If we have -1 here, pb is into sert, not into ouptu
|
||||
{
|
||||
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
|
||||
|
||||
|
||||
@ -550,7 +550,7 @@ function GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NU
|
||||
if (! is_array($out) || empty($out)) $out=array();
|
||||
break;
|
||||
case 'nohtml':
|
||||
$out=dol_string_nohtmltag($out);
|
||||
$out=dol_string_nohtmltag($out, 0);
|
||||
break;
|
||||
case 'alphanohtml': // Recommended for search params
|
||||
if (! is_array($out))
|
||||
|
||||
@ -131,7 +131,7 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][
|
||||
}
|
||||
else
|
||||
{
|
||||
print $extrafields->showOutputField($key, $value);
|
||||
print $extrafields->showOutputField($key, $value, '', (empty($extrafieldsobjectkey)?'':$extrafieldsobjectkey));
|
||||
}
|
||||
print '</td></tr>' . "\n";
|
||||
|
||||
|
||||
@ -131,7 +131,7 @@ if ($nolinesbefore) {
|
||||
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
|
||||
$coldisplay=2;
|
||||
?>
|
||||
<td class="linecolnum" align="center" width="5">
|
||||
<td class="nobottom linecolnum" align="center" width="5">
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
@ -403,9 +403,6 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da
|
||||
{
|
||||
$colspan = 6;
|
||||
|
||||
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
|
||||
$colspan++;
|
||||
}
|
||||
if ($this->situation_cycle_ref) {
|
||||
$colspan++;
|
||||
}
|
||||
@ -447,6 +444,7 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da
|
||||
?>
|
||||
|
||||
<tr id="trlinefordates" <?php echo $bcnd[$var]; ?>>
|
||||
<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print '<td></td>'; } ?>
|
||||
<td colspan="<?php echo $colspan; ?>">
|
||||
<?php
|
||||
$date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
|
||||
|
||||
@ -153,8 +153,8 @@ if (empty($reshook))
|
||||
$object->socid = GETPOST('socid','int');
|
||||
$object->description = GETPOST('description','none'); // Do not use 'alpha' here, we want field as it is
|
||||
$object->public = GETPOST('public','alpha');
|
||||
$object->opp_amount = price2num(GETPOST('opp_amount'));
|
||||
$object->budget_amount = price2num(GETPOST('budget_amount'));
|
||||
$object->opp_amount = price2num(GETPOST('opp_amount','alpha'));
|
||||
$object->budget_amount = price2num(GETPOST('budget_amount','alpha'));
|
||||
$object->datec = dol_now();
|
||||
$object->date_start = $date_start;
|
||||
$object->date_end = $date_end;
|
||||
@ -251,13 +251,14 @@ if (empty($reshook))
|
||||
|
||||
$object->ref = GETPOST('ref','alpha');
|
||||
$object->title = GETPOST('title','none'); // Do not use 'alpha' here, we want field as it is
|
||||
$object->statut = GETPOST('status','int');
|
||||
$object->socid = GETPOST('socid','int');
|
||||
$object->description = GETPOST('description','none'); // Do not use 'alpha' here, we want field as it is
|
||||
$object->public = GETPOST('public','alpha');
|
||||
$object->date_start = empty($_POST["projectstart"])?'':$date_start;
|
||||
$object->date_end = empty($_POST["projectend"])?'':$date_end;
|
||||
if (isset($_POST['opp_amount'])) $object->opp_amount = price2num(GETPOST('opp_amount'));
|
||||
if (isset($_POST['budget_amount'])) $object->budget_amount= price2num(GETPOST('budget_amount'));
|
||||
if (isset($_POST['opp_amount'])) $object->opp_amount = price2num(GETPOST('opp_amount','alpha'));
|
||||
if (isset($_POST['budget_amount'])) $object->budget_amount= price2num(GETPOST('budget_amount','alpha'));
|
||||
if (isset($_POST['opp_status'])) $object->opp_status = $opp_status;
|
||||
if (isset($_POST['opp_percent'])) $object->opp_percent = $opp_percent;
|
||||
|
||||
@ -737,6 +738,16 @@ elseif ($object->id > 0)
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
|
||||
print '<td><input class="quatrevingtpercent" name="title" value="'.$object->title.'"></td></tr>';
|
||||
|
||||
// Status
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td><td>';
|
||||
print '<select class="flat" name="status">';
|
||||
foreach($object->statuts_short as $key => $val)
|
||||
{
|
||||
print '<option value="'.$key.'"'.((GETPOSTISSET('status')?GETPOST('status'):$object->statut) == $key ? ' selected="selected"':'').'>'.$langs->trans($val).'</option>';
|
||||
}
|
||||
print '</select>';
|
||||
print '</td></tr>';
|
||||
|
||||
// Thirdparty
|
||||
if ($conf->societe->enabled)
|
||||
{
|
||||
@ -765,9 +776,6 @@ elseif ($object->id > 0)
|
||||
print $form->selectarray('public',$array,$object->public);
|
||||
print '</td></tr>';
|
||||
|
||||
// Status
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
|
||||
{
|
||||
// Opportunity status
|
||||
@ -1205,7 +1213,7 @@ elseif ($object->id > 0)
|
||||
// List of actions on element
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||
$formactions = new FormActions($db);
|
||||
$somethingshown = $formactions->showactions($object, 'project', $socid, 1, '', $MAXEVENT, '', $morehtmlright);
|
||||
$somethingshown = $formactions->showactions($object, 'project', 0, 1, '', $MAXEVENT, '', $morehtmlright);
|
||||
|
||||
print '</div></div></div>';
|
||||
}
|
||||
|
||||
@ -303,16 +303,9 @@ class Project extends CommonObject
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if (!$notrigger)
|
||||
// Update extrafield
|
||||
if (! $error)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('PROJECT_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
//Update extrafield
|
||||
if (!$error) {
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
@ -323,6 +316,14 @@ class Project extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error && !$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('PROJECT_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref))
|
||||
{
|
||||
// We remove directory
|
||||
@ -508,13 +509,13 @@ class Project extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of elements for type, linked to project
|
||||
* Return list of elements for type, linked to a project
|
||||
*
|
||||
* @param string $type 'propal','order','invoice','order_supplier','invoice_supplier',...
|
||||
* @param string $tablename name of table associated of the type
|
||||
* @param string $datefieldname name of date field for filter
|
||||
* @param string $dates Start date (ex 00:00:00)
|
||||
* @param string $datee End date (ex 23:59:59)
|
||||
* @param int $dates Start date
|
||||
* @param int $datee End date
|
||||
* @return mixed Array list of object ids linked to project, < 0 or string if error
|
||||
*/
|
||||
function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='')
|
||||
@ -523,29 +524,31 @@ class Project extends CommonObject
|
||||
|
||||
if ($this->id <= 0) return $elements;
|
||||
|
||||
$ids = $this->id;
|
||||
|
||||
if ($type == 'agenda')
|
||||
{
|
||||
$sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id;
|
||||
$sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project IN (". $ids .")";
|
||||
}
|
||||
elseif ($type == 'expensereport')
|
||||
{
|
||||
$sql = "SELECT ed.rowid FROM " . MAIN_DB_PREFIX . "expensereport as e, " . MAIN_DB_PREFIX . "expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND ed.fk_projet=" . $this->id;
|
||||
$sql = "SELECT ed.rowid FROM " . MAIN_DB_PREFIX . "expensereport as e, " . MAIN_DB_PREFIX . "expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND ed.fk_projet IN (". $ids .")";
|
||||
}
|
||||
elseif ($type == 'project_task')
|
||||
{
|
||||
$sql = "SELECT DISTINCT pt.rowid FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=" . $this->id;
|
||||
$sql = "SELECT DISTINCT pt.rowid FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet IN (". $ids .")";
|
||||
}
|
||||
elseif ($type == 'project_task_time') // Case we want to duplicate line foreach user
|
||||
{
|
||||
$sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=" . $this->id;
|
||||
$sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet IN (". $ids .")";
|
||||
}
|
||||
elseif ($type == 'stock_mouvement')
|
||||
{
|
||||
$sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM ' . MAIN_DB_PREFIX . 'stock_mouvement as ms WHERE ms.origintype = "project" AND ms.fk_origin = ' . $this->id . ' AND ms.type_mouvement = 1';
|
||||
$sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM ' . MAIN_DB_PREFIX . "stock_mouvement as ms WHERE ms.origintype = 'project' AND ms.fk_origin IN (". $ids .") AND ms.type_mouvement = 1";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id;
|
||||
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet IN (". $ids .")";
|
||||
}
|
||||
|
||||
if ($dates > 0)
|
||||
|
||||
@ -103,9 +103,9 @@ $socid=$object->socid;
|
||||
//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement.
|
||||
$result = restrictedArea($user, 'projet', $projectid, 'projet&project');
|
||||
|
||||
|
||||
$hookmanager->initHooks(array('projectOverview'));
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -470,7 +470,7 @@ $listofreferent=array(
|
||||
);
|
||||
|
||||
$parameters=array('listofreferent'=>$listofreferent);
|
||||
$resHook = $hookmanager->executeHooks('completeListOfReferent',$parameters,$object,$action);
|
||||
$resHook = $hookmanager->executeHooks('completeListOfReferent', $parameters, $object, $action);
|
||||
|
||||
if(!empty($hookmanager->resArray)) {
|
||||
|
||||
|
||||
@ -551,6 +551,139 @@ class Thirdparties extends DolibarrApi
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get outstanding proposals of thirdparty
|
||||
*
|
||||
* @param int $id ID of the thirdparty
|
||||
* @param string $mode 'customer' or 'supplier'
|
||||
*
|
||||
* @url GET {id}/outstandingproposals
|
||||
*
|
||||
* @return array List of outstandings proposals of thirdparty
|
||||
*
|
||||
* @throws 400
|
||||
* @throws 401
|
||||
* @throws 404
|
||||
*/
|
||||
function getOutStandingProposals($id, $mode='customer')
|
||||
{
|
||||
$obj_ret = array();
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
if(empty($id)) {
|
||||
throw new RestException(400, 'Thirdparty ID is mandatory');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe',$id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
$result = $this->company->getOutstandingProposals($mode);
|
||||
|
||||
unset($result['total_ht']);
|
||||
unset($result['total_ttc']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get outstanding orders of thirdparty
|
||||
*
|
||||
* @param int $id ID of the thirdparty
|
||||
* @param string $mode 'customer' or 'supplier'
|
||||
*
|
||||
* @url GET {id}/outstandingorders
|
||||
*
|
||||
* @return array List of outstandings orders of thirdparty
|
||||
*
|
||||
* @throws 400
|
||||
* @throws 401
|
||||
* @throws 404
|
||||
*/
|
||||
function getOutStandingOrder($id, $mode='customer')
|
||||
{
|
||||
$obj_ret = array();
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
if(empty($id)) {
|
||||
throw new RestException(400, 'Thirdparty ID is mandatory');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe',$id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
$result = $this->company->getOutstandingOrders($mode);
|
||||
|
||||
unset($result['total_ht']);
|
||||
unset($result['total_ttc']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get outstanding invoices of thirdparty
|
||||
*
|
||||
* @param int $id ID of the thirdparty
|
||||
* @param string $mode 'customer' or 'supplier'
|
||||
*
|
||||
* @url GET {id}/outstandinginvoices
|
||||
*
|
||||
* @return array List of outstandings invoices of thirdparty
|
||||
*
|
||||
* @throws 400
|
||||
* @throws 401
|
||||
* @throws 404
|
||||
*/
|
||||
function getOutStandingInvoices($id, $mode='customer')
|
||||
{
|
||||
$obj_ret = array();
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
if(empty($id)) {
|
||||
throw new RestException(400, 'Thirdparty ID is mandatory');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe',$id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
$result = $this->company->getOutstandingBills($mode);
|
||||
|
||||
unset($result['total_ht']);
|
||||
unset($result['total_ttc']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get fixed amount discount of a thirdparty (all sources: deposit, credit note, commercial offers...)
|
||||
*
|
||||
|
||||
@ -3466,7 +3466,7 @@ class Societe extends CommonObject
|
||||
$outstandingOpened+=$obj->total_ttc;
|
||||
}
|
||||
}
|
||||
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax);
|
||||
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes'
|
||||
}
|
||||
else
|
||||
return array();
|
||||
@ -3506,7 +3506,7 @@ class Societe extends CommonObject
|
||||
$outstandingOpened+=$obj->total_ttc;
|
||||
}
|
||||
}
|
||||
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax);
|
||||
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes'
|
||||
}
|
||||
else
|
||||
return array();
|
||||
@ -3577,7 +3577,7 @@ class Societe extends CommonObject
|
||||
$outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits;
|
||||
}
|
||||
}
|
||||
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax);
|
||||
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes'
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -998,16 +998,7 @@ while ($i < min($num, $limit))
|
||||
$savalias = $obj->name_alias;
|
||||
if (! empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias='';
|
||||
print '<td class="tdoverflowmax200">';
|
||||
//if (! empty($arrayfields['s.name_alias']['checked'])) // Hide alias from output
|
||||
//{
|
||||
$savalias=$companystatic->name_alias;
|
||||
$companystatic->name_alias='';
|
||||
//}
|
||||
print $companystatic->getNomUrl(1,'',100);
|
||||
//if (! empty($arrayfields['s.name_alias']['checked'])) // Hide alias from output
|
||||
//{
|
||||
$companystatic->name_alias=$savalias;
|
||||
//}
|
||||
print "</td>\n";
|
||||
$companystatic->name_alias = $savalias;
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user