Merge branch '7.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2018-02-02 10:07:16 +01:00
commit f51d6a2e50
15 changed files with 265 additions and 82 deletions

View File

@ -773,7 +773,7 @@ if ($object->id > 0)
} }
/* /*
* Last sendings * Last shipments
*/ */
if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire) { if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire) {
$sendingstatic = new Expedition($db); $sendingstatic = new Expedition($db);

View File

@ -153,6 +153,7 @@ class Orders extends DolibarrApi
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit)); $min = min($num, ($limit <= 0 ? $num : $limit));
$i=0;
while ($i < $min) while ($i < $min)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
@ -276,7 +277,7 @@ class Orders extends DolibarrApi
$request_data->product_type, $request_data->product_type,
$request_data->rang, $request_data->rang,
$request_data->special_code, $request_data->special_code,
$fk_parent_line, $request_data->fk_parent_line,
$request_data->fk_fournprice, $request_data->fk_fournprice,
$request_data->pa_ht, $request_data->pa_ht,
$request_data->label, $request_data->label,

View File

@ -67,7 +67,7 @@ class Invoices extends DolibarrApi
} }
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id);
if( ! $result ) { if (! $result) {
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
} }
@ -77,7 +77,7 @@ class Invoices extends DolibarrApi
$this->invoice->totaldeposits = $this->invoice->getSumDepositsUsed(); $this->invoice->totaldeposits = $this->invoice->getSumDepositsUsed();
$this->invoice->resteapayer = price2num($this->invoice->total_ttc - $this->invoice->totalpaye - $this->invoice->totalcreditnotes - $this->invoice->totaldeposits, 'MT'); $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); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }

View File

@ -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); $label.= '<br><b>' . $langs->trans('AmountHT') . ':</b> ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
if (! empty($this->total_tva)) if (! empty($this->total_tva))
$label.= '<br><b>' . $langs->trans('VAT') . ':</b> ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); $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); $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); $label.= '<br><b>' . $langs->trans('LT2') . ':</b> ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency);
if (! empty($this->total_ttc)) if (! empty($this->total_ttc))
$label.= '<br><b>' . $langs->trans('AmountTTC') . ':</b> ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); $label.= '<br><b>' . $langs->trans('AmountTTC') . ':</b> ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);

View File

@ -78,7 +78,7 @@ abstract class CommonObject
*/ */
public $array_options=array(); 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; 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. * @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 * @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; if (empty($rowid)) $rowid=$this->id;
@ -4540,12 +4540,26 @@ abstract class CommonObject
$attributeType = $extrafields->attribute_type[$attributeKey]; $attributeType = $extrafields->attribute_type[$attributeKey];
$attributeLabel = $extrafields->attribute_label[$attributeKey]; $attributeLabel = $extrafields->attribute_label[$attributeKey];
$attributeParam = $extrafields->attribute_param[$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) switch ($attributeType)
{ {
case 'int': case 'int':
if (!is_numeric($value) && $value!='') if (!is_numeric($value) && $value!='')
{ {
$this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel); $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
return -1; return -1;
} }
elseif ($value=='') elseif ($value=='')
@ -4569,23 +4583,27 @@ abstract class CommonObject
$new_array_options[$key] = $this->db->idate($this->array_options[$key]); $new_array_options[$key] = $this->db->idate($this->array_options[$key]);
break; break;
case 'link': case 'link':
$param_list=array_keys($attributeParam ['options']); $param_list=array_keys($attributeParam['options']);
// 0 : ObjectName // 0 : ObjectName
// 1 : classPath // 1 : classPath
$InfoFieldList = explode(":", $param_list[0]); $InfoFieldList = explode(":", $param_list[0]);
dol_include_once($InfoFieldList[1]); dol_include_once($InfoFieldList[1]);
if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) if ($InfoFieldList[0] && class_exists($InfoFieldList[0]))
{ {
$object = new $InfoFieldList[0]($this->db); if ($value == '-1') // -1 is key for no defined in combo list of objects
if ($value)
{ {
$new_array_options[$key]='';
}
elseif ($value)
{
$object = new $InfoFieldList[0]($this->db);
if (is_numeric($value)) $res=$object->fetch($value); if (is_numeric($value)) $res=$object->fetch($value);
else $res=$object->fetch('',$value); else $res=$object->fetch('',$value);
if ($res > 0) $new_array_options[$key]=$object->id; if ($res > 0) $new_array_options[$key]=$object->id;
else 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(); $this->db->rollback();
return -1; return -1;
} }
@ -4598,6 +4616,7 @@ abstract class CommonObject
break; break;
} }
} }
$this->db->begin(); $this->db->begin();
$table_element = $this->table_element; $table_element = $this->table_element;
@ -4730,9 +4749,9 @@ abstract class CommonObject
// 1 : classPath // 1 : classPath
$InfoFieldList = explode(":", $param_list[0]); $InfoFieldList = explode(":", $param_list[0]);
dol_include_once($InfoFieldList[1]); dol_include_once($InfoFieldList[1]);
$object = new $InfoFieldList[0]($this->db);
if ($value) if ($value)
{ {
$object = new $InfoFieldList[0]($this->db);
$object->fetch(0,$value); $object->fetch(0,$value);
$this->array_options["options_".$key]=$object->id; $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); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
} }
// Create extrafields
if (! $error) if (! $error)
{ {
$result=$this->insertExtraFields(); $result=$this->insertExtraFields();
if ($result < 0) $error++; if ($result < 0) $error++;
} }
// Triggers
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {
// Call triggers // Call triggers
@ -6327,7 +6348,7 @@ abstract class CommonObject
*/ */
public function updateCommon(User $user, $notrigger = false) public function updateCommon(User $user, $notrigger = false)
{ {
global $langs; global $conf, $langs;
$error = 0; $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 // Call triggers
$result=$this->call_trigger(strtoupper(get_class($this)).'_MODIFY',$user); $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 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) if (! $error)
{ {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id;

View File

@ -1621,8 +1621,8 @@ class ExtraFields
{ {
$out=''; $out='';
// only if something to display (perf) // Only if something to display (perf)
if ($value) if ($value) // If we have -1 here, pb is into sert, not into ouptu
{ {
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'

View File

@ -550,7 +550,7 @@ function GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NU
if (! is_array($out) || empty($out)) $out=array(); if (! is_array($out) || empty($out)) $out=array();
break; break;
case 'nohtml': case 'nohtml':
$out=dol_string_nohtmltag($out); $out=dol_string_nohtmltag($out, 0);
break; break;
case 'alphanohtml': // Recommended for search params case 'alphanohtml': // Recommended for search params
if (! is_array($out)) if (! is_array($out))

View File

@ -131,7 +131,7 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][
} }
else else
{ {
print $extrafields->showOutputField($key, $value); print $extrafields->showOutputField($key, $value, '', (empty($extrafieldsobjectkey)?'':$extrafieldsobjectkey));
} }
print '</td></tr>' . "\n"; print '</td></tr>' . "\n";

View File

@ -131,7 +131,7 @@ if ($nolinesbefore) {
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$coldisplay=2; $coldisplay=2;
?> ?>
<td class="linecolnum" align="center" width="5"> <td class="nobottom linecolnum" align="center" width="5">
<?php <?php
} }
else { else {
@ -403,9 +403,6 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da
{ {
$colspan = 6; $colspan = 6;
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$colspan++;
}
if ($this->situation_cycle_ref) { if ($this->situation_cycle_ref) {
$colspan++; $colspan++;
} }
@ -447,6 +444,7 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da
?> ?>
<tr id="trlinefordates" <?php echo $bcnd[$var]; ?>> <tr id="trlinefordates" <?php echo $bcnd[$var]; ?>>
<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print '<td></td>'; } ?>
<td colspan="<?php echo $colspan; ?>"> <td colspan="<?php echo $colspan; ?>">
<?php <?php
$date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));

View File

@ -153,8 +153,8 @@ if (empty($reshook))
$object->socid = GETPOST('socid','int'); $object->socid = GETPOST('socid','int');
$object->description = GETPOST('description','none'); // Do not use 'alpha' here, we want field as it is $object->description = GETPOST('description','none'); // Do not use 'alpha' here, we want field as it is
$object->public = GETPOST('public','alpha'); $object->public = GETPOST('public','alpha');
$object->opp_amount = price2num(GETPOST('opp_amount')); $object->opp_amount = price2num(GETPOST('opp_amount','alpha'));
$object->budget_amount = price2num(GETPOST('budget_amount')); $object->budget_amount = price2num(GETPOST('budget_amount','alpha'));
$object->datec = dol_now(); $object->datec = dol_now();
$object->date_start = $date_start; $object->date_start = $date_start;
$object->date_end = $date_end; $object->date_end = $date_end;
@ -251,13 +251,14 @@ if (empty($reshook))
$object->ref = GETPOST('ref','alpha'); $object->ref = GETPOST('ref','alpha');
$object->title = GETPOST('title','none'); // Do not use 'alpha' here, we want field as it is $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->socid = GETPOST('socid','int');
$object->description = GETPOST('description','none'); // Do not use 'alpha' here, we want field as it is $object->description = GETPOST('description','none'); // Do not use 'alpha' here, we want field as it is
$object->public = GETPOST('public','alpha'); $object->public = GETPOST('public','alpha');
$object->date_start = empty($_POST["projectstart"])?'':$date_start; $object->date_start = empty($_POST["projectstart"])?'':$date_start;
$object->date_end = empty($_POST["projectend"])?'':$date_end; $object->date_end = empty($_POST["projectend"])?'':$date_end;
if (isset($_POST['opp_amount'])) $object->opp_amount = price2num(GETPOST('opp_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')); 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_status'])) $object->opp_status = $opp_status;
if (isset($_POST['opp_percent'])) $object->opp_percent = $opp_percent; 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 '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
print '<td><input class="quatrevingtpercent" name="title" value="'.$object->title.'"></td></tr>'; 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 // Thirdparty
if ($conf->societe->enabled) if ($conf->societe->enabled)
{ {
@ -765,9 +776,6 @@ elseif ($object->id > 0)
print $form->selectarray('public',$array,$object->public); print $form->selectarray('public',$array,$object->public);
print '</td></tr>'; print '</td></tr>';
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{ {
// Opportunity status // Opportunity status
@ -1205,7 +1213,7 @@ elseif ($object->id > 0)
// List of actions on element // List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db); $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>'; print '</div></div></div>';
} }

View File

@ -303,16 +303,9 @@ class Project extends CommonObject
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) 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 if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
$result=$this->insertExtraFields(); $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)) if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref))
{ {
// We remove directory // 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 $type 'propal','order','invoice','order_supplier','invoice_supplier',...
* @param string $tablename name of table associated of the type * @param string $tablename name of table associated of the type
* @param string $datefieldname name of date field for filter * @param string $datefieldname name of date field for filter
* @param string $dates Start date (ex 00:00:00) * @param int $dates Start date
* @param string $datee End date (ex 23:59:59) * @param int $datee End date
* @return mixed Array list of object ids linked to project, < 0 or string if error * @return mixed Array list of object ids linked to project, < 0 or string if error
*/ */
function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='') function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='')
@ -523,29 +524,31 @@ class Project extends CommonObject
if ($this->id <= 0) return $elements; if ($this->id <= 0) return $elements;
$ids = $this->id;
if ($type == 'agenda') 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') 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') 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 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') 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 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) if ($dates > 0)

View File

@ -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. //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'); $result = restrictedArea($user, 'projet', $projectid, 'projet&project');
$hookmanager->initHooks(array('projectOverview')); $hookmanager->initHooks(array('projectOverview'));
/* /*
* View * View
*/ */
@ -470,7 +470,7 @@ $listofreferent=array(
); );
$parameters=array('listofreferent'=>$listofreferent); $parameters=array('listofreferent'=>$listofreferent);
$resHook = $hookmanager->executeHooks('completeListOfReferent',$parameters,$object,$action); $resHook = $hookmanager->executeHooks('completeListOfReferent', $parameters, $object, $action);
if(!empty($hookmanager->resArray)) { if(!empty($hookmanager->resArray)) {

View File

@ -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...) * Get fixed amount discount of a thirdparty (all sources: deposit, credit note, commercial offers...)
* *

View File

@ -3466,7 +3466,7 @@ class Societe extends CommonObject
$outstandingOpened+=$obj->total_ttc; $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 else
return array(); return array();
@ -3506,7 +3506,7 @@ class Societe extends CommonObject
$outstandingOpened+=$obj->total_ttc; $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 else
return array(); return array();
@ -3577,7 +3577,7 @@ class Societe extends CommonObject
$outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; $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 else
{ {

View File

@ -998,16 +998,7 @@ while ($i < min($num, $limit))
$savalias = $obj->name_alias; $savalias = $obj->name_alias;
if (! empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias=''; if (! empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias='';
print '<td class="tdoverflowmax200">'; 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); print $companystatic->getNomUrl(1,'',100);
//if (! empty($arrayfields['s.name_alias']['checked'])) // Hide alias from output
//{
$companystatic->name_alias=$savalias;
//}
print "</td>\n"; print "</td>\n";
$companystatic->name_alias = $savalias; $companystatic->name_alias = $savalias;
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;