code syntax fichinter directory

This commit is contained in:
Frédéric FRANCE 2021-02-25 23:00:32 +01:00
parent f7c119e48c
commit fb07484d3f
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
16 changed files with 1138 additions and 1038 deletions

View File

@ -39,13 +39,17 @@ $form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'fichinter'; //Must be the $element of the class that manage extrafield
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
/*
@ -77,8 +81,7 @@ print dol_get_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit')
/* */
/* ************************************************************************** */
if ($action == 'create')
{
if ($action == 'create') {
print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
@ -104,8 +106,7 @@ if ($action == 'create')
/* Edition of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'edit' && !empty($attrname))
{
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -39,13 +39,17 @@ $form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'fichinterdet'; //Must be the $element of the class that manage extrafield
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
/*
@ -78,8 +82,7 @@ print dol_get_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
@ -92,8 +95,7 @@ if ($action != 'create' && $action != 'edit')
/* */
/* ************************************************************************** */
if ($action == 'create')
{
if ($action == 'create') {
print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
@ -105,8 +107,7 @@ if ($action == 'create')
/* Edition d'un champ optionnel */
/* */
/* ************************************************************************** */
if ($action == 'edit' && !empty($attrname))
{
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -52,22 +52,29 @@ $langs->loadLangs(array("interventions", "admin", "compta", "bills"));
// Security check
$id = (GETPOST('fichinterid', 'int') ?GETPOST('fichinterid', 'int') : GETPOST('id', 'int'));
$action = GETPOST('action', 'aZ09');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$objecttype = 'fichinter_rec';
if ($action == "create" || $action == "add") $objecttype = '';
if ($action == "create" || $action == "add") {
$objecttype = '';
}
$result = restrictedArea($user, 'ficheinter', $id, $objecttype);
if ($page == -1)
if ($page == -1) {
$page = 0;
}
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
if ($sortorder == "")
if ($sortorder == "") {
$sortorder = "DESC";
}
if ($sortfield == "")
if ($sortfield == "") {
$sortfield = "f.datec";
}
$object = new FichinterRec($db);
$extrafields = new ExtraFields($db);
@ -212,7 +219,9 @@ if ($action == 'add') {
// Set next date of execution
$object->fetch($id);
$date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear'));
if (!empty($date)) $object->setNextDate($date);
if (!empty($date)) {
$object->setNextDate($date);
}
} elseif ($action == 'setnb_gen_max' && $user->rights->ficheinter->creer) {
// Set max period
$object->fetch($id);
@ -261,8 +270,12 @@ if ($action == 'create') {
print dol_get_fiche_head();
$rowspan = 4;
if (!empty($conf->projet->enabled) && $object->fk_project > 0) $rowspan++;
if (!empty($conf->contrat->enabled) && $object->fk_contrat > 0) $rowspan++;
if (!empty($conf->projet->enabled) && $object->fk_project > 0) {
$rowspan++;
}
if (!empty($conf->contrat->enabled) && $object->fk_contrat > 0) {
$rowspan++;
}
print '<table class="border centpercent">';
@ -595,9 +608,11 @@ if ($action == 'create') {
print '<td class="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>';
} else {
if ($object->frequency > 0)
if ($object->frequency > 0) {
print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
else print $langs->trans("NotARecurringInterventionalTemplate");
} else {
print $langs->trans("NotARecurringInterventionalTemplate");
}
}
print '</td></tr>';
@ -619,12 +634,16 @@ if ($action == 'create') {
print '<tr><td>';
if ($user->rights->ficheinter->creer && ($action == 'nb_gen_max' || $object->frequency > 0)) {
print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer);
} else print $langs->trans("MaxPeriodNumber");
} else {
print $langs->trans("MaxPeriodNumber");
}
print '</td><td>';
if ($action == 'nb_gen_max' || $object->frequency > 0) {
print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max : '', $object, $user->rights->facture->creer);
} else print '';
} else {
print '';
}
print '</td>';
print '</tr>';
@ -688,13 +707,19 @@ if ($action == 'create') {
$i = 0;
while ($i < $num) {
// Show product and description
if (isset($object->lines[$i]->product_type))
if (isset($object->lines[$i]->product_type)) {
$type = $object->lines[$i]->product_type;
else $object->lines[$i]->fk_product_type;
} else {
$object->lines[$i]->fk_product_type;
}
// Try to enhance type detection using date_start and date_end for free lines when type
// was not saved.
if (!empty($objp->date_start)) $type = 1;
if (!empty($objp->date_end)) $type = 1;
if (!empty($objp->date_start)) {
$type = 1;
}
if (!empty($objp->date_end)) {
$type = 1;
}
// Show line
print '<tr class="oddeven">';
@ -727,7 +752,9 @@ if ($action == 'create') {
print $langs->trans('Delete').'</a></div>';
}
print '</div>';
} else print $langs->trans("ErrorRecordNotFound");
} else {
print $langs->trans("ErrorRecordNotFound");
}
} else {
/*
* List mode
@ -743,14 +770,24 @@ if ($action == 'create') {
}
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.entity = ".$conf->entity;
if ($socid) $sql .= " AND s.rowid = ".$socid;
if ($socid) {
$sql .= " AND s.rowid = ".$socid;
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($search_ref) $sql .= natural_search('f.titre', $search_ref);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_frequency == '1') $sql .= ' AND f.frequency > 0';
if ($search_frequency == '0') $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
if ($search_ref) {
$sql .= natural_search('f.titre', $search_ref);
}
if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe);
}
if ($search_frequency == '1') {
$sql .= ' AND f.frequency > 0';
}
if ($search_frequency == '0') {
$sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
}
//$sql .= " ORDER BY $sortfield $sortorder, rowid DESC ";
@ -855,8 +892,12 @@ if ($action == 'create') {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=createfrommodel';
print '&socid='.$objp->socid.'&id='.$objp->fich_rec.'">';
print $langs->trans("CreateFichInter").'</a>';
} else print $langs->trans("DateIsNotEnough");
} else print "&nbsp;";
} else {
print $langs->trans("DateIsNotEnough");
}
} else {
print "&nbsp;";
}
print "</td>";

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@ class Interventions extends DolibarrApi
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
public static $FIELDS = array(
'socid',
'fk_project',
'description',
@ -41,7 +41,7 @@ class Interventions extends DolibarrApi
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDSLINE = array(
public static $FIELDSLINE = array(
'description',
'date',
'duree',
@ -117,27 +117,37 @@ class Interventions extends DolibarrApi
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
$search_sale = DolibarrApiAccess::$user->id;
}
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as t";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
}
$sql .= ' WHERE t.entity IN ('.getEntity('intervention').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc";
if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= " AND t.fk_soc = sc.fk_soc";
}
if ($socids) {
$sql .= " AND t.fk_soc IN (".$socids.")";
}
if ($search_sale > 0) {
$sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
}
// Insert sale filter
if ($search_sale > 0) {
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
{
if (!DolibarrApi::_checkFilters($sqlfilters))
{
if ($sqlfilters) {
if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -146,8 +156,7 @@ class Interventions extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
@ -158,13 +167,11 @@ class Interventions extends DolibarrApi
dol_syslog("API Rest request");
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0;
while ($i < $min)
{
while ($i < $min) {
$obj = $this->db->fetch_object($result);
$fichinter_static = new Fichinter($this->db);
if ($fichinter_static->fetch($obj->rowid)) {
@ -216,28 +223,28 @@ class Interventions extends DolibarrApi
* @return int
*/
/* TODO
public function getLines($id)
{
if(! DolibarrApiAccess::$user->rights->ficheinter->lire) {
throw new RestException(401);
}
public function getLines($id)
{
if(! DolibarrApiAccess::$user->rights->ficheinter->lire) {
throw new RestException(401);
}
$result = $this->fichinter->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Intervention not found');
}
$result = $this->fichinter->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Intervention not found');
}
if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->fichinter->getLinesArray();
$result = array();
foreach ($this->fichinter->lines as $line) {
array_push($result,$this->_cleanObjectDatas($line));
}
return $result;
}
*/
if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->fichinter->getLinesArray();
$result = array();
foreach ($this->fichinter->lines as $line) {
array_push($result,$this->_cleanObjectDatas($line));
}
return $result;
}
*/
/**
* Add a line to given intervention
@ -270,11 +277,11 @@ class Interventions extends DolibarrApi
}
$updateRes = $this->fichinter->addLine(
DolibarrApiAccess::$user,
$id,
$this->fichinter->description,
$this->fichinter->date,
$this->fichinter->duree
DolibarrApiAccess::$user,
$id,
$this->fichinter->description,
$this->fichinter->date,
$this->fichinter->duree
);
if ($updateRes > 0) {
@ -369,8 +376,7 @@ class Interventions extends DolibarrApi
*/
public function closeFichinter($id)
{
if (!DolibarrApiAccess::$user->rights->ficheinter->creer)
{
if (!DolibarrApiAccess::$user->rights->ficheinter->creer) {
throw new RestException(401, "Insuffisant rights");
}
$result = $this->fichinter->fetch($id);
@ -408,8 +414,9 @@ class Interventions extends DolibarrApi
{
$fichinter = array();
foreach (Interventions::$FIELDS as $field) {
if (!isset($data[$field]))
if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
}
$fichinter[$field] = $data[$field];
}
return $fichinter;
@ -447,8 +454,9 @@ class Interventions extends DolibarrApi
{
$fichinter = array();
foreach (Interventions::$FIELDSLINE as $field) {
if (!isset($data[$field]))
if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
}
$fichinter[$field] = $data[$field];
}
return $fichinter;

View File

@ -204,8 +204,7 @@ class Fichinter extends CommonObject
$sql = "SELECT count(fi.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as fi";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON fi.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->socid)
{
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql .= " WHERE sc.fk_user = ".$user->id;
$clause = "AND";
@ -213,10 +212,8 @@ class Fichinter extends CommonObject
$sql .= " ".$clause." fi.entity IN (".getEntity('intervention').")";
$resql = $this->db->query($sql);
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
{
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
$this->nb["interventions"] = $obj->nb;
}
$this->db->free($resql);
@ -244,21 +241,20 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::create ref=".$this->ref);
// Check parameters
if (!empty($this->ref)) // We check that ref is not already used
{
if (!empty($this->ref)) { // We check that ref is not already used
$result = self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used
if ($result > 0)
{
if ($result > 0) {
$this->error = 'ErrorRefAlreadyExists';
dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING);
$this->db->rollback();
return -1;
}
}
if (!is_numeric($this->duration)) $this->duration = 0;
if (!is_numeric($this->duration)) {
$this->duration = 0;
}
if ($this->socid <= 0)
{
if ($this->socid <= 0) {
$this->error = 'ErrorBadParameterForFunc';
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1;
@ -304,42 +300,42 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."fichinter");
if ($this->id)
{
if ($this->id) {
$this->ref = '(PROV'.$this->id.')';
$sql = 'UPDATE '.MAIN_DB_PREFIX."fichinter SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) $error++;
if (!$resql) {
$error++;
}
}
if (!$error)
{
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0)
{
if ($result < 0) {
$error++;
}
}
// Add linked object
if (!$error && $this->origin && $this->origin_id)
{
if (!$error && $this->origin && $this->origin_id) {
$ret = $this->add_object_linked();
if (!$ret) dol_print_error($this->db);
if (!$ret) {
dol_print_error($this->db);
}
}
if (!$error && !$notrigger)
{
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('FICHINTER_CREATE', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
@ -370,14 +366,14 @@ class Fichinter extends CommonObject
{
global $conf;
if (!is_numeric($this->duration)) {
$this->duration = 0;
}
if (!dol_strlen($this->fk_project)) {
$this->fk_project = 0;
}
if (!is_numeric($this->duration)) {
$this->duration = 0;
}
if (!dol_strlen($this->fk_project)) {
$this->fk_project = 0;
}
$error = 0;
$error = 0;
$this->db->begin();
@ -391,22 +387,20 @@ class Fichinter extends CommonObject
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
if ($this->db->query($sql))
{
if (!$error)
{
if ($this->db->query($sql)) {
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0)
{
if ($result < 0) {
$error++;
}
}
if (!$error && !$notrigger)
{
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('FICHINTER_MODIFY', $user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
if ($result < 0) {
$error++; $this->db->rollback(); return -1;
}
// End call triggers
}
@ -437,14 +431,14 @@ class Fichinter extends CommonObject
if ($ref) {
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.ref='".$this->db->escape($ref)."'";
} else $sql .= " WHERE f.rowid=".$rowid;
} else {
$sql .= " WHERE f.rowid=".$rowid;
}
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -470,7 +464,9 @@ class Fichinter extends CommonObject
$this->extraparams = (array) json_decode($obj->extraparams, true);
if ($this->statut == 0) $this->brouillon = 1;
if ($this->statut == 0) {
$this->brouillon = 1;
}
// Retrieve extrafields
$this->fetch_optionals();
@ -479,8 +475,7 @@ class Fichinter extends CommonObject
* Lines
*/
$result = $this->fetch_lines();
if ($result < 0)
{
if ($result < 0) {
return -3;
}
$this->db->free($resql);
@ -505,8 +500,7 @@ class Fichinter extends CommonObject
$error = 0;
// Protection
if ($this->statut <= self::STATUS_DRAFT)
{
if ($this->statut <= self::STATUS_DRAFT) {
return 0;
}
@ -519,8 +513,7 @@ class Fichinter extends CommonObject
$sql .= " WHERE rowid = ".$this->id;
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
if (!$error) {
$this->oldcopy = clone $this;
}
@ -528,7 +521,9 @@ class Fichinter extends CommonObject
if (!$error) {
// Call trigger
$result = $this->call_trigger('FICHINTER_UNVALIDATE', $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
}
if (!$error) {
@ -560,15 +555,13 @@ class Fichinter extends CommonObject
$error = 0;
if ($this->statut != 1)
{
if ($this->statut != 1) {
$this->db->begin();
$now = dol_now();
// Define new ref
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
{
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
$num = $this->getNextNumRef($this->thirdparty);
} else {
$num = $this->ref;
@ -586,51 +579,48 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::setValid", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
dol_print_error($this->db);
$error++;
}
if (!$error && !$notrigger)
{
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('FICHINTER_VALIDATE', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
if (!$error)
{
if (!$error) {
$this->oldref = $this->ref;
// Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref))
{
if (preg_match('/^[\(]?PROV/i', $this->ref)) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Now we rename also files into index
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'ficheinter/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'ficheinter/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->error = $this->db->lasterror(); }
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->ficheinter->dir_output.'/'.$oldref;
$dirdest = $conf->ficheinter->dir_output.'/'.$newref;
if (!$error && file_exists($dirsource))
{
if (!$error && file_exists($dirsource)) {
dol_syslog(get_class($this)."::setValid rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest))
{
if (@rename($dirsource, $dirdest)) {
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles = dol_dir_list($conf->ficheinter->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
foreach ($listoffiles as $fileentry)
{
foreach ($listoffiles as $fileentry) {
$dirsource = $fileentry['name'];
$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
$dirsource = $fileentry['path'].'/'.$dirsource;
@ -643,8 +633,7 @@ class Fichinter extends CommonObject
}
// Set new ref and define current statut
if (!$error)
{
if (!$error) {
$this->ref = $num;
$this->statut = 1;
$this->brouillon = 0;
@ -740,8 +729,7 @@ class Fichinter extends CommonObject
{
// phpcs:enable
// Init/load array of translation of status
if (empty($this->statuts) || empty($this->statuts_short) || empty($this->statuts_logo))
{
if (empty($this->statuts) || empty($this->statuts_short) || empty($this->statuts_logo)) {
global $langs;
$langs->load("fichinter");
@ -785,19 +773,20 @@ class Fichinter extends CommonObject
$url = DOL_URL_ROOT.'/fichinter/card.php?id='.$this->id;
if ($option !== 'nolink')
{
if ($option !== 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
}
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
}
$linkclose = '';
if (empty($notooltip))
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowIntervention");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
@ -817,16 +806,23 @@ class Fichinter extends CommonObject
$linkend = '</a>';
$result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= $this->ref;
if ($withpicto) {
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend;
global $action;
$hookmanager->initHooks(array('interventiondao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint;
else $result .= $hookmanager->resPrint;
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result;
}
@ -844,8 +840,7 @@ class Fichinter extends CommonObject
global $conf, $db, $langs;
$langs->load("interventions");
if (!empty($conf->global->FICHEINTER_ADDON))
{
if (!empty($conf->global->FICHEINTER_ADDON)) {
$mybool = false;
$file = "mod_".$conf->global->FICHEINTER_ADDON.".php";
@ -870,8 +865,7 @@ class Fichinter extends CommonObject
$numref = "";
$numref = $obj->getNextValue($soc, $this);
if ($numref != "")
{
if ($numref != "") {
return $numref;
} else {
dol_print_error($db, "Fichinter::getNextNumRef ".$obj->error);
@ -905,10 +899,8 @@ class Fichinter extends CommonObject
$sql .= " WHERE f.rowid = ".$id;
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -921,14 +913,12 @@ class Fichinter extends CommonObject
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
if ($obj->fk_user_valid)
{
if ($obj->fk_user_valid) {
$vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
if ($obj->fk_user_modification)
{
if ($obj->fk_user_modification) {
$muser = new User($this->db);
$muser->fetch($obj->fk_user_modification);
$this->user_modification = $muser;
@ -956,27 +946,27 @@ class Fichinter extends CommonObject
$this->db->begin();
if (!$error && !$notrigger)
{
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('FICHINTER_DELETE', $user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
if ($result < 0) {
$error++; $this->db->rollback(); return -1;
}
// End call triggers
}
// Delete linked object
if (!$error)
{
if (!$error) {
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
if ($res < 0) {
$error++;
}
}
// Delete linked contacts
if (!$error)
{
if (!$error) {
$res = $this->delete_linked_contact();
if ($res < 0)
{
if ($res < 0) {
$this->error = 'ErrorFailToDeleteLinkedContact';
$error++;
}
@ -988,62 +978,61 @@ class Fichinter extends CommonObject
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_fichinter = ".$this->id.")";
$resql = $this->db->query($sql);
if (!$resql) $error++;
if (!$resql) {
$error++;
}
}
if (!$error)
{
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet";
$sql .= " WHERE fk_fichinter = ".$this->id;
$resql = $this->db->query($sql);
if (!$resql) $error++;
if (!$resql) {
$error++;
}
}
if (!$error)
{
if (!$error) {
// Remove extrafields
$res = $this->deleteExtraFields();
if ($res < 0) $error++;
if ($res < 0) {
$error++;
}
}
if (!$error)
{
if (!$error) {
// Delete object
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter";
$sql .= " WHERE rowid = ".$this->id;
dol_syslog("Fichinter::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) $error++;
if (!$resql) {
$error++;
}
}
if (!$error)
{
if (!$error) {
// Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
$this->deleteEcmFiles();
// Remove directory with files
$fichinterref = dol_sanitizeFileName($this->ref);
if ($conf->ficheinter->dir_output)
{
if ($conf->ficheinter->dir_output) {
$dir = $conf->ficheinter->dir_output."/".$fichinterref;
$file = $conf->ficheinter->dir_output."/".$fichinterref."/".$fichinterref.".pdf";
if (file_exists($file))
{
if (file_exists($file)) {
dol_delete_preview($this);
if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers
{
if (!dol_delete_file($file, 0, 0, 0, $this)) { // For triggers
$langs->load("errors");
$this->error = $langs->trans("ErrorFailToDeleteFile", $file);
return 0;
}
}
if (file_exists($dir))
{
if (!dol_delete_dir_recursive($dir))
{
if (file_exists($dir)) {
if (!dol_delete_dir_recursive($dir)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorFailToDeleteDir", $dir);
return 0;
@ -1052,8 +1041,7 @@ class Fichinter extends CommonObject
}
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -1075,15 +1063,13 @@ class Fichinter extends CommonObject
// phpcs:enable
global $conf;
if ($user->rights->ficheinter->creer)
{
if ($user->rights->ficheinter->creer) {
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
$sql .= " SET datei = '".$this->db->idate($date_delivery)."'";
$sql .= " WHERE rowid = ".$this->id;
$sql .= " AND fk_statut = 0";
if ($this->db->query($sql))
{
if ($this->db->query($sql)) {
$this->date_delivery = $date_delivery;
return 1;
} else {
@ -1107,15 +1093,13 @@ class Fichinter extends CommonObject
// phpcs:enable
global $conf;
if ($user->rights->ficheinter->creer)
{
if ($user->rights->ficheinter->creer) {
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
$sql .= " SET description = '".$this->db->escape($description)."',";
$sql .= " fk_user_modif = ".$user->id;
$sql .= " WHERE rowid = ".$this->id;
if ($this->db->query($sql))
{
if ($this->db->query($sql)) {
$this->description = $description;
return 1;
} else {
@ -1140,14 +1124,12 @@ class Fichinter extends CommonObject
// phpcs:enable
global $conf;
if ($user->rights->ficheinter->creer)
{
if ($user->rights->ficheinter->creer) {
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
$sql .= " SET fk_contrat = ".((int) $contractid);
$sql .= " WHERE rowid = ".$this->id;
if ($this->db->query($sql))
{
if ($this->db->query($sql)) {
$this->fk_contrat = $contractid;
return 1;
} else {
@ -1176,19 +1158,18 @@ class Fichinter extends CommonObject
$this->db->begin();
// get extrafields so they will be clone
foreach ($this->lines as $line)
foreach ($this->lines as $line) {
$line->fetch_optionals();
}
// Load source object
$objFrom = clone $this;
// Change socid if needed
if (!empty($socid) && $socid != $this->socid)
{
if (!empty($socid) && $socid != $this->socid) {
$objsoc = new Societe($this->db);
if ($objsoc->fetch($socid) > 0)
{
if ($objsoc->fetch($socid) > 0) {
$this->socid = $objsoc->id;
//$this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
//$this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
@ -1213,31 +1194,31 @@ class Fichinter extends CommonObject
// Create clone
$this->context['createfromclone'] = 'createfromclone';
$result = $this->create($user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
if (!$error)
{
if (!$error) {
// Add lines because it is not included into create function
foreach ($this->lines as $line)
{
foreach ($this->lines as $line) {
$this->addline($user, $this->id, $line->desc, $line->datei, $line->duration);
}
// Hook of thirdparty module
if (is_object($hookmanager))
{
if (is_object($hookmanager)) {
$parameters = array('objFrom'=>$objFrom);
$action = '';
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++;
if ($reshook < 0) {
$error++;
}
}
}
unset($this->context['createfromclone']);
// End
if (!$error)
{
if (!$error) {
$this->db->commit();
return $this->id;
} else {
@ -1262,8 +1243,7 @@ class Fichinter extends CommonObject
{
dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration");
if ($this->statut == 0)
{
if ($this->statut == 0) {
$this->db->begin();
// Insertion ligne
@ -1280,8 +1260,7 @@ class Fichinter extends CommonObject
$result = $line->insert($user);
if ($result >= 0)
{
if ($result >= 0) {
$this->db->commit();
return 1;
} else {
@ -1317,8 +1296,7 @@ class Fichinter extends CommonObject
$this->duration = 0;
$nbp = 25;
$xnbp = 0;
while ($xnbp < $nbp)
{
while ($xnbp < $nbp) {
$line = new FichinterLigne($this->db);
$line->desc = $langs->trans("Description")." ".$xnbp;
$line->datei = ($now - 3600 * (1 + $xnbp));
@ -1348,12 +1326,10 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$objp = $this->db->fetch_object($resql);
$line = new FichinterLigne($this->db);
@ -1466,8 +1442,7 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::fetch", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid;
$this->id = $objp->rowid;
@ -1503,14 +1478,12 @@ class FichinterLigne extends CommonObjectLine
$this->db->begin();
$rangToUse = $this->rang;
if ($rangToUse == -1)
{
if ($rangToUse == -1) {
// Recupere rang max de la ligne d'intervention dans $rangmax
$sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'fichinterdet';
$sql .= ' WHERE fk_fichinter ='.$this->fk_fichinter;
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
$rangToUse = $obj->max + 1;
} else {
@ -1532,16 +1505,13 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::insert", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet');
$this->rowid = $this->id;
if (!$error)
{
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0)
{
if ($result < 0) {
$error++;
}
}
@ -1549,15 +1519,15 @@ class FichinterLigne extends CommonObjectLine
$result = $this->update_total();
if ($result > 0)
{
if ($result > 0) {
$this->rang = $rangToUse;
if (!$notrigger)
{
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('LINEFICHINTER_CREATE', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
}
@ -1602,31 +1572,27 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if (!$error)
{
if ($resql) {
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0)
{
if ($result < 0) {
$error++;
}
}
$result = $this->update_total();
if ($result > 0)
{
if (!$notrigger)
{
if ($result > 0) {
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('LINEFICHINTER_UPDATE', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return $result;
} else {
@ -1660,11 +1626,12 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::update_total", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
$total_duration = 0;
if (!empty($obj->total_duration)) $total_duration = $obj->total_duration;
if (!empty($obj->total_duration)) {
$total_duration = $obj->total_duration;
}
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
$sql .= " SET duree = ".$total_duration;
@ -1674,8 +1641,7 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::update_total", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$this->db->commit();
return 1;
} else {
@ -1703,8 +1669,7 @@ class FichinterLigne extends CommonObjectLine
$error = 0;
if ($this->statut == 0)
{
if ($this->statut == 0) {
dol_syslog(get_class($this)."::deleteline lineid=".$this->id);
$this->db->begin();
@ -1718,16 +1683,15 @@ class FichinterLigne extends CommonObjectLine
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE rowid = ".$this->id;
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$result = $this->update_total();
if ($result > 0)
{
if (!$notrigger)
{
if ($result > 0) {
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('LINEFICHINTER_DELETE', $user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
if ($result < 0) {
$error++; $this->db->rollback(); return -1;
}
// End call triggers
}

View File

@ -214,8 +214,8 @@ class FichinterRec extends Fichinter
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
/*
* Lines
*/
* Lines
*/
$num = count($fichintsrc->lines);
for ($i = 0; $i < $num; $i++) {
//var_dump($fichintsrc->lines[$i]);
@ -239,13 +239,14 @@ class FichinterRec extends Fichinter
$fichintsrc->lines[$i]->fk_unit
);
if ($result_insert < 0)
if ($result_insert < 0) {
$error++;
}
}
if ($error)
if ($error) {
$this->db->rollback();
else {
} else {
$this->db->commit();
return $this->id;
}
@ -277,8 +278,11 @@ class FichinterRec extends Fichinter
$sql .= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.auto_validate';
$sql .= ', f.note_private, f.note_public, f.fk_user_author';
$sql .= ' FROM '.MAIN_DB_PREFIX.'fichinter_rec as f';
if ($rowid > 0) $sql .= ' WHERE f.rowid='.$rowid;
elseif ($ref) $sql .= " WHERE f.titre='".$this->db->escape($ref)."'";
if ($rowid > 0) {
$sql .= ' WHERE f.rowid='.$rowid;
} elseif ($ref) {
$sql .= " WHERE f.titre='".$this->db->escape($ref)."'";
}
dol_syslog(get_class($this)."::fetch rowid=".$rowid, LOG_DEBUG);
@ -421,7 +425,9 @@ class FichinterRec extends Fichinter
*/
public function delete($rowid = 0, $notrigger = 0, $idwarehouse = -1)
{
if (empty($rowid)) $rowid = $this->id;
if (empty($rowid)) {
$rowid = $this->id;
}
dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG);
@ -481,14 +487,20 @@ class FichinterRec extends Fichinter
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Check parameters
if ($type < 0) return -1;
if ($type < 0) {
return -1;
}
if ($this->brouillon) {
// Clean parameters
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
if (!$qty) $qty = 1;
if (!$info_bits) $info_bits = 0;
if (!$qty) {
$qty = 1;
}
if (!$info_bits) {
$info_bits = 0;
}
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
if (!preg_match('/\((.*)\)/', $txtva)) {
@ -623,7 +635,9 @@ class FichinterRec extends Fichinter
$url = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$this->id;
if ($short) return $url;
if ($short) {
return $url;
}
$picto = 'intervention';
@ -709,7 +723,9 @@ class FichinterRec extends Fichinter
dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG);
if ($this->db->query($sql)) {
$this->frequency = $frequency;
if (!empty($unit)) $this->unit_frequency = $unit;
if (!empty($unit)) {
$this->unit_frequency = $unit;
}
return 1;
} else {
dol_print_error($this->db);
@ -732,13 +748,17 @@ class FichinterRec extends Fichinter
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null");
if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1';
if ($increment_nb_gen_done > 0) {
$sql .= ', nb_gen_done = nb_gen_done + 1';
}
$sql .= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG);
if ($this->db->query($sql)) {
$this->date_when = $date;
if ($increment_nb_gen_done > 0) $this->nb_gen_done++;
if ($increment_nb_gen_done > 0) {
$this->nb_gen_done++;
}
return 1;
} else {
dol_print_error($this->db);
@ -759,7 +779,9 @@ class FichinterRec extends Fichinter
return -1;
}
if (empty($nb)) $nb = 0;
if (empty($nb)) {
$nb = 0;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET nb_gen_max = '.$nb;
@ -818,8 +840,9 @@ class FichinterRec extends Fichinter
$sql .= ' SET nb_gen_done = nb_gen_done + 1';
$sql .= ' , date_last_gen = now()';
// si on et arrivé à la fin des génération
if ($this->nb_gen_max == $this->nb_gen_done + 1)
if ($this->nb_gen_max == $this->nb_gen_done + 1) {
$sql .= ' , statut = 1';
}
$sql .= ' WHERE rowid = '.$this->id;

View File

@ -64,8 +64,7 @@ class FichinterStats extends Stats
$this->userid = $userid;
$this->cachefilesuffix = $mode;
if ($mode == 'customer')
{
if ($mode == 'customer') {
$object = new Fichinter($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as c";
$this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl";
@ -73,14 +72,17 @@ class FichinterStats extends Stats
$this->field_line = '0';
//$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled
}
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
if (!$user->rights->societe->client->voir && !$this->socid) {
$this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
$this->where .= ($this->where ? ' AND ' : '')."c.entity IN (".getEntity('fichinter').')';
if ($this->socid)
{
if ($this->socid) {
$this->where .= " AND c.fk_soc = ".$this->socid;
}
if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid;
if ($this->userid > 0) {
$this->where .= ' AND c.fk_user_author = '.$this->userid;
}
}
/**
@ -96,7 +98,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
$sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
@ -118,7 +122,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0";
$sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');
@ -139,7 +145,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%m') as dm, 0";
$sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
@ -161,7 +169,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%m') as dm, 0";
$sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
@ -181,7 +191,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg";
$sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE ".$this->where;
$sql .= " GROUP BY year";
$sql .= $this->db->order('year', 'DESC');

View File

@ -39,13 +39,14 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db);
$result = $object->fetch($id, $ref);
if (!$result)
{
if (!$result) {
print 'Record not found';
exit;
}
@ -54,17 +55,14 @@ if (!$result)
* Adding a new contact
*/
if ($action == 'addcontact' && $user->rights->ficheinter->creer)
{
if ($result > 0 && $id > 0)
{
if ($action == 'addcontact' && $user->rights->ficheinter->creer) {
if ($result > 0 && $id > 0) {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
}
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@ -77,21 +75,14 @@ if ($action == 'addcontact' && $user->rights->ficheinter->creer)
setEventMessages($mesg, null, 'errors');
}
}
// Toggle the status of a contact
elseif ($action == 'swapstatut' && $user->rights->ficheinter->creer)
{
} elseif ($action == 'swapstatut' && $user->rights->ficheinter->creer) {
// Toggle the status of a contact
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
}
// Deletes a contact
elseif ($action == 'deletecontact' && $user->rights->ficheinter->creer)
{
} elseif ($action == 'deletecontact' && $user->rights->ficheinter->creer) {
// Deletes a contact
$result = $object->delete_contact(GETPOST('lineid', 'int'));
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@ -114,8 +105,7 @@ llxHeader('', $langs->trans("Intervention"));
// Mode vue et edition
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$object->fetch_thirdparty();
$head = fichinter_prepare_head($object);
@ -133,12 +123,10 @@ if ($id > 0 || !empty($ref))
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->ficheinter->creer)
{
if ($user->rights->ficheinter->creer) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ';
@ -174,15 +162,20 @@ if ($id > 0 || !empty($ref))
print '<br>';
if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser = 1;
if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty = 1;
if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) {
$hideaddcontactforuser = 1;
}
if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) {
$hideaddcontactforthirdparty = 1;
}
// Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
foreach ($dirtpls as $reldir)
{
foreach ($dirtpls as $reldir) {
$res = @include dol_buildpath($reldir.'/contacts.tpl.php');
if ($res) break;
if ($res) {
break;
}
}
}

View File

@ -47,7 +47,9 @@ $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
@ -56,12 +58,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "name";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$object = new Fichinter($db);
@ -86,8 +94,7 @@ $form = new Form($db);
llxHeader('', $langs->trans("Intervention"));
if ($object->id)
{
if ($object->id) {
$object->fetch_thirdparty();
$head = fichinter_prepare_head($object);
@ -98,8 +105,7 @@ if ($object->id)
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
foreach ($filearray as $key => $file)
{
foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
}
@ -115,12 +121,10 @@ if ($object->id)
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->commande->creer)
{
if ($user->rights->commande->creer) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ';

View File

@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
if (!$user->rights->ficheinter->lire) accessforbidden();
if (!$user->rights->ficheinter->lire) {
accessforbidden();
}
$hookmanager = new HookManager($db);
@ -42,8 +44,7 @@ $langs->load("interventions");
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid > 0)
{
if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
@ -66,8 +67,7 @@ print load_fiche_titre($langs->trans("InterventionsArea"), '', 'intervention');
print '<div class="fichecenter"><div class="fichethirdleft">';
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
{
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo
// Search ficheinter
$var = false;
print '<form method="post" action="'.DOL_URL_ROOT.'/fichinter/list.php">';
@ -88,15 +88,20 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles
$sql = "SELECT count(f.rowid), f.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."fichinter as f";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.fk_soc = s.rowid";
if ($user->socid) $sql .= ' AND f.fk_soc = '.$user->socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) {
$sql .= ' AND f.fk_soc = '.$user->socid;
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
$sql .= " GROUP BY f.fk_statut";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
@ -106,15 +111,15 @@ if ($resql)
$vals = array();
$bool = false;
// -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not)
while ($i < $num)
{
while ($i < $num) {
$row = $db->fetch_row($resql);
if ($row)
{
if ($row) {
//if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1))
{
$bool = (!empty($row[2]) ?true:false);
if (!isset($vals[$row[1].$bool])) $vals[$row[1].$bool] = 0;
if (!isset($vals[$row[1].$bool])) {
$vals[$row[1].$bool] = 0;
}
$vals[$row[1].$bool] += $row[0];
$totalinprocess += $row[0];
}
@ -131,19 +136,28 @@ if ($resql)
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Interventions").'</th></tr>'."\n";
$listofstatus = array(0, 1, 3);
$bool = false;
foreach ($listofstatus as $status)
{
foreach ($listofstatus as $status) {
$dataseries[] = array($fichinterstatic->LibStatut($status, $bool, 1), (isset($vals[$status.$bool]) ? (int) $vals[$status.$bool] : 0));
if ($status == 3 && !$bool) $bool = true;
else $bool = false;
if ($status == 3 && !$bool) {
$bool = true;
} else {
$bool = false;
}
if ($status == Fichinter::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
if ($status == Fichinter::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1;
if ($status == Fichinter::STATUS_BILLED) $colorseries[$status] = $badgeStatus4;
if ($status == Fichinter::STATUS_CLOSED) $colorseries[$status] = $badgeStatus6;
if ($status == Fichinter::STATUS_DRAFT) {
$colorseries[$status] = '-'.$badgeStatus0;
}
if ($status == Fichinter::STATUS_VALIDATED) {
$colorseries[$status] = $badgeStatus1;
}
if ($status == Fichinter::STATUS_BILLED) {
$colorseries[$status] = $badgeStatus4;
}
if ($status == Fichinter::STATUS_CLOSED) {
$colorseries[$status] = $badgeStatus6;
}
}
if ($conf->use_javascript_ajax)
{
if ($conf->use_javascript_ajax) {
print '<tr class="impair"><td class="center" colspan="2">';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@ -160,10 +174,8 @@ if ($resql)
print '</td></tr>';
}
$bool = false;
foreach ($listofstatus as $status)
{
if (!$conf->use_javascript_ajax)
{
foreach ($listofstatus as $status) {
if (!$conf->use_javascript_ajax) {
print '<tr class="oddeven">';
print '<td>'.$fichinterstatic->LibStatut($status, $bool, 0).'</td>';
print '<td class="right"><a href="list.php?search_status='.$status.'">'.(isset($vals[$status.$bool]) ? $vals[$status.$bool] : 0).' ';
@ -171,8 +183,11 @@ if ($resql)
print '</a>';
print '</td>';
print "</tr>\n";
if ($status == 3 && !$bool) $bool = true;
else $bool = false;
if ($status == 3 && !$bool) {
$bool = true;
} else {
$bool = false;
}
}
}
//if ($totalinprocess != $total)
@ -187,32 +202,34 @@ if ($resql)
/*
* Draft orders
*/
if (!empty($conf->ficheinter->enabled))
{
if (!empty($conf->ficheinter->enabled)) {
$sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.fk_statut = 0";
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) {
$sql .= " AND f.fk_soc = ".$socid;
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="2">'.$langs->trans("DraftFichinter").'</th></tr>';
$langs->load("fichinter");
$num = $db->num_rows($resql);
if ($num)
{
if ($num) {
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td class="nowrap">';
@ -239,29 +256,32 @@ $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.date_valid as datec, f.tms as date
$sql .= " s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f,";
$sql .= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.fk_soc = s.rowid";
//$sql.= " AND c.fk_statut > 2";
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) {
$sql .= " AND f.fk_soc = ".$socid;
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
$sql .= " ORDER BY f.tms DESC";
$sql .= $db->plimit($max, 0);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="4">'.$langs->trans("LastModifiedInterventions", $max).'</th></tr>';
$num = $db->num_rows($resql);
if ($num)
{
if ($num) {
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
@ -296,29 +316,35 @@ if ($resql)
}
}
print "</table></div><br>";
} else dol_print_error($db);
} else {
dol_print_error($db);
}
/*
* interventions to process
*/
if (!empty($conf->ficheinter->enabled))
{
if (!empty($conf->ficheinter->enabled)) {
$sql = "SELECT f.rowid, f.ref, f.fk_statut, s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.fk_statut = 1";
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) {
$sql .= " AND f.fk_soc = ".$socid;
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
$sql .= " ORDER BY f.rowid DESC";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
print '<div class="div-table-responsive-no-min">';
@ -326,11 +352,9 @@ if (!empty($conf->ficheinter->enabled))
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("FichinterToProcess").' <a href="'.DOL_URL_ROOT.'/fichinter/list.php?search_status=1"><span class="badge">'.$num.'</span></a></th></tr>';
if ($num)
{
if ($num) {
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td class="nowrap" width="20%">';
@ -366,7 +390,9 @@ if (!empty($conf->ficheinter->enabled))
}
print "</table></div><br>";
} else dol_print_error($db);
} else {
dol_print_error($db);
}
}
print '</div></div></div>';

View File

@ -40,13 +40,14 @@ $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db);
if (!$object->fetch($id, $ref) > 0)
{
if (!$object->fetch($id, $ref) > 0) {
dol_print_error($db);
exit;
}
@ -77,15 +78,14 @@ $morehtmlref = '<div class="refidno">';
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
if ($user->rights->commande->creer) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ';
}
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';

View File

@ -32,13 +32,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
if (!empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
}
if (!empty($conf->contrat->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
}
// Load translation files required by the page
$langs->loadLangs(array('companies', 'bills', 'interventions'));
if (!empty($conf->projet->enabled)) $langs->load("projects");
if (!empty($conf->contrat->enabled)) $langs->load("contracts");
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
}
if (!empty($conf->contrat->enabled)) {
$langs->load("contracts");
}
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha');
@ -59,7 +67,9 @@ $socid = GETPOST('socid', 'int');
// Security check
$id = GETPOST('id', 'int');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$diroutputmassaction = $conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id;
@ -68,14 +78,17 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "DESC";
if (!$sortfield)
{
$sortfield = "f.ref";
if (!$sortorder) {
$sortorder = "DESC";
}
if (!$sortfield) {
$sortfield = "f.ref";
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@ -97,8 +110,12 @@ $fieldstosearchall = array(
'f.note_public'=>'NotePublic',
'fd.description'=>'DescriptionOfLine',
);
if (empty($user->socid)) $fieldstosearchall["f.note_private"] = "NotePrivate";
if (!empty($conf->global->FICHINTER_DISABLE_DETAILS)) unset($fieldstosearchall['fd.description']);
if (empty($user->socid)) {
$fieldstosearchall["f.note_private"] = "NotePrivate";
}
if (!empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
unset($fieldstosearchall['fd.description']);
}
// Definition of fields for list
$arrayfields = array(
@ -127,21 +144,25 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; }
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
$massaction = '';
}
$parameters = array('socid'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$search_ref = "";
$search_company = "";
$search_projet_ref = "";
@ -187,10 +208,8 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$atleastonefieldinlines = 0;
foreach ($arrayfields as $tmpkey => $tmpval)
{
if (preg_match('/^fd\./', $tmpkey) && !empty($arrayfields[$tmpkey]['checked']))
{
foreach ($arrayfields as $tmpkey => $tmpval) {
if (preg_match('/^fd\./', $tmpkey) && !empty($arrayfields[$tmpkey]['checked'])) {
$atleastonefieldinlines++;
break;
}
@ -198,7 +217,9 @@ foreach ($arrayfields as $tmpkey => $tmpval)
$sql = "SELECT";
$sql .= " f.ref, f.rowid, f.fk_statut as status, f.description, f.datec as date_creation, f.tms as date_update, f.note_public, f.note_private,";
if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= " fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,";
if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) {
$sql .= " fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,";
}
$sql .= " s.nom as name, s.rowid as socid, s.client, s.fournisseur, s.email, s.status as thirdpartystatus";
if (!empty($conf->projet->enabled)) {
$sql .= ", pr.rowid as projet_id, pr.ref as projet_ref, pr.title as projet_title";
@ -208,7 +229,9 @@ if (!empty($conf->contrat->enabled)) {
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
}
}
// Add fields from hooks
$parameters = array();
@ -221,9 +244,15 @@ if (!empty($conf->projet->enabled)) {
if (!empty($conf->contrat->enabled)) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contrat as c on f.fk_contrat = c.rowid";
}
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)";
if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
if (!$user->rights->societe->client->voir && empty($socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)";
}
if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
}
if (!$user->rights->societe->client->voir && empty($socid)) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.fk_soc = s.rowid";
@ -240,16 +269,21 @@ if ($search_contrat_ref) {
$sql .= natural_search('c.ref', $search_contrat_ref);
}
if ($search_desc) {
if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= natural_search(array('f.description', 'fd.description'), $search_desc);
else $sql .= natural_search(array('f.description'), $search_desc);
if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) {
$sql .= natural_search(array('f.description', 'fd.description'), $search_desc);
} else {
$sql .= natural_search(array('f.description'), $search_desc);
}
}
if ($search_status != '' && $search_status >= 0) {
$sql .= ' AND f.fk_statut = '.urlencode($search_status);
}
if (!$user->rights->societe->client->voir && empty($socid))
if (!$user->rights->societe->client->voir && empty($socid)) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid)
}
if ($socid) {
$sql .= " AND s.rowid = ".$socid;
}
if ($sall) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
}
@ -263,12 +297,10 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
@ -278,30 +310,50 @@ $sql .= $db->plimit($limit + 1, $offset);
//print $sql;
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$arrayofselected = is_array($toselect) ? $toselect : array();
if ($socid > 0)
{
if ($socid > 0) {
$soc = new Societe($db);
$soc->fetch($socid);
if (empty($search_company)) $search_company = $soc->name;
if (empty($search_company)) {
$search_company = $soc->name;
}
}
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($sall) $param .= "&sall=".urlencode($sall);
if ($socid) $param .= "&socid=".urlencode($socid);
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
if ($search_company) $param .= "&search_company=".urlencode($search_company);
if ($search_desc) $param .= "&search_desc=".urlencode($search_desc);
if ($search_status != '' && $search_status > -1) $param .= "&search_status=".urlencode($search_status);
if ($show_files) $param .= '&show_files='.urlencode($show_files);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($sall) {
$param .= "&sall=".urlencode($sall);
}
if ($socid) {
$param .= "&socid=".urlencode($socid);
}
if ($search_ref) {
$param .= "&search_ref=".urlencode($search_ref);
}
if ($search_company) {
$param .= "&search_company=".urlencode($search_company);
}
if ($search_desc) {
$param .= "&search_desc=".urlencode($search_desc);
}
if ($search_status != '' && $search_status > -1) {
$param .= "&search_status=".urlencode($search_status);
}
if ($show_files) {
$param .= '&show_files='.urlencode($show_files);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -311,19 +363,27 @@ if ($resql)
'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
);
if ($user->rights->ficheinter->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if ($user->rights->ficheinter->supprimer) {
$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
}
if (in_array($massaction, array('presend', 'predelete'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = '';
$url = DOL_URL_ROOT.'/fichinter/card.php?action=create';
if (!empty($socid)) $url .= '&socid='.$socid;
if (!empty($socid)) {
$url .= '&socid='.$socid;
}
$newcardbutton = dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', $url, '', $user->rights->ficheinter->creer);
// Lines of title fields
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -339,9 +399,10 @@ if ($resql)
$trackid = 'int'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($sall)
{
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
if ($sall) {
foreach ($fieldstosearchall as $key => $val) {
$fieldstosearchall[$key] = $langs->trans($val);
}
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
}
@ -349,48 +410,47 @@ if ($resql)
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
if (empty($reshook)) {
$moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
if (!empty($moreforfilter))
{
if (!empty($moreforfilter)) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
}
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
if ($massactionbutton) {
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
}
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['f.ref']['checked']))
{
if (!empty($arrayfields['f.ref']['checked'])) {
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">';
print '</td>';
}
if (!empty($arrayfields['s.nom']['checked']))
{
if (!empty($arrayfields['s.nom']['checked'])) {
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_company" value="'.$search_company.'" size="10">';
print '</td>';
}
if (!empty($arrayfields['pr.ref']['checked']))
{
if (!empty($arrayfields['pr.ref']['checked'])) {
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_projet_ref" value="'.$search_projet_ref.'" size="8">';
print '</td>';
}
if (!empty($arrayfields['c.ref']['checked']))
{
if (!empty($arrayfields['c.ref']['checked'])) {
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_contrat_ref" value="'.$search_contrat_ref.'" size="8">';
print '</td>';
}
if (!empty($arrayfields['f.description']['checked']))
{
if (!empty($arrayfields['f.description']['checked'])) {
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_desc" value="'.$search_desc.'" size="12">';
print '</td>';
@ -402,51 +462,45 @@ if ($resql)
$parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!empty($arrayfields['f.datec']['checked']))
{
if (!empty($arrayfields['f.datec']['checked'])) {
// Date creation
print '<td class="liste_titre">';
print '</td>';
}
if (!empty($arrayfields['f.tms']['checked']))
{
if (!empty($arrayfields['f.tms']['checked'])) {
// Date modification
print '<td class="liste_titre">';
print '</td>';
}
if (!empty($arrayfields['f.note_public']['checked']))
{
if (!empty($arrayfields['f.note_public']['checked'])) {
// Note public
print '<td class="liste_titre">';
print '</td>';
}
if (!empty($arrayfields['f.note_private']['checked']))
{
if (!empty($arrayfields['f.note_private']['checked'])) {
// Note private
print '<td class="liste_titre">';
print '</td>';
}
// Status
if (!empty($arrayfields['f.fk_statut']['checked']))
{
if (!empty($arrayfields['f.fk_statut']['checked'])) {
print '<td class="liste_titre right">';
$tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short
$liststatus = $objectstatic->statuts_short;
if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) {
unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
}
print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1);
print '</td>';
}
// Fields of detail line
if (!empty($arrayfields['fd.description']['checked']))
{
if (!empty($arrayfields['fd.description']['checked'])) {
print '<td class="liste_titre">&nbsp;</td>';
}
if (!empty($arrayfields['fd.date']['checked']))
{
if (!empty($arrayfields['fd.date']['checked'])) {
print '<td class="liste_titre">&nbsp;</td>';
}
if (!empty($arrayfields['fd.duree']['checked']))
{
if (!empty($arrayfields['fd.duree']['checked'])) {
print '<td class="liste_titre">&nbsp;</td>';
}
print '<td class="liste_titre maxwidthsearch">';
@ -457,33 +511,58 @@ if ($resql)
print "</tr>\n";
print '<tr class="liste_titre">';
if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['f.description']['checked'])) print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['f.ref']['checked'])) {
print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['s.nom']['checked'])) {
print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['pr.ref']['checked'])) {
print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['c.ref']['checked'])) {
print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['f.description']['checked'])) {
print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder);
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (!empty($arrayfields['f.note_public']['checked'])) print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (!empty($arrayfields['f.note_private']['checked'])) print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (!empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['fd.description']['checked'])) print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], '');
if (!empty($arrayfields['fd.date']['checked'])) print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['fd.duree']['checked'])) print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['f.datec']['checked'])) {
print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
}
if (!empty($arrayfields['f.tms']['checked'])) {
print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
}
if (!empty($arrayfields['f.note_public']['checked'])) {
print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
}
if (!empty($arrayfields['f.note_private']['checked'])) {
print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
}
if (!empty($arrayfields['f.fk_statut']['checked'])) {
print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['fd.description']['checked'])) {
print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], '');
}
if (!empty($arrayfields['fd.date']['checked'])) {
print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['fd.duree']['checked'])) {
print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right ');
}
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n";
$total = 0;
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
$objectstatic->id = $obj->rowid;
@ -500,8 +579,7 @@ if ($resql)
print '<tr class="oddeven">';
if (!empty($arrayfields['f.ref']['checked']))
{
if (!empty($arrayfields['f.ref']['checked'])) {
print "<td>";
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
@ -512,15 +590,13 @@ if ($resql)
// Warning
$warnornote = '';
//if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
if (!empty($obj->note_private))
{
if (!empty($obj->note_private)) {
$warnornote .= ($warnornote ? ' ' : '');
$warnornote .= '<span class="note">';
$warnornote .= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>';
$warnornote .= '</span>';
}
if ($warnornote)
{
if ($warnornote) {
print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
print $warnornote;
print '</td>';
@ -535,17 +611,19 @@ if ($resql)
print '</td></tr></table>';
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['s.nom']['checked']))
{
if (!empty($arrayfields['s.nom']['checked'])) {
print '<td>';
print $companystatic->getNomUrl(1, '', 44);
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['pr.ref']['checked']))
{
if (!empty($arrayfields['pr.ref']['checked'])) {
print '<td>';
$projetstatic->id = $obj->projet_id;
$projetstatic->ref = $obj->projet_ref;
@ -554,10 +632,11 @@ if ($resql)
print $projetstatic->getNomUrl(1, '');
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['c.ref']['checked']))
{
if (!empty($arrayfields['c.ref']['checked'])) {
print '<td>';
$contratstatic->id = $obj->contrat_id;
$contratstatic->ref = $obj->contrat_ref;
@ -567,12 +646,15 @@ if ($resql)
print $contratstatic->getNomUrl(1, '');
print '</td>';
}
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['f.description']['checked']))
{
if (!empty($arrayfields['f.description']['checked'])) {
print '<td>'.dol_trunc(dolGetFirstLineOfText($obj->description), 48).'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Extra fields
@ -582,71 +664,84 @@ if ($resql)
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (!empty($arrayfields['f.datec']['checked']))
{
if (!empty($arrayfields['f.datec']['checked'])) {
print '<td class="center">';
print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Date modification
if (!empty($arrayfields['f.tms']['checked']))
{
if (!empty($arrayfields['f.tms']['checked'])) {
print '<td class="center">';
print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Note public
if (!empty($arrayfields['f.note_public']['checked']))
{
if (!empty($arrayfields['f.note_public']['checked'])) {
print '<td class="center">';
print dol_escape_htmltag($obj->note_public);
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Note private
if (!empty($arrayfields['f.note_private']['checked']))
{
if (!empty($arrayfields['f.note_private']['checked'])) {
print '<td class="center">';
print dol_escape_htmltag($obj->note_private);
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Status
if (!empty($arrayfields['f.fk_statut']['checked']))
{
if (!empty($arrayfields['f.fk_statut']['checked'])) {
print '<td class="right">'.$objectstatic->getLibStatut(5).'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Fields of detail of line
if (!empty($arrayfields['fd.description']['checked']))
{
if (!empty($arrayfields['fd.description']['checked'])) {
print '<td>'.dolGetFirstLineOfText($obj->descriptiondetail).'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['fd.date']['checked']))
{
if (!empty($arrayfields['fd.date']['checked'])) {
print '<td class="center">'.dol_print_date($db->jdate($obj->dp), 'dayhour')."</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['fd.duree']['checked']))
{
if (!empty($arrayfields['fd.duree']['checked'])) {
print '<td class="right">'.convertSecondToTime($obj->duree, 'allhourmin').'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'fd.duree';
}
$totalarray['val']['fd.duree'] += $obj->duree;
}
// Action column
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
if (in_array($obj->rowid, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
print "</tr>\n";
@ -669,7 +764,9 @@ if ($resql)
print "</form>\n";
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
$hidegeneratedfilelistifempty = 0;
}
// Show list of available documents
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;

View File

@ -39,7 +39,9 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db);
@ -62,8 +64,7 @@ llxHeader('', $langs->trans("Intervention"));
$form = new Form($db);
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$object->fetch_thirdparty();
$head = fichinter_prepare_head($object);
@ -80,12 +81,10 @@ if ($id > 0 || !empty($ref))
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->commande->creer)
{
if ($user->rights->commande->creer) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ';

View File

@ -30,13 +30,14 @@ $WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
$mode = 'customer';
if (!$user->rights->ficheinter->lire) accessforbidden();
if (!$user->rights->ficheinter->lire) {
accessforbidden();
}
$userid = GETPOST('userid', 'int');
$socid = GETPOST('socid', 'int');
// Security check
if ($user->socid > 0)
{
if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
@ -70,15 +71,16 @@ print load_fiche_titre($title, '', 'intervention');
dol_mkdir($dir);
$stats = new FichinterStats($db, $socid, $mode, ($userid > 0 ? $userid : 0));
if ($object_status != '' && $object_status > -1) $stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')';
if ($object_status != '' && $object_status > -1) {
$stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')';
}
// Build graphic number of object
$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
// $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->socid)
{
if (!$user->rights->societe->client->voir || $user->socid) {
$filenamenb = $dir.'/interventionsnbinyear-'.$user->id.'-'.$year.'.png';
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.'-'.$year.'.png';
} else {
@ -88,12 +90,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px1->SetData($data);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
while ($i <= $endyear) {
$legend[] = $i;
$i++;
}
@ -115,8 +115,7 @@ if (!$mesg)
$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
// $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->socid)
{
if (!$user->rights->societe->client->voir || $user->socid) {
$filenameamount = $dir.'/interventionsamountinyear-'.$user->id.'-'.$year.'.png';
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png';
} else {
@ -126,12 +125,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px2->SetData($data);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
while ($i <= $endyear) {
$legend[] = $i;
$i++;
}
@ -152,8 +149,7 @@ if (!$mesg)
$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
if (!$user->rights->societe->client->voir || $user->socid)
{
if (!$user->rights->societe->client->voir || $user->socid) {
$filename_avg = $dir.'/interventionsaverage-'.$user->id.'-'.$year.'.png';
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.'-'.$year.'.png';
} else {
@ -163,12 +159,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
$px3 = new DolGraph();
$mesg = $px3->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px3->SetData($data);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
while ($i <= $endyear) {
$legend[] = $i;
$i++;
}
@ -196,7 +190,9 @@ foreach ($data as $val) {
$arrayyears[$val['year']] = $val['year'];
}
}
if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
if (!count($arrayyears)) {
$arrayyears[$nowyear] = $nowyear;
}
$h = 0;
$head = array();
@ -236,13 +232,19 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
print '<tr><td class="left">'.$langs->trans("Status").'</td><td class="left">';
$tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short
$liststatus = $objectstatic->statuts_short;
if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) {
unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
}
print $form->selectarray('object_status', $liststatus, $object_status, 1, 0, 0, '', 1);
print '</td></tr>';
// Year
print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">';
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
if (!in_array($year, $arrayyears)) {
$arrayyears[$year] = $year;
}
if (!in_array($nowyear, $arrayyears)) {
$arrayyears[$nowyear] = $nowyear;
}
arsort($arrayyears);
print $form->selectarray('year', $arrayyears, $year, 0);
print '</td></tr>';
@ -265,11 +267,9 @@ print '<td class="right">%</td>';
print '</tr>';
$oldyear = 0;
foreach ($data as $val)
{
foreach ($data as $val) {
$year = $val['year'];
while (!empty($year) && $oldyear > $year + 1)
{
while (!empty($year) && $oldyear > $year + 1) {
// If we have empty year
$oldyear--;
@ -307,12 +307,14 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Show graphs
print '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
if ($mesg) { print $mesg; } else {
if ($mesg) {
print $mesg;
} else {
print $px1->show();
/*print "<br>\n";
print $px2->show();
print "<br>\n";
print $px3->show();*/
print $px2->show();
print "<br>\n";
print $px3->show();*/
}
print '</td></tr></table>';

View File

@ -16,8 +16,7 @@
*/
// Protection to avoid direct call of template
if (empty($conf) || !is_object($conf))
{
if (empty($conf) || !is_object($conf)) {
print "Error, template page can't be called as URL";
exit;
}
@ -36,17 +35,18 @@ $langs->load("interventions");
$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
$ilink = 0;
foreach ($linkedObjectBlock as $key => $objectlink)
{
foreach ($linkedObjectBlock as $key => $objectlink) {
$ilink++;
$trclass = 'oddeven';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
$trclass .= ' liste_sub_total';
}
?>
<tr class="<?php echo $trclass; ?>">
<tr class="<?php echo $trclass; ?>">
<td><?php echo $langs->trans("Intervention"); ?></td>
<td><?php echo $objectlink->getNomUrl(1); ?></td>
<td></td>
<td><?php echo $objectlink->getNomUrl(1); ?></td>
<td></td>
<td class="center"><?php echo dol_print_date($objectlink->datev, 'day'); ?></td>
<td></td>
<td class="right"><?php echo $objectlink->getLibStatut(3); ?></td>