diff --git a/dev/tools/spider.php b/dev/tools/spider.php new file mode 100644 index 00000000000..954978b24df --- /dev/null +++ b/dev/tools/spider.php @@ -0,0 +1,145 @@ +#!/usr/bin/env php +. + */ + +/** + * \file dev/tools/spider.php + * \brief Script to spider Dolibarr app. + * + * To use it: + * - Disable module "bookmark" + * - Exclude param optioncss, token, sortfield, sortorder + */ + +$crawledLinks=array(); +const MAX_DEPTH=2; + + +/** + * @param string $url URL + * @param string $depth Depth + * @return string String + */ +function followLink($url, $depth = 0) +{ + global $crawledLinks; + $crawling=array(); + if ($depth>MAX_DEPTH) { + echo "
| '; + print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); + print ' | '; + print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); + print ' | ||
| ';
$textdesc = $langs->trans("CostPriceDescription");
$textdesc .= " ".$langs->trans("CostPriceUsage"); $text = $form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', ''); print $form->editfieldkey($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); - print ' | '; + print ' | '; print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); print ' | |
| '.$langs->trans("BuyingPriceMin").' | '; - print ''; + print ' | '; $product_fourn = new ProductFournisseur($db); if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) { if ($product_fourn->product_fourn_price_id > 0) { diff --git a/htdocs/product/price.php b/htdocs/product/price.php index bb46839e588..03867bb65e9 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -717,8 +717,18 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ $soc->id = $socid; $soc->fetch($socid); + // Type + if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) { + $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); + print ' | |
| '; + print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); + print ' | '; + print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); + print ' | ||
| '; + print ' | |||
| '; print $langs->trans("SellingPrice"); print ' | '; print ''; @@ -791,13 +801,33 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ } } else { if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { // using this option is a bug. kept for backward compatibility + // Type + if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) { + $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); + print ' | ||
| '; + print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); + print ' | '; + print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); + print ' | ||
| '.$langs->trans("DefaultTaxRate").' | '; + print '|||
| '.$langs->trans("DefaultTaxRate").' | '; print ''.vatrate($object->multiprices_tva_tx[1], true).' | '; print '||
| '; + print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); + print ' | '; + print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); + print ' | ||
| '.$langs->trans("DefaultTaxRate").' | '; + print ' | ||
| '.$langs->trans("DefaultTaxRate").' | '; $positiverates = ''; if (price2num($object->tva_tx)) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index a00feb194a0..7fcee8f59cd 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -77,6 +77,7 @@ $batchnumber = GETPOST('batch_number', 'san_alpha'); if (!empty($batchnumber)) { $batchnumber = trim($batchnumber); } +$cost_price = GETPOST('cost_price', 'alpha'); // Security check if ($user->socid) { @@ -113,6 +114,9 @@ $hookmanager->initHooks(array('stockproductcard', 'globalcard')); $error = 0; +$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); +$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); + if ($object->id > 0) { if ($object->type == $object::TYPE_PRODUCT) { restrictedArea($user, 'produit', $object->id, 'product&product', '', ''); @@ -139,6 +143,21 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } +if ($action == 'setcost_price') { + if ($id) { + $result = $object->fetch($id); + $object->cost_price = price2num($cost_price); + $result = $object->update($object->id, $user); + if ($result > 0) { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + $action = ''; + } else { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } +} + if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer)) { $seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); @@ -600,9 +619,9 @@ if ($id > 0 || $ref) { if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) { $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); print ' | ||
| '; - print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans('Type'); + print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); print ' | '; - print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat); + print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); print ' | '; + print ' | '; print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); print ' | '; diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index aff3e4cce92..d3c7ba504cb 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -729,7 +729,7 @@ if ($id) { if ($action == 'edit') { print '
| ' . $langs->trans("Amount") . ' | |||
| ' . $langs->trans("Amount") . ' | ' . price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency) . ' | ||
| ' . $langs->trans("Amount") . ' | ' . price($object->amount, 0, $langs, 1, -1, -1, $conf->currency) . ' | ||
| '.$langs->trans("Module").' | '; if ($caneditperms) { print ''; - print 'id.'&action=addrights&entity='.$entity.'&module=allmodules&token='.newToken().'">'.$langs->trans("All").""; + print 'id.'&action=addrights&entity='.$entity.'&module=allmodules&confirm=yes&token='.newToken().'">'.$langs->trans("All").""; print '/'; - print 'id.'&action=delrights&entity='.$entity.'&module=allmodules&token='.newToken().'">'.$langs->trans("None").""; + print 'id.'&action=delrights&entity='.$entity.'&module=allmodules&confirm=yes&token='.newToken().'">'.$langs->trans("None").""; print ' | '; } print ''; print ' | '.$langs->trans("Permissions").' | '; if ($user->admin) { - print ''.$langs->trans("ID").' | '; + print ''; } print ''."\n"; - $sql = "SELECT r.id, r.libelle as label, r.module"; + $sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault"; $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" - $sql .= " AND r.entity = ".$entity; + $sql .= " AND r.entity = ".((int) $entity); if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable } - $sql .= " ORDER BY r.module, r.id"; + $sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id"; $result = $db->query($sql); if ($result) { @@ -265,13 +278,16 @@ if ($object->id > 0) { while ($i < $num) { $obj = $db->fetch_object($result); - // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it + // If line is for a module that does not exist anymore (absent of includes/module), we ignore it if (empty($modules[$obj->module])) { $i++; continue; } - if ($oldmod <> $obj->module) { + $objMod = $modules[$obj->module]; + + // Break found, it's a new module to catch + if (isset($obj->module) && ($oldmod <> $obj->module)) { $oldmod = $obj->module; // Break detected, we get objMod @@ -286,21 +302,22 @@ if ($object->id > 0) { print ''; if ($caneditperms) { print ' | '; - print 'id.'&action=addrights&entity='.$entity.'&module='.$obj->module.'&token='.newToken().'">'.$langs->trans("All").""; + print 'id.'&action=addrights&entity='.$entity.'&module='.$obj->module.'&token='.newToken().'">'.$langs->trans("All").""; print '/'; - print 'id.'&action=delrights&entity='.$entity.'&module='.$obj->module.'&token='.newToken().'">'.$langs->trans("None").""; + print 'id.'&action=delrights&entity='.$entity.'&module='.$obj->module.'&token='.newToken().'">'.$langs->trans("None").""; print ' | '; } else { print ''; } - print ' | '; + print ' | '; + print ' | '; // Permission id if ($user->admin) { print ' | '; } - print ''; + print ''."\n"; } print ''."\n"; @@ -315,7 +332,7 @@ if ($object->id > 0) { if (in_array($obj->id, $permsgroupbyentity[$entity])) { // Own permission by group if ($caneditperms) { - print ' | id.'&action=delrights&entity='.$entity.'&rights='.$obj->id.'&token='.newToken().'">'; + print ' | id.'&action=delrights&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&token='.newToken().'">'; //print img_edit_remove($langs->trans("Remove")); print img_picto($langs->trans("Remove"), 'switch_on'); print ' | '; @@ -326,7 +343,7 @@ if ($object->id > 0) { } else { // Do not own permission if ($caneditperms) { - print 'id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'&token='.newToken().'">'; + print ' | id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&token='.newToken().'">'; //print img_edit_add($langs->trans("Add")); print img_picto($langs->trans("Add"), 'switch_off'); print ' | '; @@ -336,7 +353,7 @@ if ($object->id > 0) { } else { // Do not own permission if ($caneditperms) { - print 'id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'&token='.newToken().'">'; + print ' | id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&token='.newToken().'">'; //print img_edit_add($langs->trans("Add")); print img_picto($langs->trans("Add"), 'switch_off'); print ' | '; @@ -344,12 +361,25 @@ if ($object->id > 0) { print ''; } - $permlabel = ($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label))); - print ' | '.$permlabel.' | '; + // Description of permission + $permlabel = (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label))); + print ''; + print $permlabel; + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { + if (preg_match('/_advance$/', $obj->perms)) { + print ' ('.$langs->trans("AdvancedModeOnly").')'; + } + } + print ' | '; // Permission id if ($user->admin) { - print ''.$obj->id.' | '; + print '';
+ $htmltext = $langs->trans("ID").': '.$obj->id;
+ $htmltext .= ' '.$langs->trans("Permission").': user->rights->'.$obj->module.'->'.$obj->perms.($obj->subperms ? '->'.$obj->subperms : ''); + print $form->textwithpicto('', $htmltext); + //print ''.$obj->id.''; + print ' | ';
}
print ''."\n";
diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php
index 957c7a3a819..5e96a76119c 100644
--- a/htdocs/user/perms.php
+++ b/htdocs/user/perms.php
@@ -90,7 +90,7 @@ $hookmanager->initHooks(array('usercard', 'userperms', 'globalcard'));
* Actions
*/
-$parameters = array('id'=>$socid);
+$parameters = array('socid'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -193,7 +193,7 @@ $permsuser = array();
$sql = "SELECT DISTINCT ur.fk_id";
$sql .= " FROM ".MAIN_DB_PREFIX."user_rights as ur";
-$sql .= " WHERE ur.entity = ".$entity;
+$sql .= " WHERE ur.entity = ".((int) $entity);
$sql .= " AND ur.fk_user = ".((int) $object->id);
dol_syslog("get user perms", LOG_DEBUG);
@@ -386,7 +386,7 @@ if ($result) {
// Picto and label of module
print ''; - //print img_object('', $picto, 'class="pictoobjectwidth"').' '.$objMod->getName(); + //print img_object('', $picto, 'class="inline-block pictoobjectwidth"').' '.$objMod->getName(); print ' | '; // Permission and tick