Merge pull request #16408 from frederic34/categ_codesyntax
code syntax categorie collab directory
This commit is contained in:
commit
563a9bd7ec
@ -27,8 +27,9 @@ require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
|
||||
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("categories", "admin"));
|
||||
@ -40,11 +41,9 @@ $action = GETPOST('action', 'aZ09');
|
||||
*/
|
||||
|
||||
$reg = array();
|
||||
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
||||
{
|
||||
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
|
||||
$code = $reg[1];
|
||||
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
@ -52,11 +51,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
|
||||
{
|
||||
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
|
||||
$code = $reg[1];
|
||||
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
|
||||
{
|
||||
if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
@ -100,12 +97,10 @@ print '<td>'.$langs->trans("CategorieRecursiv").'</td>';
|
||||
print '<td align="center" width="20">'.$form->textwithpicto('', $langs->trans("CategorieRecursivHelp"), 1, 'help').'</td>';
|
||||
|
||||
print '<td align="center" width="100">';
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print ajax_constantonoff('CATEGORIE_RECURSIV_ADD');
|
||||
} else {
|
||||
if (empty($conf->global->CATEGORIE_RECURSIV_ADD))
|
||||
{
|
||||
if (empty($conf->global->CATEGORIE_RECURSIV_ADD)) {
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_CATEGORIE_RECURSIV_ADD">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||
} else {
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_CATEGORIE_RECURSIV_ADD">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
|
||||
|
||||
@ -37,13 +37,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 = 'categorie'; //Must be the $element of the class that manage extrafield
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -76,8 +80,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>";
|
||||
@ -90,8 +93,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'));
|
||||
|
||||
@ -103,8 +105,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));
|
||||
|
||||
|
||||
@ -37,14 +37,16 @@ $langs->load("categories");
|
||||
|
||||
// Security check
|
||||
$socid = (int) GETPOST('socid', 'int');
|
||||
if (!$user->rights->categorie->lire) accessforbidden();
|
||||
if (!$user->rights->categorie->lire) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$origin = GETPOST('origin', 'alpha');
|
||||
$catorigin = (int) GETPOST('catorigin', 'int');
|
||||
$type = GETPOST('type', 'aZ09');
|
||||
$urlfrom = GETPOST('urlfrom', 'alpha');
|
||||
$type = GETPOST('type', 'aZ09');
|
||||
$urlfrom = GETPOST('urlfrom', 'alpha');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
$label = (string) GETPOST('label', 'alphanohtml');
|
||||
@ -54,15 +56,29 @@ $visible = (int) GETPOST('visible', 'int');
|
||||
$parent = (int) GETPOST('parent', 'int');
|
||||
|
||||
if ($origin) {
|
||||
if ($type == Categorie::TYPE_PRODUCT) $idProdOrigin = $origin;
|
||||
if ($type == Categorie::TYPE_SUPPLIER) $idSupplierOrigin = $origin;
|
||||
if ($type == Categorie::TYPE_CUSTOMER) $idCompanyOrigin = $origin;
|
||||
if ($type == Categorie::TYPE_MEMBER) $idMemberOrigin = $origin;
|
||||
if ($type == Categorie::TYPE_CONTACT) $idContactOrigin = $origin;
|
||||
if ($type == Categorie::TYPE_PROJECT) $idProjectOrigin = $origin;
|
||||
if ($type == Categorie::TYPE_PRODUCT) {
|
||||
$idProdOrigin = $origin;
|
||||
}
|
||||
if ($type == Categorie::TYPE_SUPPLIER) {
|
||||
$idSupplierOrigin = $origin;
|
||||
}
|
||||
if ($type == Categorie::TYPE_CUSTOMER) {
|
||||
$idCompanyOrigin = $origin;
|
||||
}
|
||||
if ($type == Categorie::TYPE_MEMBER) {
|
||||
$idMemberOrigin = $origin;
|
||||
}
|
||||
if ($type == Categorie::TYPE_CONTACT) {
|
||||
$idContactOrigin = $origin;
|
||||
}
|
||||
if ($type == Categorie::TYPE_PROJECT) {
|
||||
$idProjectOrigin = $origin;
|
||||
}
|
||||
}
|
||||
|
||||
if ($catorigin && $type == Categorie::TYPE_PRODUCT) $idCatOrigin = $catorigin;
|
||||
if ($catorigin && $type == Categorie::TYPE_PRODUCT) {
|
||||
$idCatOrigin = $catorigin;
|
||||
}
|
||||
|
||||
$object = new Categorie($db);
|
||||
|
||||
@ -80,13 +96,10 @@ $error = 0;
|
||||
*/
|
||||
|
||||
// Add action
|
||||
if ($action == 'add' && $user->rights->categorie->creer)
|
||||
{
|
||||
if ($action == 'add' && $user->rights->categorie->creer) {
|
||||
// Action ajout d'une categorie
|
||||
if ($cancel)
|
||||
{
|
||||
if ($urlfrom)
|
||||
{
|
||||
if ($cancel) {
|
||||
if ($urlfrom) {
|
||||
header("Location: ".$urlfrom);
|
||||
exit;
|
||||
} elseif ($backtopage) {
|
||||
@ -125,24 +138,25 @@ if ($action == 'add' && $user->rights->categorie->creer)
|
||||
$object->visible = $visible;
|
||||
$object->type = $type;
|
||||
|
||||
if ($parent != "-1") $object->fk_parent = $parent;
|
||||
if ($parent != "-1") {
|
||||
$object->fk_parent = $parent;
|
||||
}
|
||||
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||
if ($ret < 0) $error++;
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$object->label)
|
||||
{
|
||||
if (!$object->label) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
// Create category in database
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$result = $object->create($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$action = 'confirmed';
|
||||
$_POST["addcat"] = '';
|
||||
} else {
|
||||
@ -152,41 +166,31 @@ if ($action == 'add' && $user->rights->categorie->creer)
|
||||
}
|
||||
|
||||
// Confirm action
|
||||
if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->creer)
|
||||
{
|
||||
if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->creer) {
|
||||
// Action confirmation de creation categorie
|
||||
if ($action == 'confirmed')
|
||||
{
|
||||
if ($urlfrom)
|
||||
{
|
||||
if ($action == 'confirmed') {
|
||||
if ($urlfrom) {
|
||||
header("Location: ".$urlfrom);
|
||||
exit;
|
||||
} elseif ($backtopage)
|
||||
{
|
||||
} elseif ($backtopage) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
} elseif ($idProdOrigin)
|
||||
{
|
||||
} elseif ($idProdOrigin) {
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated")));
|
||||
exit;
|
||||
} elseif ($idCompanyOrigin)
|
||||
{
|
||||
} elseif ($idCompanyOrigin) {
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCompanyOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated")));
|
||||
exit;
|
||||
} elseif ($idSupplierOrigin)
|
||||
{
|
||||
} elseif ($idSupplierOrigin) {
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idSupplierOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated")));
|
||||
exit;
|
||||
} elseif ($idMemberOrigin)
|
||||
{
|
||||
} elseif ($idMemberOrigin) {
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated")));
|
||||
exit;
|
||||
} elseif ($idContactOrigin)
|
||||
{
|
||||
} elseif ($idContactOrigin) {
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated")));
|
||||
exit;
|
||||
} elseif ($idProjectOrigin)
|
||||
{
|
||||
} elseif ($idProjectOrigin) {
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated")));
|
||||
exit;
|
||||
}
|
||||
@ -207,11 +211,9 @@ $formother = new FormOther($db);
|
||||
$helpurl = '';
|
||||
llxHeader("", $langs->trans("Categories"), $helpurl);
|
||||
|
||||
if ($user->rights->categorie->creer)
|
||||
{
|
||||
if ($user->rights->categorie->creer) {
|
||||
// Create or add
|
||||
if ($action == 'create' || GETPOST("addcat") == 'addcat')
|
||||
{
|
||||
if ($action == 'create' || GETPOST("addcat") == 'addcat') {
|
||||
dol_set_focus('#label');
|
||||
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].'?type='.$type.'" method="POST">';
|
||||
@ -222,8 +224,12 @@ if ($user->rights->categorie->creer)
|
||||
print '<input type="hidden" name="id" value="'.GETPOST('origin', 'alpha').'">';
|
||||
print '<input type="hidden" name="type" value="'.$type.'">';
|
||||
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||
if ($origin) print '<input type="hidden" name="origin" value="'.$origin.'">';
|
||||
if ($catorigin) print '<input type="hidden" name="catorigin" value="'.$catorigin.'">';
|
||||
if ($origin) {
|
||||
print '<input type="hidden" name="origin" value="'.$origin.'">';
|
||||
}
|
||||
if ($catorigin) {
|
||||
print '<input type="hidden" name="catorigin" value="'.$catorigin.'">';
|
||||
}
|
||||
|
||||
print load_fiche_titre($langs->trans("CreateCat"));
|
||||
|
||||
@ -257,8 +263,7 @@ if ($user->rights->categorie->creer)
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
print $object->showOptionals($extrafields, 'edit', $parameters);
|
||||
}
|
||||
|
||||
|
||||
@ -140,15 +140,12 @@ class Categories extends DolibarrApi
|
||||
$sql = "SELECT t.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."categorie as t";
|
||||
$sql .= ' WHERE t.entity IN ('.getEntity('category').')';
|
||||
if (!empty($type))
|
||||
{
|
||||
if (!empty($type)) {
|
||||
$sql .= ' AND t.type='.array_search($type, Categories::$TYPES);
|
||||
}
|
||||
// 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 = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -157,8 +154,7 @@ class Categories extends DolibarrApi
|
||||
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
{
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
@ -167,13 +163,11 @@ class Categories extends DolibarrApi
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$i = 0;
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
while ($i < $min)
|
||||
{
|
||||
while ($i < $min) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$category_static = new Categorie($this->db);
|
||||
if ($category_static->fetch($obj->rowid)) {
|
||||
@ -181,8 +175,7 @@ class Categories extends DolibarrApi
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
@ -238,7 +231,9 @@ class Categories extends DolibarrApi
|
||||
}
|
||||
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field == 'id') continue;
|
||||
if ($field == 'id') {
|
||||
continue;
|
||||
}
|
||||
$this->category->$field = $value;
|
||||
}
|
||||
|
||||
@ -721,8 +716,9 @@ class Categories extends DolibarrApi
|
||||
{
|
||||
$category = array();
|
||||
foreach (Categories::$FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
if (!isset($data[$field])) {
|
||||
throw new RestException(400, "$field field missing");
|
||||
}
|
||||
$category[$field] = $data[$field];
|
||||
}
|
||||
return $category;
|
||||
@ -747,8 +743,7 @@ class Categories extends DolibarrApi
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
if (empty($type))
|
||||
{
|
||||
if (empty($type)) {
|
||||
throw new RestException(500, 'The "type" parameter is required.');
|
||||
}
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ class Categorie extends CommonObject
|
||||
8 => 'bank_line',
|
||||
9 => 'warehouse',
|
||||
10 => 'actioncomm',
|
||||
11 => 'website_page'
|
||||
11 => 'website_page'
|
||||
);
|
||||
|
||||
/**
|
||||
@ -197,7 +197,7 @@ class Categorie extends CommonObject
|
||||
/**
|
||||
* @var string Category label
|
||||
*/
|
||||
public $label;
|
||||
public $label;
|
||||
|
||||
/**
|
||||
* @var string description
|
||||
@ -231,9 +231,9 @@ class Categorie extends CommonObject
|
||||
* @see Categorie::TYPE_PROJECT
|
||||
* @see Categorie::TYPE_ACCOUNT
|
||||
* @see Categorie::TYPE_BANK_LINE
|
||||
* @see Categorie::TYPE_WAREHOUSE
|
||||
* @see Categorie::TYPE_ACTIONCOMM
|
||||
* @see Categorie::TYPE_WEBSITE_PAGE
|
||||
* @see Categorie::TYPE_WAREHOUSE
|
||||
* @see Categorie::TYPE_ACTIONCOMM
|
||||
* @see Categorie::TYPE_WEBSITE_PAGE
|
||||
*/
|
||||
public $type;
|
||||
|
||||
@ -266,9 +266,9 @@ class Categorie extends CommonObject
|
||||
$mapList = $hookmanager->resArray;
|
||||
$mapId = $mapList['id'];
|
||||
$mapCode = $mapList['code'];
|
||||
self::$MAP_ID_TO_CODE[$mapId] = $mapCode;
|
||||
$this->MAP_ID[$mapCode] = $mapId;
|
||||
$this->MAP_CAT_FK[$mapCode] = $mapList['cat_fk'];
|
||||
self::$MAP_ID_TO_CODE[$mapId] = $mapCode;
|
||||
$this->MAP_ID[$mapCode] = $mapId;
|
||||
$this->MAP_CAT_FK[$mapCode] = $mapList['cat_fk'];
|
||||
$this->MAP_CAT_TABLE[$mapCode] = $mapList['cat_table'];
|
||||
$this->MAP_OBJ_CLASS[$mapCode] = $mapList['obj_class'];
|
||||
$this->MAP_OBJ_TABLE[$mapCode] = $mapList['obj_table'];
|
||||
@ -313,8 +313,12 @@ class Categorie extends CommonObject
|
||||
global $conf;
|
||||
|
||||
// Check parameters
|
||||
if (empty($id) && empty($label) && empty($ref_ext)) return -1;
|
||||
if (!is_null($type) && !is_numeric($type)) $type = $this->MAP_ID[$type];
|
||||
if (empty($id) && empty($label) && empty($ref_ext)) {
|
||||
return -1;
|
||||
}
|
||||
if (!is_null($type) && !is_numeric($type)) {
|
||||
$type = $this->MAP_ID[$type];
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext";
|
||||
$sql .= ", date_creation, tms, fk_user_creat, fk_user_modif";
|
||||
@ -325,7 +329,9 @@ class Categorie extends CommonObject
|
||||
$sql .= " WHERE ref_ext LIKE '".$this->db->escape($ref_ext)."'";
|
||||
} else {
|
||||
$sql .= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")";
|
||||
if (!is_null($type)) $sql .= " AND type = ".((int) $type);
|
||||
if (!is_null($type)) {
|
||||
$sql .= " AND type = ".((int) $type);
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
@ -357,7 +363,9 @@ class Categorie extends CommonObject
|
||||
$this->db->free($resql);
|
||||
|
||||
// multilangs
|
||||
if (!empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs();
|
||||
if (!empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$this->getMultiLangs();
|
||||
}
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
@ -387,7 +395,9 @@ class Categorie extends CommonObject
|
||||
|
||||
$type = $this->type;
|
||||
|
||||
if (!is_numeric($type)) $type = $this->MAP_ID[$type];
|
||||
if (!is_numeric($type)) {
|
||||
$type = $this->MAP_ID[$type];
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
@ -399,7 +409,9 @@ class Categorie extends CommonObject
|
||||
$this->color = trim($this->color);
|
||||
$this->import_key = trim($this->import_key);
|
||||
$this->ref_ext = trim($this->ref_ext);
|
||||
if (empty($this->visible)) $this->visible = 0;
|
||||
if (empty($this->visible)) {
|
||||
$this->visible = 0;
|
||||
}
|
||||
$this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0);
|
||||
|
||||
if ($this->already_exists()) {
|
||||
@ -463,7 +475,9 @@ class Categorie extends CommonObject
|
||||
if (!$error) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('CATEGORY_CREATE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -542,7 +556,9 @@ class Categorie extends CommonObject
|
||||
if (!$error) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('CATEGORY_MODIFY', $user);
|
||||
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
|
||||
if ($result < 0) {
|
||||
$error++; $this->db->rollback(); return -1;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -579,7 +595,9 @@ class Categorie extends CommonObject
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('CATEGORY_DELETE', $user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -649,9 +667,13 @@ class Categorie extends CommonObject
|
||||
|
||||
$error = 0;
|
||||
|
||||
if ($this->id == -1) return -2;
|
||||
if ($this->id == -1) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (empty($type)) $type = $obj->element;
|
||||
if (empty($type)) {
|
||||
$type = $obj->element;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -699,7 +721,9 @@ class Categorie extends CommonObject
|
||||
// Call trigger
|
||||
$this->context = array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger
|
||||
$result = $this->call_trigger('CATEGORY_LINK', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
|
||||
if (!$error) {
|
||||
@ -757,7 +781,9 @@ class Categorie extends CommonObject
|
||||
// Call trigger
|
||||
$this->context = array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger
|
||||
$result = $this->call_trigger('CATEGORY_UNLINK', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
|
||||
if (!$error) {
|
||||
@ -805,7 +831,9 @@ class Categorie extends CommonObject
|
||||
if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) {
|
||||
$sql .= " AND o.rowid = ".$user->socid;
|
||||
}
|
||||
if ($limit > 0 || $offset > 0) $sql .= $this->db->plimit($limit + 1, $offset);
|
||||
if ($limit > 0 || $offset > 0) {
|
||||
$sql .= $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
dol_syslog(get_class($this)."::getObjectsInCateg", LOG_DEBUG);
|
||||
@ -1037,7 +1065,9 @@ class Categorie extends CommonObject
|
||||
// phpcs:enable
|
||||
global $conf, $langs;
|
||||
|
||||
if (!is_numeric($type)) $type = $this->MAP_ID[$type];
|
||||
if (!is_numeric($type)) {
|
||||
$type = $this->MAP_ID[$type];
|
||||
}
|
||||
if (is_null($type)) {
|
||||
$this->error = 'BadValueForParameterType';
|
||||
return -1;
|
||||
@ -1063,9 +1093,13 @@ class Categorie extends CommonObject
|
||||
|
||||
// Init $this->cats array
|
||||
$sql = "SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates
|
||||
if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= ", t.label as label_trans, t.description as description_trans";
|
||||
if (!empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$sql .= ", t.label as label_trans, t.description as description_trans";
|
||||
}
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."categorie as c";
|
||||
if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$this->db->escape($current_lang)."'";
|
||||
if (!empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$this->db->escape($current_lang)."'";
|
||||
}
|
||||
$sql .= " WHERE c.entity IN (".getEntity('category').")";
|
||||
$sql .= " AND c.type = ".(int) $type;
|
||||
|
||||
@ -1204,14 +1238,18 @@ class Categorie extends CommonObject
|
||||
public function get_all_categories($type = null, $parent = false)
|
||||
{
|
||||
// phpcs:enable
|
||||
if (!is_numeric($type)) $type = $this->MAP_ID[$type];
|
||||
if (!is_numeric($type)) {
|
||||
$type = $this->MAP_ID[$type];
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
|
||||
$sql .= " WHERE entity IN (".getEntity('category').")";
|
||||
if (!is_null($type))
|
||||
if (!is_null($type)) {
|
||||
$sql .= " AND type = ".(int) $type;
|
||||
if ($parent)
|
||||
}
|
||||
if ($parent) {
|
||||
$sql .= " AND fk_parent = 0";
|
||||
}
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
if ($res) {
|
||||
@ -1252,7 +1290,9 @@ class Categorie extends CommonObject
|
||||
// phpcs:enable
|
||||
$type = $this->type;
|
||||
|
||||
if (!is_numeric($type)) $type = $this->MAP_ID[$type];
|
||||
if (!is_numeric($type)) {
|
||||
$type = $this->MAP_ID[$type];
|
||||
}
|
||||
|
||||
/* We have to select any rowid from llx_categorie which category's mother and label
|
||||
* are equals to those of the calling category
|
||||
@ -1318,7 +1358,9 @@ class Categorie extends CommonObject
|
||||
// Check contrast with background and correct text color
|
||||
$forced_color = 'categtextwhite';
|
||||
if ($cat->color) {
|
||||
if (colorIsLight($cat->color)) $forced_color = 'categtextblack';
|
||||
if (colorIsLight($cat->color)) {
|
||||
$forced_color = 'categtextblack';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1399,8 +1441,9 @@ class Categorie extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (count($ways) == 0)
|
||||
if (count($ways) == 0) {
|
||||
$ways[0][0] = $this;
|
||||
}
|
||||
|
||||
return $ways;
|
||||
}
|
||||
@ -1419,7 +1462,9 @@ class Categorie extends CommonObject
|
||||
{
|
||||
$cats = array();
|
||||
|
||||
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type];
|
||||
if (is_numeric($type)) {
|
||||
$type = Categorie::$MAP_ID_TO_CODE[$type];
|
||||
}
|
||||
|
||||
if ($type === Categorie::TYPE_BANK_LINE) { // TODO Remove this with standard category code after migration of llx_bank_categ into llx_categorie
|
||||
// Load bank categories
|
||||
@ -1509,11 +1554,14 @@ class Categorie extends CommonObject
|
||||
$sql .= " WHERE type = ".$this->MAP_ID[$type];
|
||||
$sql .= " AND entity IN (".getEntity('category').")";
|
||||
if ($nom) {
|
||||
if (!$exact)
|
||||
if (!$exact) {
|
||||
$nom = '%'.str_replace('*', '%', $nom).'%';
|
||||
if (!$case)
|
||||
}
|
||||
if (!$case) {
|
||||
$sql .= " AND label LIKE '".$this->db->escape($nom)."'";
|
||||
else $sql .= " AND label LIKE BINARY '".$this->db->escape($nom)."'";
|
||||
} else {
|
||||
$sql .= " AND label LIKE BINARY '".$this->db->escape($nom)."'";
|
||||
}
|
||||
}
|
||||
if ($id) {
|
||||
$sql .= " AND rowid = '".$id."'";
|
||||
@ -1554,7 +1602,9 @@ class Categorie extends CommonObject
|
||||
// Check contrast with background and correct text color
|
||||
$forced_color = 'categtextwhite';
|
||||
if ($this->color) {
|
||||
if (colorIsLight($this->color)) $forced_color = 'categtextblack';
|
||||
if (colorIsLight($this->color)) {
|
||||
$forced_color = 'categtextblack';
|
||||
}
|
||||
}
|
||||
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.$moreparam.'&backtopage='.urlencode($_SERVER['PHP_SELF'].($moreparam ? '?'.$moreparam : '')).'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip '.$forced_color.'">';
|
||||
@ -1563,9 +1613,15 @@ class Categorie extends CommonObject
|
||||
$picto = 'category';
|
||||
|
||||
|
||||
if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
|
||||
if ($withpicto && $withpicto != 2) $result .= ' ';
|
||||
if ($withpicto != 2) $result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend;
|
||||
if ($withpicto) {
|
||||
$result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
|
||||
}
|
||||
if ($withpicto && $withpicto != 2) {
|
||||
$result .= ' ';
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -1653,13 +1709,18 @@ class Categorie extends CommonObject
|
||||
// Objet
|
||||
$obj = array();
|
||||
$obj['photo'] = $photo;
|
||||
if ($photo_vignette && is_file($dirthumb.$photo_vignette)) $obj['photo_vignette'] = 'thumbs/'.$photo_vignette;
|
||||
else $obj['photo_vignette'] = "";
|
||||
if ($photo_vignette && is_file($dirthumb.$photo_vignette)) {
|
||||
$obj['photo_vignette'] = 'thumbs/'.$photo_vignette;
|
||||
} else {
|
||||
$obj['photo_vignette'] = "";
|
||||
}
|
||||
|
||||
$tabobj[$nbphoto - 1] = $obj;
|
||||
|
||||
// On continue ou on arrete de boucler
|
||||
if ($nbmax && $nbphoto >= $nbmax) break;
|
||||
if ($nbmax && $nbphoto >= $nbmax) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1764,8 +1825,9 @@ class Categorie extends CommonObject
|
||||
}
|
||||
|
||||
// on ne sauvegarde pas des champs vides
|
||||
if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"])
|
||||
if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"]) {
|
||||
dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG);
|
||||
}
|
||||
if (!$this->db->query($sql2)) {
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
@ -1876,7 +1938,9 @@ class Categorie extends CommonObject
|
||||
*/
|
||||
public static function getFilterJoinQuery($type, $rowIdName)
|
||||
{
|
||||
if ($type == 'bank_account') $type = 'account';
|
||||
if ($type == 'bank_account') {
|
||||
$type = 'account';
|
||||
}
|
||||
|
||||
return " LEFT JOIN ".MAIN_DB_PREFIX."categorie_".$type." as cp ON ".$rowIdName." = cp.fk_".$type;
|
||||
}
|
||||
@ -1891,7 +1955,9 @@ class Categorie extends CommonObject
|
||||
*/
|
||||
public static function getFilterSelectQuery($type, $rowIdName, $searchList)
|
||||
{
|
||||
if ($type == 'bank_account') $type = 'account';
|
||||
if ($type == 'bank_account') {
|
||||
$type = 'account';
|
||||
}
|
||||
|
||||
if (empty($searchList) && !is_array($searchList)) {
|
||||
return "";
|
||||
|
||||
@ -62,7 +62,9 @@ if ($result <= 0) {
|
||||
}
|
||||
|
||||
$type = $object->type;
|
||||
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
if (is_numeric($type)) {
|
||||
$type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
}
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
@ -90,7 +92,7 @@ if ($cancel) {
|
||||
// Action mise a jour d'une categorie
|
||||
if ($action == 'update' && $user->rights->categorie->creer) {
|
||||
$object->oldcopy = dol_clone($object);
|
||||
$object->label = $label;
|
||||
$object->label = $label;
|
||||
$object->description = dol_htmlcleanlastbr($description);
|
||||
$object->color = $color;
|
||||
$object->socid = ($socid > 0 ? $socid : 0);
|
||||
@ -105,10 +107,11 @@ if ($action == 'update' && $user->rights->categorie->creer) {
|
||||
}
|
||||
if (!$error && empty($object->error)) {
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||
if ($ret < 0) $error++;
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error && $object->update($user) > 0)
|
||||
{
|
||||
if (!$error && $object->update($user) > 0) {
|
||||
if ($backtopage) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
|
||||
@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
// Load translation files required by the page
|
||||
$langs->load("categories");
|
||||
|
||||
if (!$user->rights->categorie->lire) accessforbidden();
|
||||
if (!$user->rights->categorie->lire) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$id = GETPOST('id', 'int');
|
||||
$type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT);
|
||||
@ -42,7 +44,9 @@ $catname = GETPOST('catname', 'alpha');
|
||||
$nosearch = GETPOST('nosearch', 'int');
|
||||
|
||||
$categstatic = new Categorie($db);
|
||||
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
if (is_numeric($type)) {
|
||||
$type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -54,11 +58,15 @@ $form = new Form($db);
|
||||
$moreparam = ($nosearch ? '&nosearch=1' : '');
|
||||
|
||||
$typetext = $type;
|
||||
if ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans('AccountsCategoriesArea');
|
||||
elseif ($type == Categorie::TYPE_WAREHOUSE) $title = $langs->trans('StocksCategoriesArea');
|
||||
elseif ($type == Categorie::TYPE_ACTIONCOMM) $title = $langs->trans('ActionCommCategoriesArea');
|
||||
elseif ($type == Categorie::TYPE_WEBSITE_PAGE) $title = $langs->trans('WebsitePagesCategoriesArea');
|
||||
else {
|
||||
if ($type == Categorie::TYPE_ACCOUNT) {
|
||||
$title = $langs->trans('AccountsCategoriesArea');
|
||||
} elseif ($type == Categorie::TYPE_WAREHOUSE) {
|
||||
$title = $langs->trans('StocksCategoriesArea');
|
||||
} elseif ($type == Categorie::TYPE_ACTIONCOMM) {
|
||||
$title = $langs->trans('ActionCommCategoriesArea');
|
||||
} elseif ($type == Categorie::TYPE_WEBSITE_PAGE) {
|
||||
$title = $langs->trans('WebsitePagesCategoriesArea');
|
||||
} else {
|
||||
$title = $langs->trans(ucfirst($type).'sCategoriesArea');
|
||||
}
|
||||
|
||||
@ -100,15 +108,13 @@ if (empty($nosearch)) {
|
||||
/*
|
||||
* Categories found
|
||||
*/
|
||||
if ($catname || $id > 0)
|
||||
{
|
||||
if ($catname || $id > 0) {
|
||||
$cats = $categstatic->rechercher($id, $catname, $typetext);
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("FoundCats").'</td></tr>';
|
||||
|
||||
foreach ($cats as $cat)
|
||||
{
|
||||
foreach ($cats as $cat) {
|
||||
$color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"';
|
||||
|
||||
print "\t".'<tr class="oddeven">'."\n";
|
||||
@ -128,7 +134,9 @@ if (empty($nosearch)) {
|
||||
print "\t</tr>\n";
|
||||
}
|
||||
print "</table>";
|
||||
} else print ' ';
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
|
||||
print '</div></div>';
|
||||
}
|
||||
@ -143,19 +151,25 @@ $cate_arbo = $categstatic->get_full_arbo($typetext);
|
||||
$fulltree = $cate_arbo;
|
||||
|
||||
// Load possible missing includes
|
||||
if ($conf->global->CATEGORY_SHOW_COUNTS)
|
||||
{
|
||||
if ($type == Categorie::TYPE_MEMBER) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
if ($type == Categorie::TYPE_ACCOUNT) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
if ($type == Categorie::TYPE_PROJECT) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
if ($type == Categorie::TYPE_USER) require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
if ($conf->global->CATEGORY_SHOW_COUNTS) {
|
||||
if ($type == Categorie::TYPE_MEMBER) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
}
|
||||
if ($type == Categorie::TYPE_ACCOUNT) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
}
|
||||
if ($type == Categorie::TYPE_PROJECT) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
}
|
||||
if ($type == Categorie::TYPE_USER) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
}
|
||||
}
|
||||
|
||||
// Define data (format for treeview)
|
||||
$data = array();
|
||||
$data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>'');
|
||||
foreach ($fulltree as $key => $val)
|
||||
{
|
||||
foreach ($fulltree as $key => $val) {
|
||||
$categstatic->id = $val['id'];
|
||||
$categstatic->ref = $val['label'];
|
||||
$categstatic->color = $val['color'];
|
||||
@ -163,8 +177,7 @@ foreach ($fulltree as $key => $val)
|
||||
$desc = dol_htmlcleanlastbr($val['description']);
|
||||
|
||||
$counter = '';
|
||||
if ($conf->global->CATEGORY_SHOW_COUNTS)
|
||||
{
|
||||
if ($conf->global->CATEGORY_SHOW_COUNTS) {
|
||||
// we need only a count of the elements, so it is enough to consume only the id's from the database
|
||||
$elements = $type == Categorie::TYPE_ACCOUNT
|
||||
? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account"
|
||||
@ -206,15 +219,13 @@ foreach ($fulltree as $key => $val)
|
||||
|
||||
print '<table class="liste nohover" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Categories").'</td><td></td><td class="right">';
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
{
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
print '<div id="iddivjstreecontrol"><a class="notasortlink" href="#">'.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").'</a> | <a class="notasortlink" href="#">'.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").'</a></div>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
$nbofentries = (count($data) - 1);
|
||||
if ($nbofentries > 0)
|
||||
{
|
||||
if ($nbofentries > 0) {
|
||||
print '<tr class="pair"><td colspan="3">';
|
||||
tree_recur($data, $data[0], 0);
|
||||
print '</td></tr>';
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
/**
|
||||
* \file htdocs/categories/info.php
|
||||
* \ingroup categories
|
||||
* \brief Category info page
|
||||
* \brief Category info page
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
@ -40,7 +40,9 @@ $id = GETPOST('id', 'int');
|
||||
$label = GETPOST('label', 'alpha');
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'categorie', $id, '&category');
|
||||
|
||||
$object = new Categorie($db);
|
||||
@ -50,7 +52,9 @@ if ($result <= 0) {
|
||||
}
|
||||
|
||||
$type = $object->type;
|
||||
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
if (is_numeric($type)) {
|
||||
$type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
|
||||
@ -38,11 +38,10 @@ $langs->loadlangs(array('categories', 'bills'));
|
||||
|
||||
$id = GETPOST('id', 'int');
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$confirm = GETPOST('confirm');
|
||||
|
||||
if ($id == '' && $label == '')
|
||||
{
|
||||
if ($id == '' && $label == '') {
|
||||
dol_print_error('', 'Missing parameter id');
|
||||
exit();
|
||||
}
|
||||
@ -57,7 +56,9 @@ if ($result <= 0) {
|
||||
}
|
||||
|
||||
$type = $object->type;
|
||||
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
if (is_numeric($type)) {
|
||||
$type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
}
|
||||
|
||||
$upload_dir = $conf->categorie->multidir_output[$object->entity];
|
||||
|
||||
@ -65,16 +66,12 @@ $upload_dir = $conf->categorie->multidir_output[$object->entity];
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) {
|
||||
if ($object->id) {
|
||||
$file = $_FILES['userfile'];
|
||||
if (is_array($file['name']) && count($file['name']) > 0)
|
||||
{
|
||||
foreach ($file['name'] as $i => $name)
|
||||
{
|
||||
if (empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i]))
|
||||
{
|
||||
if (is_array($file['name']) && count($file['name']) > 0) {
|
||||
foreach ($file['name'] as $i => $name) {
|
||||
if (empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i])) {
|
||||
setEventMessage($file['name'][$i].' : '.$langs->trans(empty($file['tmp_name'][$i]) ? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles'));
|
||||
unset($file['name'][$i], $file['type'][$i], $file['tmp_name'][$i], $file['error'][$i], $file['size'][$i]);
|
||||
}
|
||||
@ -87,13 +84,11 @@ if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sen
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->rights->categorie->creer)
|
||||
{
|
||||
if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->rights->categorie->creer) {
|
||||
$object->delete_photo($upload_dir."/".$_GET["file"]);
|
||||
}
|
||||
|
||||
if ($action == 'addthumb' && $_GET["file"])
|
||||
{
|
||||
if ($action == 'addthumb' && $_GET["file"]) {
|
||||
$object->addThumbs($upload_dir."/".$_GET["file"]);
|
||||
}
|
||||
|
||||
@ -107,8 +102,7 @@ llxHeader("", "", $langs->trans("Categories"));
|
||||
$form = new Form($db);
|
||||
$formother = new FormOther($db);
|
||||
|
||||
if ($object->id)
|
||||
{
|
||||
if ($object->id) {
|
||||
$title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
|
||||
|
||||
$head = categories_prepare_head($object, $type);
|
||||
@ -119,8 +113,7 @@ if ($object->id)
|
||||
$object->ref = $object->label;
|
||||
$morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
|
||||
$ways = $object->print_all_ways(" >> ", '', 1);
|
||||
foreach ($ways as $way)
|
||||
{
|
||||
foreach ($ways as $way) {
|
||||
$morehtmlref .= $way."<br>\n";
|
||||
}
|
||||
$morehtmlref .= '</div>';
|
||||
@ -130,8 +123,7 @@ if ($object->id)
|
||||
/*
|
||||
* Confirmation de la suppression de photo
|
||||
*/
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1);
|
||||
}
|
||||
|
||||
@ -168,10 +160,8 @@ if ($object->id)
|
||||
|
||||
print '<div class="tabsAction">'."\n";
|
||||
|
||||
if ($action != 'ajout_photo' && $user->rights->categorie->creer)
|
||||
{
|
||||
if (!empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
if ($action != 'ajout_photo' && $user->rights->categorie->creer) {
|
||||
if (!empty($conf->global->MAIN_UPLOAD_DOC)) {
|
||||
print '<a class="butAction hideonsmartphone" href="'.$_SERVER['PHP_SELF'].'?action=ajout_photo&id='.$object->id.'&type='.$type.'">';
|
||||
print $langs->trans("AddPhoto").'</a>';
|
||||
} else {
|
||||
@ -185,16 +175,14 @@ if ($object->id)
|
||||
/*
|
||||
* Ajouter une photo
|
||||
*/
|
||||
if ($action == 'ajout_photo' && $user->rights->categorie->creer && !empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
if ($action == 'ajout_photo' && $user->rights->categorie->creer && !empty($conf->global->MAIN_UPLOAD_DOC)) {
|
||||
// Affiche formulaire upload
|
||||
$formfile = new FormFile($db);
|
||||
$formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&type='.$type, $langs->trans("AddPhoto"), 1, '', $user->rights->categorie->creer, 50, $object, '', false, '', 0);
|
||||
}
|
||||
|
||||
// Affiche photos
|
||||
if ($action != 'ajout_photo')
|
||||
{
|
||||
if ($action != 'ajout_photo') {
|
||||
$nbphoto = 0;
|
||||
$nbbyrow = 5;
|
||||
|
||||
@ -206,23 +194,24 @@ if ($object->id)
|
||||
|
||||
$listofphoto = $object->liste_photos($dir);
|
||||
|
||||
if (is_array($listofphoto) && count($listofphoto))
|
||||
{
|
||||
if (is_array($listofphoto) && count($listofphoto)) {
|
||||
print '<br>';
|
||||
print '<table width="100%" valign="top" align="center">';
|
||||
|
||||
foreach ($listofphoto as $key => $obj)
|
||||
{
|
||||
foreach ($listofphoto as $key => $obj) {
|
||||
$nbphoto++;
|
||||
|
||||
if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>';
|
||||
if ($nbbyrow) print '<td width="'.ceil(100 / $nbbyrow).'%" class="photo">';
|
||||
if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) {
|
||||
print '<tr align=center valign=middle border=1>';
|
||||
}
|
||||
if ($nbbyrow) {
|
||||
print '<td width="'.ceil(100 / $nbbyrow).'%" class="photo">';
|
||||
}
|
||||
|
||||
print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">';
|
||||
|
||||
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
|
||||
if ($obj['photo_vignette'])
|
||||
{
|
||||
if ($obj['photo_vignette']) {
|
||||
$filename = $obj['photo_vignette'];
|
||||
} else {
|
||||
$filename = $obj['photo'];
|
||||
@ -243,22 +232,23 @@ if ($object->id)
|
||||
print '<br>';
|
||||
|
||||
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
|
||||
if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight))
|
||||
{
|
||||
if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight)) {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addthumb&type='.$type.'&file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'), 'refresh').' </a>';
|
||||
}
|
||||
if ($user->rights->categorie->creer)
|
||||
{
|
||||
if ($user->rights->categorie->creer) {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&type='.$type.'&file='.urlencode($pdir.$viewfilename).'">';
|
||||
print img_delete().'</a>';
|
||||
}
|
||||
if ($nbbyrow) print '</td>';
|
||||
if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>';
|
||||
if ($nbbyrow) {
|
||||
print '</td>';
|
||||
}
|
||||
if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) {
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
// Ferme tableau
|
||||
while ($nbphoto % $nbbyrow)
|
||||
{
|
||||
while ($nbphoto % $nbbyrow) {
|
||||
print '<td width="'.ceil(100 / $nbbyrow).'%"> </td>';
|
||||
$nbphoto++;
|
||||
}
|
||||
@ -266,8 +256,7 @@ if ($object->id)
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
if ($nbphoto < 1)
|
||||
{
|
||||
if ($nbphoto < 1) {
|
||||
print '<div class="opacitymedium">'.$langs->trans("NoPhotoYet")."</div>";
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,13 +35,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('categories', 'languages'));
|
||||
|
||||
$id = GETPOST('id', 'int');
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$id = GETPOST('id', 'int');
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
|
||||
if ($id == '' && $label == '')
|
||||
{
|
||||
if ($id == '' && $label == '') {
|
||||
dol_print_error('', 'Missing parameter id');
|
||||
exit();
|
||||
}
|
||||
@ -56,7 +55,9 @@ if ($result <= 0) {
|
||||
}
|
||||
|
||||
$type = $object->type;
|
||||
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
if (is_numeric($type)) {
|
||||
$type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
}
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -64,8 +65,7 @@ if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backwar
|
||||
$error = 0;
|
||||
|
||||
// retour a l'affichage des traduction si annulation
|
||||
if ($cancel == $langs->trans("Cancel"))
|
||||
{
|
||||
if ($cancel == $langs->trans("Cancel")) {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
@ -73,8 +73,7 @@ if ($cancel == $langs->trans("Cancel"))
|
||||
// Validation de l'ajout
|
||||
if ($action == 'vadd' &&
|
||||
$cancel != $langs->trans("Cancel") &&
|
||||
($user->rights->categorie->creer))
|
||||
{
|
||||
($user->rights->categorie->creer)) {
|
||||
$object->fetch($id);
|
||||
$current_lang = $langs->getDefaultLang();
|
||||
|
||||
@ -106,7 +105,9 @@ $cancel != $langs->trans("Cancel") &&
|
||||
|
||||
// sauvegarde en base
|
||||
$res = $object->setMultiLangs($user);
|
||||
if ($res < 0) $error++;
|
||||
if ($res < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,13 +122,11 @@ $cancel != $langs->trans("Cancel") &&
|
||||
// Validation de l'edition
|
||||
if ($action == 'vedit' &&
|
||||
$cancel != $langs->trans("Cancel") &&
|
||||
($user->rights->categorie->creer))
|
||||
{
|
||||
($user->rights->categorie->creer)) {
|
||||
$object->fetch($id);
|
||||
$current_lang = $langs->getDefaultLang();
|
||||
|
||||
foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet
|
||||
{
|
||||
foreach ($object->multilangs as $key => $value) { // enregistrement des nouvelles valeurs dans l'objet
|
||||
$libelle = GETPOST('libelle-'.$key, 'alpha');
|
||||
$desc = GETPOST('desc-'.$key);
|
||||
|
||||
@ -147,7 +146,9 @@ $cancel != $langs->trans("Cancel") &&
|
||||
|
||||
if (!$error) {
|
||||
$res = $object->setMultiLangs($user);
|
||||
if ($res < 0) $error++;
|
||||
if ($res < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
@ -175,10 +176,8 @@ $head = categories_prepare_head($object, $type);
|
||||
|
||||
// Calculate $cnt_trans
|
||||
$cnt_trans = 0;
|
||||
if (!empty($object->multilangs))
|
||||
{
|
||||
foreach ($object->multilangs as $key => $value)
|
||||
{
|
||||
if (!empty($object->multilangs)) {
|
||||
foreach ($object->multilangs as $key => $value) {
|
||||
$cnt_trans++;
|
||||
}
|
||||
}
|
||||
@ -232,12 +231,12 @@ print dol_get_fiche_end();
|
||||
|
||||
print "\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($action == '')
|
||||
{
|
||||
if ($user->rights->produit->creer || $user->rights->service->creer)
|
||||
{
|
||||
if ($action == '') {
|
||||
if ($user->rights->produit->creer || $user->rights->service->creer) {
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=add&id='.$object->id.'&type='.$type.'">'.$langs->trans('Add').'</a>';
|
||||
if ($cnt_trans > 0) print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$object->id.'&type='.$type.'">'.$langs->trans('Update').'</a>';
|
||||
if ($cnt_trans > 0) {
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$object->id.'&type='.$type.'">'.$langs->trans('Update').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,8 +244,7 @@ print "\n</div>\n";
|
||||
|
||||
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
//WYSIWYG Editor
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
@ -256,10 +254,8 @@ if ($action == 'edit')
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
print '<input type="hidden" name="type" value="'.$type.'">';
|
||||
|
||||
if (!empty($object->multilangs))
|
||||
{
|
||||
foreach ($object->multilangs as $key => $value)
|
||||
{
|
||||
if (!empty($object->multilangs)) {
|
||||
foreach ($object->multilangs as $key => $value) {
|
||||
print "<br><b><u>".$langs->trans('Language_'.$key)." :</u></b><br>";
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
@ -287,27 +283,27 @@ if ($action == 'edit')
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
} elseif ($action != 'add')
|
||||
{
|
||||
if ($cnt_trans) print '<div class="underbanner clearboth"></div>';
|
||||
} elseif ($action != 'add') {
|
||||
if ($cnt_trans) {
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
}
|
||||
|
||||
if (!empty($object->multilangs))
|
||||
{
|
||||
foreach ($object->multilangs as $key => $value)
|
||||
{
|
||||
if (!empty($object->multilangs)) {
|
||||
foreach ($object->multilangs as $key => $value) {
|
||||
$s = picto_from_langcode($key);
|
||||
print '<table class="border centpercent">';
|
||||
print '<tr class="liste_titre"><td colspan="2">'.($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'&type='.$type.'">'.img_delete('', '').'</a></td></tr>';
|
||||
print '<tr><td class="titlefield">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>';
|
||||
if (!empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION))
|
||||
{
|
||||
if (!empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION)) {
|
||||
print '<tr><td>'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')</td><td>'.$object->multilangs[$key]["other"].'</td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
if (!$cnt_trans && $action != 'add') print '<div class="opacitymedium">'.$langs->trans('NoTranslation').'</div>';
|
||||
if (!$cnt_trans && $action != 'add') {
|
||||
print '<div class="opacitymedium">'.$langs->trans('NoTranslation').'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -315,8 +311,7 @@ if ($action == 'edit')
|
||||
* Form to add a new translation
|
||||
*/
|
||||
|
||||
if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer))
|
||||
{
|
||||
if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) {
|
||||
//WYSIWYG Editor
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
|
||||
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'categorylist'; // To manage different context of search
|
||||
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
||||
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
||||
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
||||
|
||||
|
||||
// Load variable for pagination
|
||||
@ -57,13 +57,14 @@ $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 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
if ($id == "" && $label == "")
|
||||
{
|
||||
if ($id == "" && $label == "") {
|
||||
dol_print_error('', 'Missing parameter id');
|
||||
exit();
|
||||
}
|
||||
@ -78,7 +79,9 @@ if ($result <= 0) {
|
||||
}
|
||||
|
||||
$type = $object->type;
|
||||
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
if (is_numeric($type)) {
|
||||
$type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
}
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
@ -90,8 +93,7 @@ $hookmanager->initHooks(array('categorycard', 'globalcard'));
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($confirm == 'no')
|
||||
{
|
||||
if ($confirm == 'no') {
|
||||
if ($backtopage) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
@ -101,26 +103,21 @@ if ($confirm == 'no')
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
// Remove element from category
|
||||
if ($id > 0 && $removeelem > 0)
|
||||
{
|
||||
if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer))
|
||||
{
|
||||
if ($id > 0 && $removeelem > 0) {
|
||||
if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
$tmpobject = new Product($db);
|
||||
$result = $tmpobject->fetch($removeelem);
|
||||
$elementtype = 'product';
|
||||
} elseif ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer)
|
||||
{
|
||||
} elseif ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) {
|
||||
$tmpobject = new Societe($db);
|
||||
$result = $tmpobject->fetch($removeelem);
|
||||
$elementtype = 'supplier';
|
||||
} elseif ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer)
|
||||
{
|
||||
} elseif ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) {
|
||||
$tmpobject = new Societe($db);
|
||||
$result = $tmpobject->fetch($removeelem);
|
||||
$elementtype = 'customer';
|
||||
} elseif ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer)
|
||||
{
|
||||
} elseif ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
$tmpobject = new Adherent($db);
|
||||
$result = $tmpobject->fetch($removeelem);
|
||||
@ -130,20 +127,17 @@ if ($id > 0 && $removeelem > 0)
|
||||
$tmpobject = new Contact($db);
|
||||
$result = $tmpobject->fetch($removeelem);
|
||||
$elementtype = 'contact';
|
||||
} elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer)
|
||||
{
|
||||
} elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
$tmpobject = new Account($db);
|
||||
$result = $tmpobject->fetch($removeelem);
|
||||
$elementtype = 'account';
|
||||
} elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer)
|
||||
{
|
||||
} elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$tmpobject = new Project($db);
|
||||
$result = $tmpobject->fetch($removeelem);
|
||||
$elementtype = 'project';
|
||||
} elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer)
|
||||
{
|
||||
} elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
$tmpobject = new User($db);
|
||||
$result = $tmpobject->fetch($removeelem);
|
||||
@ -151,13 +145,13 @@ if ($id > 0 && $removeelem > 0)
|
||||
}
|
||||
|
||||
$result = $object->del_type($tmpobject, $elementtype);
|
||||
if ($result < 0) dol_print_error('', $object->error);
|
||||
if ($result < 0) {
|
||||
dol_print_error('', $object->error);
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes')
|
||||
{
|
||||
if ($object->delete($user) >= 0)
|
||||
{
|
||||
if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes') {
|
||||
if ($object->delete($user) >= 0) {
|
||||
if ($backtopage) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
@ -174,20 +168,16 @@ if ($elemid && $action == 'addintocategory' &&
|
||||
(($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) ||
|
||||
($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) ||
|
||||
($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer)
|
||||
))
|
||||
{
|
||||
if ($type == Categorie::TYPE_PRODUCT)
|
||||
{
|
||||
)) {
|
||||
if ($type == Categorie::TYPE_PRODUCT) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
$newobject = new Product($db);
|
||||
$elementtype = 'product';
|
||||
} elseif ($type == Categorie::TYPE_CUSTOMER)
|
||||
{
|
||||
} elseif ($type == Categorie::TYPE_CUSTOMER) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
$newobject = new Societe($db);
|
||||
$elementtype = 'customer';
|
||||
} elseif ($type == Categorie::TYPE_SUPPLIER)
|
||||
{
|
||||
} elseif ($type == Categorie::TYPE_SUPPLIER) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
$newobject = new Societe($db);
|
||||
$elementtype = 'supplier';
|
||||
@ -196,12 +186,10 @@ if ($elemid && $action == 'addintocategory' &&
|
||||
|
||||
// TODO Add into categ
|
||||
$result = $object->add_type($newobject, $elementtype);
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs');
|
||||
} else {
|
||||
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
@ -233,8 +221,7 @@ $object->next_prev_filter = ' type = '.$object->type;
|
||||
$object->ref = $object->label;
|
||||
$morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
|
||||
$ways = $object->print_all_ways(" >> ", '', 1);
|
||||
foreach ($ways as $way)
|
||||
{
|
||||
foreach ($ways as $way) {
|
||||
$morehtmlref .= $way."<br>\n";
|
||||
}
|
||||
$morehtmlref .= '</div>';
|
||||
@ -246,8 +233,7 @@ dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'la
|
||||
* Confirmation suppression
|
||||
*/
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
if ($backtopage) {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2);
|
||||
} else {
|
||||
@ -288,16 +274,16 @@ print dol_get_fiche_end();
|
||||
|
||||
print "<div class='tabsAction'>\n";
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $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 ($user->rights->categorie->creer)
|
||||
{
|
||||
if ($user->rights->categorie->creer) {
|
||||
$socid = ($object->socid ? "&socid=".$object->socid : "");
|
||||
print '<a class="butAction" href="edit.php?id='.$object->id.$socid.'&type='.$type.'">'.$langs->trans("Modify").'</a>';
|
||||
}
|
||||
|
||||
if ($user->rights->categorie->supprimer)
|
||||
{
|
||||
if ($user->rights->categorie->supprimer) {
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'&type='.$type.'&backtolist='.urlencode($backtolist).'">'.$langs->trans("Delete").'</a>';
|
||||
}
|
||||
}
|
||||
@ -305,8 +291,7 @@ if (empty($reshook)) {
|
||||
print "</div>";
|
||||
|
||||
$newcardbutton = '';
|
||||
if (!empty($user->rights->categorie->creer))
|
||||
{
|
||||
if (!empty($user->rights->categorie->creer)) {
|
||||
$link = DOL_URL_ROOT.'/categories/card.php';
|
||||
$link .= '?action=create';
|
||||
$link .= '&type='.$type;
|
||||
@ -335,8 +320,7 @@ print '<td>'.$langs->trans("SubCats").'</td>';
|
||||
print '<td></td>';
|
||||
print '<td class="right">';
|
||||
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
{
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
print '<div id="iddivjstreecontrol">';
|
||||
print '<a class="notasortlink" href="#">'.img_picto('', 'folder').' '.$langs->trans("UndoExpandAll").'</a>';
|
||||
print " | ";
|
||||
@ -348,11 +332,9 @@ print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$cats = $object->get_filles();
|
||||
if ($cats < 0)
|
||||
{
|
||||
if ($cats < 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
} elseif (count($cats) < 1)
|
||||
{
|
||||
} elseif (count($cats) < 1) {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("NoSubCat").'</td>';
|
||||
print '</tr>';
|
||||
@ -362,19 +344,25 @@ if ($cats < 0)
|
||||
$fulltree = $categstatic->get_full_arbo($type, $object->id, 1);
|
||||
|
||||
// Load possible missing includes
|
||||
if ($conf->global->CATEGORY_SHOW_COUNTS)
|
||||
{
|
||||
if ($type == Categorie::TYPE_MEMBER) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
if ($type == Categorie::TYPE_ACCOUNT) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
if ($type == Categorie::TYPE_PROJECT) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
if ($type == Categorie::TYPE_USER) require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
if ($conf->global->CATEGORY_SHOW_COUNTS) {
|
||||
if ($type == Categorie::TYPE_MEMBER) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
}
|
||||
if ($type == Categorie::TYPE_ACCOUNT) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
}
|
||||
if ($type == Categorie::TYPE_PROJECT) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
}
|
||||
if ($type == Categorie::TYPE_USER) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
}
|
||||
}
|
||||
|
||||
// Define data (format for treeview)
|
||||
$data = array();
|
||||
$data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>'');
|
||||
foreach ($fulltree as $key => $val)
|
||||
{
|
||||
foreach ($fulltree as $key => $val) {
|
||||
$categstatic->id = $val['id'];
|
||||
$categstatic->ref = $val['label'];
|
||||
$categstatic->color = $val['color'];
|
||||
@ -382,8 +370,7 @@ if ($cats < 0)
|
||||
$desc = dol_htmlcleanlastbr($val['description']);
|
||||
|
||||
$counter = '';
|
||||
if ($conf->global->CATEGORY_SHOW_COUNTS)
|
||||
{
|
||||
if ($conf->global->CATEGORY_SHOW_COUNTS) {
|
||||
// we need only a count of the elements, so it is enough to consume only the id's from the database
|
||||
$elements = $type == Categorie::TYPE_ACCOUNT
|
||||
? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account"
|
||||
@ -421,8 +408,7 @@ if ($cats < 0)
|
||||
}
|
||||
|
||||
$nbofentries = (count($data) - 1);
|
||||
if ($nbofentries > 0)
|
||||
{
|
||||
if ($nbofentries > 0) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
|
||||
print '<tr class="pair">';
|
||||
print '<td colspan="3">';
|
||||
@ -465,19 +451,16 @@ $typeid = $type;
|
||||
|
||||
|
||||
// List of products or services (type is type of category)
|
||||
if ($type == Categorie::TYPE_PRODUCT)
|
||||
{
|
||||
if ($type == Categorie::TYPE_PRODUCT) {
|
||||
$permission = ($user->rights->produit->creer || $user->rights->service->creer);
|
||||
|
||||
$prods = $object->getObjectsInCateg($type, 0, $limit, $offset);
|
||||
if ($prods < 0)
|
||||
{
|
||||
if ($prods < 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
} else {
|
||||
// Form to add record into a category
|
||||
$showclassifyform = 1;
|
||||
if ($showclassifyform)
|
||||
{
|
||||
if ($showclassifyform) {
|
||||
print '<br>';
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
@ -510,13 +493,13 @@ if ($type == Categorie::TYPE_PRODUCT)
|
||||
print '<table class="noborder centpercent">'."\n";
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
|
||||
|
||||
if (count($prods) > 0)
|
||||
{
|
||||
if (count($prods) > 0) {
|
||||
$i = 0;
|
||||
foreach ($prods as $prod)
|
||||
{
|
||||
foreach ($prods as $prod) {
|
||||
$i++;
|
||||
if ($i > $limit) break;
|
||||
if ($i > $limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
print "\t".'<tr class="oddeven">'."\n";
|
||||
print '<td class="nowrap" valign="top">';
|
||||
@ -525,8 +508,7 @@ if ($type == Categorie::TYPE_PRODUCT)
|
||||
print '<td class="tdtop">'.$prod->label."</td>\n";
|
||||
// Link to delete from category
|
||||
print '<td class="right">';
|
||||
if ($permission)
|
||||
{
|
||||
if ($permission) {
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&removeelem=".$prod->id."'>";
|
||||
print $langs->trans("DeleteFromCat");
|
||||
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
|
||||
@ -544,19 +526,16 @@ if ($type == Categorie::TYPE_PRODUCT)
|
||||
}
|
||||
}
|
||||
|
||||
if ($type == Categorie::TYPE_CUSTOMER)
|
||||
{
|
||||
if ($type == Categorie::TYPE_CUSTOMER) {
|
||||
$permission = $user->rights->societe->creer;
|
||||
|
||||
$socs = $object->getObjectsInCateg($type, 0, $limit, $offset);
|
||||
if ($socs < 0)
|
||||
{
|
||||
if ($socs < 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
} else {
|
||||
// Form to add record into a category
|
||||
$showclassifyform = 1;
|
||||
if ($showclassifyform)
|
||||
{
|
||||
if ($showclassifyform) {
|
||||
print '<br>';
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
@ -588,13 +567,13 @@ if ($type == Categorie::TYPE_CUSTOMER)
|
||||
print '<table class="noborder centpercent">'."\n";
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name").'</td></tr>'."\n";
|
||||
|
||||
if (count($socs) > 0)
|
||||
{
|
||||
if (count($socs) > 0) {
|
||||
$i = 0;
|
||||
foreach ($socs as $key => $soc)
|
||||
{
|
||||
foreach ($socs as $key => $soc) {
|
||||
$i++;
|
||||
if ($i > $limit) break;
|
||||
if ($i > $limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
print "\t".'<tr class="oddeven">'."\n";
|
||||
print '<td class="nowrap" valign="top">';
|
||||
@ -602,8 +581,7 @@ if ($type == Categorie::TYPE_CUSTOMER)
|
||||
print "</td>\n";
|
||||
// Link to delete from category
|
||||
print '<td class="right">';
|
||||
if ($permission)
|
||||
{
|
||||
if ($permission) {
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&removeelem=".$soc->id."'>";
|
||||
print $langs->trans("DeleteFromCat");
|
||||
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
|
||||
@ -622,19 +600,16 @@ if ($type == Categorie::TYPE_CUSTOMER)
|
||||
}
|
||||
|
||||
|
||||
if ($type == Categorie::TYPE_SUPPLIER)
|
||||
{
|
||||
if ($type == Categorie::TYPE_SUPPLIER) {
|
||||
$permission = $user->rights->societe->creer;
|
||||
|
||||
$socs = $object->getObjectsInCateg($type, 0, $limit, $offset);
|
||||
if ($socs < 0)
|
||||
{
|
||||
if ($socs < 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
} else {
|
||||
// Form to add record into a category
|
||||
$showclassifyform = 1;
|
||||
if ($showclassifyform)
|
||||
{
|
||||
if ($showclassifyform) {
|
||||
print '<br>';
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
@ -666,13 +641,13 @@ if ($type == Categorie::TYPE_SUPPLIER)
|
||||
print '<table class="noborder centpercent">'."\n";
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name")."</td></tr>\n";
|
||||
|
||||
if (count($socs) > 0)
|
||||
{
|
||||
if (count($socs) > 0) {
|
||||
$i = 0;
|
||||
foreach ($socs as $soc)
|
||||
{
|
||||
foreach ($socs as $soc) {
|
||||
$i++;
|
||||
if ($i > $limit) break;
|
||||
if ($i > $limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
print "\t".'<tr class="oddeven">'."\n";
|
||||
print '<td class="nowrap" valign="top">';
|
||||
@ -680,8 +655,7 @@ if ($type == Categorie::TYPE_SUPPLIER)
|
||||
print "</td>\n";
|
||||
// Link to delete from category
|
||||
print '<td class="right">';
|
||||
if ($permission)
|
||||
{
|
||||
if ($permission) {
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&removeelem=".$soc->id."'>";
|
||||
print $langs->trans("DeleteFromCat");
|
||||
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
|
||||
@ -701,15 +675,13 @@ if ($type == Categorie::TYPE_SUPPLIER)
|
||||
}
|
||||
|
||||
// List of members
|
||||
if ($type == Categorie::TYPE_MEMBER)
|
||||
{
|
||||
if ($type == Categorie::TYPE_MEMBER) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
|
||||
$permission = $user->rights->adherent->creer;
|
||||
|
||||
$prods = $object->getObjectsInCateg($type, 0, $limit, $offset);
|
||||
if ($prods < 0)
|
||||
{
|
||||
if ($prods < 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
} else {
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
@ -726,13 +698,13 @@ if ($type == Categorie::TYPE_MEMBER)
|
||||
print "<table class='noborder' width='100%'>\n";
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Name").'</td></tr>'."\n";
|
||||
|
||||
if (count($prods) > 0)
|
||||
{
|
||||
if (count($prods) > 0) {
|
||||
$i = 0;
|
||||
foreach ($prods as $key => $member)
|
||||
{
|
||||
foreach ($prods as $key => $member) {
|
||||
$i++;
|
||||
if ($i > $limit) break;
|
||||
if ($i > $limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
print "\t".'<tr class="oddeven">'."\n";
|
||||
print '<td class="nowrap" valign="top">';
|
||||
@ -743,8 +715,7 @@ if ($type == Categorie::TYPE_MEMBER)
|
||||
print '<td class="tdtop">'.$member->firstname."</td>\n";
|
||||
// Link to delete from category
|
||||
print '<td class="right">';
|
||||
if ($permission)
|
||||
{
|
||||
if ($permission) {
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&removeelem=".$member->id."'>";
|
||||
print $langs->trans("DeleteFromCat");
|
||||
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
|
||||
@ -762,13 +733,11 @@ if ($type == Categorie::TYPE_MEMBER)
|
||||
}
|
||||
|
||||
// Categorie contact
|
||||
if ($type == Categorie::TYPE_CONTACT)
|
||||
{
|
||||
if ($type == Categorie::TYPE_CONTACT) {
|
||||
$permission = $user->rights->societe->creer;
|
||||
|
||||
$contacts = $object->getObjectsInCateg($type, 0, $limit, $offset);
|
||||
if ($contacts < 0)
|
||||
{
|
||||
if ($contacts < 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
} else {
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
@ -788,13 +757,13 @@ if ($type == Categorie::TYPE_CONTACT)
|
||||
print '<table class="noborder centpercent">'."\n";
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Ref").'</td></tr>'."\n";
|
||||
|
||||
if (count($contacts) > 0)
|
||||
{
|
||||
if (count($contacts) > 0) {
|
||||
$i = 0;
|
||||
foreach ($contacts as $key => $contact)
|
||||
{
|
||||
foreach ($contacts as $key => $contact) {
|
||||
$i++;
|
||||
if ($i > $limit) break;
|
||||
if ($i > $limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
print "\t".'<tr class="oddeven">'."\n";
|
||||
print '<td class="nowrap" valign="top">';
|
||||
@ -802,8 +771,7 @@ if ($type == Categorie::TYPE_CONTACT)
|
||||
print "</td>\n";
|
||||
// Link to delete from category
|
||||
print '<td class="right">';
|
||||
if ($permission)
|
||||
{
|
||||
if ($permission) {
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&removeelem=".$contact->id."'>";
|
||||
print $langs->trans("DeleteFromCat");
|
||||
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
|
||||
@ -822,15 +790,13 @@ if ($type == Categorie::TYPE_CONTACT)
|
||||
}
|
||||
|
||||
// List of bank accounts
|
||||
if ($type == Categorie::TYPE_ACCOUNT)
|
||||
{
|
||||
if ($type == Categorie::TYPE_ACCOUNT) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
$permission = $user->rights->banque->creer;
|
||||
|
||||
$accounts = $object->getObjectsInCateg($type, 0, $limit, $offset);
|
||||
if ($accounts < 0)
|
||||
{
|
||||
if ($accounts < 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
} else {
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
@ -847,13 +813,13 @@ if ($type == Categorie::TYPE_ACCOUNT)
|
||||
print "<table class='noborder' width='100%'>\n";
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
|
||||
|
||||
if (count($accounts) > 0)
|
||||
{
|
||||
if (count($accounts) > 0) {
|
||||
$i = 0;
|
||||
foreach ($accounts as $key => $account)
|
||||
{
|
||||
foreach ($accounts as $key => $account) {
|
||||
$i++;
|
||||
if ($i > $limit) break;
|
||||
if ($i > $limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
print "\t".'<tr class="oddeven">'."\n";
|
||||
print '<td class="nowrap" valign="top">';
|
||||
@ -863,8 +829,7 @@ if ($type == Categorie::TYPE_ACCOUNT)
|
||||
print '<td class="tdtop">'.$account->number."</td>\n";
|
||||
// Link to delete from category
|
||||
print '<td class="right">';
|
||||
if ($permission)
|
||||
{
|
||||
if ($permission) {
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&removeelem=".$account->id."'>";
|
||||
print $langs->trans("DeleteFromCat");
|
||||
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
|
||||
@ -882,15 +847,13 @@ if ($type == Categorie::TYPE_ACCOUNT)
|
||||
}
|
||||
|
||||
// List of Project
|
||||
if ($type == Categorie::TYPE_PROJECT)
|
||||
{
|
||||
if ($type == Categorie::TYPE_PROJECT) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
|
||||
$permission = $user->rights->projet->creer;
|
||||
|
||||
$objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
|
||||
if ($objects < 0)
|
||||
{
|
||||
if ($objects < 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
} else {
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
@ -908,13 +871,13 @@ if ($type == Categorie::TYPE_PROJECT)
|
||||
print "<table class='noborder' width='100%'>\n";
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
|
||||
|
||||
if (count($objects) > 0)
|
||||
{
|
||||
if (count($objects) > 0) {
|
||||
$i = 0;
|
||||
foreach ($objects as $key => $project)
|
||||
{
|
||||
foreach ($objects as $key => $project) {
|
||||
$i++;
|
||||
if ($i > $limit) break;
|
||||
if ($i > $limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
print "\t".'<tr class="oddeven">'."\n";
|
||||
print '<td class="nowrap" valign="top">';
|
||||
@ -924,8 +887,7 @@ if ($type == Categorie::TYPE_PROJECT)
|
||||
print '<td class="tdtop">'.$project->title."</td>\n";
|
||||
// Link to delete from category
|
||||
print '<td class="right">';
|
||||
if ($permission)
|
||||
{
|
||||
if ($permission) {
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&removeelem=".$project->id."'>";
|
||||
print $langs->trans("DeleteFromCat");
|
||||
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
|
||||
@ -943,13 +905,11 @@ if ($type == Categorie::TYPE_PROJECT)
|
||||
}
|
||||
|
||||
// List of users
|
||||
if ($type == Categorie::TYPE_USER)
|
||||
{
|
||||
if ($type == Categorie::TYPE_USER) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
|
||||
$users = $object->getObjectsInCateg($type);
|
||||
if ($users < 0)
|
||||
{
|
||||
if ($users < 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
} else {
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
@ -969,11 +929,9 @@ if ($type == Categorie::TYPE_USER)
|
||||
print "<table class='noborder' width='100%'>\n";
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Users").' <span class="badge">'.$num.'</span></td></tr>'."\n";
|
||||
|
||||
if (count($users) > 0)
|
||||
{
|
||||
if (count($users) > 0) {
|
||||
// Use "$userentry" here, because "$user" is the current user
|
||||
foreach ($users as $key => $userentry)
|
||||
{
|
||||
foreach ($users as $key => $userentry) {
|
||||
print "\t".'<tr class="oddeven">'."\n";
|
||||
print '<td class="nowrap" valign="top">';
|
||||
print $userentry->getNomUrl(1);
|
||||
@ -982,8 +940,7 @@ if ($type == Categorie::TYPE_USER)
|
||||
|
||||
// Link to delete from category
|
||||
print '<td class="right">';
|
||||
if ($user->rights->user->user->creer)
|
||||
{
|
||||
if ($user->rights->user->user->creer) {
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$type."&removeelem=".$userentry->id."'>";
|
||||
print $langs->trans("DeleteFromCat");
|
||||
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
|
||||
@ -1002,15 +959,13 @@ if ($type == Categorie::TYPE_USER)
|
||||
|
||||
|
||||
// List of warehouses
|
||||
if ($type == Categorie::TYPE_WAREHOUSE)
|
||||
{
|
||||
if ($type == Categorie::TYPE_WAREHOUSE) {
|
||||
$permission = $user->rights->stock->creer;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
|
||||
|
||||
$objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
|
||||
if ($objects < 0)
|
||||
{
|
||||
if ($objects < 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
} else {
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
@ -1028,13 +983,13 @@ if ($type == Categorie::TYPE_WAREHOUSE)
|
||||
print "<table class='noborder' width='100%'>\n";
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
|
||||
|
||||
if (count($objects) > 0)
|
||||
{
|
||||
if (count($objects) > 0) {
|
||||
$i = 0;
|
||||
foreach ($objects as $key => $project)
|
||||
{
|
||||
foreach ($objects as $key => $project) {
|
||||
$i++;
|
||||
if ($i > $limit) break;
|
||||
if ($i > $limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
print "\t".'<tr class="oddeven">'."\n";
|
||||
print '<td class="nowrap" valign="top">';
|
||||
@ -1044,8 +999,7 @@ if ($type == Categorie::TYPE_WAREHOUSE)
|
||||
print '<td class="tdtop">'.$project->title."</td>\n";
|
||||
// Link to delete from category
|
||||
print '<td class="right">';
|
||||
if ($permission)
|
||||
{
|
||||
if ($permission) {
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&removeelem=".$project->id."'>";
|
||||
print $langs->trans("DeleteFromCat");
|
||||
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
|
||||
|
||||
@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin", "other", "website"));
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$conf->dol_hide_leftmenu = 1; // Force hide of left menu.
|
||||
|
||||
@ -41,17 +43,37 @@ $page = GETPOST('page', 'alpha');
|
||||
$pageid = GETPOST('pageid', 'int');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
if (GETPOST('delete')) { $action = 'delete'; }
|
||||
if (GETPOST('preview')) $action = 'preview';
|
||||
if (GETPOST('create')) { $action = 'create'; }
|
||||
if (GETPOST('editmedia')) { $action = 'editmedia'; }
|
||||
if (GETPOST('editcss')) { $action = 'editcss'; }
|
||||
if (GETPOST('editmenu')) { $action = 'editmenu'; }
|
||||
if (GETPOST('setashome')) { $action = 'setashome'; }
|
||||
if (GETPOST('editmeta')) { $action = 'editmeta'; }
|
||||
if (GETPOST('editcontent')) { $action = 'editcontent'; }
|
||||
if (GETPOST('delete')) {
|
||||
$action = 'delete';
|
||||
}
|
||||
if (GETPOST('preview')) {
|
||||
$action = 'preview';
|
||||
}
|
||||
if (GETPOST('create')) {
|
||||
$action = 'create';
|
||||
}
|
||||
if (GETPOST('editmedia')) {
|
||||
$action = 'editmedia';
|
||||
}
|
||||
if (GETPOST('editcss')) {
|
||||
$action = 'editcss';
|
||||
}
|
||||
if (GETPOST('editmenu')) {
|
||||
$action = 'editmenu';
|
||||
}
|
||||
if (GETPOST('setashome')) {
|
||||
$action = 'setashome';
|
||||
}
|
||||
if (GETPOST('editmeta')) {
|
||||
$action = 'editmeta';
|
||||
}
|
||||
if (GETPOST('editcontent')) {
|
||||
$action = 'editcontent';
|
||||
}
|
||||
|
||||
if (empty($action)) $action = 'preview';
|
||||
if (empty($action)) {
|
||||
$action = 'preview';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -60,13 +82,16 @@ if (empty($action)) $action = 'preview';
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('refreshsite')) $pageid = 0; // If we change the site, we reset the pageid.
|
||||
if (GETPOST('refreshpage')) $action = 'preview';
|
||||
if (GETPOST('refreshsite')) {
|
||||
$pageid = 0; // If we change the site, we reset the pageid.
|
||||
}
|
||||
if (GETPOST('refreshpage')) {
|
||||
$action = 'preview';
|
||||
}
|
||||
|
||||
|
||||
// Add a collab page
|
||||
if ($action == 'add')
|
||||
{
|
||||
if ($action == 'add') {
|
||||
$db->begin();
|
||||
|
||||
$objectpage->title = GETPOST('WEBSITE_TITLE');
|
||||
@ -74,23 +99,19 @@ if ($action == 'add')
|
||||
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
|
||||
$objectpage->keywords = GETPOST('WEBSITE_KEYWORD');
|
||||
|
||||
if (empty($objectpage->title))
|
||||
{
|
||||
if (empty($objectpage->title)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$res = $objectpage->create($user);
|
||||
if ($res <= 0)
|
||||
{
|
||||
if ($res <= 0) {
|
||||
$error++;
|
||||
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
|
||||
}
|
||||
}
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs');
|
||||
$action = '';
|
||||
@ -103,25 +124,21 @@ if ($action == 'add')
|
||||
}
|
||||
|
||||
// Update page
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
$db->begin();
|
||||
|
||||
$res = $object->fetch(0, $website);
|
||||
|
||||
$res = $objectpage->fetch($pageid, $object->fk_website);
|
||||
|
||||
if ($res > 0)
|
||||
{
|
||||
if ($res > 0) {
|
||||
$res = $objectpage->delete($user);
|
||||
if (!($res > 0))
|
||||
{
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
|
||||
|
||||
@ -149,15 +166,16 @@ llxHeader('', $langs->trans("WebsiteSetup"), $help_url, '', 0, '', '', '', '', '
|
||||
|
||||
print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST"><div>';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
}
|
||||
|
||||
|
||||
// Add a margin under toolbar ?
|
||||
$style = '';
|
||||
if ($action != 'preview' && $action != 'editcontent') $style = ' margin-bottom: 5px;';
|
||||
if ($action != 'preview' && $action != 'editcontent') {
|
||||
$style = ' margin-bottom: 5px;';
|
||||
}
|
||||
|
||||
//var_dump($objectpage);exit;
|
||||
print '<div class="centpercent websitebar">';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user