';
$MAXEVENT = 10;
-
+
$morehtmlright = '
';
$morehtmlright.= $langs->trans("SeeAll");
$morehtmlright.= '';
-
+
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php
index cea53f610c0..d0097a11647 100644
--- a/htdocs/product/inventory/class/inventory.class.php
+++ b/htdocs/product/inventory/class/inventory.class.php
@@ -51,18 +51,24 @@ class Inventory extends CommonObject
/**
* @var string String with name of icon for inventory
*/
- public $picto = 'inventory';
+ public $picto = 'stock';
/**
- * 'type' if the field format, 'label' the translation key, 'enabled' is a condition when the filed must be managed,
- * 'visible' says if field is visible in list (-1 means not shown by default but can be aded into list to be viewed)
- * 'notnull' if not null in database
- * 'index' if we want an index in database
- * 'position' is the sort order of field
- * 'searchall' is 1 if we want to search in this field when making a search from the quick search button
- * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
- * 'comment' is not used. You can store here any text of your choice.
+ * 'type' if the field format.
+ * 'label' the translation key.
+ * 'enabled' is a condition when the field must be managed.
+ * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
+ * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
+ * 'index' if we want an index in database.
+ * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
+ * 'position' is the sort order of field.
+ * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
+ * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
+ * 'help' is a string visible as a tooltip on field
+ * 'comment' is not used. You can store here any text of your choice. It is not used by application.
+ * 'default' is a default value for creation (can still be replaced by the global setup of default values)
+ * 'showoncombobox' if field must be shown into the label of combobox
*/
// BEGIN MODULEBUILDER PROPERTIES
@@ -150,16 +156,130 @@ class Inventory extends CommonObject
}
+ /**
+ * Create object into database
+ *
+ * @param User $user User that creates
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, Id of created object if OK
+ */
+ public function create(User $user, $notrigger = false)
+ {
+ return $this->createCommon($user, $notrigger);
+ }
+
+ /**
+ * Clone and object into another one
+ *
+ * @param User $user User that creates
+ * @param int $fromid Id of object to clone
+ * @return mixed New object created, <0 if KO
+ */
+ public function createFromClone(User $user, $fromid)
+ {
+ global $hookmanager, $langs;
+ $error = 0;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+
+ $object = new self($this->db);
+
+ $this->db->begin();
+
+ // Load source object
+ $object->fetchCommon($fromid);
+ // Reset some properties
+ unset($object->id);
+ unset($object->fk_user_creat);
+ unset($object->import_key);
+
+ // Clear fields
+ $object->ref = "copy_of_".$object->ref;
+ $object->title = $langs->trans("CopyOf")." ".$object->title;
+ // ...
+
+ // Create clone
+ $object->context['createfromclone'] = 'createfromclone';
+ $result = $object->createCommon($user);
+ if ($result < 0) {
+ $error++;
+ $this->error = $object->error;
+ $this->errors = $object->errors;
+ }
+
+ // End
+ if (!$error) {
+ $this->db->commit();
+ return $object;
+ } else {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+
+ /**
+ * Load object in memory from the database
+ *
+ * @param int $id Id object
+ * @param string $ref Ref
+ * @return int <0 if KO, 0 if not found, >0 if OK
+ */
+ public function fetch($id, $ref = null)
+ {
+ $result = $this->fetchCommon($id, $ref);
+ if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
+ return $result;
+ }
+
+ /**
+ * Load object lines in memory from the database
+ *
+ * @return int <0 if KO, 0 if not found, >0 if OK
+ */
+ /*public function fetchLines()
+ {
+ $this->lines=array();
+
+ // Load lines with object MyObjectLine
+
+ return count($this->lines)?1:0;
+ }*/
+
+ /**
+ * Update object into database
+ *
+ * @param User $user User that modifies
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function update(User $user, $notrigger = false)
+ {
+ return $this->updateCommon($user, $notrigger);
+ }
+
+ /**
+ * Delete object in database
+ *
+ * @param User $user User that deletes
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function delete(User $user, $notrigger = false)
+ {
+ return $this->deleteCommon($user, $notrigger);
+ }
+
/**
* Return a link to the object card (with optionaly the picto)
*
- * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
- * @param string $option On what the link point to
- * @param int $notooltip 1=Disable tooltip
- * @param string $morecss Add more css on link
- * @return string String with URL
+ * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
+ * @param string $option On what the link point to
+ * @param int $notooltip 1=Disable tooltip
+ * @param string $morecss Add more css on link
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @return string String with URL
*/
- function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='')
+ function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
{
global $db, $conf, $langs;
global $dolibarr_main_authentication, $dolibarr_main_demo;
@@ -174,7 +294,7 @@ class Inventory extends CommonObject
$label.= '
';
$label.= '
' . $langs->trans('Ref') . ': ' . $this->ref;
- $url = $url = dol_buildpath('/inventory/m_card.php',1).'?id='.$this->id;
+ $url = dol_buildpath('/product/inventory/card.php',1).'?id='.$this->id;
$linkclose='';
if (empty($notooltip))
@@ -193,12 +313,12 @@ class Inventory extends CommonObject
$linkstart.=$linkclose.'>';
$linkend='';
- if ($withpicto)
- {
- $result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
- if ($withpicto != 2) $result.=' ';
- }
- $result.= $linkstart . $this->ref . $linkend;
+ $result .= $linkstart;
+ if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
+ if ($withpicto != 2) $result.= $this->ref;
+ $result .= $linkend;
+ //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
+
return $result;
}
@@ -217,7 +337,7 @@ class Inventory extends CommonObject
* Return the status
*
* @param int $status Id status
- * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto
+ * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto, 6=Long label + Picto
* @return string Label of status
*/
static function LibStatut($status,$mode=0)
@@ -227,41 +347,101 @@ class Inventory extends CommonObject
if ($mode == 0)
{
$prefix='';
+ if ($status == 0) return $langs->trans('Draft');
if ($status == 1) return $langs->trans('Enabled');
- if ($status == 0) return $langs->trans('Disabled');
+ if ($status == -1) return $langs->trans('Canceled');
}
if ($mode == 1)
{
+ if ($status == 0) return $langs->trans('Draft');
if ($status == 1) return $langs->trans('Enabled');
- if ($status == 0) return $langs->trans('Disabled');
+ if ($status == -1) return $langs->trans('Canceled');
}
if ($mode == 2)
{
+ if ($status == 0) return img_picto($langs->trans('Draft'),'statut5').' '.$langs->trans('Draft');
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
- if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
+ if ($status == -1) return img_picto($langs->trans('Canceled'),'statut6').' '.$langs->trans('Canceled');
}
if ($mode == 3)
{
+ if ($status == 0) return img_picto($langs->trans('Draft'),'statut5');
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
- if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
+ if ($status == -1) return img_picto($langs->trans('Canceled'),'statut6');
}
if ($mode == 4)
{
+ if ($status == 0) return img_picto($langs->trans('Draft'),'statut5').' '.$langs->trans('Draft');
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
- if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
+ if ($status == -1) return img_picto($langs->trans('Canceled'),'statut6').' '.$langs->trans('Canceled');
}
if ($mode == 5)
{
+ if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut5');
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
- if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
+ if ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'),'statut6');
}
if ($mode == 6)
{
+ if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut5');
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
- if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
+ if ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'),'statut6');
}
}
+ /**
+ * Charge les informations d'ordre info dans l'objet commande
+ *
+ * @param int $id Id of order
+ * @return void
+ */
+ function info($id)
+ {
+ $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
+ $sql.= ' fk_user_creat, fk_user_modif';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
+ $sql.= ' WHERE t.rowid = '.$id;
+ $result=$this->db->query($sql);
+ if ($result)
+ {
+ if ($this->db->num_rows($result))
+ {
+ $obj = $this->db->fetch_object($result);
+ $this->id = $obj->rowid;
+ if ($obj->fk_user_author)
+ {
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
+ $this->user_creation = $cuser;
+ }
+
+ if ($obj->fk_user_valid)
+ {
+ $vuser = new User($this->db);
+ $vuser->fetch($obj->fk_user_valid);
+ $this->user_validation = $vuser;
+ }
+
+ if ($obj->fk_user_cloture)
+ {
+ $cluser = new User($this->db);
+ $cluser->fetch($obj->fk_user_cloture);
+ $this->user_cloture = $cluser;
+ }
+
+ $this->date_creation = $this->db->jdate($obj->datec);
+ $this->date_modification = $this->db->jdate($obj->datem);
+ $this->date_validation = $this->db->jdate($obj->datev);
+ }
+
+ $this->db->free($result);
+
+ }
+ else
+ {
+ dol_print_error($this->db);
+ }
+ }
/**
* Initialise object with example values
diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php
index 17f60f22944..7496ae18078 100644
--- a/htdocs/product/inventory/list.php
+++ b/htdocs/product/inventory/list.php
@@ -117,37 +117,37 @@ if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
$parameters=array();
-$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+$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 (empty($reshook))
{
- // Selection of new fields
- include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
+ // 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
- {
- foreach($object->fields as $key => $val)
- {
- $search[$key]='';
- }
- $toselect='';
- $search_array_options=array();
- }
- if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')
- || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha'))
- {
- $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
- }
+ // 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
+ {
+ foreach($object->fields as $key => $val)
+ {
+ $search[$key]='';
+ }
+ $toselect='';
+ $search_array_options=array();
+ }
+ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')
+ || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha'))
+ {
+ $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
+ }
- // Mass actions
- $objectclass='Inventory';
- $objectlabel='Inventory';
- $permtoread = $user->rights->inventory->read;
- $permtodelete = $user->rights->inventory->delete;
- $uploaddir = $conf->inventory->dir_output;
- //include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // TODO to fix for product module
+ // Mass actions
+ $objectclass='Inventory';
+ $objectlabel='Inventory';
+ $permtoread = $user->rights->stock->lire;
+ $permtodelete = $user->rights->stock->supprimer;
+ $uploaddir = $conf->stock->dir_output;
+ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@@ -209,6 +209,21 @@ foreach ($search_array_options as $key => $val)
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
+
+/* If a group by is required
+ $sql.= " GROUP BY "
+ foreach($object->fields as $key => $val)
+ {
+ $sql.='t.'.$key.', ';
+ }
+ // Add fields from extrafields
+ foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : '');
+ // Add where from hooks
+ $parameters=array();
+ $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
+ $sql.=$hookmanager->resPrint;
+ */
+
$sql.=$db->order($sortfield,$sortorder);
// Count total nb of records
@@ -221,7 +236,6 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql.= $db->plimit($limit+1, $offset);
-dol_syslog($script_file, LOG_DEBUG);
$resql=$db->query($sql);
if (! $resql)
{
@@ -283,7 +297,7 @@ $arrayofmassactions = array(
'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
);
-if ($user->rights->inventory->delete) $arrayofmassactions['predelete']=$langs->trans("Delete");
+if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
@@ -445,8 +459,8 @@ while ($i < min($num, $limit))
foreach($object->fields as $key => $val)
{
$align='';
- if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
- if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
+ if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
+ if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked']))
{
@@ -500,9 +514,9 @@ while ($i < min($num, $limit))
}
print '';
if (! $i) $totalarray['nbfield']++;
-
+
print '';
-
+
$i++;
}