diff --git a/admin/shippableorder_setup.php b/admin/shippableorder_setup.php index a69ce63..40cc8b6 100644 --- a/admin/shippableorder_setup.php +++ b/admin/shippableorder_setup.php @@ -32,7 +32,6 @@ require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT . "/core/class/extrafields.class.php"; require_once '../lib/shippableorder.lib.php'; -dol_include_once('/abricot/includes/class/class.form.core.php'); // Translations $langs->load("admin"); @@ -47,7 +46,7 @@ // Parameters $action = GETPOST('action', 'alpha'); - + /* * Actions */ @@ -55,7 +54,7 @@ { $code=$reg[1]; - + $value = GETPOST($code); if(is_array($value))$value = implode(',',$value); @@ -71,7 +70,7 @@ dol_print_error($db); } } - + if (preg_match('/del_(.*)/',$action,$reg)) { $code=$reg[1]; @@ -110,17 +109,15 @@ ); // Setup page goes here -$form=new Form($db); +$form = new Form($db); $var=false; print ''; print ''; -print ''."\n"; +print ''; print ''; -print ''."\n"; - +print ''; +print ''; -$form=new TFormCore(); -$formdoli=new Form($db); // Add shipment as titles in invoice $var=!$var; print ''; @@ -135,17 +132,15 @@ dol_include_once('/product/class/html.formproduct.class.php'); -$formDoli=new Form($db); $formprod = new FormProduct($db); $formprod->loadWarehouses(); $TWareHouse = array(); foreach($formprod->cache_warehouses as $id=>$ent) { - $TWareHouse[$id]=$ent['label']; + $TWareHouse[$id]=$ent['label']; } - -echo $formDoli->multiselectarray('SHIPPABLEORDER_SPECIFIC_WAREHOUSE',$TWareHouse,explode(',', getDolGlobalString('SHIPPABLEORDER_SPECIFIC_WAREHOUSE'))); +echo $form->multiselectarray('SHIPPABLEORDER_SPECIFIC_WAREHOUSE',$TWareHouse,explode(',', getDolGlobalString('SHIPPABLEORDER_SPECIFIC_WAREHOUSE')), 5, 0, 'minwidth150'); print ''; print ''; @@ -160,7 +155,7 @@ print ''; print ''; print ''; -print $formdoli->selectyesno("SHIPPABLEORDER_ENTREPOT_BY_USER", getDolGlobalString('SHIPPABLEORDER_ENTREPOT_BY_USER'),1); +print $form->selectyesno("SHIPPABLEORDER_ENTREPOT_BY_USER", getDolGlobalString('SHIPPABLEORDER_ENTREPOT_BY_USER'),1); print ''; print ''; print ''; @@ -176,7 +171,7 @@ print ''; dol_include_once('/core/modules/expedition/modules_expedition.php'); $liste = ModelePdfExpedition::liste_modeles($db); -print $formdoli->selectarray('SHIPPABLEORDER_GENERATE_SHIPMENT_PDF', $liste, getDolGlobalString('SHIPPABLEORDER_GENERATE_SHIPMENT_PDF'), 1); +print $form->selectarray('SHIPPABLEORDER_GENERATE_SHIPMENT_PDF', $liste, getDolGlobalString('SHIPPABLEORDER_GENERATE_SHIPMENT_PDF'), 1); print ''; print ''; print ''; @@ -191,7 +186,7 @@ print ''; print ''; print ''; - print $formdoli->selectyesno("SHIPPABLEORDER_GENERATE_GLOBAL_PDF",getDolGlobalString('SHIPPABLEORDER_GENERATE_GLOBAL_PDF'),1); + print $form->selectyesno("SHIPPABLEORDER_GENERATE_GLOBAL_PDF",getDolGlobalString('SHIPPABLEORDER_GENERATE_GLOBAL_PDF'),1); print ''; print ''; print ''; @@ -206,7 +201,7 @@ print ''; print ''; print ''; -print $formdoli->selectyesno("SHIPPABLEORDER_CLOSE_ORDER", getDolGlobalString('SHIPPABLEORDER_CLOSE_ORDER'),1); +print $form->selectyesno("SHIPPABLEORDER_CLOSE_ORDER", getDolGlobalString('SHIPPABLEORDER_CLOSE_ORDER'),1); print ''; print ''; print ''; @@ -219,7 +214,7 @@ print ''; print ''; print ''; -print $formdoli->selectyesno("SHIPPABLE_ORDER_ALLOW_ALL_LINE",getDolGlobalString('SHIPPABLE_ORDER_ALLOW_ALL_LINE'),1); +print $form->selectyesno("SHIPPABLE_ORDER_ALLOW_ALL_LINE",getDolGlobalString('SHIPPABLE_ORDER_ALLOW_ALL_LINE'),1); print ''; print ''; print ''; @@ -232,7 +227,7 @@ print ''; print ''; print ''; -print $formdoli->selectyesno("SHIPPABLE_ORDER_ALLOW_SHIPPING_IF_NOT_ENOUGH_STOCK", getDolGlobalString('SHIPPABLE_ORDER_ALLOW_SHIPPING_IF_NOT_ENOUGH_STOCK'),1); +print $form->selectyesno("SHIPPABLE_ORDER_ALLOW_SHIPPING_IF_NOT_ENOUGH_STOCK", getDolGlobalString('SHIPPABLE_ORDER_ALLOW_SHIPPING_IF_NOT_ENOUGH_STOCK'),1); print ''; print ''; print ''; @@ -245,7 +240,7 @@ print ''; print ''; print ''; -print $formdoli->selectyesno("SHIPPABLE_ORDER_AUTO_VALIDATE_SHIPPING", getDolGlobalString('SHIPPABLE_ORDER_AUTO_VALIDATE_SHIPPING'),1); +print $form->selectyesno("SHIPPABLE_ORDER_AUTO_VALIDATE_SHIPPING", getDolGlobalString('SHIPPABLE_ORDER_AUTO_VALIDATE_SHIPPING'),1); print ''; print ''; print ''; @@ -258,7 +253,7 @@ print ''; print ''; print ''; -print $formdoli->selectyesno("SHIPPABLE_ORDER_DISABLE_AUTO_REDIRECT",getDolGlobalString('SHIPPABLE_ORDER_DISABLE_AUTO_REDIRECT'),1); +print $form->selectyesno("SHIPPABLE_ORDER_DISABLE_AUTO_REDIRECT",getDolGlobalString('SHIPPABLE_ORDER_DISABLE_AUTO_REDIRECT'),1); print ''; print ''; print ''; @@ -271,7 +266,7 @@ print ''; print ''; print ''; -print $formdoli->selectyesno("SHIPPABLEORDER_NO_DEFAULT_CHECK",getDolGlobalString('SHIPPABLEORDER_NO_DEFAULT_CHECK'),1); +print $form->selectyesno("SHIPPABLEORDER_NO_DEFAULT_CHECK",getDolGlobalString('SHIPPABLEORDER_NO_DEFAULT_CHECK'),1); print ''; print ''; print ''; @@ -284,7 +279,7 @@ print ''; print ''; print ''; -print $formdoli->selectyesno("SHIPPABLEORDER_DONT_CHECK_DRAFT_SHIPPING_QTY", getDolGlobalString('SHIPPABLEORDER_DONT_CHECK_DRAFT_SHIPPING_QTY'),1); +print $form->selectyesno("SHIPPABLEORDER_DONT_CHECK_DRAFT_SHIPPING_QTY", getDolGlobalString('SHIPPABLEORDER_DONT_CHECK_DRAFT_SHIPPING_QTY'),1); print ''; print ''; print ''; @@ -298,7 +293,7 @@ print ''; print ''; print ''; -print $formdoli->selectyesno("SHIPPABLEORDER_SELECT_BY_LINE",getDolGlobalString('SHIPPABLEORDER_SELECT_BY_LINE'),1); +print $form->selectyesno("SHIPPABLEORDER_SELECT_BY_LINE",getDolGlobalString('SHIPPABLEORDER_SELECT_BY_LINE'),1); print ''; print ''; print ''; @@ -312,10 +307,10 @@ $db->close(); function create_extrafield($code, $label, $type, $elementtype, $options='') { - + global $db; - + $e = new ExtraFields($db); $e->addExtraField($code, $label, $type, '', '', $elementtype, 0, 0, '', $options); - + } diff --git a/class/actions_shippableorder.class.php b/class/actions_shippableorder.class.php index 6e55a0d..9e35cea 100644 --- a/class/actions_shippableorder.class.php +++ b/class/actions_shippableorder.class.php @@ -1,4 +1,19 @@ . + */ require_once __DIR__ . '/../backport/v19/core/class/commonhookactions.class.php'; diff --git a/class/shippableorder.class.php b/class/shippableorder.class.php index 825096c..b2a92ec 100644 --- a/class/shippableorder.class.php +++ b/class/shippableorder.class.php @@ -1,4 +1,19 @@ . + */ class ShippableOrder { function __construct (&$db) { @@ -38,6 +53,13 @@ function __construct (&$db) { } + /** + * Selects the shippable order status. + * + * @param string $htmlname The HTML name for the select element. Defaults to 'search_status'. + * @param array $selected The currently selected status(es). + * @return string HTML string for the select/multiselect element. + */ public function selectShippableOrderStatus($htmlname='search_status', $selected) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; diff --git a/class/techatm.class.php b/class/techatm.class.php index 49f6823..66de98f 100644 --- a/class/techatm.class.php +++ b/class/techatm.class.php @@ -148,7 +148,7 @@ public static function getLastModuleVersionUrl($moduleDescriptor){ /** - * @param $url + * @param string $url The URL to fetch JSON data from. * @return false|object */ public function getJsonData($url){ @@ -170,7 +170,7 @@ public function getJsonData($url){ } /** - * @param $url + * @param string $url The URL to fetch content from. * @return false|string */ public function getContents($url){ diff --git a/config.default.php b/config.default.php index 4be23d6..6fa79b5 100644 --- a/config.default.php +++ b/config.default.php @@ -1,5 +1,20 @@ . + */ + if(is_file('../main.inc.php'))$dir = '../'; else if(is_file('../../../main.inc.php'))$dir = '../../../'; else $dir = '../../'; @@ -22,10 +37,5 @@ define('DB_DRIVER',$dolibarr_main_db_type); } - if(!dol_include_once('/abricot/inc.core.php')) { - print $langs->trans('AbricotNotFound'). ' : Abricot'; - exit; - } - diff --git a/config.php b/config.php index a20fa5a..22a1e00 100644 --- a/config.php +++ b/config.php @@ -1,4 +1,19 @@ . + */ require('config.default.php'); diff --git a/core/modules/modShippableOrder.class.php b/core/modules/modShippableOrder.class.php index 39de364..f17cded 100644 --- a/core/modules/modShippableOrder.class.php +++ b/core/modules/modShippableOrder.class.php @@ -96,7 +96,7 @@ function __construct($db) $this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with - $this->phpmin = array(7,0); // Minimum version of PHP required by module + $this->phpmin = array(7,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(16, 0); // Minimum version of Dolibarr required by module $this->langfiles = array("shippableorder@shippableorder"); @@ -108,8 +108,8 @@ function __construct($db) $this->const = array(); // Array to add new pages in new tabs - // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@shippableorder:$user->rights->shippableorder->read:/shippableorder/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 - // 'objecttype:+tabname2:Title2:mylangfile@shippableorder:$user->rights->othermodule->read:/shippableorder/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 + // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@shippableorder:$user->hasRight('shippableorder', 'read'):/shippableorder/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 + // 'objecttype:+tabname2:Title2:mylangfile@shippableorder:$user->hasRight('othermodule', 'read'):/shippableorder/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname // where objecttype can be // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) diff --git a/core/triggers/interface_99_modShippableOrder_ShippableOrdertrigger.class.php b/core/triggers/interface_99_modShippableOrder_ShippableOrdertrigger.class.php index e034535..d260682 100644 --- a/core/triggers/interface_99_modShippableOrder_ShippableOrdertrigger.class.php +++ b/core/triggers/interface_99_modShippableOrder_ShippableOrdertrigger.class.php @@ -48,7 +48,7 @@ public function __construct($db) $this->db = $db; $this->name = preg_replace('/^Interface/i', '', get_class($this)); - $this->family = "demo"; + $this->family = "ATM Consulting - CRM"; $this->description = "Triggers of this module are empty functions." . "They have no effect." . "They are provided for tutorial purpose only."; @@ -100,18 +100,21 @@ public function getVersion() } /** - * Function called when a Dolibarrr business event is done. - * All functions "run_trigger" are triggered if file - * is inside directory core/triggers - * - * @param string $action Event action code - * @param Object $object Object - * @param User $user Object user - * @param Translate $langs Object langs - * @param conf $conf Object conf - * @return int <0 if KO, 0 if no triggered ran, >0 if OK - */ - public function run_trigger($action, $object, $user, $langs, $conf) + /** + * Executes actions based on Dolibarr business events. + * + * Specifically, when the 'SHIPPING_VALIDATE' action is triggered, + * it checks if the order associated with the shipping is fully shipped. + * If so, and if 'SHIPPABLEORDER_CLOSE_ORDER' is enabled, the order is closed. + * + * @param string $action Event action code (e.g., 'SHIPPING_VALIDATE'). + * @param Object $object The object related to the event (e.g., Expedition object for SHIPPING_VALIDATE). + * @param User $user User object. + * @param Translate $langs Language object. + * @param conf $conf Configuration object. + * @return int <0 if KO, 0 if no triggered ran, >0 if OK. + */ + public function runTrigger($action, $object, $user, $langs, $conf) { if ($action == 'SHIPPING_VALIDATE') { @@ -119,22 +122,22 @@ public function run_trigger($action, $object, $user, $langs, $conf) if(getDolGlobalString('SHIPPABLEORDER_CLOSE_ORDER')) { dol_include_once('/commande/class/commande.class.php'); dol_include_once('/shippableorder/class/shippableorder.class.php'); - + $object->fetchObjectLinked(0,'commande'); - + if(!empty($object->linkedObjects['commande'])){ $commande = array_pop($object->linkedObjects['commande']); - + $orderShippable = new ShippableOrder($this->db); $orderShippable->isOrderShippable($commande->id); - + if($orderShippable->nbProduct == 0) { $commande->cloture($user); setEventMessage($langs->trans('OrderClosed',$commande->ref)); } } } - + dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); diff --git a/script/interface.php b/script/interface.php index d396811..d6ecb6b 100644 --- a/script/interface.php +++ b/script/interface.php @@ -1,4 +1,19 @@ . + */ if (!defined("NOCSRFCHECK")) define('NOCSRFCHECK', 1); if (!defined("NOTOKENRENEWAL")) define('NOTOKENRENEWAL', 1);
'.$langs->trans("Parameters").''.$langs->trans("Parameters").' '.$langs->trans("Value").''.$langs->trans("Value").'