--- /tmp/dsg/dolibarr/htdocs/core/modules/github_DolibarrModules.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_DolibarrModules.class.php @@ -36,2196 +36,2252 @@ */ class DolibarrModules // Can not be abstract, because we need to instantiate it into unActivateModule to be able to disable a module whose files were removed. { - /** - * @var DoliDb Database handler - */ - public $db; - - /** - * @var int Module unique ID - * @see https://wiki.dolibarr.org/index.php/List_of_modules_id - */ - public $numero; - - /** - * @var string Publisher name - * @since 4.0.0 - */ - public $editor_name; - - /** - * @var string URL of module at publisher site - * @since 4.0.0 - */ - public $editor_url; - - /** - * @var string Family - * @see $familyinfo - * - * Native values: 'crm', 'financial', 'hr', 'projects', 'products', 'ecm', 'technic', 'other'. - * Use familyinfo to declare a custom value. - */ - public $family; - - /** - * @var array Custom family informations - * @see $family - * - * e.g.: - * array( - * 'myownfamily' => array( - * 'position' => '001', - * 'label' => $langs->trans("MyOwnFamily") - * ) - * ); - */ - public $familyinfo; - - /** - * @var string Module position on 2 digits - */ - public $module_position = '50'; - - /** - * @var string Module name - * - * Only used if Module[ID]Name translation string is not found. - * - * You can use the following code to automatically derive it from your module's class name: - * preg_replace('/^mod/i', '', get_class($this)) - */ - public $name; - - /** - * @var string[] Paths to create when module is activated - * - * e.g.: array('/mymodule/temp') - */ - public $dirs = array(); - - /** - * @var array Module boxes - */ - public $boxes = array(); - - /** - * @var array Module constants - */ - public $const = array(); - - /** - * @var array Module cron jobs entries - */ - public $cronjobs = array(); - - /** - * @var array Module access rights - */ - public $rights; - - /** - * @var string Module access rights family - */ - public $rights_class; - - /** - * @var array|int Module menu entries (1 means the menu entries are not declared into module descriptor but are hardcoded into menu manager) - */ - public $menu = array(); - - /** - * @var array Module parts - * array( - * // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers) - * 'triggers' => 0, - * // Set this to 1 if module has its own login method directory (/mymodule/core/login) - * 'login' => 0, - * // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions) - * 'substitutions' => 0, - * // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus) - * 'menus' => 0, - * // Set this to 1 if module has its own theme directory (/mymodule/theme) - * 'theme' => 0, - * // Set this to 1 if module overwrite template dir (/mymodule/core/tpl) - * 'tpl' => 0, - * // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode) - * 'barcode' => 0, - * // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx) - * 'models' => 0, - * // Set this to relative path of css file if module has its own css file - * 'css' => '/mymodule/css/mymodule.css.php', - * // Set this to relative path of js file if module must load a js on all pages - * 'js' => '/mymodule/js/mymodule.js', - * // Set here all hooks context managed by module - * 'hooks' => array('hookcontext1','hookcontext2') - * ) - */ - public $module_parts = array(); - - /** - * @var string Module documents ? - * @deprecated Seems unused anywhere - */ - public $docs; - - /** - * @var string ? - * @deprecated Seems unused anywhere - */ - public $dbversion = "-"; - - /** - * @var string Error message - */ - public $error; - - /** - * @var string Module version - * @see http://semver.org - * - * The following keywords can also be used: - * 'development' - * 'experimental' - * 'dolibarr': only for core modules that share its version - * 'dolibarr_deprecated': only for deprecated core modules - */ - public $version; - - /** - * @var string Module description (short text) - * - * Only used if Module[ID]Desc translation string is not found. - */ - public $description; - - /** - * @var string Module description (long text) - * @since 4.0.0 - * - * HTML content supported. - */ - public $descriptionlong; - - - // For exports - - /** - * @var string Module export code - */ - public $export_code; - - /** - * @var string Module export label - */ - public $export_label; - - public $export_permission; - public $export_fields_array; - public $export_TypeFields_array; // Array of key=>type where type can be 'Numeric', 'Date', 'Text', 'Boolean', 'Status', 'List:xxx:login:rowid' - public $export_entities_array; - public $export_special_array; // special or computed field - public $export_dependencies_array; - public $export_sql_start; - public $export_sql_end; - public $export_sql_order; - - - // For import - - /** - * @var string Module import code - */ - public $import_code; - - /** - * @var string Module import label - */ - public $import_label; - - - /** - * @var string Module constant name - */ - public $const_name; - - /** - * @var bool Module can't be disabled - */ - public $always_enabled; - - /** - * @var int Module is enabled globally (Multicompany support) - */ - public $core_enabled; - - /** - * @var string Name of image file used for this module - * - * If file is in theme/yourtheme/img directory under name object_pictoname.png use 'pictoname' - * If file is in module/img directory under name object_pictoname.png use 'pictoname@module' - */ - public $picto; - - /** - * @var string[] List of config pages - * - * Name of php pages stored into module/admin directory, used to setup module. - * e.g.: "admin.php@module" - */ - public $config_page_url; - - - /** - * @var string[] List of module class names that must be enabled if this module is enabled. e.g.: array('modAnotherModule', 'FR'=>'modYetAnotherModule') + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var int Module unique ID + * @see https://wiki.dolibarr.org/index.php/List_of_modules_id + */ + public $numero; + + /** + * @var string Publisher name + * @since 4.0.0 + */ + public $editor_name; + + /** + * @var string URL of module at publisher site + * @since 4.0.0 + */ + public $editor_url; + + /** + * @var string Family + * @see $familyinfo + * + * Native values: 'crm', 'financial', 'hr', 'projects', 'products', 'ecm', 'technic', 'other'. + * Use familyinfo to declare a custom value. + */ + public $family; + + /** + * @var array Custom family informations + * @see $family + * + * e.g.: + * array( + * 'myownfamily' => array( + * 'position' => '001', + * 'label' => $langs->trans("MyOwnFamily") + * ) + * ); + */ + public $familyinfo; + + /** + * @var string Module position on 2 digits + */ + public $module_position = '50'; + + /** + * @var string Module name + * + * Only used if Module[ID]Name translation string is not found. + * + * You can use the following code to automatically derive it from your module's class name: + * preg_replace('/^mod/i', '', get_class($this)) + */ + public $name; + + /** + * @var string[] Paths to create when module is activated + * + * e.g.: array('/mymodule/temp') + */ + public $dirs = array(); + + /** + * @var array Module boxes + */ + public $boxes = array(); + + /** + * @var array Module constants + */ + public $const = array(); + + /** + * @var array Module cron jobs entries + */ + public $cronjobs = array(); + + /** + * @var array Module access rights + */ + public $rights; + + /** + * @var string Module access rights family + */ + public $rights_class; + + /** + * @var array Module menu entries + */ + public $menu = array(); + + /** + * @var array Module parts + * array( + * // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers) + * 'triggers' => 0, + * // Set this to 1 if module has its own login method directory (/mymodule/core/login) + * 'login' => 0, + * // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions) + * 'substitutions' => 0, + * // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus) + * 'menus' => 0, + * // Set this to 1 if module has its own theme directory (/mymodule/theme) + * 'theme' => 0, + * // Set this to 1 if module overwrite template dir (/mymodule/core/tpl) + * 'tpl' => 0, + * // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode) + * 'barcode' => 0, + * // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx) + * 'models' => 0, + * // Set this to relative path of css file if module has its own css file + * 'css' => '/mymodule/css/mymodule.css.php', + * // Set this to relative path of js file if module must load a js on all pages + * 'js' => '/mymodule/js/mymodule.js', + * // Set here all hooks context managed by module + * 'hooks' => array('hookcontext1','hookcontext2') + * ) + */ + public $module_parts = array(); + + /** + * @var string Module documents ? + * @deprecated Seems unused anywhere + */ + public $docs; + + /** + * @var string ? + * @deprecated Seems unused anywhere + */ + public $dbversion = "-"; + + /** + * @var string Error message + */ + public $error; + + /** + * @var string Module version + * @see http://semver.org + * + * The following keywords can also be used: + * 'development' + * 'experimental' + * 'dolibarr': only for core modules that share its version + * 'dolibarr_deprecated': only for deprecated core modules + */ + public $version; + + /** + * @var string Module description (short text) + * + * Only used if Module[ID]Desc translation string is not found. + */ + public $description; + + /** + * @var string Module description (long text) + * @since 4.0.0 + * + * HTML content supported. + */ + public $descriptionlong; + + + // For exports + + /** + * @var string Module export code + */ + public $export_code; + + /** + * @var string Module export label + */ + public $export_label; + + public $export_permission; + public $export_fields_array; + public $export_TypeFields_array; // Array of key=>type where type can be 'Numeric', 'Date', 'Text', 'Boolean', 'Status', 'List:xxx:login:rowid' + public $export_entities_array; + public $export_special_array; // special or computed field + public $export_dependencies_array; + public $export_sql_start; + public $export_sql_end; + public $export_sql_order; + + + // For import + + /** + * @var string Module import code + */ + public $import_code; + + /** + * @var string Module import label + */ + public $import_label; + + + /** + * @var string Module constant name + */ + public $const_name; + + /** + * @var bool Module can't be disabled + */ + public $always_enabled; + + /** + * @var int Module is enabled globally (Multicompany support) + */ + public $core_enabled; + + /** + * @var string Name of image file used for this module + * + * If file is in theme/yourtheme/img directory under name object_pictoname.png use 'pictoname' + * If file is in module/img directory under name object_pictoname.png use 'pictoname@module' + */ + public $picto; + + /** + * @var string[] List of config pages + * + * Name of php pages stored into module/admin directory, used to setup module. + * e.g.: "admin.php@module" + */ + public $config_page_url; + + + /** + * @var string[] List of module class names that must be enabled if this module is enabled. e.g.: array('modAnotherModule', 'FR'=>'modYetAnotherModule') * @see $requiredby - */ - public $depends; - - /** - * @var string[] List of module class names to disable if the module is disabled. - * @see $depends - */ - public $requiredby; - - /** - * @var string[] List of module class names as string this module is in conflict with. - * @see $depends - */ - public $conflictwith; - - /** - * @var string[] Module language files - */ - public $langfiles; - - /** - * @var array Array of warnings to show when we activate the module - * - * array('always'='text') or array('FR'='text') - */ - public $warnings_activation; - - /** - * @var array Array of warnings to show when we activate an external module - * - * array('always'='text') or array('FR'='text') - */ - public $warnings_activation_ext; - - - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 5.4 = array(5, 4) - */ - public $phpmin; - - /** - * @var array Minimum version of Dolibarr required by module. - * e.g.: Dolibarr ≥ 3.6 = array(3, 6) - */ - public $need_dolibarr_version; - - /** - * @var bool Whether to hide the module. - */ - public $hidden = false; - - - - - - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } - // We should but can't set this as abstract because this will make dolibarr hang - // after migration due to old module not implementing. We must wait PHP is able to make - // a try catch on Fatal error to manage this correctly. - // We need constructor into function unActivateModule into admin.lib.php - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Enables a module. - * Inserts all informations into database - * - * @param array $array_sql SQL requests to be executed when enabling module - * @param string $options String with options when disabling module: - * - 'noboxes' = Do not insert boxes - - * 'newboxdefonly' = For boxes, insert def of - * boxes only and not boxes activation - * - * @return int 1 if OK, 0 if KO - */ - protected function _init($array_sql, $options = '') - { - // phpcs:enable - global $conf; - $err = 0; - - $this->db->begin(); - - // Insert activation module constant - if (!$err) { - $err += $this->_active(); - } - - // Insert new pages for tabs (into llx_const) - if (!$err) { - $err += $this->insert_tabs(); - } - - // Insert activation of module's parts - if (!$err) { - $err += $this->insert_module_parts(); - } - - // Insert constant defined by modules (into llx_const) - if (!$err && !preg_match('/newboxdefonly/', $options)) { - $err += $this->insert_const(); // Test on newboxdefonly to avoid to erase value during upgrade - } - - // Insert boxes def into llx_boxes_def and boxes setup (into llx_boxes) - if (!$err && !preg_match('/noboxes/', $options)) { - $err += $this->insert_boxes($options); - } - - // Insert cron job entries (entry in llx_cronjobs) - if (!$err) { - $err += $this->insert_cronjobs(); - } - - // Insert permission definitions of module into llx_rights_def. If user is admin, grant this permission to user. - if (!$err) { - $err += $this->insert_permissions(1, null, 1); - } - - // Insert specific menus entries into database - if (!$err) { - $err += $this->insert_menus(); - } - - // Create module's directories - if (!$err) { - $err += $this->create_dirs(); - } - - // Execute addons requests - $num = count($array_sql); - for ($i = 0; $i < $num; $i++) - { - if (!$err) { - $val = $array_sql[$i]; - $sql = $val; - $ignoreerror = 0; - if (is_array($val)) { - $sql = $val['sql']; - $ignoreerror = $val['ignoreerror']; - } - // Add current entity id - $sql = str_replace('__ENTITY__', $conf->entity, $sql); - - dol_syslog(get_class($this)."::_init ignoreerror=".$ignoreerror."", LOG_DEBUG); - $result = $this->db->query($sql, $ignoreerror); - if (!$result) { - if (!$ignoreerror) { - $this->error = $this->db->lasterror(); - $err++; - } else { - dol_syslog(get_class($this)."::_init Warning ".$this->db->lasterror(), LOG_WARNING); - } - } - } - } - - // Return code - if (!$err) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return 0; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Disable function. Deletes the module constants and boxes from the database. - * - * @param string[] $array_sql SQL requests to be executed when module is disabled - * @param string $options Options when disabling module: - * - * @return int 1 if OK, 0 if KO - */ - protected function _remove($array_sql, $options = '') - { - // phpcs:enable - $err = 0; - - $this->db->begin(); - - // Remove activation module line (constant MAIN_MODULE_MYMODULE in llx_const) - if (!$err) { - $err += $this->_unactive(); - } - - // Remove activation of module's new tabs (MAIN_MODULE_MYMODULE_TABS_XXX in llx_const) - if (!$err) { - $err += $this->delete_tabs(); - } - - // Remove activation of module's parts (MAIN_MODULE_MYMODULE_XXX in llx_const) - if (!$err) { - $err += $this->delete_module_parts(); - } - - // Remove constants defined by modules - if (!$err) { - $err += $this->delete_const(); - } - - // Remove list of module's available boxes (entry in llx_boxes) - if (!$err && !preg_match('/(newboxdefonly|noboxes)/', $options)) { - $err += $this->delete_boxes(); // We don't have to delete if option ask to keep boxes safe or ask to add new box def only - } - - // Remove list of module's cron job entries (entry in llx_cronjobs) - if (!$err) { - $err += $this->delete_cronjobs(); - } - - // Remove module's permissions from list of available permissions (entries in llx_rights_def) - if (!$err) { - $err += $this->delete_permissions(); - } - - // Remove module's menus (entries in llx_menu) - if (!$err) { - $err += $this->delete_menus(); - } - - // Remove module's directories - if (!$err) { - $err += $this->delete_dirs(); - } - - // Run complementary sql requests - $num = count($array_sql); - for ($i = 0; $i < $num; $i++) - { - if (!$err) { - dol_syslog(get_class($this)."::_remove", LOG_DEBUG); - $result = $this->db->query($array_sql[$i]); - if (!$result) { - $this->error = $this->db->error(); - $err++; - } - } - } - - // Return code - if (!$err) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return 0; - } - } - - - /** - * Gives the translated module name if translation exists in admin.lang or into language files of module. - * Otherwise return the module key name. - * - * @return string Translated module name - */ - public function getName() - { - global $langs; - $langs->load("admin"); - - if ($langs->transnoentitiesnoconv("Module".$this->numero."Name") != ("Module".$this->numero."Name")) { - // If module name translation exists - return $langs->transnoentitiesnoconv("Module".$this->numero."Name"); - } else { - // If module name translation using it's unique id does not exist, we try to use its name to find translation - if (is_array($this->langfiles)) { - foreach ($this->langfiles as $val) - { - if ($val) { $langs->load($val); - } - } - } - - if ($langs->trans("Module".$this->name."Name") != ("Module".$this->name."Name")) { - // If module name translation exists - return $langs->transnoentitiesnoconv("Module".$this->name."Name"); - } - - // Last chance with simple label - return $langs->transnoentitiesnoconv($this->name); - } - } - - - /** - * Gives the translated module description if translation exists in admin.lang or the default module description - * - * @return string Translated module description - */ - public function getDesc() - { - global $langs; - $langs->load("admin"); - - if ($langs->transnoentitiesnoconv("Module".$this->numero."Desc") != ("Module".$this->numero."Desc")) { - // If module description translation exists - return $langs->transnoentitiesnoconv("Module".$this->numero."Desc"); - } else { - // If module description translation does not exist using its unique id, we can use its name to find translation - if (is_array($this->langfiles)) { - foreach ($this->langfiles as $val) - { - if ($val) { $langs->load($val); - } - } - } - - if ($langs->transnoentitiesnoconv("Module".$this->name."Desc") != ("Module".$this->name."Desc")) { - // If module name translation exists - return $langs->trans("Module".$this->name."Desc"); - } - - // Last chance with simple label - return $langs->trans($this->description); - } - } - - /** - * Gives the long description of a module. First check README-la_LA.md then README.md - * If no markdown files found, it returns translated value of the key ->descriptionlong. - * - * @return string Long description of a module from README.md of from property. - */ - public function getDescLong() - { - global $langs; - $langs->load("admin"); - - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; - - $pathoffile = $this->getDescLongReadmeFound(); - - if ($pathoffile) // Mostly for external modules - { - $content = file_get_contents($pathoffile); - - if ((float) DOL_VERSION >= 6.0) { - @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; - - $content = dolMd2Html( - $content, - 'parsedown', - array( - 'doc/' => dol_buildpath(strtolower($this->name).'/doc/', 1), - 'img/' => dol_buildpath(strtolower($this->name).'/img/', 1), - 'images/' => dol_buildpath(strtolower($this->name).'/images/', 1), - ) - ); - } else { - $content = nl2br($content); - } - } else { - // Mostly for internal modules - if (!empty($this->descriptionlong)) { - if (is_array($this->langfiles)) { - foreach ($this->langfiles as $val) - { - if ($val) { $langs->load($val); - } - } - } - - $content = $langs->transnoentitiesnoconv($this->descriptionlong); - } - } - - return $content; - } - - /** - * Return path of file if a README file was found. - * - * @return string Path of file if a README file was found. - */ - public function getDescLongReadmeFound() - { - global $langs; - - $filefound = false; - - // Define path to file README.md. - // First check README-la_LA.md then README-la.md then README.md - $pathoffile = dol_buildpath(strtolower($this->name).'/README-'.$langs->defaultlang.'.md', 0); - if (dol_is_file($pathoffile)) { - $filefound = true; - } - if (!$filefound) { - $tmp = explode('_', $langs->defaultlang); - $pathoffile = dol_buildpath(strtolower($this->name).'/README-'.$tmp[0].'.md', 0); - if (dol_is_file($pathoffile)) { - $filefound = true; - } - } - if (!$filefound) { - $pathoffile = dol_buildpath(strtolower($this->name).'/README.md', 0); - if (dol_is_file($pathoffile)) { - $filefound = true; - } - } - - return ($filefound ? $pathoffile : ''); - } - - - /** - * Gives the changelog. First check ChangeLog-la_LA.md then ChangeLog.md - * - * @return string Content of ChangeLog - */ - public function getChangeLog() - { - global $langs; - $langs->load("admin"); - - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; - - $filefound = false; - - // Define path to file README.md. - // First check ChangeLog-la_LA.md then ChangeLog.md - $pathoffile = dol_buildpath(strtolower($this->name).'/ChangeLog-'.$langs->defaultlang.'.md', 0); - if (dol_is_file($pathoffile)) { - $filefound = true; - } - if (!$filefound) { - $pathoffile = dol_buildpath(strtolower($this->name).'/ChangeLog.md', 0); - if (dol_is_file($pathoffile)) { - $filefound = true; - } - } - - if ($filefound) // Mostly for external modules - { - $content = file_get_contents($pathoffile); - - if ((float) DOL_VERSION >= 6.0) { - @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; - $content = dolMd2Html($content, 'parsedown', array('doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1))); - } else { - $content = nl2br($content); - } - } - - return $content; - } - - /** - * Gives the publisher name - * - * @return string Publisher name - */ - public function getPublisher() - { - return $this->editor_name; - } - - /** - * Gives the publisher url - * - * @return string Publisher url - */ - public function getPublisherUrl() - { - return $this->editor_url; - } - - /** - * Gives module version (translated if param $translated is on) - * For 'experimental' modules, gives 'experimental' translation - * For 'dolibarr' modules, gives Dolibarr version - * - * @param int $translated 1=Special version keys are translated, 0=Special version keys are not translated - * @return string Module version - */ - public function getVersion($translated = 1) - { - global $langs; - $langs->load("admin"); - - $ret = ''; - - $newversion = preg_replace('/_deprecated/', '', $this->version); - if ($newversion == 'experimental') { - $ret = ($translated ? $langs->transnoentitiesnoconv("VersionExperimental") : $newversion); - } elseif ($newversion == 'development') { - $ret = ($translated ? $langs->transnoentitiesnoconv("VersionDevelopment") : $newversion); - } elseif ($newversion == 'dolibarr') { - $ret = DOL_VERSION; - } elseif ($newversion) { - $ret = $newversion; - } else { - $ret = ($translated ? $langs->transnoentitiesnoconv("VersionUnknown") : 'unknown'); - } - - if (preg_match('/_deprecated/', $this->version)) { - $ret .= ($translated ? ' ('.$langs->transnoentitiesnoconv("Deprecated").')' : $this->version); - } - return $ret; - } - - - /** - * Tells if module is core or external - * - * @return string 'core', 'external' or 'unknown' - */ - public function isCoreOrExternalModule() - { - if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') { - return 'core'; - } - if (!empty($this->version) && !in_array($this->version, array('experimental', 'development'))) { - return 'external'; - } - if (!empty($this->editor_name) || !empty($this->editor_url)) { - return 'external'; - } - if ($this->numero >= 100000) { - return 'external'; - } - return 'unknown'; - } - - - /** - * Gives module related language files list - * - * @return string[] Language files list - */ - public function getLangFilesArray() - { - return $this->langfiles; - } - - /** - * Gives translated label of an export dataset - * - * @param int $r Dataset index - * - * @return string Translated databaset label - */ - public function getExportDatasetLabel($r) - { - global $langs; - - $langstring = "ExportDataset_".$this->export_code[$r]; - if ($langs->trans($langstring) == $langstring) { - // Translation not found - return $langs->trans($this->export_label[$r]); - } else { - // Translation found - return $langs->trans($langstring); - } - } - - - /** - * Gives translated label of an import dataset - * - * @param int $r Dataset index - * - * @return string Translated dataset label - */ - public function getImportDatasetLabel($r) - { - global $langs; - - $langstring = "ImportDataset_".$this->import_code[$r]; - //print "x".$langstring; - if ($langs->trans($langstring) == $langstring) { - // Translation not found - return $langs->transnoentitiesnoconv($this->import_label[$r]); - } else { - // Translation found - return $langs->transnoentitiesnoconv($langstring); - } - } - - - /** - * Gives the last date of activation - * - * @return int|string Date of last activation or '' if module was never activated - */ - public function getLastActivationDate() - { - global $conf; - - $err = 0; - - $sql = "SELECT tms FROM ".MAIN_DB_PREFIX."const"; - $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; - $sql .= " AND entity IN (0, ".$conf->entity.")"; - - dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $err++; - } else { - $obj = $this->db->fetch_object($resql); - if ($obj) { - return $this->db->jdate($obj->tms); - } - } - - return ''; - } - - - /** - * Gives the last author of activation - * - * @return array Array array('authorid'=>Id of last activation user, 'lastactivationdate'=>Date of last activation) - */ - public function getLastActivationInfo() - { - global $conf; - - $err = 0; + */ + public $depends; + + /** + * @var string[] List of module class names to disable if the module is disabled. + * @see $depends + */ + public $requiredby; + + /** + * @var string[] List of module class names as string this module is in conflict with. + * @see $depends + */ + public $conflictwith; + + /** + * @var string[] Module language files + */ + public $langfiles; + + /** + * @var array Array of warnings to show when we activate the module + * + * array('always'='text') or array('FR'='text') + */ + public $warnings_activation; + + /** + * @var array Array of warnings to show when we activate an external module + * + * array('always'='text') or array('FR'='text') + */ + public $warnings_activation_ext; + + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.4 = array(5, 4) + */ + public $phpmin; + + /** + * @var array Minimum version of Dolibarr required by module. + * e.g.: Dolibarr ≥ 3.6 = array(3, 6) + */ + public $need_dolibarr_version; + + /** + * @var bool Whether to hide the module. + */ + public $hidden = false; + + + + + + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + // We should but can't set this as abstract because this will make dolibarr hang + // after migration due to old module not implementing. We must wait PHP is able to make + // a try catch on Fatal error to manage this correctly. + // We need constructor into function unActivateModule into admin.lib.php + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Enables a module. + * Inserts all informations into database + * + * @param array $array_sql SQL requests to be executed when enabling module + * @param string $options String with options when disabling module: + * - 'noboxes' = Do not insert boxes - + * 'newboxdefonly' = For boxes, insert def of + * boxes only and not boxes activation + * + * @return int 1 if OK, 0 if KO + */ + protected function _init($array_sql, $options = '') + { + // phpcs:enable + global $conf; + $err = 0; + + $this->db->begin(); + + // Insert activation module constant + if (!$err) { + $err += $this->_active(); + } + + // Insert new pages for tabs (into llx_const) + if (!$err) { + $err += $this->insert_tabs(); + } + + // Insert activation of module's parts + if (!$err) { + $err += $this->insert_module_parts(); + } + + // Insert constant defined by modules (into llx_const) + if (!$err && !preg_match('/newboxdefonly/', $options)) { + $err += $this->insert_const(); // Test on newboxdefonly to avoid to erase value during upgrade + } + + // Insert boxes def into llx_boxes_def and boxes setup (into llx_boxes) + if (!$err && !preg_match('/noboxes/', $options)) { + $err += $this->insert_boxes($options); + } + + // Insert cron job entries (entry in llx_cronjobs) + if (!$err) { + $err += $this->insert_cronjobs(); + } + + // Insert permission definitions of module into llx_rights_def. If user is admin, grant this permission to user. + if (!$err) { + $err += $this->insert_permissions(1, null, 1); + } + + // Insert specific menus entries into database + if (!$err) { + $err += $this->insert_menus(); + } + + // Create module's directories + if (!$err) { + $err += $this->create_dirs(); + } + + // Execute addons requests + $num = count($array_sql); + for ($i = 0; $i < $num; $i++) + { + if (!$err) { + $val = $array_sql[$i]; + $sql = $val; + $ignoreerror = 0; + if (is_array($val)) { + $sql = $val['sql']; + $ignoreerror = $val['ignoreerror']; + } + // Add current entity id + $sql = str_replace('__ENTITY__', $conf->entity, $sql); + + dol_syslog(get_class($this)."::_init ignoreerror=".$ignoreerror."", LOG_DEBUG); + $result = $this->db->query($sql, $ignoreerror); + if (!$result) { + if (!$ignoreerror) { + $this->error = $this->db->lasterror(); + $err++; + } + else + { + dol_syslog(get_class($this)."::_init Warning ".$this->db->lasterror(), LOG_WARNING); + } + } + } + } + + // Return code + if (!$err) { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return 0; + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Disable function. Deletes the module constants and boxes from the database. + * + * @param string[] $array_sql SQL requests to be executed when module is disabled + * @param string $options Options when disabling module: + * + * @return int 1 if OK, 0 if KO + */ + protected function _remove($array_sql, $options = '') + { + // phpcs:enable + $err = 0; + + $this->db->begin(); + + // Remove activation module line (constant MAIN_MODULE_MYMODULE in llx_const) + if (!$err) { + $err += $this->_unactive(); + } + + // Remove activation of module's new tabs (MAIN_MODULE_MYMODULE_TABS_XXX in llx_const) + if (!$err) { + $err += $this->delete_tabs(); + } + + // Remove activation of module's parts (MAIN_MODULE_MYMODULE_XXX in llx_const) + if (!$err) { + $err += $this->delete_module_parts(); + } + + // Remove constants defined by modules + if (!$err) { + $err += $this->delete_const(); + } + + // Remove list of module's available boxes (entry in llx_boxes) + if (!$err && !preg_match('/(newboxdefonly|noboxes)/', $options)) { + $err += $this->delete_boxes(); // We don't have to delete if option ask to keep boxes safe or ask to add new box def only + } + + // Remove list of module's cron job entries (entry in llx_cronjobs) + if (!$err) { + $err += $this->delete_cronjobs(); + } + + // Remove module's permissions from list of available permissions (entries in llx_rights_def) + if (!$err) { + $err += $this->delete_permissions(); + } + + // Remove module's menus (entries in llx_menu) + if (!$err) { + $err += $this->delete_menus(); + } + + // Remove module's directories + if (!$err) { + $err += $this->delete_dirs(); + } + + // Run complementary sql requests + $num = count($array_sql); + for ($i = 0; $i < $num; $i++) + { + if (!$err) { + dol_syslog(get_class($this)."::_remove", LOG_DEBUG); + $result = $this->db->query($array_sql[$i]); + if (!$result) { + $this->error = $this->db->error(); + $err++; + } + } + } + + // Return code + if (!$err) { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return 0; + } + } + + + /** + * Gives the translated module name if translation exists in admin.lang or into language files of module. + * Otherwise return the module key name. + * + * @return string Translated module name + */ + public function getName() + { + global $langs; + $langs->load("admin"); + + if ($langs->transnoentitiesnoconv("Module".$this->numero."Name") != ("Module".$this->numero."Name")) { + // If module name translation exists + return $langs->transnoentitiesnoconv("Module".$this->numero."Name"); + } + else + { + // If module name translation using it's unique id does not exist, we try to use its name to find translation + if (is_array($this->langfiles)) { + foreach ($this->langfiles as $val) + { + if ($val) { $langs->load($val); + } + } + } + + if ($langs->trans("Module".$this->name."Name") != ("Module".$this->name."Name")) { + // If module name translation exists + return $langs->transnoentitiesnoconv("Module".$this->name."Name"); + } + + // Last chance with simple label + return $langs->transnoentitiesnoconv($this->name); + } + } + + + /** + * Gives the translated module description if translation exists in admin.lang or the default module description + * + * @return string Translated module description + */ + public function getDesc() + { + global $langs; + $langs->load("admin"); + + if ($langs->transnoentitiesnoconv("Module".$this->numero."Desc") != ("Module".$this->numero."Desc")) { + // If module description translation exists + return $langs->transnoentitiesnoconv("Module".$this->numero."Desc"); + } + else + { + // If module description translation does not exist using its unique id, we can use its name to find translation + if (is_array($this->langfiles)) { + foreach ($this->langfiles as $val) + { + if ($val) { $langs->load($val); + } + } + } + + if ($langs->transnoentitiesnoconv("Module".$this->name."Desc") != ("Module".$this->name."Desc")) { + // If module name translation exists + return $langs->trans("Module".$this->name."Desc"); + } + + // Last chance with simple label + return $langs->trans($this->description); + } + } + + /** + * Gives the long description of a module. First check README-la_LA.md then README.md + * If no markdown files found, it returns translated value of the key ->descriptionlong. + * + * @return string Long description of a module from README.md of from property. + */ + public function getDescLong() + { + global $langs; + $langs->load("admin"); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + + $pathoffile = $this->getDescLongReadmeFound(); + + if ($pathoffile) // Mostly for external modules + { + $content = file_get_contents($pathoffile); + + if ((float) DOL_VERSION >= 6.0) { + @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; + + $content = dolMd2Html( + $content, + 'parsedown', + array( + 'doc/' => dol_buildpath(strtolower($this->name).'/doc/', 1), + 'img/' => dol_buildpath(strtolower($this->name).'/img/', 1), + 'images/' => dol_buildpath(strtolower($this->name).'/images/', 1), + ) + ); + } + else + { + $content = nl2br($content); + } + } + else + { + // Mostly for internal modules + if (!empty($this->descriptionlong)) { + if (is_array($this->langfiles)) { + foreach ($this->langfiles as $val) + { + if ($val) { $langs->load($val); + } + } + } + + $content = $langs->transnoentitiesnoconv($this->descriptionlong); + } + } + + return $content; + } + + /** + * Return path of file if a README file was found. + * + * @return string Path of file if a README file was found. + */ + public function getDescLongReadmeFound() + { + global $langs; + + $filefound = false; + + // Define path to file README.md. + // First check README-la_LA.md then README-la.md then README.md + $pathoffile = dol_buildpath(strtolower($this->name).'/README-'.$langs->defaultlang.'.md', 0); + if (dol_is_file($pathoffile)) { + $filefound = true; + } + if (!$filefound) { + $tmp = explode('_', $langs->defaultlang); + $pathoffile = dol_buildpath(strtolower($this->name).'/README-'.$tmp[0].'.md', 0); + if (dol_is_file($pathoffile)) { + $filefound = true; + } + } + if (!$filefound) { + $pathoffile = dol_buildpath(strtolower($this->name).'/README.md', 0); + if (dol_is_file($pathoffile)) { + $filefound = true; + } + } + + return ($filefound ? $pathoffile : ''); + } + + + /** + * Gives the changelog. First check ChangeLog-la_LA.md then ChangeLog.md + * + * @return string Content of ChangeLog + */ + public function getChangeLog() + { + global $langs; + $langs->load("admin"); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + + $filefound = false; + + // Define path to file README.md. + // First check ChangeLog-la_LA.md then ChangeLog.md + $pathoffile = dol_buildpath(strtolower($this->name).'/ChangeLog-'.$langs->defaultlang.'.md', 0); + if (dol_is_file($pathoffile)) { + $filefound = true; + } + if (!$filefound) { + $pathoffile = dol_buildpath(strtolower($this->name).'/ChangeLog.md', 0); + if (dol_is_file($pathoffile)) { + $filefound = true; + } + } + + if ($filefound) // Mostly for external modules + { + $content = file_get_contents($pathoffile); + + if ((float) DOL_VERSION >= 6.0) { + @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; + $content = dolMd2Html($content, 'parsedown', array('doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1))); + } + else + { + $content = nl2br($content); + } + } + + return $content; + } + + /** + * Gives the publisher name + * + * @return string Publisher name + */ + public function getPublisher() + { + return $this->editor_name; + } + + /** + * Gives the publisher url + * + * @return string Publisher url + */ + public function getPublisherUrl() + { + return $this->editor_url; + } + + /** + * Gives module version (translated if param $translated is on) + * For 'experimental' modules, gives 'experimental' translation + * For 'dolibarr' modules, gives Dolibarr version + * + * @param int $translated 1=Special version keys are translated, 0=Special version keys are not translated + * @return string Module version + */ + public function getVersion($translated = 1) + { + global $langs; + $langs->load("admin"); + + $ret = ''; + + $newversion = preg_replace('/_deprecated/', '', $this->version); + if ($newversion == 'experimental') { + $ret = ($translated ? $langs->transnoentitiesnoconv("VersionExperimental") : $newversion); + } elseif ($newversion == 'development') { + $ret = ($translated ? $langs->transnoentitiesnoconv("VersionDevelopment") : $newversion); + } elseif ($newversion == 'dolibarr') { + $ret = DOL_VERSION; + } elseif ($newversion) { + $ret = $newversion; + } else { + $ret = ($translated ? $langs->transnoentitiesnoconv("VersionUnknown") : 'unknown'); + } + + if (preg_match('/_deprecated/', $this->version)) { + $ret .= ($translated ? ' ('.$langs->transnoentitiesnoconv("Deprecated").')' : $this->version); + } + return $ret; + } + + + /** + * Tells if module is core or external + * + * @return string 'core', 'external' or 'unknown' + */ + public function isCoreOrExternalModule() + { + if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') { + return 'core'; + } + if (!empty($this->version) && !in_array($this->version, array('experimental', 'development'))) { + return 'external'; + } + if (!empty($this->editor_name) || !empty($this->editor_url)) { + return 'external'; + } + if ($this->numero >= 100000) { + return 'external'; + } + return 'unknown'; + } + + + /** + * Gives module related language files list + * + * @return string[] Language files list + */ + public function getLangFilesArray() + { + return $this->langfiles; + } + + /** + * Gives translated label of an export dataset + * + * @param int $r Dataset index + * + * @return string Translated databaset label + */ + public function getExportDatasetLabel($r) + { + global $langs; + + $langstring = "ExportDataset_".$this->export_code[$r]; + if ($langs->trans($langstring) == $langstring) { + // Translation not found + return $langs->trans($this->export_label[$r]); + } + else + { + // Translation found + return $langs->trans($langstring); + } + } + + + /** + * Gives translated label of an import dataset + * + * @param int $r Dataset index + * + * @return string Translated dataset label + */ + public function getImportDatasetLabel($r) + { + global $langs; + + $langstring = "ImportDataset_".$this->import_code[$r]; + //print "x".$langstring; + if ($langs->trans($langstring) == $langstring) { + // Translation not found + return $langs->transnoentitiesnoconv($this->import_label[$r]); + } + else + { + // Translation found + return $langs->transnoentitiesnoconv($langstring); + } + } + + + /** + * Gives the last date of activation + * + * @return int|string Date of last activation or '' if module was never activated + */ + public function getLastActivationDate() + { + global $conf; + + $err = 0; + + $sql = "SELECT tms FROM ".MAIN_DB_PREFIX."const"; + $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; + $sql .= " AND entity IN (0, ".$conf->entity.")"; + + dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $err++; + } + else + { + $obj = $this->db->fetch_object($resql); + if ($obj) { + return $this->db->jdate($obj->tms); + } + } + + return ''; + } + + + /** + * Gives the last author of activation + * + * @return array Array array('authorid'=>Id of last activation user, 'lastactivationdate'=>Date of last activation) + */ + public function getLastActivationInfo() + { + global $conf; + + $err = 0; $sql = "SELECT tms, note FROM ".MAIN_DB_PREFIX."const"; $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; $sql .= " AND entity IN (0, ".$conf->entity.")"; - dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $err++; - } else { - $obj = $this->db->fetch_object($resql); - $tmp = array(); - if ($obj->note) { - $tmp = json_decode($obj->note, true); - } - if ($obj) { - return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms)); - } - } - - return array(); - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Insert constants for module activation - * - * @return int Error count (0 if OK) - */ - protected function _active() - { - // phpcs:enable - global $conf, $user; - - $err = 0; - - // Common module - $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; - $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; - $sql .= " AND entity IN (0, ".$entity.")"; - - dol_syslog(get_class($this)."::_active delete activation constant", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $err++; - } - - $note = json_encode(array('authorid'=>(is_object($user) ? $user->id : 0), 'ip'=>(empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']))); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name, value, visible, entity, note) VALUES"; - $sql .= " (".$this->db->encrypt($this->const_name, 1); - $sql .= ", ".$this->db->encrypt('1', 1); - $sql .= ", 0, ".$entity; - $sql .= ", '".$this->db->escape($note)."')"; - - dol_syslog(get_class($this)."::_active insert activation constant", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $err++; - } - - return $err; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Module deactivation - * - * @return int Error count (0 if OK) - */ - protected function _unactive() - { - // phpcs:enable - global $conf; - - $err = 0; - - // Common module - $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; - $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; - $sql .= " AND entity IN (0, ".$entity.")"; - - dol_syslog(get_class($this)."::_unactive", LOG_DEBUG); - $this->db->query($sql); - - return $err; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Create tables and keys required by module. - * Files module.sql and module.key.sql with create table and create keys - * commands must be stored in directory reldir='/module/sql/' - * This function is called by this->init - * - * @param string $reldir Relative directory where to scan files - * @return int <=0 if KO, >0 if OK - */ - protected function _load_tables($reldir) - { - // phpcs:enable - global $conf; - - $error = 0; - $dirfound = 0; - - if (empty($reldir)) { - return 1; - } - - include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - - $ok = 1; - foreach ($conf->file->dol_document_root as $dirroot) - { - if ($ok) { - $dir = $dirroot.$reldir; - $ok = 0; - - $handle = @opendir($dir); // Dir may not exists - if (is_resource($handle)) { - $dirfound++; - - // Run llx_mytable.sql files, then llx_mytable_*.sql - $files = array(); - while (($file = readdir($handle)) !== false) - { - $files[] = $file; - } - sort($files); - foreach ($files as $file) - { - if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') { - $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); - if ($result <= 0) { $error++; - } - } - } - - rewinddir($handle); - - // Run llx_mytable.key.sql files (Must be done after llx_mytable.sql) then then llx_mytable_*.key.sql - $files = array(); - while (($file = readdir($handle)) !== false) - { - $files[] = $file; - } - sort($files); - foreach ($files as $file) - { - if (preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') { - $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); - if ($result <= 0) { $error++; - } - } - } - - rewinddir($handle); - - // Run data_xxx.sql files (Must be done after llx_mytable.key.sql) - $files = array(); - while (($file = readdir($handle)) !== false) - { - $files[] = $file; - } - sort($files); - foreach ($files as $file) - { - if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'data') { - $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); - if ($result <= 0) { $error++; - } - } - } - - rewinddir($handle); - - // Run update_xxx.sql files - $files = array(); - while (($file = readdir($handle)) !== false) - { - $files[] = $file; - } - sort($files); - foreach ($files as $file) - { - if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 6) == 'update') { - $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); - if ($result <= 0) { $error++; - } - } - } - - closedir($handle); - } - - if ($error == 0) { - $ok = 1; - } - } - } - - if (!$dirfound) { - dol_syslog("A module ask to load sql files into ".$reldir." but this directory was not found.", LOG_WARNING); - } - return $ok; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Adds boxes - * - * @param string $option Options when disabling module ('newboxdefonly'=insert only boxes definition) - * - * @return int Error count (0 if OK) - */ - public function insert_boxes($option = '') - { - // phpcs:enable - include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; - - global $conf; - - $err = 0; - - if (is_array($this->boxes)) { - dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG); - - $pos_name = InfoBox::getListOfPagesForBoxes(); - - foreach ($this->boxes as $key => $value) - { - $file = isset($this->boxes[$key]['file']) ? $this->boxes[$key]['file'] : ''; - $note = isset($this->boxes[$key]['note']) ? $this->boxes[$key]['note'] : ''; - $enabledbydefaulton = isset($this->boxes[$key]['enabledbydefaulton']) ? $this->boxes[$key]['enabledbydefaulton'] : 'Home'; - - if (empty($file)) { $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] : ''; // For backward compatibility - } - if (empty($note)) { $note = isset($this->boxes[$key][2]) ? $this->boxes[$key][2] : ''; // For backward compatibility - } - - // Search if boxes def already present - $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."boxes_def"; - $sql .= " WHERE file = '".$this->db->escape($file)."'"; - $sql .= " AND entity = ".$conf->entity; - if ($note) { $sql .= " AND note ='".$this->db->escape($note)."'"; - } - - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); - if ($obj->nb == 0) { - $this->db->begin(); - - if (!$err) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, entity, note)"; - $sql .= " VALUES ('".$this->db->escape($file)."', "; - $sql .= $conf->entity.", "; - $sql .= $note ? "'".$this->db->escape($note)."'" : "null"; - $sql .= ")"; - - dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $err++; - } - } - if (!$err && !preg_match('/newboxdefonly/', $option)) { - $lastid = $this->db->last_insert_id(MAIN_DB_PREFIX."boxes_def", "rowid"); - - foreach ($pos_name as $key2 => $val2) - { - //print 'key2='.$key2.'-val2='.$val2."
\n"; - if ($enabledbydefaulton && $val2 != $enabledbydefaulton) { continue; // Not enabled by default onto this page. - } - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id,position,box_order,fk_user,entity)"; - $sql .= " VALUES (".$lastid.", ".$key2.", '0', 0, ".$conf->entity.")"; - - dol_syslog(get_class($this)."::insert_boxes onto page ".$key2."=".$val2."", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $err++; - } - } - } - - if (!$err) { - $this->db->commit(); - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - } - } - // else box already registered into database - } else { - $this->error = $this->db->lasterror(); - $err++; - } - } - } - - return $err; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Removes boxes - * - * @return int Error count (0 if OK) - */ - public function delete_boxes() - { - // phpcs:enable - global $conf; - - $err = 0; - - if (is_array($this->boxes)) { - foreach ($this->boxes as $key => $value) - { - //$titre = $this->boxes[$key][0]; - $file = $this->boxes[$key]['file']; - //$note = $this->boxes[$key][2]; - - // TODO If the box is also included by another module and the other module is still on, we should not remove it. - // For the moment, we manage this with hard coded exception - //print "Remove box ".$file.'
'; - if ($file == 'box_graph_product_distribution.php') { - if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - dol_syslog("We discard deleting module ".$file." because another module still active requires it."); - continue; - } - } - - if (empty($file)) { - $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] : ''; // For backward compatibility - } - - if ($this->db->type == 'sqlite3') { - // sqlite doesn't support "USING" syntax. - // TODO: remove this dependency. - $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes "; - $sql .= "WHERE ".MAIN_DB_PREFIX."boxes.box_id IN ("; - $sql .= "SELECT ".MAIN_DB_PREFIX."boxes_def.rowid "; - $sql .= "FROM ".MAIN_DB_PREFIX."boxes_def "; - $sql .= "WHERE ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."') "; - $sql .= "AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity; - } else { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; - $sql .= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def"; - $sql .= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid"; - $sql .= " AND ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."'"; - $sql .= " AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity; - } - - dol_syslog(get_class($this)."::delete_boxes", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $this->error = $this->db->lasterror(); - $err++; - } - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def"; - $sql .= " WHERE file = '".$this->db->escape($file)."'"; - $sql .= " AND entity = ".$conf->entity; // Do not use getEntity here, we want to delete only in current company - - dol_syslog(get_class($this)."::delete_boxes", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $this->error = $this->db->lasterror(); - $err++; - } - } - } - - return $err; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Adds cronjobs - * - * @return int Error count (0 if OK) - */ - public function insert_cronjobs() - { - // phpcs:enable - include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; - - global $conf; - - $err = 0; - - if (is_array($this->cronjobs)) { - dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG); - - foreach ($this->cronjobs as $key => $value) - { - $entity = isset($this->cronjobs[$key]['entity']) ? $this->cronjobs[$key]['entity'] : $conf->entity; - $label = isset($this->cronjobs[$key]['label']) ? $this->cronjobs[$key]['label'] : ''; - $jobtype = isset($this->cronjobs[$key]['jobtype']) ? $this->cronjobs[$key]['jobtype'] : ''; - $class = isset($this->cronjobs[$key]['class']) ? $this->cronjobs[$key]['class'] : ''; - $objectname = isset($this->cronjobs[$key]['objectname']) ? $this->cronjobs[$key]['objectname'] : ''; - $method = isset($this->cronjobs[$key]['method']) ? $this->cronjobs[$key]['method'] : ''; - $command = isset($this->cronjobs[$key]['command']) ? $this->cronjobs[$key]['command'] : ''; - $parameters = isset($this->cronjobs[$key]['parameters']) ? $this->cronjobs[$key]['parameters'] : ''; - $comment = isset($this->cronjobs[$key]['comment']) ? $this->cronjobs[$key]['comment'] : ''; - $frequency = isset($this->cronjobs[$key]['frequency']) ? $this->cronjobs[$key]['frequency'] : ''; - $unitfrequency = isset($this->cronjobs[$key]['unitfrequency']) ? $this->cronjobs[$key]['unitfrequency'] : ''; - $priority = isset($this->cronjobs[$key]['priority']) ? $this->cronjobs[$key]['priority'] : ''; - $datestart = isset($this->cronjobs[$key]['datestart']) ? $this->cronjobs[$key]['datestart'] : ''; - $dateend = isset($this->cronjobs[$key]['dateend']) ? $this->cronjobs[$key]['dateend'] : ''; - $status = isset($this->cronjobs[$key]['status']) ? $this->cronjobs[$key]['status'] : ''; - $test = isset($this->cronjobs[$key]['test']) ? $this->cronjobs[$key]['test'] : ''; // Line must be enabled or not (so visible or not) - - // Search if cron entry already present - $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob"; - $sql .= " WHERE module_name = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."'"; - if ($class) { - $sql .= " AND classesname = '".$this->db->escape($class)."'"; - } - if ($objectname) { - $sql .= " AND objectname = '".$this->db->escape($objectname)."'"; - } - if ($method) { - $sql .= " AND methodename = '".$this->db->escape($method)."'"; - } - if ($command) { - $sql .= " AND command = '".$this->db->escape($command)."'"; - } - $sql .= " AND entity = ".$entity; // Must be exact entity - - $now = dol_now(); - - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); - if ($obj->nb == 0) { - $this->db->begin(); - - if (!$err) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob (module_name, datec, datestart, dateend, label, jobtype, classesname, objectname, methodename, command, params, note,"; - if (is_int($frequency)) { $sql .= ' frequency,'; } - if (is_int($unitfrequency)) { $sql .= ' unitfrequency,'; } - if (is_int($priority)) { $sql .= ' priority,'; } - if (is_int($status)) { $sql .= ' status,'; } - $sql .= " entity, test)"; - $sql .= " VALUES ("; - $sql .= "'".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."', "; - $sql .= "'".$this->db->idate($now)."', "; - $sql .= ($datestart ? "'".$this->db->idate($datestart)."'" : "'".$this->db->idate($now)."'").", "; - $sql .= ($dateend ? "'".$this->db->idate($dateend)."'" : "NULL").", "; - $sql .= "'".$this->db->escape($label)."', "; - $sql .= "'".$this->db->escape($jobtype)."', "; - $sql .= ($class ? "'".$this->db->escape($class)."'" : "null").","; - $sql .= ($objectname ? "'".$this->db->escape($objectname)."'" : "null").","; - $sql .= ($method ? "'".$this->db->escape($method)."'" : "null").","; - $sql .= ($command ? "'".$this->db->escape($command)."'" : "null").","; - $sql .= ($parameters ? "'".$this->db->escape($parameters)."'" : "null").","; - $sql .= ($comment ? "'".$this->db->escape($comment)."'" : "null").","; - if (is_int($frequency)) { $sql .= "'".$this->db->escape($frequency)."', "; - } - if (is_int($unitfrequency)) { $sql .= "'".$this->db->escape($unitfrequency)."', "; - } - if (is_int($priority)) {$sql .= "'".$this->db->escape($priority)."', "; - } - if (is_int($status)) { $sql .= "'".$this->db->escape($status)."', "; - } - $sql .= $entity.","; - $sql .= "'".$this->db->escape($test)."'"; - $sql .= ")"; - - $resql = $this->db->query($sql); - if (!$resql) { $err++; - } - } - - if (!$err) { - $this->db->commit(); - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - } - } - // else box already registered into database - } else { - $this->error = $this->db->lasterror(); - $err++; - } - } - } - - return $err; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Removes boxes - * - * @return int Error count (0 if OK) - */ - public function delete_cronjobs() - { - // phpcs:enable - global $conf; - - $err = 0; - - if (is_array($this->cronjobs)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob"; - $sql .= " WHERE module_name = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."'"; - $sql .= " AND entity = ".$conf->entity; - $sql .= " AND test = '1'"; // We delete on lines that are not set with a complete test that is '$conf->module->enabled' so when module is disabled, the cron is also removed. - // For crons declared with a '$conf->module->enabled', there is no need to delete the line, so we don't loose setup if we reenable module. - - dol_syslog(get_class($this)."::delete_cronjobs", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $this->error = $this->db->lasterror(); - $err++; - } - } - - return $err; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Removes tabs - * - * @return int Error count (0 if OK) - */ - public function delete_tabs() - { - // phpcs:enable - global $conf; - - $err = 0; - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; - $sql .= " WHERE ".$this->db->decrypt('name')." like '".$this->db->escape($this->const_name)."_TABS_%'"; - $sql .= " AND entity = ".$conf->entity; - - dol_syslog(get_class($this)."::delete_tabs", LOG_DEBUG); - if (!$this->db->query($sql)) { - $this->error = $this->db->lasterror(); - $err++; - } - - return $err; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Adds tabs - * - * @return int Error count (0 if ok) - */ - public function insert_tabs() - { - // phpcs:enable - global $conf; - - $err = 0; - - if (!empty($this->tabs)) { - dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG); - - $i = 0; - foreach ($this->tabs as $key => $value) - { - if (is_array($value) && count($value) == 0) { continue; // Discard empty arrays - } - - $entity = $conf->entity; - $newvalue = $value; - - if (is_array($value)) { - $newvalue = $value['data']; - if (isset($value['entity'])) { $entity = $value['entity']; - } - } - - if ($newvalue) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."const ("; - $sql .= "name"; - $sql .= ", type"; - $sql .= ", value"; - $sql .= ", note"; - $sql .= ", visible"; - $sql .= ", entity"; - $sql .= ")"; - $sql .= " VALUES ("; - $sql .= $this->db->encrypt($this->const_name."_TABS_".$i, 1); - $sql .= ", 'chaine'"; - $sql .= ", ".$this->db->encrypt($newvalue, 1); - $sql .= ", null"; - $sql .= ", '0'"; - $sql .= ", ".$entity; - $sql .= ")"; - - $resql = $this->db->query($sql); - if (!$resql) { - dol_syslog($this->db->lasterror(), LOG_ERR); - if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $this->error = $this->db->lasterror(); - $this->errors[] = $this->db->lasterror(); - $err++; - break; - } - } - } - $i++; - } - } - return $err; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Adds constants - * - * @return int Error count (0 if OK) - */ - public function insert_const() - { - // phpcs:enable - global $conf; - - $err = 0; - - if (empty($this->const)) { return 0; - } - - dol_syslog(get_class($this)."::insert_const", LOG_DEBUG); - - foreach ($this->const as $key => $value) - { - $name = $this->const[$key][0]; - $type = $this->const[$key][1]; - $val = $this->const[$key][2]; - $note = isset($this->const[$key][3]) ? $this->const[$key][3] : ''; - $visible = isset($this->const[$key][4]) ? $this->const[$key][4] : 0; - $entity = (!empty($this->const[$key][5]) && $this->const[$key][5] != 'current') ? 0 : $conf->entity; - - // Clean - if (empty($visible)) { $visible = '0'; - } - if (empty($val) && $val != '0') { $val = ''; - } - - $sql = "SELECT count(*)"; - $sql .= " FROM ".MAIN_DB_PREFIX."const"; - $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($name)."'"; - $sql .= " AND entity = ".$entity; - - $result = $this->db->query($sql); - if ($result) { - $row = $this->db->fetch_row($result); - - if ($row[0] == 0) // If not found - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,note,visible,entity)"; - $sql .= " VALUES ("; - $sql .= $this->db->encrypt($name, 1); - $sql .= ",'".$this->db->escape($type)."'"; - $sql .= ",".(($val != '') ? $this->db->encrypt($val, 1) : "''"); - $sql .= ",".($note ? "'".$this->db->escape($note)."'" : "null"); - $sql .= ",'".$this->db->escape($visible)."'"; - $sql .= ",".$entity; - $sql .= ")"; - - if (!$this->db->query($sql)) { - $err++; - } - } else { - dol_syslog(get_class($this)."::insert_const constant '".$name."' already exists", LOG_WARNING); - } - } else { - $err++; - } - } - - return $err; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Removes constants tagged 'deleteonunactive' - * - * @return int <0 if KO, 0 if OK - */ - public function delete_const() - { - // phpcs:enable - global $conf; - - $err = 0; - - if (empty($this->const)) { return 0; - } - - foreach ($this->const as $key => $value) - { - $name = $this->const[$key][0]; - $deleteonunactive = (!empty($this->const[$key][6])) ? 1 : 0; - - if ($deleteonunactive) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; - $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($name)."'"; - $sql .= " AND entity in (0, ".$conf->entity.")"; - dol_syslog(get_class($this)."::delete_const", LOG_DEBUG); - if (!$this->db->query($sql)) { - $this->error = $this->db->lasterror(); - $err++; - } - } - } - - return $err; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Adds access rights - * - * @param int $reinitadminperms If 1, we also grant them to all admin users - * @param int $force_entity Force current entity - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int Error count (0 if OK) - */ - public function insert_permissions($reinitadminperms = 0, $force_entity = null, $notrigger = 0) - { - // phpcs:enable - global $conf, $user; - - $err = 0; - $entity = (!empty($force_entity) ? $force_entity : $conf->entity); - - dol_syslog(get_class($this)."::insert_permissions", LOG_DEBUG); - - // Test if module is activated - $sql_del = "SELECT ".$this->db->decrypt('value')." as value"; - $sql_del .= " FROM ".MAIN_DB_PREFIX."const"; - $sql_del .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; - $sql_del .= " AND entity IN (0,".$entity.")"; - - $resql = $this->db->query($sql_del); - - if ($resql) { - $obj = $this->db->fetch_object($resql); - if ($obj !== null && !empty($obj->value) && !empty($this->rights)) { - // If the module is active - foreach ($this->rights as $key => $value) - { - $r_id = $this->rights[$key][0]; - $r_desc = $this->rights[$key][1]; - $r_type = isset($this->rights[$key][2]) ? $this->rights[$key][2] : ''; - $r_def = empty($this->rights[$key][3]) ? 0 : $this->rights[$key][3]; - $r_perms = $this->rights[$key][4]; - $r_subperms = isset($this->rights[$key][5]) ? $this->rights[$key][5] : ''; - $r_modul = empty($this->rights_class) ?strtolower($this->name) : $this->rights_class; - - if (empty($r_type)) { $r_type = 'w'; } - - // Search if perm already present - $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def"; - $sql .= " WHERE id = ".$r_id." AND entity = ".$entity; - - $resqlselect = $this->db->query($sql); - if ($resqlselect) { - $objcount = $this->db->fetch_object($resqlselect); - if ($objcount && $objcount->nb == 0) { - if (dol_strlen($r_perms)) { - if (dol_strlen($r_subperms)) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def"; - $sql .= " (id, entity, libelle, module, type, bydefault, perms, subperms)"; - $sql .= " VALUES "; - $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$this->db->escape($r_modul)."','".$this->db->escape($r_type)."',".$r_def.",'".$this->db->escape($r_perms)."','".$this->db->escape($r_subperms)."')"; - } else { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def"; - $sql .= " (id, entity, libelle, module, type, bydefault, perms)"; - $sql .= " VALUES "; - $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$this->db->escape($r_modul)."','".$this->db->escape($r_type)."',".$r_def.",'".$this->db->escape($r_perms)."')"; - } - } else { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def "; - $sql .= " (id, entity, libelle, module, type, bydefault)"; - $sql .= " VALUES "; - $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$this->db->escape($r_modul)."','".$this->db->escape($r_type)."',".$r_def.")"; - } - - $resqlinsert = $this->db->query($sql, 1); - - if (!$resqlinsert) { - if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") { - $this->error = $this->db->lasterror(); - $err++; - break; - } else { dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO); - } - } - - $this->db->free($resqlinsert); - } - - $this->db->free($resqlselect); - } - - // If we want to init permissions on admin users - if ($reinitadminperms) { - if (!class_exists('User')) { - include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - } - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 1"; - dol_syslog(get_class($this)."::insert_permissions Search all admin users", LOG_DEBUG); - $resqlseladmin = $this->db->query($sql, 1); - if ($resqlseladmin) { - $num = $this->db->num_rows($resqlseladmin); - $i = 0; - while ($i < $num) - { - $obj2 = $this->db->fetch_object($resqlseladmin); - dol_syslog(get_class($this)."::insert_permissions Add permission to user id=".$obj2->rowid); - - $tmpuser = new User($this->db); - $result = $tmpuser->fetch($obj2->rowid); - if ($result > 0) { - $tmpuser->addrights($r_id, '', '', 0, 1); - } else { - dol_syslog(get_class($this)."::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR); - } - $i++; - } - } else { - dol_print_error($this->db); - } - } - } - - if ($reinitadminperms && !empty($user->admin)) // Reload permission for current user if defined - { - // We reload permissions - $user->clearrights(); - $user->getrights(); - } - } - $this->db->free($resql); - } else { - $this->error = $this->db->lasterror(); - $err++; - } - - return $err; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Removes access rights - * - * @return int Error count (0 if OK) - */ - public function delete_permissions() - { - // phpcs:enable - global $conf; - - $err = 0; - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."rights_def"; - $sql .= " WHERE module = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."'"; - $sql .= " AND entity = ".$conf->entity; - dol_syslog(get_class($this)."::delete_permissions", LOG_DEBUG); - if (!$this->db->query($sql)) { - $this->error = $this->db->lasterror(); - $err++; - } - - return $err; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Adds menu entries - * - * @return int Error count (0 if OK) - */ - public function insert_menus() - { - // phpcs:enable - global $user; - - if (!is_array($this->menu) || empty($this->menu)) { return 0; - } - - include_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; - - dol_syslog(get_class($this)."::insert_menus", LOG_DEBUG); - - $err = 0; - - $this->db->begin(); - - foreach ($this->menu as $key => $value) - { - $menu = new Menubase($this->db); - $menu->menu_handler = 'all'; - - //$menu->module=strtolower($this->name); TODO When right_class will be same than module name - $menu->module = empty($this->rights_class) ?strtolower($this->name) : $this->rights_class; - - if (!$this->menu[$key]['fk_menu']) { - $menu->fk_menu = 0; - } else { - $foundparent = 0; - $fk_parent = $this->menu[$key]['fk_menu']; - if (preg_match('/^r=/', $fk_parent)) // old deprecated method - { - $fk_parent = str_replace('r=', '', $fk_parent); - if (isset($this->menu[$fk_parent]['rowid'])) { - $menu->fk_menu = $this->menu[$fk_parent]['rowid']; - $foundparent = 1; - } - } elseif (preg_match('/^fk_mainmenu=([a-zA-Z0-9_]+),fk_leftmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) { - $menu->fk_menu = -1; - $menu->fk_mainmenu = $reg[1]; - $menu->fk_leftmenu = $reg[2]; - $foundparent = 1; - } elseif (preg_match('/^fk_mainmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) { - $menu->fk_menu = -1; - $menu->fk_mainmenu = $reg[1]; - $menu->fk_leftmenu = ''; - $foundparent = 1; - } - if (!$foundparent) { - $this->error = "ErrorBadDefinitionOfMenuArrayInModuleDescriptor"; - dol_syslog(get_class($this)."::insert_menus ".$this->error." ".$this->menu[$key]['fk_menu'], LOG_ERR); - $err++; - } - } - $menu->type = $this->menu[$key]['type']; - $menu->mainmenu = isset($this->menu[$key]['mainmenu']) ? $this->menu[$key]['mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu : ''); - $menu->leftmenu = isset($this->menu[$key]['leftmenu']) ? $this->menu[$key]['leftmenu'] : ''; - $menu->title = $this->menu[$key]['titre']; - $menu->url = $this->menu[$key]['url']; - $menu->langs = $this->menu[$key]['langs']; - $menu->position = $this->menu[$key]['position']; - $menu->perms = $this->menu[$key]['perms']; - $menu->target = isset($this->menu[$key]['target']) ? $this->menu[$key]['target'] : ''; - $menu->user = $this->menu[$key]['user']; - $menu->enabled = isset($this->menu[$key]['enabled']) ? $this->menu[$key]['enabled'] : 0; - $menu->position = $this->menu[$key]['position']; - - if (!$err) { - $result = $menu->create($user); // Save menu entry into table llx_menu - if ($result > 0) { - $this->menu[$key]['rowid'] = $result; - } else { - $this->error = $menu->error; - dol_syslog(get_class($this).'::insert_menus result='.$result." ".$this->error, LOG_ERR); - $err++; - break; - } - } - } - - if (!$err) { - $this->db->commit(); - } else { - dol_syslog(get_class($this)."::insert_menus ".$this->error, LOG_ERR); - $this->db->rollback(); - } - - return $err; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Removes menu entries - * - * @return int Error count (0 if OK) - */ - public function delete_menus() - { - // phpcs:enable - global $conf; - - $err = 0; - - //$module=strtolower($this->name); TODO When right_class will be same than module name - $module = empty($this->rights_class) ?strtolower($this->name) : $this->rights_class; - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu"; - $sql .= " WHERE module = '".$this->db->escape($module)."'"; - $sql .= " AND entity = ".$conf->entity; - - dol_syslog(get_class($this)."::delete_menus", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $this->error = $this->db->lasterror(); - $err++; - } - - return $err; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Creates directories - * - * @return int Error count (0 if OK) - */ - public function create_dirs() - { - // phpcs:enable - global $langs, $conf; - - $err = 0; - - if (isset($this->dirs) && is_array($this->dirs)) { - foreach ($this->dirs as $key => $value) - { - $addtodatabase = 0; - - if (!is_array($value)) { $dir = $value; // Default simple mode - } else { - $constname = $this->const_name."_DIR_"; - $dir = $this->dirs[$key][1]; - $addtodatabase = empty($this->dirs[$key][2]) ? '' : $this->dirs[$key][2]; // Create constante in llx_const - $subname = empty($this->dirs[$key][3]) ? '' : strtoupper($this->dirs[$key][3]); // Add submodule name (ex: $conf->module->submodule->dir_output) - $forcename = empty($this->dirs[$key][4]) ? '' : strtoupper($this->dirs[$key][4]); // Change the module name if different - - if (!empty($forcename)) { $constname = 'MAIN_MODULE_'.$forcename."_DIR_"; - } - if (!empty($subname)) { $constname = $constname.$subname."_"; - } - - $name = $constname.strtoupper($this->dirs[$key][0]); - } - - // Define directory full path ($dir must start with "/") - if (empty($conf->global->MAIN_MODULE_MULTICOMPANY) || $conf->entity == 1) { $fulldir = DOL_DATA_ROOT.$dir; - } else { $fulldir = DOL_DATA_ROOT."/".$conf->entity.$dir; - } - // Create dir if it does not exists - if (!empty($fulldir) && !file_exists($fulldir)) { - if (dol_mkdir($fulldir, DOL_DATA_ROOT) < 0) { - $this->error = $langs->trans("ErrorCanNotCreateDir", $fulldir); - dol_syslog(get_class($this)."::_init ".$this->error, LOG_ERR); - $err++; - } - } - - // Define the constant in database if requested (not the default mode) - if (!empty($addtodatabase)) { - $result = $this->insert_dirs($name, $dir); - if ($result) { $err++; - } - } - } - } - - return $err; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Adds directories definitions - * - * @param string $name Name - * @param string $dir Directory - * - * @return int Error count (0 if OK) - */ - public function insert_dirs($name, $dir) - { - // phpcs:enable - global $conf; - - $err = 0; - - $sql = "SELECT count(*)"; - $sql .= " FROM ".MAIN_DB_PREFIX."const"; - $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($name)."'"; - $sql .= " AND entity = ".$conf->entity; - - dol_syslog(get_class($this)."::insert_dirs", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $row = $this->db->fetch_row($result); - - if ($row[0] == 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,note,visible,entity)"; - $sql .= " VALUES (".$this->db->encrypt($name, 1).",'chaine',".$this->db->encrypt($dir, 1).",'Directory for module ".$this->name."','0',".$conf->entity.")"; - - dol_syslog(get_class($this)."::insert_dirs", LOG_DEBUG); - $this->db->query($sql); - } - } else { - $this->error = $this->db->lasterror(); - $err++; - } - - return $err; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Removes directories - * - * @return int Error count (0 if OK) - */ - public function delete_dirs() - { - // phpcs:enable - global $conf; - - $err = 0; - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; - $sql .= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->db->escape($this->const_name)."_DIR_%'"; - $sql .= " AND entity = ".$conf->entity; - - dol_syslog(get_class($this)."::delete_dirs", LOG_DEBUG); - if (!$this->db->query($sql)) { - $this->error = $this->db->lasterror(); - $err++; - } - - return $err; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Adds generic parts - * - * @return int Error count (0 if OK) - */ - public function insert_module_parts() - { - // phpcs:enable - global $conf; - - $error = 0; - - if (is_array($this->module_parts) && !empty($this->module_parts)) { - foreach ($this->module_parts as $key => $value) - { - if (is_array($value) && count($value) == 0) { continue; // Discard empty arrays - } - - $entity = $conf->entity; // Reset the current entity - $newvalue = $value; - - // Serialize array parameters - if (is_array($value)) { - // Can defined other parameters - // Example when $key='hooks', then $value is an array('data'=>array('hookcontext1','hookcontext2'), 'entity'=>X) - if (isset($value['data']) && is_array($value['data'])) { - $newvalue = json_encode($value['data']); - if (isset($value['entity'])) { $entity = $value['entity']; - } - } elseif (isset($value['data']) && !is_array($value['data'])) { - $newvalue = $value['data']; - if (isset($value['entity'])) { $entity = $value['entity']; - } - } else // when hook is declared with syntax 'hook'=>array('hookcontext1','hookcontext2',...) - { - $newvalue = json_encode($value); - } - } - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."const ("; - $sql .= "name"; - $sql .= ", type"; - $sql .= ", value"; - $sql .= ", note"; - $sql .= ", visible"; - $sql .= ", entity"; - $sql .= ")"; - $sql .= " VALUES ("; - $sql .= $this->db->encrypt($this->const_name."_".strtoupper($key), 1); - $sql .= ", 'chaine'"; - $sql .= ", ".$this->db->encrypt($newvalue, 1); - $sql .= ", null"; - $sql .= ", '0'"; - $sql .= ", ".$entity; - $sql .= ")"; - - dol_syslog(get_class($this)."::insert_module_parts for key=".$this->const_name."_".strtoupper($key), LOG_DEBUG); - - $resql = $this->db->query($sql, 1); - if (!$resql) { - if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $error++; - $this->error = $this->db->lasterror(); - } else { - dol_syslog(get_class($this)."::insert_module_parts for ".$this->const_name."_".strtoupper($key)." Record already exists.", LOG_WARNING); - } - } - } - } - return $error; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Removes generic parts - * - * @return int Error count (0 if OK) - */ - public function delete_module_parts() - { - // phpcs:enable - global $conf; - - $err = 0; - $entity = $conf->entity; - - if (is_array($this->module_parts) && !empty($this->module_parts)) { - foreach ($this->module_parts as $key => $value) - { - // If entity is defined - if (is_array($value) && isset($value['entity'])) { $entity = $value['entity']; - } - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; - $sql .= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->db->escape($this->const_name)."_".strtoupper($key)."'"; - $sql .= " AND entity = ".$entity; - - dol_syslog(get_class($this)."::delete_const_".$key."", LOG_DEBUG); - if (!$this->db->query($sql)) { - $this->error = $this->db->lasterror(); - $err++; - } - } - } - return $err; - } - - /** - * Function called when module is enabled. - * The init function adds tabs, constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') - * 'noboxes' = Do not insert boxes 'newboxdefonly' = For boxes, - * insert def of boxes only and not boxes activation - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - return $this->_init(array(), $options); - } - - /** - * Function called when module is disabled. - * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function remove($options = '') - { - return $this->_remove(array(), $options); - } - - - /** - * Return Kanban view of a module - * - * @param string $codeenabledisable HTML code for button to enable/disable module - * @param string $codetoconfig HTML code to go to config page - * @return string HTML code of Kanban view - */ - public function getKanbanView($codeenabledisable = '', $codetoconfig = '') - { - global $conf, $langs; - - // Define imginfo - $imginfo = "info"; - if ($this->isCoreOrExternalModule() == 'external') - { - $imginfo = "info_black"; - } - - $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($this))); - - $version = $this->getVersion(0); - $versiontrans = ''; - if (preg_match('/development/i', $version)) $versiontrans .= 'warning'; - if (preg_match('/experimental/i', $version)) $versiontrans .= 'warning'; - if (preg_match('/deprecated/i', $version)) $versiontrans .= 'warning'; + dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $err++; + } + else + { + $obj = $this->db->fetch_object($resql); + $tmp = array(); + if ($obj->note) { + $tmp = json_decode($obj->note, true); + } + if ($obj) { + return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms)); + } + } + + return array(); + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Insert constants for module activation + * + * @return int Error count (0 if OK) + */ + protected function _active() + { + // phpcs:enable + global $conf, $user; + + $err = 0; + + // Common module + $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; + $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; + $sql .= " AND entity IN (0, ".$entity.")"; + + dol_syslog(get_class($this)."::_active delete activation constant", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $err++; + } + + $note = json_encode(array('authorid'=>(is_object($user) ? $user->id : 0), 'ip'=>(empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']))); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name, value, visible, entity, note) VALUES"; + $sql .= " (".$this->db->encrypt($this->const_name, 1); + $sql .= ", ".$this->db->encrypt('1', 1); + $sql .= ", 0, ".$entity; + $sql .= ", '".$this->db->escape($note)."')"; + + dol_syslog(get_class($this)."::_active insert activation constant", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { $err++; + } + + return $err; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Module deactivation + * + * @return int Error count (0 if OK) + */ + protected function _unactive() + { + // phpcs:enable + global $conf; + + $err = 0; + + // Common module + $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; + $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; + $sql .= " AND entity IN (0, ".$entity.")"; + + dol_syslog(get_class($this)."::_unactive", LOG_DEBUG); + $this->db->query($sql); + + return $err; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Create tables and keys required by module. + * Files module.sql and module.key.sql with create table and create keys + * commands must be stored in directory reldir='/module/sql/' + * This function is called by this->init + * + * @param string $reldir Relative directory where to scan files + * @return int <=0 if KO, >0 if OK + */ + protected function _load_tables($reldir) + { + // phpcs:enable + global $conf; + + $error = 0; + $dirfound = 0; + + if (empty($reldir)) { + return 1; + } + + include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + + $ok = 1; + foreach ($conf->file->dol_document_root as $dirroot) + { + if ($ok) { + $dir = $dirroot.$reldir; + $ok = 0; + + $handle = @opendir($dir); // Dir may not exists + if (is_resource($handle)) { + $dirfound++; + + // Run llx_mytable.sql files, then llx_mytable_*.sql + $files = array(); + while (($file = readdir($handle)) !== false) + { + $files[] = $file; + } + sort($files); + foreach ($files as $file) + { + if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') { + $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); + if ($result <= 0) { $error++; + } + } + } + + rewinddir($handle); + + // Run llx_mytable.key.sql files (Must be done after llx_mytable.sql) then then llx_mytable_*.key.sql + $files = array(); + while (($file = readdir($handle)) !== false) + { + $files[] = $file; + } + sort($files); + foreach ($files as $file) + { + if (preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') { + $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); + if ($result <= 0) { $error++; + } + } + } + + rewinddir($handle); + + // Run data_xxx.sql files (Must be done after llx_mytable.key.sql) + $files = array(); + while (($file = readdir($handle)) !== false) + { + $files[] = $file; + } + sort($files); + foreach ($files as $file) + { + if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'data') { + $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); + if ($result <= 0) { $error++; + } + } + } + + rewinddir($handle); + + // Run update_xxx.sql files + $files = array(); + while (($file = readdir($handle)) !== false) + { + $files[] = $file; + } + sort($files); + foreach ($files as $file) + { + if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 6) == 'update') { + $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); + if ($result <= 0) { $error++; + } + } + } + + closedir($handle); + } + + if ($error == 0) { + $ok = 1; + } + } + } + + if (!$dirfound) { + dol_syslog("A module ask to load sql files into ".$reldir." but this directory was not found.", LOG_WARNING); + } + return $ok; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Adds boxes + * + * @param string $option Options when disabling module ('newboxdefonly'=insert only boxes definition) + * + * @return int Error count (0 if OK) + */ + public function insert_boxes($option = '') + { + // phpcs:enable + include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; + + global $conf; + + $err = 0; + + if (is_array($this->boxes)) { + dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG); + + $pos_name = InfoBox::getListOfPagesForBoxes(); + + foreach ($this->boxes as $key => $value) + { + $file = isset($this->boxes[$key]['file']) ? $this->boxes[$key]['file'] : ''; + $note = isset($this->boxes[$key]['note']) ? $this->boxes[$key]['note'] : ''; + $enabledbydefaulton = isset($this->boxes[$key]['enabledbydefaulton']) ? $this->boxes[$key]['enabledbydefaulton'] : 'Home'; + + if (empty($file)) { $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] : ''; // For backward compatibility + } + if (empty($note)) { $note = isset($this->boxes[$key][2]) ? $this->boxes[$key][2] : ''; // For backward compatibility + } + + // Search if boxes def already present + $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."boxes_def"; + $sql .= " WHERE file = '".$this->db->escape($file)."'"; + $sql .= " AND entity = ".$conf->entity; + if ($note) { $sql .= " AND note ='".$this->db->escape($note)."'"; + } + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + if ($obj->nb == 0) { + $this->db->begin(); + + if (!$err) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, entity, note)"; + $sql .= " VALUES ('".$this->db->escape($file)."', "; + $sql .= $conf->entity.", "; + $sql .= $note ? "'".$this->db->escape($note)."'" : "null"; + $sql .= ")"; + + dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { $err++; + } + } + if (!$err && !preg_match('/newboxdefonly/', $option)) { + $lastid = $this->db->last_insert_id(MAIN_DB_PREFIX."boxes_def", "rowid"); + + foreach ($pos_name as $key2 => $val2) + { + //print 'key2='.$key2.'-val2='.$val2."
\n"; + if ($enabledbydefaulton && $val2 != $enabledbydefaulton) { continue; // Not enabled by default onto this page. + } + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id,position,box_order,fk_user,entity)"; + $sql .= " VALUES (".$lastid.", ".$key2.", '0', 0, ".$conf->entity.")"; + + dol_syslog(get_class($this)."::insert_boxes onto page ".$key2."=".$val2."", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { $err++; + } + } + } + + if (!$err) { + $this->db->commit(); + } + else + { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + } + } + // else box already registered into database + } + else + { + $this->error = $this->db->lasterror(); + $err++; + } + } + } + + return $err; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Removes boxes + * + * @return int Error count (0 if OK) + */ + public function delete_boxes() + { + // phpcs:enable + global $conf; + + $err = 0; + + if (is_array($this->boxes)) { + foreach ($this->boxes as $key => $value) + { + //$titre = $this->boxes[$key][0]; + $file = $this->boxes[$key]['file']; + //$note = $this->boxes[$key][2]; + + // TODO If the box is also included by another module and the other module is still on, we should not remove it. + // For the moment, we manage this with hard coded exception + //print "Remove box ".$file.'
'; + if ($file == 'box_graph_product_distribution.php') { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + dol_syslog("We discard disabling of module ".$file." because another module still active require it."); + continue; + } + } + + if (empty($file)) { $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] : ''; // For backward compatibility + } + + if ($this->db->type == 'sqlite3') { + // sqlite doesn't support "USING" syntax. + // TODO: remove this dependency. + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes "; + $sql .= "WHERE ".MAIN_DB_PREFIX."boxes.box_id IN ("; + $sql .= "SELECT ".MAIN_DB_PREFIX."boxes_def.rowid "; + $sql .= "FROM ".MAIN_DB_PREFIX."boxes_def "; + $sql .= "WHERE ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."') "; + $sql .= "AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity; + } else { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; + $sql .= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def"; + $sql .= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid"; + $sql .= " AND ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."'"; + $sql .= " AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity; + } + + dol_syslog(get_class($this)."::delete_boxes", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = $this->db->lasterror(); + $err++; + } + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def"; + $sql .= " WHERE file = '".$this->db->escape($file)."'"; + $sql .= " AND entity = ".$conf->entity; + + dol_syslog(get_class($this)."::delete_boxes", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = $this->db->lasterror(); + $err++; + } + } + } + + return $err; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Adds cronjobs + * + * @return int Error count (0 if OK) + */ + public function insert_cronjobs() + { + // phpcs:enable + include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; + + global $conf; + + $err = 0; + + if (is_array($this->cronjobs)) { + dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG); + + foreach ($this->cronjobs as $key => $value) + { + $entity = isset($this->cronjobs[$key]['entity']) ? $this->cronjobs[$key]['entity'] : $conf->entity; + $label = isset($this->cronjobs[$key]['label']) ? $this->cronjobs[$key]['label'] : ''; + $jobtype = isset($this->cronjobs[$key]['jobtype']) ? $this->cronjobs[$key]['jobtype'] : ''; + $class = isset($this->cronjobs[$key]['class']) ? $this->cronjobs[$key]['class'] : ''; + $objectname = isset($this->cronjobs[$key]['objectname']) ? $this->cronjobs[$key]['objectname'] : ''; + $method = isset($this->cronjobs[$key]['method']) ? $this->cronjobs[$key]['method'] : ''; + $command = isset($this->cronjobs[$key]['command']) ? $this->cronjobs[$key]['command'] : ''; + $parameters = isset($this->cronjobs[$key]['parameters']) ? $this->cronjobs[$key]['parameters'] : ''; + $comment = isset($this->cronjobs[$key]['comment']) ? $this->cronjobs[$key]['comment'] : ''; + $frequency = isset($this->cronjobs[$key]['frequency']) ? $this->cronjobs[$key]['frequency'] : ''; + $unitfrequency = isset($this->cronjobs[$key]['unitfrequency']) ? $this->cronjobs[$key]['unitfrequency'] : ''; + $priority = isset($this->cronjobs[$key]['priority']) ? $this->cronjobs[$key]['priority'] : ''; + $datestart = isset($this->cronjobs[$key]['datestart']) ? $this->cronjobs[$key]['datestart'] : ''; + $dateend = isset($this->cronjobs[$key]['dateend']) ? $this->cronjobs[$key]['dateend'] : ''; + $status = isset($this->cronjobs[$key]['status']) ? $this->cronjobs[$key]['status'] : ''; + $test = isset($this->cronjobs[$key]['test']) ? $this->cronjobs[$key]['test'] : ''; // Line must be enabled or not (so visible or not) + + // Search if cron entry already present + $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob"; + $sql .= " WHERE module_name = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."'"; + if ($class) { + $sql .= " AND classesname = '".$this->db->escape($class)."'"; + } + if ($objectname) { + $sql .= " AND objectname = '".$this->db->escape($objectname)."'"; + } + if ($method) { + $sql .= " AND methodename = '".$this->db->escape($method)."'"; + } + if ($command) { + $sql .= " AND command = '".$this->db->escape($command)."'"; + } + $sql .= " AND entity = ".$entity; // Must be exact entity + + $now = dol_now(); + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + if ($obj->nb == 0) { + $this->db->begin(); + + if (!$err) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob (module_name, datec, datestart, dateend, label, jobtype, classesname, objectname, methodename, command, params, note,"; + if (is_int($frequency)) { $sql .= ' frequency,'; } + if (is_int($unitfrequency)) { $sql .= ' unitfrequency,'; } + if (is_int($priority)) { $sql .= ' priority,'; } + if (is_int($status)) { $sql .= ' status,'; } + $sql .= " entity, test)"; + $sql .= " VALUES ("; + $sql .= "'".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."', "; + $sql .= "'".$this->db->idate($now)."', "; + $sql .= ($datestart ? "'".$this->db->idate($datestart)."'" : "'".$this->db->idate($now)."'").", "; + $sql .= ($dateend ? "'".$this->db->idate($dateend)."'" : "NULL").", "; + $sql .= "'".$this->db->escape($label)."', "; + $sql .= "'".$this->db->escape($jobtype)."', "; + $sql .= ($class ? "'".$this->db->escape($class)."'" : "null").","; + $sql .= ($objectname ? "'".$this->db->escape($objectname)."'" : "null").","; + $sql .= ($method ? "'".$this->db->escape($method)."'" : "null").","; + $sql .= ($command ? "'".$this->db->escape($command)."'" : "null").","; + $sql .= ($parameters ? "'".$this->db->escape($parameters)."'" : "null").","; + $sql .= ($comment ? "'".$this->db->escape($comment)."'" : "null").","; + if (is_int($frequency)) { $sql .= "'".$this->db->escape($frequency)."', "; + } + if (is_int($unitfrequency)) { $sql .= "'".$this->db->escape($unitfrequency)."', "; + } + if (is_int($priority)) {$sql .= "'".$this->db->escape($priority)."', "; + } + if (is_int($status)) { $sql .= "'".$this->db->escape($status)."', "; + } + $sql .= $entity.","; + $sql .= "'".$this->db->escape($test)."'"; + $sql .= ")"; + + $resql = $this->db->query($sql); + if (!$resql) { $err++; + } + } + + if (!$err) { + $this->db->commit(); + } + else + { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + } + } + // else box already registered into database + } + else + { + $this->error = $this->db->lasterror(); + $err++; + } + } + } + + return $err; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Removes boxes + * + * @return int Error count (0 if OK) + */ + public function delete_cronjobs() + { + // phpcs:enable + global $conf; + + $err = 0; + + if (is_array($this->cronjobs)) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob"; + $sql .= " WHERE module_name = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."'"; + $sql .= " AND entity = ".$conf->entity; + $sql .= " AND test = '1'"; // We delete on lines that are not set with a complete test that is '$conf->module->enabled' so when module is disabled, the cron is also removed. + // For crons declared with a '$conf->module->enabled', there is no need to delete the line, so we don't loose setup if we reenable module. + + dol_syslog(get_class($this)."::delete_cronjobs", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = $this->db->lasterror(); + $err++; + } + } + + return $err; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Removes tabs + * + * @return int Error count (0 if OK) + */ + public function delete_tabs() + { + // phpcs:enable + global $conf; + + $err = 0; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; + $sql .= " WHERE ".$this->db->decrypt('name')." like '".$this->db->escape($this->const_name)."_TABS_%'"; + $sql .= " AND entity = ".$conf->entity; + + dol_syslog(get_class($this)."::delete_tabs", LOG_DEBUG); + if (!$this->db->query($sql)) { + $this->error = $this->db->lasterror(); + $err++; + } + + return $err; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Adds tabs + * + * @return int Error count (0 if ok) + */ + public function insert_tabs() + { + // phpcs:enable + global $conf; + + $err = 0; + + if (!empty($this->tabs)) { + dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG); + + $i = 0; + foreach ($this->tabs as $key => $value) + { + if (is_array($value) && count($value) == 0) { continue; // Discard empty arrays + } + + $entity = $conf->entity; + $newvalue = $value; + + if (is_array($value)) { + $newvalue = $value['data']; + if (isset($value['entity'])) { $entity = $value['entity']; + } + } + + if ($newvalue) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."const ("; + $sql .= "name"; + $sql .= ", type"; + $sql .= ", value"; + $sql .= ", note"; + $sql .= ", visible"; + $sql .= ", entity"; + $sql .= ")"; + $sql .= " VALUES ("; + $sql .= $this->db->encrypt($this->const_name."_TABS_".$i, 1); + $sql .= ", 'chaine'"; + $sql .= ", ".$this->db->encrypt($newvalue, 1); + $sql .= ", null"; + $sql .= ", '0'"; + $sql .= ", ".$entity; + $sql .= ")"; + + $resql = $this->db->query($sql); + if (!$resql) { + dol_syslog($this->db->lasterror(), LOG_ERR); + if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); + $err++; + break; + } + } + } + $i++; + } + } + return $err; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Adds constants + * + * @return int Error count (0 if OK) + */ + public function insert_const() + { + // phpcs:enable + global $conf; + + $err = 0; + + if (empty($this->const)) { return 0; + } + + dol_syslog(get_class($this)."::insert_const", LOG_DEBUG); + + foreach ($this->const as $key => $value) + { + $name = $this->const[$key][0]; + $type = $this->const[$key][1]; + $val = $this->const[$key][2]; + $note = isset($this->const[$key][3]) ? $this->const[$key][3] : ''; + $visible = isset($this->const[$key][4]) ? $this->const[$key][4] : 0; + $entity = (!empty($this->const[$key][5]) && $this->const[$key][5] != 'current') ? 0 : $conf->entity; + + // Clean + if (empty($visible)) { $visible = '0'; + } + if (empty($val) && $val != '0') { $val = ''; + } + + $sql = "SELECT count(*)"; + $sql .= " FROM ".MAIN_DB_PREFIX."const"; + $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($name)."'"; + $sql .= " AND entity = ".$entity; + + $result = $this->db->query($sql); + if ($result) { + $row = $this->db->fetch_row($result); + + if ($row[0] == 0) // If not found + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,note,visible,entity)"; + $sql .= " VALUES ("; + $sql .= $this->db->encrypt($name, 1); + $sql .= ",'".$type."'"; + $sql .= ",".(($val != '') ? $this->db->encrypt($val, 1) : "''"); + $sql .= ",".($note ? "'".$this->db->escape($note)."'" : "null"); + $sql .= ",'".$visible."'"; + $sql .= ",".$entity; + $sql .= ")"; + + if (!$this->db->query($sql)) { + $err++; + } + } + else + { + dol_syslog(get_class($this)."::insert_const constant '".$name."' already exists", LOG_WARNING); + } + } + else + { + $err++; + } + } + + return $err; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Removes constants tagged 'deleteonunactive' + * + * @return int <0 if KO, 0 if OK + */ + public function delete_const() + { + // phpcs:enable + global $conf; + + $err = 0; + + if (empty($this->const)) { return 0; + } + + foreach ($this->const as $key => $value) + { + $name = $this->const[$key][0]; + $deleteonunactive = (!empty($this->const[$key][6])) ? 1 : 0; + + if ($deleteonunactive) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; + $sql .= " WHERE ".$this->db->decrypt('name')." = '".$name."'"; + $sql .= " AND entity in (0, ".$conf->entity.")"; + dol_syslog(get_class($this)."::delete_const", LOG_DEBUG); + if (!$this->db->query($sql)) { + $this->error = $this->db->lasterror(); + $err++; + } + } + } + + return $err; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Adds access rights + * + * @param int $reinitadminperms If 1, we also grant them to all admin users + * @param int $force_entity Force current entity + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int Error count (0 if OK) + */ + public function insert_permissions($reinitadminperms = 0, $force_entity = null, $notrigger = 0) + { + // phpcs:enable + global $conf, $user; + + $err = 0; + $entity = (!empty($force_entity) ? $force_entity : $conf->entity); + + dol_syslog(get_class($this)."::insert_permissions", LOG_DEBUG); + + // Test if module is activated + $sql_del = "SELECT ".$this->db->decrypt('value')." as value"; + $sql_del .= " FROM ".MAIN_DB_PREFIX."const"; + $sql_del .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; + $sql_del .= " AND entity IN (0,".$entity.")"; + + $resql = $this->db->query($sql_del); + + if ($resql) { + $obj = $this->db->fetch_object($resql); + if ($obj !== null && !empty($obj->value) && !empty($this->rights)) { + // If the module is active + foreach ($this->rights as $key => $value) + { + $r_id = $this->rights[$key][0]; + $r_desc = $this->rights[$key][1]; + $r_type = isset($this->rights[$key][2]) ? $this->rights[$key][2] : ''; + $r_def = $this->rights[$key][3]; + $r_perms = $this->rights[$key][4]; + $r_subperms = isset($this->rights[$key][5]) ? $this->rights[$key][5] : ''; + $r_modul = empty($this->rights_class) ?strtolower($this->name) : $this->rights_class; + + if (empty($r_type)) { $r_type = 'w'; } + if (empty($r_def)) { $r_def = 0; } + + // Search if perm already present + $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def"; + $sql .= " WHERE id = ".$r_id." AND entity = ".$entity; + + $resqlselect = $this->db->query($sql); + if ($resqlselect) { + $objcount = $this->db->fetch_object($resqlselect); + if ($objcount && $objcount->nb == 0) { + if (dol_strlen($r_perms)) { + if (dol_strlen($r_subperms)) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def"; + $sql .= " (id, entity, libelle, module, type, bydefault, perms, subperms)"; + $sql .= " VALUES "; + $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')"; + } + else + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def"; + $sql .= " (id, entity, libelle, module, type, bydefault, perms)"; + $sql .= " VALUES "; + $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')"; + } + } + else + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def "; + $sql .= " (id, entity, libelle, module, type, bydefault)"; + $sql .= " VALUES "; + $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")"; + } + + $resqlinsert = $this->db->query($sql, 1); + + if (!$resqlinsert) { + if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") { + $this->error = $this->db->lasterror(); + $err++; + break; + } + else { dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO); + } + } + + $this->db->free($resqlinsert); + } + + $this->db->free($resqlselect); + } + + // If we want to init permissions on admin users + if ($reinitadminperms) { + if (!class_exists('User')) { + include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + } + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 1"; + dol_syslog(get_class($this)."::insert_permissions Search all admin users", LOG_DEBUG); + $resqlseladmin = $this->db->query($sql, 1); + if ($resqlseladmin) { + $num = $this->db->num_rows($resqlseladmin); + $i = 0; + while ($i < $num) + { + $obj2 = $this->db->fetch_object($resqlseladmin); + dol_syslog(get_class($this)."::insert_permissions Add permission to user id=".$obj2->rowid); + + $tmpuser = new User($this->db); + $result = $tmpuser->fetch($obj2->rowid); + if ($result > 0) { + $tmpuser->addrights($r_id, '', '', 0, 1); + } + else + { + dol_syslog(get_class($this)."::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR); + } + $i++; + } + } + else + { + dol_print_error($this->db); + } + } + } + + if ($reinitadminperms && !empty($user->admin)) // Reload permission for current user if defined + { + // We reload permissions + $user->clearrights(); + $user->getrights(); + } + } + $this->db->free($resql); + } + else + { + $this->error = $this->db->lasterror(); + $err++; + } + + return $err; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Removes access rights + * + * @return int Error count (0 if OK) + */ + public function delete_permissions() + { + // phpcs:enable + global $conf; + + $err = 0; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."rights_def"; + $sql .= " WHERE module = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."'"; + $sql .= " AND entity = ".$conf->entity; + dol_syslog(get_class($this)."::delete_permissions", LOG_DEBUG); + if (!$this->db->query($sql)) { + $this->error = $this->db->lasterror(); + $err++; + } + + return $err; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Adds menu entries + * + * @return int Error count (0 if OK) + */ + public function insert_menus() + { + // phpcs:enable + global $user; + + if (!is_array($this->menu) || empty($this->menu)) { return 0; + } + + include_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; + + dol_syslog(get_class($this)."::insert_menus", LOG_DEBUG); + + $err = 0; + + $this->db->begin(); + + foreach ($this->menu as $key => $value) + { + $menu = new Menubase($this->db); + $menu->menu_handler = 'all'; + + //$menu->module=strtolower($this->name); TODO When right_class will be same than module name + $menu->module = empty($this->rights_class) ?strtolower($this->name) : $this->rights_class; + + if (!$this->menu[$key]['fk_menu']) { + $menu->fk_menu = 0; + } + else + { + $foundparent = 0; + $fk_parent = $this->menu[$key]['fk_menu']; + if (preg_match('/^r=/', $fk_parent)) // old deprecated method + { + $fk_parent = str_replace('r=', '', $fk_parent); + if (isset($this->menu[$fk_parent]['rowid'])) { + $menu->fk_menu = $this->menu[$fk_parent]['rowid']; + $foundparent = 1; + } + } + elseif (preg_match('/^fk_mainmenu=([a-zA-Z0-9_]+),fk_leftmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) { + $menu->fk_menu = -1; + $menu->fk_mainmenu = $reg[1]; + $menu->fk_leftmenu = $reg[2]; + $foundparent = 1; + } + elseif (preg_match('/^fk_mainmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) { + $menu->fk_menu = -1; + $menu->fk_mainmenu = $reg[1]; + $menu->fk_leftmenu = ''; + $foundparent = 1; + } + if (!$foundparent) { + $this->error = "ErrorBadDefinitionOfMenuArrayInModuleDescriptor"; + dol_syslog(get_class($this)."::insert_menus ".$this->error." ".$this->menu[$key]['fk_menu'], LOG_ERR); + $err++; + } + } + $menu->type = $this->menu[$key]['type']; + $menu->mainmenu = isset($this->menu[$key]['mainmenu']) ? $this->menu[$key]['mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu : ''); + $menu->leftmenu = isset($this->menu[$key]['leftmenu']) ? $this->menu[$key]['leftmenu'] : ''; + $menu->titre = $this->menu[$key]['titre']; // deprecated + $menu->title = $this->menu[$key]['titre']; + $menu->url = $this->menu[$key]['url']; + $menu->langs = $this->menu[$key]['langs']; + $menu->position = $this->menu[$key]['position']; + $menu->perms = $this->menu[$key]['perms']; + $menu->target = isset($this->menu[$key]['target']) ? $this->menu[$key]['target'] : ''; + $menu->user = $this->menu[$key]['user']; + $menu->enabled = isset($this->menu[$key]['enabled']) ? $this->menu[$key]['enabled'] : 0; + $menu->position = $this->menu[$key]['position']; + + if (!$err) { + $result = $menu->create($user); // Save menu entry into table llx_menu + if ($result > 0) { + $this->menu[$key]['rowid'] = $result; + } + else + { + $this->error = $menu->error; + dol_syslog(get_class($this).'::insert_menus result='.$result." ".$this->error, LOG_ERR); + $err++; + break; + } + } + } + + if (!$err) { + $this->db->commit(); + } + else + { + dol_syslog(get_class($this)."::insert_menus ".$this->error, LOG_ERR); + $this->db->rollback(); + } + + return $err; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Removes menu entries + * + * @return int Error count (0 if OK) + */ + public function delete_menus() + { + // phpcs:enable + global $conf; + + $err = 0; + + //$module=strtolower($this->name); TODO When right_class will be same than module name + $module = empty($this->rights_class) ?strtolower($this->name) : $this->rights_class; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu"; + $sql .= " WHERE module = '".$this->db->escape($module)."'"; + $sql .= " AND entity = ".$conf->entity; + + dol_syslog(get_class($this)."::delete_menus", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = $this->db->lasterror(); + $err++; + } + + return $err; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Creates directories + * + * @return int Error count (0 if OK) + */ + public function create_dirs() + { + // phpcs:enable + global $langs, $conf; + + $err = 0; + + if (isset($this->dirs) && is_array($this->dirs)) { + foreach ($this->dirs as $key => $value) + { + $addtodatabase = 0; + + if (!is_array($value)) { $dir = $value; // Default simple mode + } else { + $constname = $this->const_name."_DIR_"; + $dir = $this->dirs[$key][1]; + $addtodatabase = empty($this->dirs[$key][2]) ? '' : $this->dirs[$key][2]; // Create constante in llx_const + $subname = empty($this->dirs[$key][3]) ? '' : strtoupper($this->dirs[$key][3]); // Add submodule name (ex: $conf->module->submodule->dir_output) + $forcename = empty($this->dirs[$key][4]) ? '' : strtoupper($this->dirs[$key][4]); // Change the module name if different + + if (!empty($forcename)) { $constname = 'MAIN_MODULE_'.$forcename."_DIR_"; + } + if (!empty($subname)) { $constname = $constname.$subname."_"; + } + + $name = $constname.strtoupper($this->dirs[$key][0]); + } + + // Define directory full path ($dir must start with "/") + if (empty($conf->global->MAIN_MODULE_MULTICOMPANY) || $conf->entity == 1) { $fulldir = DOL_DATA_ROOT.$dir; + } else { $fulldir = DOL_DATA_ROOT."/".$conf->entity.$dir; + } + // Create dir if it does not exists + if (!empty($fulldir) && !file_exists($fulldir)) { + if (dol_mkdir($fulldir, DOL_DATA_ROOT) < 0) { + $this->error = $langs->trans("ErrorCanNotCreateDir", $fulldir); + dol_syslog(get_class($this)."::_init ".$this->error, LOG_ERR); + $err++; + } + } + + // Define the constant in database if requested (not the default mode) + if (!empty($addtodatabase)) { + $result = $this->insert_dirs($name, $dir); + if ($result) { $err++; + } + } + } + } + + return $err; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Adds directories definitions + * + * @param string $name Name + * @param string $dir Directory + * + * @return int Error count (0 if OK) + */ + public function insert_dirs($name, $dir) + { + // phpcs:enable + global $conf; + + $err = 0; + + $sql = "SELECT count(*)"; + $sql .= " FROM ".MAIN_DB_PREFIX."const"; + $sql .= " WHERE ".$this->db->decrypt('name')." = '".$name."'"; + $sql .= " AND entity = ".$conf->entity; + + dol_syslog(get_class($this)."::insert_dirs", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $row = $this->db->fetch_row($result); + + if ($row[0] == 0) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,note,visible,entity)"; + $sql .= " VALUES (".$this->db->encrypt($name, 1).",'chaine',".$this->db->encrypt($dir, 1).",'Directory for module ".$this->name."','0',".$conf->entity.")"; + + dol_syslog(get_class($this)."::insert_dirs", LOG_DEBUG); + $this->db->query($sql); + } + } + else + { + $this->error = $this->db->lasterror(); + $err++; + } + + return $err; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Removes directories + * + * @return int Error count (0 if OK) + */ + public function delete_dirs() + { + // phpcs:enable + global $conf; + + $err = 0; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; + $sql .= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->db->escape($this->const_name)."_DIR_%'"; + $sql .= " AND entity = ".$conf->entity; + + dol_syslog(get_class($this)."::delete_dirs", LOG_DEBUG); + if (!$this->db->query($sql)) { + $this->error = $this->db->lasterror(); + $err++; + } + + return $err; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Adds generic parts + * + * @return int Error count (0 if OK) + */ + public function insert_module_parts() + { + // phpcs:enable + global $conf; + + $error = 0; + + if (is_array($this->module_parts) && !empty($this->module_parts)) { + foreach ($this->module_parts as $key => $value) + { + if (is_array($value) && count($value) == 0) { continue; // Discard empty arrays + } + + $entity = $conf->entity; // Reset the current entity + $newvalue = $value; + + // Serialize array parameters + if (is_array($value)) { + // Can defined other parameters + // Example when $key='hooks', then $value is an array('data'=>array('hookcontext1','hookcontext2'), 'entity'=>X) + if (isset($value['data']) && is_array($value['data'])) { + $newvalue = json_encode($value['data']); + if (isset($value['entity'])) { $entity = $value['entity']; + } + } + elseif (isset($value['data']) && !is_array($value['data'])) { + $newvalue = $value['data']; + if (isset($value['entity'])) { $entity = $value['entity']; + } + } + else // when hook is declared with syntax 'hook'=>array('hookcontext1','hookcontext2',...) + { + $newvalue = json_encode($value); + } + } + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."const ("; + $sql .= "name"; + $sql .= ", type"; + $sql .= ", value"; + $sql .= ", note"; + $sql .= ", visible"; + $sql .= ", entity"; + $sql .= ")"; + $sql .= " VALUES ("; + $sql .= $this->db->encrypt($this->const_name."_".strtoupper($key), 1); + $sql .= ", 'chaine'"; + $sql .= ", ".$this->db->encrypt($newvalue, 1); + $sql .= ", null"; + $sql .= ", '0'"; + $sql .= ", ".$entity; + $sql .= ")"; + + dol_syslog(get_class($this)."::insert_module_parts for key=".$this->const_name."_".strtoupper($key), LOG_DEBUG); + + $resql = $this->db->query($sql, 1); + if (!$resql) { + if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $error++; + $this->error = $this->db->lasterror(); + } + else + { + dol_syslog(get_class($this)."::insert_module_parts for ".$this->const_name."_".strtoupper($key)." Record already exists.", LOG_WARNING); + } + } + } + } + return $error; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Removes generic parts + * + * @return int Error count (0 if OK) + */ + public function delete_module_parts() + { + // phpcs:enable + global $conf; + + $err = 0; + $entity = $conf->entity; + + if (is_array($this->module_parts) && !empty($this->module_parts)) { + foreach ($this->module_parts as $key => $value) + { + // If entity is defined + if (is_array($value) && isset($value['entity'])) { $entity = $value['entity']; + } + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; + $sql .= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->db->escape($this->const_name)."_".strtoupper($key)."'"; + $sql .= " AND entity = ".$entity; + + dol_syslog(get_class($this)."::delete_const_".$key."", LOG_DEBUG); + if (!$this->db->query($sql)) { + $this->error = $this->db->lasterror(); + $err++; + } + } + } + return $err; + } + + /** + * Function called when module is enabled. + * The init function adds tabs, constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') + * 'noboxes' = Do not insert boxes 'newboxdefonly' = For boxes, + * insert def of boxes only and not boxes activation + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + return $this->_init(array(), $options); + } + + /** + * Function called when module is disabled. + * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + return $this->_remove(array(), $options); + } + + + /** + * Return Kanban view of a module + * + * @param string $codeenabledisable HTML code for button to enable/disable module + * @param string $codetoconfig HTML code to go to config page + * @return string HTML code of Kanban view + */ + public function getKanbanView($codeenabledisable = '', $codetoconfig = '') + { + global $conf, $langs; + + // Define imginfo + $imginfo = "info"; + if ($this->isCoreOrExternalModule() == 'external') + { + $imginfo = "info_black"; + } + + $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($this))); print '
-
'; +
'; $alttext = ''; //if (is_array($objMod->need_dolibarr_version)) $alttext.=($alttext?' - ':'').'Dolibarr >= '.join('.',$objMod->need_dolibarr_version); @@ -2234,23 +2290,45 @@ { if (preg_match('/^\//i', $this->picto)) print img_picto($alttext, $this->picto, 'class="inline-block valignmiddle"', 1); else print img_object($alttext, $this->picto, 'class="inline-block valignmiddle"'); - } else { + } + else + { print img_object($alttext, 'generic', 'class="inline-block valignmiddle"'); } + $version = $this->getVersion(0); + $versiontrans = ''; + if (preg_match('/development/i', $version)) $versiontrans .= 'warning'; + if (preg_match('/experimental/i', $version)) $versiontrans .= 'warning'; + if (preg_match('/deprecated/i', $version)) $versiontrans .= 'warning'; if ($this->isCoreOrExternalModule() == 'external' || preg_match('/development|experimental|deprecated/i', $version)) { - print 'getVersion(1).'">'; + print 'getVersion(1).'">'; print $this->getVersion(1); print ''; } + /*print ''; + print '
'; + print '
'; + print $codeenabledisable; + print '
'; + print '
'; + print $codetoconfig; + print '
'; + print '
'; + print '
'; + */ + print '
-
+
'.$this->getName().' '.nl2br($this->getDesc()).''; + /*print 'getVersion(1).'">'; + print $this->getVersion(1); + print ''; */ + print '
'; - //if ($versiontrans) print img_warning($langs->trans("Version").' '.$this->getVersion(1)).' '; print ''.img_picto(($this->isCoreOrExternalModule() == 'external' ? $langs->trans("ExternalModule").' - ' : '').$langs->trans("ClickToShowDescription"), $imginfo).''; print '

'; @@ -2267,5 +2345,5 @@
'; - } + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modAccounting.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modAccounting.class.php @@ -173,15 +173,15 @@ $this->rights = array(); // Permission array used by this module $r = 0; - $this->rights[$r][0] = 50440; - $this->rights[$r][1] = 'Manage chart of accounts, setup of accountancy'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'chartofaccount'; - $this->rights[$r][5] = ''; - $r++; - - $this->rights[$r][0] = 50401; + $this->rights[$r][0] = 50440; + $this->rights[$r][1] = 'Manage chart of accounts, setup of accountancy'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'chartofaccount'; + $this->rights[$r][5] = ''; + $r++; + + $this->rights[$r][0] = 50401; $this->rights[$r][1] = 'Bind products and invoices with accounting accounts'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; @@ -205,29 +205,29 @@ $this->rights[$r][5] = 'creer'; $r++; - $this->rights[$r][0] = 50414; - $this->rights[$r][1] = 'Delete operations in Ledger'; - $this->rights[$r][2] = 'd'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'mouvements'; - $this->rights[$r][5] = 'supprimer'; - $r++; - - $this->rights[$r][0] = 50415; - $this->rights[$r][1] = 'Delete all operations by year and journal in Ledger'; - $this->rights[$r][2] = 'd'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'mouvements'; - $this->rights[$r][5] = 'supprimer_tous'; - $r++; - - $this->rights[$r][0] = 50418; - $this->rights[$r][1] = 'Export operations of the Ledger'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'mouvements'; - $this->rights[$r][5] = 'export'; - $r++; + $this->rights[$r][0] = 50414; + $this->rights[$r][1] = 'Delete operations in Ledger'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'mouvements'; + $this->rights[$r][5] = 'supprimer'; + $r++; + + $this->rights[$r][0] = 50415; + $this->rights[$r][1] = 'Delete all operations by year and journal in Ledger'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'mouvements'; + $this->rights[$r][5] = 'supprimer_tous'; + $r++; + + $this->rights[$r][0] = 50418; + $this->rights[$r][1] = 'Export operations of the Ledger'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'mouvements'; + $this->rights[$r][5] = 'export'; + $r++; $this->rights[$r][0] = 50420; $this->rights[$r][1] = 'Report and export reports (turnover, balance, journals, ledger)'; @@ -258,13 +258,13 @@ $this->export_label[$r] = 'Chartofaccounts'; $this->export_icon[$r] = 'accounting'; $this->export_permission[$r] = array(array("accounting", "chartofaccount")); - $this->export_fields_array[$r] = array('ac.rowid'=>'ChartofaccountsId', 'ac.pcg_version'=>'Chartofaccounts', 'aa.rowid'=>'ID', 'aa.account_number'=>"AccountAccounting", 'aa.label'=>"Label", 'aa.account_parent'=>"Accountparent", 'aa.pcg_type'=>"Pcgtype", 'aa.active'=>'Status'); - $this->export_TypeFields_array[$r] = array('ac.rowid'=>'List:accounting_system:pcg_version', 'ac.pcg_version'=>'Text', 'aa.rowid'=>'Numeric', 'aa.account_number'=>"Text", 'aa.label'=>"Text", 'aa.account_parent'=>"Text", 'aa.pcg_type'=>'Text', 'aa.active'=>'Status'); + $this->export_fields_array[$r] = array('ac.rowid'=>'ChartofaccountsId', 'ac.pcg_version'=>'Chartofaccounts', 'aa.rowid'=>'Id', 'aa.account_number'=>"AccountAccounting", 'aa.label'=>"Label", 'aa.account_parent'=>"Accountparent", 'aa.pcg_type'=>"Pcgtype", 'aa.active'=>'Status'); + $this->export_TypeFields_array[$r] = array('ac.rowid'=>'List:accounting_system:pcg_version', 'aa.account_number'=>"Text", 'aa.label'=>"Text", 'aa.account_parent'=>"Text", 'aa.pcg_type'=>'Text', 'aa.active'=>'Status'); $this->export_entities_array[$r] = array('ac.rowid'=>"Accounting", 'ac.pcg_version'=>"Accounting", 'aa.rowid'=>'Accounting', 'aa.account_number'=>"Accounting", 'aa.label'=>"Accounting", 'aa.accountparent'=>"Accounting", 'aa.pcg_type'=>"Accounting", 'aa_active'=>"Accounting"); $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'accounting_account as aa'; - $this->export_sql_end[$r] .= ' ,'.MAIN_DB_PREFIX.'accounting_system as ac'; + $this->export_sql_end[$r] .= ' ,'.MAIN_DB_PREFIX.'accounting_system as ac'; $this->export_sql_end[$r] .= ' WHERE ac.pcg_version = aa.fk_pcg_version AND aa.entity IN ('.getEntity('accounting').') '; @@ -284,35 +284,33 @@ 'b.doc_date'=>"Docdate", //'b.doc_type'=>'Doctype', 'b.doc_ref'=>'Piece', - 'b.code_journal'=>'Codejournal', - //'b.journal_label'=>'JournalLabel', - 'b.numero_compte'=>'AccountAccounting', - //'b.label_compte'=>'LabelAccount', - 'b.subledger_account'=>'SubledgerAccount', - 'b.subledger_label'=>'SubledgerAccountLabel', - 'b.label_operation'=>'LabelOperation', - 'b.debit'=>"Debit", - 'b.credit'=>"Credit", - 'b.sens'=>'Direction' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit - ); + 'b.code_journal'=>'Codejournal', + //'b.journal_label'=>'JournalLabel', + 'b.numero_compte'=>'AccountAccounting', + //'b.label_compte'=>'LabelAccount', + 'b.subledger_account'=>'SubledgerAccount', + 'b.subledger_label'=>'SubledgerAccountLabel', + 'b.label_operation'=>'LabelOperation', + 'b.debit'=>"Debit", + 'b.credit'=>"Credit" + ); $this->import_fieldshidden_array[$r] = array('b.doc_type'=>'const-import_from_external', 'b.fk_doc'=>'const-0', 'b.fk_docdet'=>'const-0', 'b.fk_user_author'=>'user->id', 'b.date_creation'=>'const-'.dol_print_date(dol_now(), 'standard')); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r] = array('b.doc_date'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); $this->import_examplevalues_array[$r] = array( - 'b.piece_num'=>'123 (!!! use next value not already used)', + 'b.piece_num'=>'123 (!!! use next value not already used)', 'b.doc_date'=>dol_print_date(dol_now(), "%Y-%m-%d"), //'b.doc_type'=>'import', 'b.doc_ref'=>'My document ABC', - 'b.code_journal'=>"VTE", - //'b.journal_label'=>"Sale journal", - 'b.numero_compte'=>"707", - //'b.label_compte'=>'Product account 707', - 'b.subledger_account'=>'', - 'b.subledger_label'=>'', - 'b.label_operation'=>"Sale of ABC", - 'b.debit'=>"0", - 'b.credit'=>"100", - 'b.sens'=>'C' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit - ); + 'b.code_journal'=>"VTE", + //'b.journal_label'=>"Sale journal", + 'b.numero_compte'=>"707", + //'b.label_compte'=>'Product account 707', + 'b.subledger_account'=>'', + 'b.subledger_label'=>'', + 'b.label_operation'=>"Sale of ABC", + 'b.debit'=>"0", + 'b.credit'=>"100" + ); // Chart of accounts $r++; @@ -325,8 +323,8 @@ $this->import_fields_array[$r] = array('aa.fk_pcg_version'=>"Chartofaccounts*", 'aa.account_number'=>"AccountAccounting*", 'aa.label'=>"Label*", 'aa.account_parent'=>"Accountparent", "aa.fk_accounting_category"=>"AccountingCategory", "aa.pcg_type"=>"Pcgtype*", 'aa.active'=>'Status*', 'aa.datec'=>"DateCreation"); $this->import_regex_array[$r] = array('aa.fk_pcg_version'=>'pcg_version@'.MAIN_DB_PREFIX.'accounting_system', 'aa.account_number'=>'^.{1,32}$', 'aa.label'=>'^.{1,255}$', 'aa.account_parent'=>'^.{0,32}$', 'aa.fk_accounting_category'=>'rowid@'.MAIN_DB_PREFIX.'c_accounting_category', 'aa.pcg_type'=>'^.{1,20}$', 'aa.active'=>'^0|1$', 'aa.datec'=>'^\d{4}-\d{2}-\d{2}$'); $this->import_convertvalue_array[$r] = array( - 'aa.account_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/accountancy/class/accountingaccount.class.php', 'class'=>'AccountingAccount', 'method'=>'fetch', 'element'=>'AccountingAccount'), - 'aa.fk_accounting_category'=>array('rule'=>'fetchidfromcodeorlabel', 'classfile'=>'/accountancy/class/accountancycategory.class.php', 'class'=>'AccountancyCategory', 'method'=>'fetch', 'dict'=>'DictionaryAccountancyCategory'), + 'aa.account_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/accountancy/class/accountingaccount.class.php', 'class'=>'AccountingAccount', 'method'=>'fetch', 'element'=>'AccountingAccount'), + 'aa.fk_accounting_category'=>array('rule'=>'fetchidfromcodeorlabel', 'classfile'=>'/accountancy/class/accountancycategory.class.php', 'class'=>'AccountancyCategory', 'method'=>'fetch', 'dict'=>'DictionaryAccountancyCategory'), ); $this->import_examplevalues_array[$r] = array('aa.fk_pcg_version'=>"PCG99-ABREGE", 'aa.account_number'=>"707", 'aa.label'=>"Product sales", 'aa.account_parent'=>"ref:7 or id:1407", "aa.fk_accounting_category"=>"", "aa.pcg_type"=>"PROD", 'aa.active'=>'1', 'aa.datec'=>"2017-04-28"); $this->import_updatekeys_array[$r] = array('aa.fk_pcg_version'=>'Chartofaccounts', 'aa.account_number'=>'AccountAccounting'); --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modAdherent.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modAdherent.class.php @@ -37,370 +37,360 @@ class modAdherent extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $conf; - - $this->db = $db; - $this->numero = 310; - - $this->family = "hr"; - $this->module_position = '06'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "Management of members of a foundation or association"; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->picto = 'member'; - - // Data directories to create when module is enabled - $this->dirs = array( - "/adherent/temp", - "/doctemplates/members", - ); - - // Config pages - $this->config_page_url = array("adherent.php@adherents"); - - // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array(); // List of module ids to disable if this one is disabled - $this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with - $this->langfiles = array("members", "companies"); - $this->phpmin = array(5, 4); // Minimum version of PHP required by module - - // Constants - $this->const = array(); - $r = 0; - - $this->const[$r][0] = "ADHERENT_ADDON_PDF"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "standard"; - $this->const[$r][3] = 'Name of PDF model of member'; - $this->const[$r][4] = 0; - $r++; - - // For emails - $this->const[$r][0] = "ADHERENT_MAIL_FROM"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = ""; - $this->const[$r][3] = "From des mails"; - $this->const[$r][4] = 0; - $r++; - - $this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER"; - $this->const[$r][1] = "emailtemplate:member"; - $this->const[$r][2] = "(SendingEmailOnAutoSubscription)"; - $this->const[$r][3] = ""; - $this->const[$r][4] = 0; - $r++; - - $this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION"; - $this->const[$r][1] = "emailtemplate:member"; - $this->const[$r][2] = "(SendingEmailOnNewSubscription)"; - $this->const[$r][3] = ""; - $this->const[$r][4] = 0; - $r++; - - $this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION"; - $this->const[$r][1] = "emailtemplate:member"; - $this->const[$r][2] = "(SendingReminderForExpiredSubscription)"; - $this->const[$r][3] = ""; - $this->const[$r][4] = 0; - $r++; - - $this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_CANCELATION"; - $this->const[$r][1] = "emailtemplate:member"; - $this->const[$r][2] = "(SendingEmailOnCancelation)"; - $this->const[$r][3] = ""; - $this->const[$r][4] = 0; - $r++; - - // For cards - $this->const[$r][0] = "ADHERENT_CARD_HEADER_TEXT"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "__YEAR__"; - $this->const[$r][3] = "Texte imprimé sur le haut de la carte adhérent"; - $this->const[$r][4] = 0; - $r++; - - $this->const[$r][0] = "ADHERENT_CARD_FOOTER_TEXT"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "__COMPANY__"; - $this->const[$r][3] = "Texte imprimé sur le bas de la carte adhérent"; - $this->const[$r][4] = 0; - $r++; - - $this->const[$r][0] = "ADHERENT_CARD_TEXT"; - $this->const[$r][1] = "texte"; - $this->const[$r][2] = "__FULLNAME__\r\nID: __ID__\r\n__EMAIL__\r\n__ADDRESS__\r\n__ZIP__ __TOWN__\r\n__COUNTRY__"; - $this->const[$r][3] = "Text to print on member cards"; - $this->const[$r][4] = 0; - $r++; - - $this->const[$r][0] = "ADHERENT_MAILMAN_ADMINPW"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = ""; - $this->const[$r][3] = "Mot de passe Admin des liste mailman"; - $this->const[$r][4] = 0; - $r++; - - $this->const[$r][0] = "ADHERENT_ETIQUETTE_TYPE"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "L7163"; - $this->const[$r][3] = "Type of address sheets"; - $this->const[$r][4] = 0; - $r++; - - $this->const[$r][0] = "ADHERENT_ETIQUETTE_TEXT"; - $this->const[$r][1] = "texte"; - $this->const[$r][2] = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY%"; - $this->const[$r][3] = "Text to print on member address sheets"; - $this->const[$r][4] = 0; - $r++; - - // For subscriptions - $this->const[$r][0] = "ADHERENT_BANK_ACCOUNT"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = ""; - $this->const[$r][3] = "ID of bank account to use"; - $this->const[$r][4] = 0; - $r++; - - $this->const[$r][0] = "ADHERENT_BANK_CATEGORIE"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = ""; - $this->const[$r][3] = "ID of bank transaction category to use"; - $this->const[$r][4] = 0; - $r++; - - $this->const[$r][0] = "MEMBER_ADDON_PDF_ODT_PATH"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/members"; - $this->const[$r][3] = ""; - $this->const[$r][4] = 0; - $r++; - - - // Boxes - //------- - $this->boxes = array( + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf; + + $this->db = $db; + $this->numero = 310; + + $this->family = "hr"; + $this->module_position = '06'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "Management of members of a foundation or association"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + $this->picto = 'member'; + + // Data directories to create when module is enabled + $this->dirs = array("/adherent/temp"); + + // Config pages + $this->config_page_url = array("adherent.php@adherents"); + + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with + $this->langfiles = array("members", "companies"); + $this->phpmin = array(5, 4); // Minimum version of PHP required by module + + // Constants + $this->const = array(); + $r = 0; + + $this->const[$r][0] = "ADHERENT_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "standard"; + $this->const[$r][3] = 'Name of PDF model of member'; + $this->const[$r][4] = 0; + $r++; + + // For emails + $this->const[$r][0] = "ADHERENT_MAIL_FROM"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = ""; + $this->const[$r][3] = "From des mails"; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER"; + $this->const[$r][1] = "emailtemplate:member"; + $this->const[$r][2] = "(SendingEmailOnAutoSubscription)"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION"; + $this->const[$r][1] = "emailtemplate:member"; + $this->const[$r][2] = "(SendingEmailOnNewSubscription)"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION"; + $this->const[$r][1] = "emailtemplate:member"; + $this->const[$r][2] = "(SendingReminderForExpiredSubscription)"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_CANCELATION"; + $this->const[$r][1] = "emailtemplate:member"; + $this->const[$r][2] = "(SendingEmailOnCancelation)"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + $r++; + + // For cards + $this->const[$r][0] = "ADHERENT_CARD_HEADER_TEXT"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "__YEAR__"; + $this->const[$r][3] = "Texte imprimé sur le haut de la carte adhérent"; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "ADHERENT_CARD_FOOTER_TEXT"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "__COMPANY__"; + $this->const[$r][3] = "Texte imprimé sur le bas de la carte adhérent"; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "ADHERENT_CARD_TEXT"; + $this->const[$r][1] = "texte"; + $this->const[$r][2] = "__FULLNAME__\r\nID: __ID__\r\n__EMAIL__\r\n__ADDRESS__\r\n__ZIP__ __TOWN__\r\n__COUNTRY__"; + $this->const[$r][3] = "Text to print on member cards"; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "ADHERENT_MAILMAN_ADMINPW"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = ""; + $this->const[$r][3] = "Mot de passe Admin des liste mailman"; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "ADHERENT_ETIQUETTE_TYPE"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "L7163"; + $this->const[$r][3] = "Type of address sheets"; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "ADHERENT_ETIQUETTE_TEXT"; + $this->const[$r][1] = "texte"; + $this->const[$r][2] = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY%"; + $this->const[$r][3] = "Text to print on member address sheets"; + $this->const[$r][4] = 0; + $r++; + + // For subscriptions + $this->const[$r][0] = "ADHERENT_BANK_ACCOUNT"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = ""; + $this->const[$r][3] = "ID of bank account to use"; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "ADHERENT_BANK_CATEGORIE"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = ""; + $this->const[$r][3] = "ID of bank transaction category to use"; + $this->const[$r][4] = 0; + $r++; + + + // Boxes + //------- + $this->boxes = array( 0=>array('file'=>'box_members.php', 'enabledbydefaulton'=>'Home'), 2=>array('file'=>'box_birthdays_members.php', 'enabledbydefaulton'=>'Home') ); - // Permissions - //------------ - $this->rights = array(); - $this->rights_class = 'adherent'; - $r = 0; - - // $this->rights[$r][0] Id permission (unique tous modules confondus) - // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) - // $this->rights[$r][2] Non utilise - // $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut - // $this->rights[$r][4] Niveau 1 pour nommer permission dans code - // $this->rights[$r][5] Niveau 2 pour nommer permission dans code - - $r++; - $this->rights[$r][0] = 71; - $this->rights[$r][1] = 'Read members\' card'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'lire'; - - $r++; - $this->rights[$r][0] = 72; - $this->rights[$r][1] = 'Create/modify members (need also user module permissions if member linked to a user)'; - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'creer'; - - $r++; - $this->rights[$r][0] = 74; - $this->rights[$r][1] = 'Remove members'; - $this->rights[$r][2] = 'd'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'supprimer'; - - $r++; - $this->rights[$r][0] = 76; - $this->rights[$r][1] = 'Export members'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'export'; - - $r++; - $this->rights[$r][0] = 75; - $this->rights[$r][1] = 'Setup types of membership'; - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'configurer'; - - $r++; - $this->rights[$r][0] = 78; - $this->rights[$r][1] = 'Read subscriptions'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'cotisation'; - $this->rights[$r][5] = 'lire'; - - $r++; - $this->rights[$r][0] = 79; - $this->rights[$r][1] = 'Create/modify/remove subscriptions'; - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'cotisation'; - $this->rights[$r][5] = 'creer'; - - - // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - - // Exports - //-------- - $r = 0; - - // $this->export_code[$r] Unique code identifying the export (all modules combined) - // $this->export_label[$r] Libelle by default if translation of key "ExportXXX" not found (XXX = Code) - // $this->export_permission[$r] List of permission codes required to export - // $this->export_fields_sql[$r] List of exportable fields in SQL codiffication - // $this->export_fields_name[$r] List of exportable fields in translation codiffication - // $this->export_sql[$r] SQL query that offers data for export - - $r++; - $this->export_code[$r] = $this->rights_class.'_'.$r; - $this->export_label[$r] = 'MembersAndSubscriptions'; - $this->export_permission[$r] = array(array("adherent", "export")); - $this->export_fields_array[$r] = array( - 'a.rowid'=>'Id', 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname", 'a.firstname'=>"Firstname", 'a.login'=>"Login", 'a.gender'=>"Gender", 'a.morphy'=>'Nature', - 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", 'd.nom'=>"State", 'co.code'=>"CountryCode", 'co.label'=>"Country", - 'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile", 'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status", - 'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate", 'a.datec'=>'DateCreation', 'a.datevalid'=>'DateValidation', - 'a.tms'=>'DateLastModification', 'a.datefin'=>'DateEndSubscription', 'ta.rowid'=>'MemberTypeId', 'ta.libelle'=>'MemberTypeLabel', - 'c.rowid'=>'SubscriptionId', 'c.dateadh'=>'DateSubscription', 'c.datef'=>'DateEndSubscription', 'c.subscription'=>'Amount' - ); - $this->export_TypeFields_array[$r] = array( - 'a.civility'=>"Text", 'a.lastname'=>"Text", 'a.firstname'=>"Text", 'a.login'=>"Text", 'a.gender'=>'Text', 'a.morphy'=>'Text', 'a.societe'=>'Text', 'a.address'=>"Text", - 'a.zip'=>"Text", 'a.town'=>"Text", 'd.nom'=>"Text", 'co.code'=>'Text', 'co.label'=>"Text", 'a.phone'=>"Text", 'a.phone_perso'=>"Text", 'a.phone_mobile'=>"Text", - 'a.email'=>"Text", 'a.birth'=>"Date", 'a.statut'=>"Status", 'a.note_public'=>"Text", 'a.note_private'=>"Text", 'a.datec'=>'Date', 'a.datevalid'=>'Date', - 'a.tms'=>'Date', 'a.datefin'=>'Date', 'ta.rowid'=>'List:adherent_type:libelle::member_type', 'ta.libelle'=>'Text', + // Permissions + //------------ + $this->rights = array(); + $this->rights_class = 'adherent'; + $r = 0; + + // $this->rights[$r][0] Id permission (unique tous modules confondus) + // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) + // $this->rights[$r][2] Non utilise + // $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut + // $this->rights[$r][4] Niveau 1 pour nommer permission dans code + // $this->rights[$r][5] Niveau 2 pour nommer permission dans code + + $r++; + $this->rights[$r][0] = 71; + $this->rights[$r][1] = 'Read members\' card'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'lire'; + + $r++; + $this->rights[$r][0] = 72; + $this->rights[$r][1] = 'Create/modify members (need also user module permissions if member linked to a user)'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'creer'; + + $r++; + $this->rights[$r][0] = 74; + $this->rights[$r][1] = 'Remove members'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'supprimer'; + + $r++; + $this->rights[$r][0] = 76; + $this->rights[$r][1] = 'Export members'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'export'; + + $r++; + $this->rights[$r][0] = 75; + $this->rights[$r][1] = 'Setup types of membership'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'configurer'; + + $r++; + $this->rights[$r][0] = 78; + $this->rights[$r][1] = 'Read subscriptions'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'cotisation'; + $this->rights[$r][5] = 'lire'; + + $r++; + $this->rights[$r][0] = 79; + $this->rights[$r][1] = 'Create/modify/remove subscriptions'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'cotisation'; + $this->rights[$r][5] = 'creer'; + + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + + // Exports + //-------- + $r = 0; + + // $this->export_code[$r] Unique code identifying the export (all modules combined) + // $this->export_label[$r] Libelle by default if translation of key "ExportXXX" not found (XXX = Code) + // $this->export_permission[$r] List of permission codes required to export + // $this->export_fields_sql[$r] List of exportable fields in SQL codiffication + // $this->export_fields_name[$r] List of exportable fields in translation codiffication + // $this->export_sql[$r] SQL query that offers data for export + + $r++; + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = 'MembersAndSubscriptions'; + $this->export_permission[$r] = array(array("adherent", "export")); + $this->export_fields_array[$r] = array( + 'a.rowid'=>'Id', 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname", 'a.firstname'=>"Firstname", 'a.login'=>"Login", 'a.gender'=>"Gender", 'a.morphy'=>'Nature', + 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", 'd.nom'=>"State", 'co.code'=>"CountryCode", 'co.label'=>"Country", + 'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile", 'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status", + 'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate", 'a.datec'=>'DateCreation', 'a.datevalid'=>'DateValidation', + 'a.tms'=>'DateLastModification', 'a.datefin'=>'DateEndSubscription', 'ta.rowid'=>'MemberTypeId', 'ta.libelle'=>'MemberTypeLabel', + 'c.rowid'=>'SubscriptionId', 'c.dateadh'=>'DateSubscription', 'c.datef'=>'DateEndSubscription', 'c.subscription'=>'Amount' + ); + $this->export_TypeFields_array[$r] = array( + 'a.civility'=>"Text", 'a.lastname'=>"Text", 'a.firstname'=>"Text", 'a.login'=>"Text", 'a.gender'=>'Text', 'a.morphy'=>'Text', 'a.societe'=>'Text', 'a.address'=>"Text", + 'a.zip'=>"Text", 'a.town'=>"Text", 'd.nom'=>"Text", 'co.code'=>'Text', 'co.label'=>"Text", 'a.phone'=>"Text", 'a.phone_perso'=>"Text", 'a.phone_mobile'=>"Text", + 'a.email'=>"Text", 'a.birth'=>"Date", 'a.statut'=>"Status", 'a.note_public'=>"Text", 'a.note_private'=>"Text", 'a.datec'=>'Date', 'a.datevalid'=>'Date', + 'a.tms'=>'Date', 'a.datefin'=>'Date', 'ta.rowid'=>'List:adherent_type:libelle::member_type', 'ta.libelle'=>'Text', 'c.rowid'=>'Numeric', 'c.dateadh'=>'Date', 'c.datef'=>'Date', 'c.subscription'=>'Numeric' - ); - $this->export_entities_array[$r] = array( - 'a.rowid'=>'member', 'a.civility'=>"member", 'a.lastname'=>"member", 'a.firstname'=>"member", 'a.login'=>"member", 'a.gender'=>'member', 'a.morphy'=>'member', - 'a.societe'=>'member', 'a.address'=>"member", 'a.zip'=>"member", 'a.town'=>"member", 'd.nom'=>"member", 'co.code'=>"member", 'co.label'=>"member", - 'a.phone'=>"member", 'a.phone_perso'=>"member", 'a.phone_mobile'=>"member", 'a.email'=>"member", 'a.birth'=>"member", 'a.statut'=>"member", - 'a.photo'=>"member", 'a.note_public'=>"member", 'a.note_private'=>"member", 'a.datec'=>'member', 'a.datevalid'=>'member', 'a.tms'=>'member', - 'a.datefin'=>'member', 'ta.rowid'=>'member_type', 'ta.libelle'=>'member_type', + ); + $this->export_entities_array[$r] = array( + 'a.rowid'=>'member', 'a.civility'=>"member", 'a.lastname'=>"member", 'a.firstname'=>"member", 'a.login'=>"member", 'a.gender'=>'member', 'a.morphy'=>'member', + 'a.societe'=>'member', 'a.address'=>"member", 'a.zip'=>"member", 'a.town'=>"member", 'd.nom'=>"member", 'co.code'=>"member", 'co.label'=>"member", + 'a.phone'=>"member", 'a.phone_perso'=>"member", 'a.phone_mobile'=>"member", 'a.email'=>"member", 'a.birth'=>"member", 'a.statut'=>"member", + 'a.photo'=>"member", 'a.note_public'=>"member", 'a.note_private'=>"member", 'a.datec'=>'member', 'a.datevalid'=>'member', 'a.tms'=>'member', + 'a.datefin'=>'member', 'ta.rowid'=>'member_type', 'ta.libelle'=>'member_type', 'c.rowid'=>'subscription', 'c.dateadh'=>'subscription', 'c.datef'=>'subscription', 'c.subscription'=>'subscription' - ); - // Add extra fields - $keyforselect = 'adherent'; $keyforelement = 'member'; $keyforaliasextra = 'extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - // End add axtra fields - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON a.rowid = extra.fk_object'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'subscription as c ON c.fk_adherent = a.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid'; - $this->export_sql_end[$r] .= ' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('member_type').') '; - $this->export_dependencies_array[$r] = array('subscription'=>'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - - // Imports - //-------- - $r = 0; - - $now = dol_now(); - require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - - $r++; - $this->import_code[$r] = $this->rights_class.'_'.$r; - $this->import_label[$r] = "Members"; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = array('a'=>MAIN_DB_PREFIX.'adherent', 'extra'=>MAIN_DB_PREFIX.'adherent_extrafields'); - $this->import_tables_creator_array[$r] = array('a'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r] = array( - 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname*", 'a.firstname'=>"Firstname", 'a.gender'=>"Gender", 'a.login'=>"Login*", "a.pass"=>"Password", - "a.fk_adherent_type"=>"MemberType*", 'a.morphy'=>'Nature*', 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", - 'a.state_id'=>'StateId', 'a.country'=>"CountryId", 'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile", - 'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status*", 'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate", - 'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription' - ); - // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; - $resql = $this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj = $this->db->fetch_object($resql)) - { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - } - } - // End add extra fields - $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_regex_array[$r] = array( - 'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility', 'a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type', 'a.morphy'=>'(phy|mor)', - 'a.statut'=>'^[0|1]', 'a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); - $this->import_examplevalues_array[$r] = array( - 'a.civility'=>"MR", 'a.lastname'=>'Smith', 'a.firstname'=>'John', 'a.login'=>'jsmith', 'a.pass'=>'passofjsmith', 'a.fk_adherent_type'=>'1', - 'a.morphy'=>'"mor" or "phy"', 'a.societe'=>'JS company', 'a.address'=>'21 jump street', 'a.zip'=>'55000', 'a.town'=>'New York', 'a.country'=>'1', - 'a.email'=>'jsmith@example.com', 'a.birth'=>'1972-10-10', 'a.statut'=>"0 or 1", 'a.note_public'=>"This is a public comment on member", - 'a.note_private'=>"This is private comment on member", 'a.datec'=>dol_print_date($now, '%Y-%m__%d'), 'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d') - ); - - // Cronjobs - $arraydate = dol_getdate(dol_now()); - $datestart = dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); - $this->cronjobs = array( - 0=>array( - 'label'=>'SendReminderForExpiredSubscriptionTitle', - 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', - 'objectname'=>'Adherent', - 'method'=>'sendReminderForExpiredSubscription', - 'parameters'=>'10;0', - 'comment'=>'SendReminderForExpiredSubscription', - 'frequency'=>1, - 'unitfrequency'=> 3600 * 24, - 'priority'=>50, - 'status'=>1, - 'test'=>'$conf->adherent->enabled', - 'datestart'=>$datestart - ), - ); - } - - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - global $conf, $langs; - - // Permissions - $this->remove($options); - - //ODT template - /* + ); + // Add extra fields + $keyforselect = 'adherent'; $keyforelement = 'member'; $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + // End add axtra fields + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON a.rowid = extra.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'subscription as c ON c.fk_adherent = a.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid'; + $this->export_sql_end[$r] .= ' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('member_type').') '; + $this->export_dependencies_array[$r] = array('subscription'=>'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them + + // Imports + //-------- + $r = 0; + + $now = dol_now(); + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + + $r++; + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "Members"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('a'=>MAIN_DB_PREFIX.'adherent', 'extra'=>MAIN_DB_PREFIX.'adherent_extrafields'); + $this->import_tables_creator_array[$r] = array('a'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r] = array( + 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname*", 'a.firstname'=>"Firstname", 'a.gender'=>"Gender", 'a.login'=>"Login*", "a.pass"=>"Password", + "a.fk_adherent_type"=>"MemberType*", 'a.morphy'=>'Nature*', 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", + 'a.state_id'=>'StateId', 'a.country'=>"CountryId", 'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile", + 'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status*", 'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate", + 'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription' + ); + // Add extra fields + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; + $resql = $this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj = $this->db->fetch_object($resql)) + { + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + } + } + // End add extra fields + $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_regex_array[$r] = array( + 'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility', 'a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type', 'a.morphy'=>'(phy|mor)', + 'a.statut'=>'^[0|1]', 'a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); + $this->import_examplevalues_array[$r] = array( + 'a.civility'=>"MR", 'a.lastname'=>'Smith', 'a.firstname'=>'John', 'a.login'=>'jsmith', 'a.pass'=>'passofjsmith', 'a.fk_adherent_type'=>'1', + 'a.morphy'=>'"mor" or "phy"', 'a.societe'=>'JS company', 'a.address'=>'21 jump street', 'a.zip'=>'55000', 'a.town'=>'New York', 'a.country'=>'1', + 'a.email'=>'jsmith@example.com', 'a.birth'=>'1972-10-10', 'a.statut'=>"0 or 1", 'a.note_public'=>"This is a public comment on member", + 'a.note_private'=>"This is private comment on member", 'a.datec'=>dol_print_date($now, '%Y-%m__%d'), 'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d') + ); + + // Cronjobs + $arraydate = dol_getdate(dol_now()); + $datestart = dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); + $this->cronjobs = array( + 0=>array( + 'label'=>'SendReminderForExpiredSubscriptionTitle', + 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', + 'objectname'=>'Adherent', + 'method'=>'sendReminderForExpiredSubscription', + 'parameters'=>'10;0', + 'comment'=>'SendReminderForExpiredSubscription', + 'frequency'=>1, + 'unitfrequency'=> 3600 * 24, + 'priority'=>50, + 'status'=>1, + 'test'=>'$conf->adherent->enabled', + 'datestart'=>$datestart + ), + ); + } + + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $conf, $langs; + + // Permissions + $this->remove($options); + + //ODT template + /* $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; $dirodt=DOL_DATA_ROOT.'/doctemplates/orders'; $dest=$dirodt.'/template_order.odt'; @@ -418,11 +408,11 @@ } }*/ - $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type='member' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','member',".$conf->entity.")" - ); - - return $this->_init($sql, $options); - } + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type='member' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','member',".$conf->entity.")" + ); + + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modAgenda.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modAgenda.class.php @@ -76,29 +76,31 @@ $this->phpmin = array(5, 4); // Minimum version of PHP required by module // Module parts - $this->module_parts = array(); + $this->module_parts = array(); // Constants - //----------- - // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) - // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), - // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) - // ); + //----------- + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) + // ); $this->const = array(); //$this->const[] = array('AGENDA_DEFAULT_FILTER_TYPE', 'chaine', 'AC_NON_AUTO', 'Default filter for type of event on agenda', 0, 'current'); $sqlreadactions = "SELECT code, label, description FROM ".MAIN_DB_PREFIX."c_action_trigger ORDER by rang"; $resql = $this->db->query($sqlreadactions); if ($resql) { - while ($obj = $this->db->fetch_object($resql)) - { - //if (preg_match('/_CREATE$/',$obj->code) && (! in_array($obj->code, array('COMPANY_CREATE','PRODUCT_CREATE','TASK_CREATE')))) continue; // We don't track such events (*_CREATE) by default, we prefer validation (except thirdparty/product/task creation because there is no validation). - if (preg_match('/^TASK_/', $obj->code)) continue; // We don't track such events by default. - //if (preg_match('/^_MODIFY/',$obj->code)) continue; // We don't track such events by default. - $this->const[] = array('MAIN_AGENDA_ACTIONAUTO_'.$obj->code, "chaine", "1", '', 0, 'current'); - } - } else { - dol_print_error($this->db->lasterror()); + while ($obj = $this->db->fetch_object($resql)) + { + //if (preg_match('/_CREATE$/',$obj->code) && (! in_array($obj->code, array('COMPANY_CREATE','PRODUCT_CREATE','TASK_CREATE')))) continue; // We don't track such events (*_CREATE) by default, we prefer validation (except thirdparty/product/task creation because there is no validation). + if (preg_match('/^TASK_/', $obj->code)) continue; // We don't track such events by default. + //if (preg_match('/^_MODIFY/',$obj->code)) continue; // We don't track such events by default. + $this->const[] = array('MAIN_AGENDA_ACTIONAUTO_'.$obj->code, "chaine", "1", '', 0, 'current'); + } + } + else + { + dol_print_error($this->db->lasterror()); } // New pages on tabs @@ -113,7 +115,7 @@ //------------ $datestart = dol_now(); $this->cronjobs = array( - 0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>5, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'$conf->agenda->enabled', 'datestart'=>$datestart), + 0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>10, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'$conf->agenda->enabled', 'datestart'=>$datestart), ); // Permissions @@ -203,19 +205,19 @@ // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both // $r++; $this->menu[$r] = array( - 'fk_menu'=>0, - 'type'=>'top', - 'titre'=>'TMenuAgenda', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php', - 'langs'=>'agenda', - 'position'=>86, - 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', - 'target'=>'', - 'user'=>2, - ); - $r++; + 'fk_menu'=>0, + 'type'=>'top', + 'titre'=>'TMenuAgenda', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/index.php', + 'langs'=>'agenda', + 'position'=>86, + 'perms'=>'$user->rights->agenda->myactions->read', + 'enabled'=>'$conf->agenda->enabled', + 'target'=>'', + 'user'=>2, + ); + $r++; $this->menu[$r] = array( 'fk_menu'=>'r=0', @@ -323,7 +325,7 @@ 'type'=>'left', 'titre'=>'List', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/list.php?action=show_list&mainmenu=agenda&leftmenu=agenda', + 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda', 'langs'=>'agenda', 'position'=>110, 'perms'=>'$user->rights->agenda->myactions->read', @@ -337,7 +339,7 @@ 'type'=>'left', 'titre'=>'MenuToDoMyActions', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/list.php?action=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', + 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', 'langs'=>'agenda', 'position'=>111, 'perms'=>'$user->rights->agenda->myactions->read', @@ -351,7 +353,7 @@ 'type'=>'left', 'titre'=>'MenuDoneMyActions', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/list.php?action=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', + 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', 'langs'=>'agenda', 'position'=>112, 'perms'=>'$user->rights->agenda->myactions->read', @@ -365,7 +367,7 @@ 'type'=>'left', 'titre'=>'MenuToDoActions', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/list.php?action=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', + 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', 'langs'=>'agenda', 'position'=>113, 'perms'=>'$user->rights->agenda->allactions->read', @@ -379,7 +381,7 @@ 'type'=>'left', 'titre'=>'MenuDoneActions', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/list.php?action=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', + 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', 'langs'=>'agenda', 'position'=>114, 'perms'=>'$user->rights->agenda->allactions->read', --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modApi.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modApi.class.php @@ -40,9 +40,9 @@ */ public function __construct($db) { - global $langs, $conf; - - $this->db = $db; + global $langs, $conf; + + $this->db = $db; // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). @@ -81,7 +81,7 @@ // Dependencies $this->hidden = false; // A condition to hide module $this->depends = array(); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array('modZapier'); // List of modules id to disable if this one is disabled + $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(5, 4); // Minimum version of PHP required by module $this->langfiles = array("other"); @@ -95,8 +95,8 @@ // Array to add new pages in new tabs // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@api:$user->rights->api->read:/api/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 - // 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@api:$user->rights->othermodule->read:/api/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. - // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@api:$user->rights->othermodule->read:/api/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // '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) // 'contact' to add a tab in contact view @@ -117,19 +117,19 @@ // 'stock' to add a tab in stock view // 'thirdparty' to add a tab in third party view // 'user' to add a tab in user view - $this->tabs = array(); - - // Dictionaries - if (!isset($conf->api->enabled)) - { - $conf->api = new stdClass(); - $conf->api->enabled = 0; - } + $this->tabs = array(); + + // Dictionaries + if (!isset($conf->api->enabled)) + { + $conf->api = new stdClass(); + $conf->api->enabled = 0; + } $this->dictionaries = array(); - // Boxes + // Boxes // Add here list of php file(s) stored in core/boxes that contains class to show a box. - $this->boxes = array(); // List of boxes + $this->boxes = array(); // List of boxes // Example: //$this->boxes=array(array(0=>array('file'=>'myboxa.php','note'=>'','enabledbydefaulton'=>'Home'),1=>array('file'=>'myboxb.php','note'=>''),2=>array('file'=>'myboxc.php','note'=>''));); @@ -190,7 +190,7 @@ // Example: // $this->export_code[$r]=$this->rights_class.'_'.$r; // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - // $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled. + // $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled. // $this->export_permission[$r]=array(array("facture","facture","export")); // $this->export_fields_array[$r]=array( // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', @@ -222,17 +222,17 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - public function init($options = '') - { - $sql = array(); - - $result = $this->_load_tables('/api/sql/'); - - return $this->_init($sql, $options); - } + public function init($options = '') + { + $sql = array(); + + $result = $this->_load_tables('/api/sql/'); + + return $this->_init($sql, $options); + } /** * Function called when module is disabled. --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modAsset.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modAsset.class.php @@ -79,9 +79,9 @@ // Data directories to create when module is enabled. // Example: this->dirs = array("/asset/temp","/asset/subdir"); - $this->dirs = array("/asset/temp"); - - // Config pages. Put here list of php page, stored into asset/admin directory, to use to setup module. + $this->dirs = array(); + + // Config pages. Put here list of php page, stored into assets/admin directory, to use to setup module. $this->config_page_url = array("setup.php@asset"); // Dependencies @@ -115,8 +115,8 @@ // Array to add new pages in new tabs $this->tabs = array(); // Example: - // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@assets:$user->rights->assets->read:/asset/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 - // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@assets:$user->rights->othermodule->read:/asset/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@assets:$user->rights->assets->read:/assets/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@assets:$user->rights->othermodule->read:/assets/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname // // Where objecttype can be @@ -146,7 +146,7 @@ // Boxes/Widgets - // Add here list of php file(s) stored in asset/core/boxes that contains class to show a widget. + // Add here list of php file(s) stored in assets/core/boxes that contains class to show a widget. $this->boxes = array( //0=>array('file'=>'assetswidget1.php@asset','note'=>'Widget provided by Assets','enabledbydefaulton'=>'Home'), //1=>array('file'=>'assetswidget2.php@asset','note'=>'Widget provided by Assets'), @@ -166,44 +166,44 @@ // Permissions $this->rights = array(); // Permission array used by this module - $this->rights_class = 'asset'; - $r = 0; - - $r++; - $this->rights[$r][0] = 51001; // Permission id (must not be already used) + $this->rights_class = 'asset'; + $r = 0; + + $r++; + $this->rights[$r][0] = 51001; // Permission id (must not be already used) $this->rights[$r][1] = 'Read assets'; // Permission label - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) $r++; $this->rights[$r][0] = 51002; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/Update assets'; // Permission label - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) $r++; $this->rights[$r][0] = 51003; // Permission id (must not be already used) $this->rights[$r][1] = 'Delete assets'; // Permission label - $this->rights[$r][2] = 'd'; - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) - $r++; - $this->rights[$r][0] = 51005; // Permission id (must not be already used) - $this->rights[$r][1] = 'Setup types of asset'; // Permission label - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'setup_advance'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) - - // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. + $r++; + $this->rights[$r][0] = 51005; // Permission id (must not be already used) + $this->rights[$r][1] = 'Setup types of asset'; // Permission label + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'setup_advance'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. } /** @@ -214,13 +214,13 @@ * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - public function init($options = '') - { - // Permissions - $this->remove($options); - - $sql = array(); - - return $this->_init($sql, $options); - } + public function init($options = '') + { + // Permissions + $this->remove($options); + + $sql = array(); + + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modBanque.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modBanque.class.php @@ -71,7 +71,7 @@ $this->depends = array(); $this->requiredby = array("modComptabilite", "modAccounting", "modPrelevement"); $this->conflictwith = array(); - $this->langfiles = array("banks", "compta", "bills", "companies", "accounting"); + $this->langfiles = array("banks", "compta", "bills", "companies"); // Constants $this->const = array(); @@ -202,42 +202,6 @@ $this->export_sql_end[$r] .= ' AND p.fk_paiement = 7'; $this->export_sql_end[$r] .= ' AND ba.entity IN ('.getEntity('bank_account').')'; $this->export_sql_order[$r] = ' ORDER BY b.datev, b.num_releve'; - - // Various Payment - $r++; - $this->export_code[$r] = $this->rights_class.'_'.$r; - $this->export_label[$r] = 'VariousPayment'; - $this->export_permission[$r] = array(array("banque", "export")); - $this->export_fields_array[$r] = array( - 'v.rowid'=>'VariousPaymentId', 'v.label'=>'VariousPaymentLabel', 'v.datev'=>'DateValue', 'v.datep'=>'DateOperation', - 'v.num_payment'=>'ChequeOrTransferNumber', 'v.amount'=>'Amount', 'v.sens'=>'Sens', - 'cp.id'=>"PaymentMode", - 'v.accountancy_code'=>'AccountAccounting', 'v.subledger_account'=>'SubledgerAccount', - 'v.note'=>'Note', 'v.datec'=>'DateCreation', - 'p.ref'=>'ProjectRef', 'p.title'=>'ProjectLabel' - ); - $this->export_TypeFields_array[$r] = array( - 'v.rowid'=>'Text', 'v.label'=>'Text', 'v.datep'=>'Date', 'v.datev'=>'Date', - 'v.num_payment'=>'Text', 'v.amount'=>'Numeric', 'v.sens'=>'Numeric', - 'cp.id'=>'List:c_paiement:code:id:code', - "v.accountancy_code"=>"Text", "v.subledger_account"=>"Text", - "v.note"=>"Text", 'v.datec'=>"Date", - "p.ref"=>"Text", "p.title"=>"Text" - ); - $this->export_entities_array[$r] = array( - 'v.rowid'=>'payment', 'v.label'=>'payment', 'v.datev'=>'payment', 'v.datep'=>'payment', - 'v.num_payment'=>'payment', 'v.amount'=>'payment', 'v.sens'=>'payment', - 'cp.id'=>'payment', - 'v.accountancy_code'=>'payment', 'v.subledger_account'=>"payment", - 'v.note'=>"payment", 'v.datec'=>"payment", - "p.ref"=>"project", "p.title"=>"project" - ); - $this->export_sql_start[$r] = 'SELECT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet as p ON v.fk_projet = p.rowid"; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_paiement as cp ON v.fk_typepayment = cp.id"; - $this->export_sql_end[$r] .= ' WHERE v.entity IN ('.getEntity('payment_various').')'; - $this->export_sql_order[$r] = ' ORDER BY v.datep'; } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modBarcode.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modBarcode.class.php @@ -91,20 +91,20 @@ $this->rights[2][3] = 0; // La permission est-elle une permission par defaut $this->rights[2][4] = 'creer_advance'; - // Main menu entries - $r = 0; - $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'mainmenu'=>'tools', - 'leftmenu'=>'barcodeprint', - 'type'=>'left', // This is a Left menu entry - 'titre'=>'BarCodePrintsheet', - 'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint', - 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>200, - 'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // Main menu entries + $r = 0; + $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'mainmenu'=>'tools', + 'leftmenu'=>'barcodeprint', + 'type'=>'left', // This is a Left menu entry + 'titre'=>'BarCodePrintsheet', + 'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint', + 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>200, + 'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both $r++; $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode @@ -121,12 +121,12 @@ } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories. - * - * @param string $options Options when enabling module ('', 'noboxes') + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories. + * + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modBlockedLog.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modBlockedLog.class.php @@ -29,57 +29,57 @@ */ class modBlockedLog extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs, $conf, $mysoc; - - $this->db = $db; - $this->numero = 3200; - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'blockedlog'; - - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page - $this->family = "base"; - // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '75'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "Enable a log on some business events into a non reversible log. This module may be mandatory for some countries."; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - $this->picto = 'technic'; - - // Data directories to create when module is enabled - $this->dirs = array(); - - // Config pages - //------------- - $this->config_page_url = array('blockedlog.php?withtab=1@blockedlog'); - - // Dependancies - //------------- - $this->hidden = false; // A condition to disable module - $this->depends = array('always'=>'modFacture'); // 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->langfiles = array('blockedlog'); - - $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_unactivation = array('FR'=>'BlockedLogAreRequiredByYourCountryLegislation'); - - // Currently, activation is not automatic because only companies (in France) making invoices to non business customers must - // enable this module. - /*if (! empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs, $conf, $mysoc; + + $this->db = $db; + $this->numero = 3200; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'blockedlog'; + + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "base"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '75'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "Enable a log on some business events into a non reversible log. This module may be mandatory for some countries."; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + $this->picto = 'technic'; + + // Data directories to create when module is enabled + $this->dirs = array(); + + // Config pages + //------------- + $this->config_page_url = array('blockedlog.php?withtab=1@blockedlog'); + + // Dependancies + //------------- + $this->hidden = false; // A condition to disable module + $this->depends = array('always'=>'modFacture'); // 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->langfiles = array('blockedlog'); + + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_unactivation = array('FR'=>'BlockedLogAreRequiredByYourCountryLegislation'); + + // Currently, activation is not automatic because only companies (in France) making invoices to non business customers must + // enable this module. + /*if (! empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) { $tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY); $this->automatic_activation = array(); @@ -88,160 +88,162 @@ $this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation'; } }*/ - //var_dump($this->automatic_activation); - - $this->always_enabled = (!empty($conf->blockedlog->enabled) - && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) - && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) - && $this->alreadyUsed()); - - // Constants - //----------- - $this->const = array( - 1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0) - ); - - // New pages on tabs - // ----------------- - $this->tabs = array(); - - // Boxes - //------ - $this->boxes = array(); - - // Permissions - // ----------------- - $this->rights = array(); // Permission array used by this module - - $r = 0; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read archived events and fingerprints'; // Permission label - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; - - // Main menu entries - // ----------------- - $r = 0; - $this->menu[$r] = array( - 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'mainmenu'=>'tools', - 'leftmenu'=>'blockedlogbrowser', - 'type'=>'left', // This is a Left menu entry - 'titre'=>'BrowseBlockedLog', - 'url'=>'/blockedlog/admin/blockedlog_list.php?mainmenu=tools&leftmenu=blockedlogbrowser', - 'langs'=>'blockedlog', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>200, - 'enabled'=>'$conf->blockedlog->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->rights->blockedlog->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - $r++; - } - - - /** - * Check if module was already used before unactivation linked to warnings_unactivation property - * - * @return boolean True if already used, otherwise False - */ - public function alreadyUsed() - { - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $b = new BlockedLog($this->db); - return $b->alreadyUsed(1); - } - - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories. - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - global $conf, $user; - - $sql = array(); - - // If already used, we add an entry to show we enable module - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - - $object = new stdClass(); - $object->id = 1; - $object->element = 'module'; - $object->ref = 'systemevent'; - $object->entity = $conf->entity; - $object->date = dol_now(); - - $b = new BlockedLog($this->db); - $result = $b->setObjectData($object, 'MODULE_SET', 0); - if ($result < 0) - { - $this->error = $b->error; - $this->errors = $b->erros; - return 0; - } - - $res = $b->create($user); - if ($res <= 0) { - $this->error = $b->error; - $this->errors = $b->errors; - return $res; - } - - return $this->_init($sql, $options); - } - - /** - * Function called when module is disabled. - * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function remove($options = '') - { - - global $conf, $user; - - $sql = array(); - - // If already used, we add an entry to show we enable module - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - - $object = new stdClass(); - $object->id = 1; - $object->element = 'module'; - $object->ref = 'systemevent'; - $object->entity = $conf->entity; - $object->date = dol_now(); - - $b = new BlockedLog($this->db); - $result = $b->setObjectData($object, 'MODULE_RESET', 0); - if ($result < 0) - { - $this->error = $b->error; - $this->errors = $b->erros; - return 0; - } - - if ($b->alreadyUsed(1)) - { - $res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error - } else { - $res = $b->create($user); - } - if ($res <= 0) { - $this->error = $b->error; - $this->errors = $b->errors; - return $res; - } - - return $this->_remove($sql, $options); - } + //var_dump($this->automatic_activation); + + $this->always_enabled = (!empty($conf->blockedlog->enabled) + && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) + && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) + && $this->alreadyUsed()); + + // Constants + //----------- + $this->const = array( + 1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0) + ); + + // New pages on tabs + // ----------------- + $this->tabs = array(); + + // Boxes + //------ + $this->boxes = array(); + + // Permissions + // ----------------- + $this->rights = array(); // Permission array used by this module + + $r = 0; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read archived events and fingerprints'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = ''; + + // Main menu entries + // ----------------- + $r = 0; + $this->menu[$r] = array( + 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'mainmenu'=>'tools', + 'leftmenu'=>'blockedlogbrowser', + 'type'=>'left', // This is a Left menu entry + 'titre'=>'BrowseBlockedLog', + 'url'=>'/blockedlog/admin/blockedlog_list.php?mainmenu=tools&leftmenu=blockedlogbrowser', + 'langs'=>'blockedlog', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>200, + 'enabled'=>'$conf->blockedlog->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'$user->rights->blockedlog->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + $r++; + } + + + /** + * Check if module was already used before unactivation linked to warnings_unactivation property + * + * @return boolean True if already used, otherwise False + */ + public function alreadyUsed() + { + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + $b = new BlockedLog($this->db); + return $b->alreadyUsed(1); + } + + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories. + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $conf, $user; + + $sql = array(); + + // If already used, we add an entry to show we enable module + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + + $object = new stdClass(); + $object->id = 1; + $object->element = 'module'; + $object->ref = 'systemevent'; + $object->entity = $conf->entity; + $object->date = dol_now(); + + $b = new BlockedLog($this->db); + $result = $b->setObjectData($object, 'MODULE_SET', 0); + if ($result < 0) + { + $this->error = $b->error; + $this->errors = $b->erros; + return 0; + } + + $res = $b->create($user); + if ($res <= 0) { + $this->error = $b->error; + $this->errors = $b->errors; + return $res; + } + + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + + global $conf, $user; + + $sql = array(); + + // If already used, we add an entry to show we enable module + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + + $object = new stdClass(); + $object->id = 1; + $object->element = 'module'; + $object->ref = 'systemevent'; + $object->entity = $conf->entity; + $object->date = dol_now(); + + $b = new BlockedLog($this->db); + $result = $b->setObjectData($object, 'MODULE_RESET', 0); + if ($result < 0) + { + $this->error = $b->error; + $this->errors = $b->erros; + return 0; + } + + if ($b->alreadyUsed(1)) + { + $res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error + } + else + { + $res = $b->create($user); + } + if ($res <= 0) { + $this->error = $b->error; + $this->errors = $b->errors; + return $res; + } + + return $this->_remove($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modBom.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modBom.class.php @@ -54,7 +54,7 @@ // It is used to group modules by family in module setup page $this->family = "products"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '65'; + $this->module_position = '60'; // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); @@ -300,7 +300,6 @@ $this->export_dependencies_array[$r] = array('bomline'=>'tl.rowid'); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'bom_bom as t'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bom_extrafields as extra on (t.rowid = extra.fk_object)'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bomline as tl ON tl.fk_bom = t.rowid'; $this->export_sql_end[$r] .= ' WHERE 1 = 1'; $this->export_sql_end[$r] .= ' AND t.entity IN ('.getEntity('bom').')'; --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modBookmark.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modBookmark.class.php @@ -69,9 +69,7 @@ $this->const = array(); // Boxes - $this->boxes = array( - 0=>array('file'=>'box_bookmarks.php', 'enabledbydefaulton'=>'Home') - ); + $this->boxes = array(0=>array('file'=>'box_bookmarks.php', 'enabledbydefaulton'=>'Home')); // Permissions $this->rights = array(); --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modCashDesk.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modCashDesk.class.php @@ -46,11 +46,12 @@ $this->rights_class = 'cashdesk'; $this->family = "portal"; - $this->module_position = '59'; + $this->module_position = '55'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "CashDesk module"; + $this->revision = '1.27'; $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); @@ -101,8 +102,8 @@ 'url'=>'/cashdesk/index.php?user=__USER_LOGIN__', 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>900, - 'enabled'=>'$conf->cashdesk->enabled', - 'perms'=>'$user->rights->cashdesk->run', // Use 'perms'=>'1' if you want your menu with no permission rules + 'enabled'=>'$conf->cashdesk->enabled', + 'perms'=>'$user->rights->cashdesk->run', // Use 'perms'=>'1' if you want your menu with no permission rules 'target'=>'pointofsale', 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both @@ -120,24 +121,24 @@ // 'target'=>'', // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both // $r++; - } + } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - $sql = array(); + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + $sql = array(); - // Remove permissions and default values - $this->remove($options); + // Remove permissions and default values + $this->remove($options); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modCategorie.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modCategorie.class.php @@ -2,7 +2,6 @@ /* Copyright (C) 2005 Matthieu Valleton * Copyright (C) 2005-2014 Laurent Destailleur * Copyright (C) 2012-2016 Juanjo Menent - * Copyright (C) 2020 Stéphane Lesage * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +25,6 @@ * \brief Fichier de description et activation du module Categorie */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; -include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; /** @@ -41,7 +39,7 @@ */ public function __construct($db) { - global $conf; + global $conf; $this->db = $db; $this->numero = 1780; @@ -66,7 +64,7 @@ // Config pages $this->config_page_url = array('categorie.php@categories'); - $this->langfiles = array("products", "companies", "categories", "members", "stocks", "website"); + $this->langfiles = array("products", "companies", "categories", "members"); // Constants $this->const = array(); @@ -118,320 +116,326 @@ //-------- $r = 0; - // All Categories List - $r++; - $this->export_code[$r] = $this->rights_class.'_list'; - $this->export_label[$r] = 'CatListAll'; - $this->export_icon[$r] = $this->picto; - $this->export_enabled[$r] = 'true'; - $this->export_permission[$r] = array(array("categorie", "lire")); - - $typeexample = ""; - if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $typeexample .= ($typeexample ? " / " : "")."0=Product-Service"; } - if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { $typeexample .= ($typeexample ? "/" : "")."1=Supplier"; } - if (!empty($conf->societe->enabled)) { $typeexample .= ($typeexample ? " / " : "")."2=Customer-Prospect"; } - if (!empty($conf->adherent->enabled)) { $typeexample .= ($typeexample ? " / " : "")."3=Member"; } - if (!empty($conf->societe->enabled)) { $typeexample .= ($typeexample ? " / " : "")."4=Contact"; } - if (!empty($conf->bank->enabled)) { $typeexample .= ($typeexample ? " / " : "")."5=Bank account"; } - if (!empty($conf->projet->enabled)) { $typeexample .= ($typeexample ? " / " : "")."6=Project"; } - if (!empty($conf->user->enabled)) { $typeexample .= ($typeexample ? " / " : "")."7=User"; } - if (!empty($conf->bank->enabled)) { $typeexample .= ($typeexample ? " / " : "")."8=Bank line"; } - if (!empty($conf->stock->enabled)) { $typeexample .= ($typeexample ? " / " : "")."9=Warehouse"; } - if (!empty($conf->agenda->enabled)) { $typeexample .= ($typeexample ? " / " : "")."10=Agenda event"; } - if (!empty($conf->website->enabled)) { $typeexample .= ($typeexample ? " / " : "")."11=Website page"; } - - $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.type'=>"Type", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'pcat.label'=>"ParentCategoryLabel" ); - $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.type'=>"Numeric", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'pcat.label'=>'Text' ); - $this->export_entities_array[$r] = array(); // We define here only fields that use another picto - $this->export_help_array[$r] = array('cat.type'=>$typeexample); - - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent'; - $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; - - // 0 Products - $r++; - $this->export_code[$r] = $this->rights_class.'_0_'.Categorie::$MAP_ID_TO_CODE[0]; - $this->export_label[$r] = 'CatProdList'; - $this->export_icon[$r] = $this->picto; - $this->export_enabled[$r] = '!empty($conf->product->enabled) || !empty($conf->service->abled)'; - $this->export_permission[$r] = array(array("categorie", "lire"), array("produit", "export")); - $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'p.rowid'=>'ProductId', 'p.ref'=>'Ref', 'p.label'=>'Label'); - $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'p.ref'=>'Text', 'p.label'=>'Text'); - $this->export_entities_array[$r] = array('p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product'); // We define here only fields that use another picto - - $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_categorie = cat.rowid'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'product as p ON p.rowid = cp.fk_product'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON extra.fk_object = p.rowid'; - $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .= ' AND cat.type = 0'; - - // 1 Suppliers - $r++; - $this->export_code[$r] = $this->rights_class.'_1_'.Categorie::$MAP_ID_TO_CODE[1]; + $r++; + $this->export_code[$r] = 'category_'.$r; $this->export_label[$r] = 'CatSupList'; - $this->export_icon[$r] = $this->picto; + $this->export_icon[$r] = 'category'; $this->export_enabled[$r] = '!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)'; $this->export_permission[$r] = array(array("categorie", "lire"), array("fournisseur", "lire")); $this->export_fields_array[$r] = array( - 'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", - 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_fournisseur'=>"SupplierCode", - 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", - 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", - 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_public'=>"NotePublic", - 't.libelle'=>'ThirdPartyType' + 'u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", + 's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.address'=>"Address", + 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", + 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", + 's.note_public'=>"NotePublic" ); $this->export_TypeFields_array[$r] = array( - 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', - 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.fournisseur'=>"Text", 's.datec'=>"Date", 's.tms'=>"Date", 's.code_fournisseur'=>"Text", - 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", - 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", - 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text", - 't.libelle'=>'List:c_typent:libelle:code' + 'u.label'=>"Text", 'u.description'=>"Text", 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text", 's.datec'=>"Date", + 's.tms'=>"Date", 's.code_client'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", + 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", + 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text" ); $this->export_entities_array[$r] = array( - 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.fournisseur'=>"company", 's.datec'=>"company", 's.tms'=>"company", 's.code_fournisseur'=>"company", - 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company", - 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", - 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company", - 't.libelle'=>'company' + 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company", + 's.code_client'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company", + 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", + 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company" ); // We define here only fields that use another picto - - $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_fournisseur as cf ON cf.fk_categorie = cat.rowid'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = cf.fk_soc'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; - $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .= ' AND cat.type = 1'; - - // 2 Customers/Prospects - $r++; - $this->export_code[$r] = $this->rights_class.'_2_'.Categorie::$MAP_ID_TO_CODE[2]; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '; + $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_fournisseur as cf, '; + $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; + $this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND u.type = 1'; // Supplier categories + + $r++; + $this->export_code[$r] = 'category_'.$r; $this->export_label[$r] = 'CatCusList'; - $this->export_icon[$r] = $this->picto; - $this->export_enabled[$r] = '!empty($conf->societe->enabled)'; - $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "export")); + $this->export_icon[$r] = 'category'; + $this->export_enabled[$r] = '$conf->societe->enabled'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "lire")); $this->export_fields_array[$r] = array( - 'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", - 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", 's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", - 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", - 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", - 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_public'=>"NotePublic", - 't.libelle'=>'ThirdPartyType', 'pl.code'=>'ProspectLevel', 'st.code'=>'ProspectStatus' + 'u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", + 's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.address'=>"Address", + 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", + 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", + 's.note_public'=>"NotePublic", 's.fk_prospectlevel'=>'ProspectLevel', 's.fk_stcomm'=>'ProspectStatus' ); $this->export_TypeFields_array[$r] = array( - 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', - 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text", 's.datec'=>"Date", 's.tms'=>"Date", 's.code_client'=>"Text", - 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", - 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", - 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text", - 't.libelle'=>'List:c_typent:libelle:code', 'pl.code'=>'List:c_prospectlevel:label:code', 'st.code'=>'List:c_stcomm:libelle:code' + 'u.label'=>"Text", 'u.description'=>"Text", 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text", + 's.datec'=>"Date", 's.tms'=>"Date", 's.code_client'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", + 'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", + 's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code', + 's.fk_stcomm'=>'List:c_stcomm:libelle:code' ); $this->export_entities_array[$r] = array( - 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company", 's.code_client'=>"company", - 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company", - 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", - 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company", - 't.libelle'=>'company', 'pl.code'=>'company', 'st.code'=>'company' + 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company", + 's.code_client'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company", + 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", + 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company", 's.fk_prospectlevel'=>'company', + 's.fk_stcomm'=>'company' ); // We define here only fields that use another picto - - $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_categorie = cat.rowid'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = cs.fk_soc'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_prospectlevel as pl ON s.fk_prospectlevel = pl.code'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; - $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .= ' AND cat.type = 2'; - - // 3 Members - $r++; - $this->export_code[$r] = $this->rights_class.'_3_'.Categorie::$MAP_ID_TO_CODE[3]; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '; + $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_societe as cf, '; + $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object '; + $this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND u.type = 2'; // Customer/Prospect categories + + // Add extra fields + $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; + $resql = $this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj = $this->db->fetch_object($resql)) + { + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $typeFilter = "Text"; + switch ($obj->type) + { + case 'int': + case 'double': + case 'price': + $typeFilter = "Numeric"; + break; + case 'date': + case 'datetime': + $typeFilter = "Date"; + break; + case 'boolean': + $typeFilter = "Boolean"; + break; + case 'sellist': + $typeFilter = "List:".$obj->param; + break; + case 'select': + $typeFilter = "Select:".$obj->param; + break; + } + $this->export_fields_array[$r][$fieldname] = $fieldlabel; + $this->export_TypeFields_array[$r][$fieldname] = $typeFilter; + $this->export_entities_array[$r][$fieldname] = 'company'; + } + } + // End add axtra fields + + + + + + $r++; + $this->export_code[$r] = 'category_'.$r; + $this->export_label[$r] = 'CatProdList'; + $this->export_icon[$r] = 'category'; + $this->export_enabled[$r] = '$conf->product->enabled || $conf->service->enabled'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("produit", "lire")); + $this->export_fields_array[$r] = array('u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 'p.rowid'=>'ProductId', 'p.ref'=>'Ref'); + $this->export_TypeFields_array[$r] = array('u.label'=>"Text", 'u.description'=>"Text", 'p.ref'=>'Text'); + $this->export_entities_array[$r] = array('p.rowid'=>'product', 'p.ref'=>'product'); // We define here only fields that use another picto + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_product = p.rowid'; + $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND u.type = 0'; // Supplier categories + + $r++; + $this->export_code[$r] = 'category_'.$r; $this->export_label[$r] = 'CatMemberList'; - $this->export_icon[$r] = $this->picto; - $this->export_enabled[$r] = '!empty($conf->adherent->enabled)'; - $this->export_permission[$r] = array(array("categorie", "lire"), array("adherent", "export")); - $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'p.rowid'=>'MemberId', 'p.lastname'=>'LastName', 'p.firstname'=>'Firstname'); - $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'p.lastname'=>'Text', 'p.firstname'=>'Text'); + $this->export_icon[$r] = 'category'; + $this->export_enabled[$r] = '$conf->adherent->enabled'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("adherent", "lire")); + $this->export_fields_array[$r] = array('u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 'p.rowid'=>'MemberId', 'p.lastname'=>'LastName', 'p.firstname'=>'Firstname'); + $this->export_TypeFields_array[$r] = array('u.label'=>"Text", 'u.description'=>"Text", 'p.lastname'=>'Text', 'p.firstname'=>'Text'); $this->export_entities_array[$r] = array('p.rowid'=>'member', 'p.lastname'=>'member', 'p.firstname'=>'member'); // We define here only fields that use another picto - - $keyforselect = 'adherent'; $keyforelement = 'member'; $keyforaliasextra = 'extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_member as cm ON cm.fk_categorie = cat.rowid'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'adherent as p ON p.rowid = cm.fk_member'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON cat.rowid = extra.fk_object '; - $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .= ' AND cat.type = 3'; - - // 4 Contacts - $r++; - $this->export_code[$r] = $this->rights_class.'_4_'.Categorie::$MAP_ID_TO_CODE[4]; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_member as cp, '.MAIN_DB_PREFIX.'adherent as p'; + $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid'; + $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND u.type = 3'; // Member categories + + $r++; + $this->export_code[$r] = 'category_'.$r; $this->export_label[$r] = 'CatContactList'; - $this->export_icon[$r] = $this->picto; - $this->export_enabled[$r] = '!empty($conf->societe->enabled)'; - $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "contact", "export")); + $this->export_icon[$r] = 'category'; + $this->export_enabled[$r] = '$conf->societe->enabled'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "lire")); $this->export_fields_array[$r] = array( - 'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", - 'p.rowid' => 'ContactId', 'civ.label' => 'UserTitle', 'p.lastname' => 'LastName', 'p.firstname' => 'Firstname', - 'p.address' => 'Address', 'p.zip' => 'Zip', 'p.town' => 'Town', 'c.code' => 'CountryCode', 'c.label' => 'Country', - 'p.birthday' => 'DateOfBirth', 'p.poste' => 'PostOrFunction', - 'p.phone' => 'Phone', 'p.phone_perso' => 'PhonePerso', 'p.phone_mobile' => 'PhoneMobile', 'p.fax' => 'Fax', 'p.email' => 'Email', - 'p.note_private' => 'NotePrivate', 'p.note_public' => 'NotePublic', 'p.statut' => 'Status', - 's.nom'=>"Name", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.status'=>"Status", - 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", - 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email" + 'u.rowid' => "CategId", + 'u.label' => "Label", + 'u.description' => "Description", + 'p.rowid' => 'ContactId', + 'p.civility' => 'UserTitle', + 'p.lastname' => 'LastName', + 'p.firstname' => 'Firstname', + 'p.address' => 'Address', + 'p.zip' => 'Zip', + 'p.town' => 'Town', + 'country.code' => 'CountryCode', + 'country.label' => 'Country', + 'p.birthday' => 'DateToBirth', + 'p.poste' => 'PostOrFunction', + 'p.phone' => 'Phone', + 'p.phone_perso' => 'PhonePerso', + 'p.phone_mobile' => 'PhoneMobile', + 'p.fax' => 'Fax', + 'p.email' => 'Email', + 'p.note_private' => 'NotePrivate', + 'p.note_public' => 'NotePublic', + 'p.statut' => 'Status', + 's.nom'=>"Name", + 's.client'=>"Customer", + 's.fournisseur'=>"Supplier", + 's.status'=>"Status", + 's.address'=>"Address", + 's.zip'=>"Zip", + 's.town'=>"Town", + 's.phone'=>"Phone", + 's.fax'=>"Fax", + 's.url'=>"Url", + 's.email'=>"Email" ); $this->export_TypeFields_array[$r] = array( - 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', - 'civ.label' => 'List:c_civility:label:label', 'p.lastname' => 'Text', 'p.firstname' => 'Text', - 'p.address' => 'Text', 'p.zip' => 'Text', 'p.town' => 'Text', 'c.code' => 'Text', 'c.label' => 'List:c_country:label:label', - 'p.birthday' => 'Date', 'p.poste' => 'Text', - 'p.phone' => 'Text', 'p.phone_perso' => 'Text', 'p.phone_mobile' => 'Text', 'p.fax' => 'Text', 'p.email' => 'Text', - 'p.note_private' => 'Text', 'p.note_public' => 'Text', 'p.statut' => 'Boolean', - 's.nom'=>"Text", 's.client'=>"Boolean", 's.fournisseur'=>"Boolean", 's.status'=>"Boolean", - 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", - 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text" + 'u.label' => "Text", + 'u.description' => "Text", + 'p.lastname' => 'Text', + 'p.firstname' => 'Text', + 'p.statut'=>"Numeric", + 's.nom'=>"Text", + 's.status'=>"Text", + 's.address'=>"Text", + 's.zip'=>"Text", + 's.town'=>"Text", + 's.phone'=>"Text", + 's.fax'=>"Text", + 's.url'=>"Text", + 's.email'=>"Text" ); $this->export_entities_array[$r] = array( - 'p.rowid' => 'contact', 'civ.label' => 'contact', 'p.lastname' => 'contact', 'p.firstname' => 'contact', - 'p.address' => 'contact', 'p.zip' => 'contact', 'p.town' => 'contact', 'c.code' => 'contact', 'c.label' => 'contact', - 'p.birthday' => 'contact', 'p.poste' => 'contact', - 'p.phone' => 'contact', 'p.phone_perso' => 'contact', 'p.phone_mobile' => 'contact', 'p.fax' => 'contact', 'p.email' => 'contact', - 'p.note_private' => 'contact', 'p.note_public' => 'contact', 'p.statut' => 'contact', - 's.nom'=>"company", 's.client'=>"company", 's.fournisseur'=>"company", 's.status'=>"company", - 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", - 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company" + 'u.rowid' => "category", + 'u.label' => "category", + 'u.description' => "category", + 'p.rowid' => 'contact', + 'p.civility' => 'contact', + 'p.lastname' => 'contact', + 'p.firstname' => 'contact', + 'p.address' => 'contact', + 'p.zip' => 'contact', + 'p.town' => 'contact', + 'country.code' => 'contact', + 'country.label' => 'contact', + 'p.birthday' => 'contact', + 'p.poste' => 'contact', + 'p.phone' => 'contact', + 'p.phone_perso' => 'contact', + 'p.phone_mobile' => 'contact', + 'p.fax' => 'contact', + 'p.email' => 'contact', + 'p.note_private' => 'contact', + 'p.note_public' => 'contact', + 'p.statut' => 'contact', + 's.nom'=>"company", + 's.client'=>"company", + 's.fournisseur'=>"company", + 's.status'=>"company", + 's.address'=>"company", + 's.zip'=>"company", + 's.town'=>"company", + 's.phone'=>"company", + 's.fax'=>"company", + 's.url'=>"company", + 's.email'=>"company" ); // We define here only fields that use another picto - $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + // Add extra fields + $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; + $resql = $this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj = $this->db->fetch_object($resql)) + { + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $typeFilter = "Text"; + switch ($obj->type) + { + case 'int': + case 'double': + case 'price': + $typeFilter = "Numeric"; + break; + case 'date': + case 'datetime': + $typeFilter = "Date"; + break; + case 'boolean': + $typeFilter = "Boolean"; + break; + case 'sellist': + $typeFilter = "List:".$obj->param; + break; + case 'select': + $typeFilter = "Select:".$obj->param; + break; + } + $this->export_fields_array[$r][$fieldname] = $fieldlabel; + $this->export_TypeFields_array[$r][$fieldname] = $typeFilter; + $this->export_entities_array[$r][$fieldname] = 'contact'; + } + } + // End add axtra fields $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_contact as cc ON cc.fk_categorie = cat.rowid'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'socpeople as p ON p.rowid = cc.fk_socpeople'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = p.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_civility as civ ON civ.code = p.civility'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON c.rowid = p.fk_pays'; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_contact as cp, '.MAIN_DB_PREFIX.'socpeople as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as country ON p.fk_pays = country.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; - $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .= ' AND cat.type = 4'; - - // 5 Bank accounts, TODO ? - - // 6 Projects - $r++; - $this->export_code[$r] = $this->rights_class.'_6_'.Categorie::$MAP_ID_TO_CODE[6]; - $this->export_label[$r] = 'CatProjectsList'; - $this->export_icon[$r] = $this->picto; - $this->export_enabled[$r] = '!empty($conf->projet->enabled)'; - $this->export_permission[$r] = array(array("categorie", "lire"), array("projet", "export")); - $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'p.rowid'=>'ProjectId', 'p.ref'=>'Ref', 's.rowid'=>"IdThirdParty", 's.nom'=>"Name"); - $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'p.ref'=>'Text', 's.rowid'=>"List:societe:nom:rowid", 's.nom'=>"Text"); - $this->export_entities_array[$r] = array('p.rowid'=>'project', 'p.ref'=>'project', 's.rowid'=>"company", 's.nom'=>"company"); // We define here only fields that use another picto - - $keyforselect = 'projet'; $keyforelement = 'project'; $keyforaliasextra = 'extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_project as cp ON cp.fk_categorie = cat.rowid'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'projet as p ON p.rowid = cp.fk_project'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON extra.fk_object = p.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; - $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .= ' AND cat.type = 6'; - - // 7 Users - $r++; - $this->export_code[$r] = $this->rights_class.'_7_'.Categorie::$MAP_ID_TO_CODE[7]; - $this->export_label[$r] = 'CatUsersList'; - $this->export_icon[$r] = $this->picto; - $this->export_enabled[$r] = '!empty($conf->user->enabled)'; - $this->export_permission[$r] = array(array("categorie", "lire"), array("user", "export")); - $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'p.rowid'=>'TechnicalID', 'p.login'=>'Login', 'p.lastname'=>'Lastname', 'p.firstname'=>'Firstname'); - $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'p.login'=>'Text', 'p.lastname'=>'Text', 'p.firstname'=>'Text'); - $this->export_entities_array[$r] = array('p.rowid'=>'user', 'p.login'=>'user', 'p.lastname'=>'user', 'p.firstname'=>'user'); // We define here only fields that use another picto - - $keyforselect = 'user'; $keyforelement = 'user'; $keyforaliasextra = 'extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_user as cu ON cu.fk_categorie = cat.rowid'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'user as p ON p.rowid = cu.fk_user'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user_extrafields as extra ON extra.fk_object = p.rowid'; - $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .= ' AND cat.type = 7'; - - // 8 Bank Lines, TODO ? - - // 9 Warehouses, TODO ? - - // 10 Agenda Events, TODO ? - - // 11 Website Pages, TODO ? + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = p.rowid'; + $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories // Imports //-------- $r = 0; - // Categories - $r++; - $this->import_code[$r] = $this->rights_class.'_list'; + $r++; + $this->import_code[$r] = $this->rights_class.'_'.$r; $this->import_label[$r] = "CatList"; // Translation key $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r] = array('ca'=>MAIN_DB_PREFIX.'categorie'); - $this->import_fields_array[$r] = array( - 'ca.label'=>"Label*", 'ca.type'=>"Type*", 'ca.description'=>"Description", - 'ca.fk_parent' => 'ParentCategory' - ); - $this->import_regex_array[$r] = array('ca.type'=>'^(0|1|2|3|4|5|6|7|8|9|10|11)$'); - $this->import_convertvalue_array[$r] = array( - 'ca.fk_parent' => array( - 'rule' => 'fetchidfromcodeandlabel', - 'classfile' => '/categories/class/categorie.class.php', - 'class' => 'Categorie', - 'method' => 'fetch', - 'element' => 'category', - 'codefromfield' => 'ca.type' - ) - ); - - $this->import_examplevalues_array[$r] = array( - 'ca.label'=>"My Category Label", 'ca.type'=>$typeexample, 'ca.description'=>"My Category description", // $typeexample built above in exports - 'ca.fk_parent' => 'rowid or label' - ); - $this->import_updatekeys_array[$r] = array('ca.label'=>'Label'); - - // 0 Products + $this->import_fields_array[$r] = array( + 'ca.label'=>"Label*", 'ca.type'=>"Type*", 'ca.description'=>"Description", + 'ca.fk_parent' => 'Parent' + ); + $this->import_regex_array[$r] = array('ca.type'=>'^[0|1|2|3]'); + $this->import_convertvalue_array[$r] = array( + 'ca.fk_parent' => array( + 'rule' => 'fetchidfromcodeandlabel', + 'classfile' => '/categories/class/categorie.class.php', + 'class' => 'Categorie', + 'method' => 'fetch', + 'element' => 'category', + 'codefromfield' => 'ca.type' + ) + ); + $typeexample = ""; + if ($conf->product->enabled) { $typeexample .= ($typeexample ? "/" : "")."0=Product"; } + if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { $typeexample .= ($typeexample ? "/" : "")."1=Supplier"; } + if ($conf->societe->enabled) { $typeexample .= ($typeexample ? "/" : "")."2=Customer-Prospect"; } + if ($conf->adherent->enabled) { $typeexample .= ($typeexample ? "/" : "")."3=Member"; } + $this->import_examplevalues_array[$r] = array( + 'ca.label'=>"Supplier Category", 'ca.type'=>$typeexample, 'ca.description'=>"My Category description", + 'ca.fk_parent' => '0' + ); + if (!empty($conf->product->enabled)) { + //Products $r++; - $this->import_code[$r] = $this->rights_class.'_0_'.Categorie::$MAP_ID_TO_CODE[0]; + $this->import_code[$r] = $this->rights_class.'_'.$r; $this->import_label[$r] = "CatProdLinks"; // Translation key $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon @@ -441,16 +445,57 @@ $this->import_convertvalue_array[$r] = array( 'cp.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), - 'cp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') - ); - $this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"rowid or label", 'cp.fk_product'=>"rowid or ref"); + 'cp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'product') + ); + $this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"Imported category", 'cp.fk_product'=>"PREF123456"); } - // 1 Suppliers + if (!empty($conf->societe->enabled)) + { + // Customers + $r++; + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "CatCusLinks"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_societe'); + $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"ThirdParty*"); + $this->import_regex_array[$r] = array( + 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=2', + 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:client>0' + ); + + $this->import_convertvalue_array[$r] = array( + 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), + 'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty') + ); + $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_soc'=>"MyBigCompany"); + + // Contacts/Addresses + $r++; + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "CatContactsLinks"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_contact'); + $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_socpeople'=>"Contact ID*"); + $this->import_regex_array[$r] = array( + 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=4' + //'cs.fk_socpeople'=>'rowid@'.MAIN_DB_PREFIX.'socpeople' + ); + + $this->import_convertvalue_array[$r] = array( + 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category') + //'cs.fk_socpeople'=>array('rule'=>'fetchidfromref','classfile'=>'/contact/class/contact.class.php','class'=>'Contact','method'=>'fetch','element'=>'Contact') + ); + $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_socpeople'=>"123"); + } + if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { + // Suppliers $r++; - $this->import_code[$r] = $this->rights_class.'_1_'.Categorie::$MAP_ID_TO_CODE[1]; + $this->import_code[$r] = $this->rights_class.'_'.$r; $this->import_label[$r] = "CatSupLinks"; // Translation key $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon @@ -465,130 +510,19 @@ 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), 'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty') ); - $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"rowid or label", 'cs.fk_soc'=>"rowid or ref"); + $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_soc'=>"MyBigCompany"); } - - // 2 Customers - if (!empty($conf->societe->enabled)) - { - $r++; - $this->import_code[$r] = $this->rights_class.'_2_'.Categorie::$MAP_ID_TO_CODE[2]; - $this->import_label[$r] = "CatCusLinks"; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_societe'); - $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"Customer*"); - $this->import_regex_array[$r] = array( - 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=2', - 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:client>0' - ); - - $this->import_convertvalue_array[$r] = array( - 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), - 'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty') - ); - $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"rowid or label", 'cs.fk_soc'=>"rowid or ref"); - } - - // 3 Members - if (!empty($conf->adherent->enabled)) - { - $r++; - $this->import_code[$r] = $this->rights_class.'_3_'.Categorie::$MAP_ID_TO_CODE[3]; - $this->import_label[$r] = "CatMembersLinks"; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = array('cm'=>MAIN_DB_PREFIX.'categorie_contact'); - $this->import_fields_array[$r] = array('cm.fk_categorie'=>"Category*", 'cm.fk_member'=>"Member*"); - $this->import_regex_array[$r] = array('cm.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=3'); - - $this->import_convertvalue_array[$r] = array( - 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), - 'cs.fk_member'=>array('rule'=>'fetchidfromref','classfile'=>'/adherents/class/adherent.class.php','class'=>'Adherent','method'=>'fetch','element'=>'Member') - ); - $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"rowid or label", 'cs.fk_member'=>"rowid or ref"); - } - - // 4 Contacts/Addresses - if (!empty($conf->societe->enabled)) - { - $r++; - $this->import_code[$r] = $this->rights_class.'_4_'.Categorie::$MAP_ID_TO_CODE[4]; - $this->import_label[$r] = "CatContactsLinks"; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = array('cc'=>MAIN_DB_PREFIX.'categorie_contact'); - $this->import_fields_array[$r] = array('cc.fk_categorie'=>"Category*", 'cc.fk_socpeople'=>"IdContact*"); - $this->import_regex_array[$r] = array( - 'cc.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=4' - //'cc.fk_socpeople'=>'rowid@'.MAIN_DB_PREFIX.'socpeople' - ); - - $this->import_convertvalue_array[$r] = array( - 'cc.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), - //'cc.fk_socpeople'=>array('rule'=>'fetchidfromref','classfile'=>'/contact/class/contact.class.php','class'=>'Contact','method'=>'fetch','element'=>'Contact') - ); - $this->import_examplevalues_array[$r] = array('cc.fk_categorie'=>"rowid or label", 'cc.fk_socpeople'=>"rowid"); - } - - // 5 Bank accounts, TODO ? - - // 6 Projects - if (!empty($conf->projet->enabled)) - { - $r++; - $this->import_code[$r] = $this->rights_class.'_6_'.Categorie::$MAP_ID_TO_CODE[6]; - $this->import_label[$r] = "CatProjectsLinks"; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = array('cp'=>MAIN_DB_PREFIX.'categorie_project'); - $this->import_fields_array[$r] = array('cp.fk_categorie'=>"Category*", 'cp.fk_project'=>"Project*"); - $this->import_regex_array[$r] = array('cp.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=6'); - - $this->import_convertvalue_array[$r] = array( - 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), - 'cs.fk_project'=>array('rule'=>'fetchidfromref','classfile'=>'/projet/class/project.class.php','class'=>'Project','method'=>'fetch','element'=>'Project') - ); - $this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"rowid or label", 'cp.fk_project'=>"rowid or ref"); - } - - // 7 Users - if (!empty($conf->user->enabled)) - { - $r++; - $this->import_code[$r] = $this->rights_class.'_7_'.Categorie::$MAP_ID_TO_CODE[7]; - $this->import_label[$r] = "CatUsersLinks"; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = array('cu'=>MAIN_DB_PREFIX.'categorie_user'); - $this->import_fields_array[$r] = array('cu.fk_categorie'=>"Category*", 'cu.fk_user'=>"User*"); - $this->import_regex_array[$r] = array('cu.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=7'); - - $this->import_convertvalue_array[$r] = array( - 'cu.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), - 'cu.fk_user'=>array('rule'=>'fetchidfromref','classfile'=>'/user/class/user.class.php','class'=>'User','method'=>'fetch','element'=>'User') - ); - $this->import_examplevalues_array[$r] = array('cu.fk_categorie'=>"rowid or label", 'cu.fk_user'=>"rowid or login"); - } - - // 8 Bank Lines, TODO ? - - // 9 Warehouses, TODO ? - - // 10 Agenda Events, TODO ? - - // 11 Website Pages, TODO ? } - /** + /** * Function called when module is enabled. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO - */ + */ public function init($options = '') { // Permissions --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modCollab.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modCollab.class.php @@ -31,65 +31,65 @@ class modCollab extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs, $conf; + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs, $conf; - $this->db = $db; - $this->numero = 30000; + $this->db = $db; + $this->numero = 30000; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page - $this->family = "portal"; - $this->module_position = '51'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "Enable the public collaboration features, like shared pad, shared online sheets, etc..."; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'development'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - $this->picto = 'website'; + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "portal"; + $this->module_position = '51'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "Enable the public collaboration features, like shared pad, shared online sheets, etc..."; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'development'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + $this->picto = 'website'; - // Data directories to create when module is enabled - $this->dirs = array("/collab/temp"); + // Data directories to create when module is enabled + $this->dirs = array("/collab/temp"); - // Config pages - //------------- - $this->config_page_url = array(/*'collab.php'*/); + // Config pages + //------------- + $this->config_page_url = array(/*'collab.php'*/); - // Dependancies - //------------- - $this->hidden = !empty($conf->global->MODULE_COLLAB_DISABLED); // A condition to disable module - $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->langfiles = array("collab"); + // Dependancies + //------------- + $this->hidden = !empty($conf->global->MODULE_COLLAB_DISABLED); // A condition to disable module + $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->langfiles = array("collab"); - // Constants - //----------- - $this->const = array(); + // Constants + //----------- + $this->const = array(); - // New pages on tabs - // ----------------- - $this->tabs = array(); + // New pages on tabs + // ----------------- + $this->tabs = array(); - // Boxes - //------ - $this->boxes = array(); + // Boxes + //------ + $this->boxes = array(); - // Permissions - $this->rights = array(); // Permission array used by this module - $this->rights_class = 'collab'; - $r = 0; + // Permissions + $this->rights = array(); // Permission array used by this module + $this->rights_class = 'collab'; + $r = 0; - /*$this->rights[$r][0] = 30001; + /*$this->rights[$r][0] = 30001; $this->rights[$r][1] = 'Read website content'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read'; @@ -107,21 +107,21 @@ $this->rights[$r][4] = 'delete'; $r++;*/ - // Main menu entries - $r = 0; - $this->menu[$r] = array( + // Main menu entries + $r = 0; + $this->menu[$r] = array( 'fk_menu'=>'0', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'top', // This is a Left menu entry - 'titre'=>'Collab', - 'mainmenu'=>'collab', - 'url'=>'/collab/index.php', - 'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>100, - 'enabled'=>'$conf->collab->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2 // 0=Menu for internal users, 1=external users, 2=both - ); - $r++; - } + 'type'=>'top', // This is a Left menu entry + 'titre'=>'Collab', + 'mainmenu'=>'collab', + 'url'=>'/collab/index.php', + 'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>100, + 'enabled'=>'$conf->collab->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2 // 0=Menu for internal users, 1=external users, 2=both + ); + $r++; + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modCommande.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modCommande.class.php @@ -6,7 +6,6 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Juanjo Menent - * Copyright (C) 2020 Ahmad Jamaly Rabub * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -145,7 +144,7 @@ $this->rights[$r][2] = 'd'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'order_advance'; - $this->rights[$r][5] = 'send'; + $this->rights[$r][5] = 'send'; $r++; $this->rights[$r][0] = 87; @@ -205,11 +204,11 @@ ); if (!empty($conf->multicurrency->enabled)) { - $this->export_fields_array[$r]['c.multicurrency_code'] = 'Currency'; - $this->export_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate'; - $this->export_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; - $this->export_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; - $this->export_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; + $this->export_fields_array[$r]['c.multicurrency_code'] = 'Currency'; + $this->export_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate'; + $this->export_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; + $this->export_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; + $this->export_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; } //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label', @@ -263,162 +262,6 @@ $this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande'; $this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('commande').')'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id); - - // Imports - //-------- - $r = 0; - //Import Order Header - - $r++; - $this->import_code[$r] = 'commande_'.$r; - $this->import_label[$r] = 'CustomersOrders'; - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = []; - $this->import_tables_array[$r] = ['c' => MAIN_DB_PREFIX.'commande', 'extra' => MAIN_DB_PREFIX.'commande_extrafields']; - $this->import_tables_creator_array[$r] = ['c' => 'fk_user_author']; // Fields to store import user id - $this->import_fields_array[$r] = [ - 'c.ref' => 'Document Ref*', - 'c.ref_client' => 'RefCustomer', - 'c.fk_soc' => 'ThirdPartyName*', - 'c.fk_projet' => 'ProjectId', - 'c.date_creation' => 'DateCreation', - 'c.date_valid' => 'DateValid', - 'c.date_commande' => 'DateOrder', - 'c.fk_user_modif' => 'ModifiedById', - 'c.fk_user_valid' => 'ValidatedById', - 'c.fk_statut' => 'Status*', - 'c.remise_percent' => 'GlobalDiscount', - 'c.tva' => 'TotalTVA', - 'c.total_ht' => 'TotalHT', - 'c.total_ttc' => 'TotalTTC', - 'c.note_private' => 'NotePrivate', - 'c.note_public' => 'Note', - 'c.facture' => 'Invoice(1/0)', - 'c.date_livraison' => 'DeliveryDate', - 'c.fk_cond_reglement' => 'Payment Condition', - 'c.fk_mode_reglement' => 'Payment Mode', - 'c.model_pdf' => 'Model' - ]; - - if (!empty($conf->multicurrency->enabled)) { - $this->import_fields_array[$r]['c.multicurrency_code'] = 'Currency'; - $this->import_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate'; - $this->import_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; - $this->import_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; - $this->import_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; - } - - // Add extra fields - $import_extrafield_sample = []; - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande' AND entity IN (0, ".$conf->entity.")"; - $resql = $this->db->query($sql); - - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - $import_extrafield_sample[$fieldname] = $fieldlabel; - } - } - // End add extra fields - - $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande']; - $this->import_regex_array[$r] = [ - 'c.ref' => '(CPV\d{4}-\d{4}|CO\d{4}-\d{4}|PROV.{1,32}$)', - 'c.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency' - ]; - - $this->import_updatekeys_array[$r] = ['c.ref' => 'Ref']; - $this->import_convertvalue_array[$r] = [ - 'c.fk_soc' => [ - 'rule' => 'fetchidfromref', - 'file' => '/societe/class/societe.class.php', - 'class' => 'Societe', - 'method' => 'fetch', - 'element' => 'ThirdParty' - ], - 'c.fk_user_valid' => [ - 'rule' => 'fetchidfromref', - 'file' => '/user/class/user.class.php', - 'class' => 'User', - 'method' => 'fetch', - 'element' => 'user' - ], - 'c.fk_mode_reglement' => [ - 'rule' => 'fetchidfromcodeorlabel', - 'file' => '/compta/paiement/class/cpaiement.class.php', - 'class' => 'Cpaiement', - 'method' => 'fetch', - 'element' => 'cpayment' - ], - ]; - - //Import CPV Lines - $r++; - $this->import_code[$r] = 'commande_lines_'.$r; - $this->import_label[$r] = 'OrderLine'; - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = []; - $this->import_tables_array[$r] = ['cd' => MAIN_DB_PREFIX.'commandedet', 'extra' => MAIN_DB_PREFIX.'commandedet_extrafields']; - $this->import_fields_array[$r] = [ - 'cd.fk_commande' => 'Document Ref*', - 'cd.fk_parent_line' => 'PrParentLine', - 'cd.fk_product' => 'IdProduct', - 'cd.label' => 'Label', - 'cd.description' => 'LineDescription', - 'cd.tva_tx' => 'LineVATRate', - 'cd.qty' => 'LineQty', - 'cd.remise_percent' => 'Reduc. Percent', - 'cd.remise' => 'Reduc.', - 'cd.price' => 'Price', - 'cd.subprice' => 'Sub Price', - 'cd.total_ht' => 'LineTotalHT', - 'cd.total_tva' => 'LineTotalVAT', - 'cd.total_ttc' => 'LineTotalTTC', - 'cd.product_type' => 'TypeOfLineServiceOrProduct', - 'cd.date_start' => 'Start Date', - 'cd.date_end' => 'End Date', - 'cd.buy_price_ht' => 'LineBuyPriceHT', - 'cd.rang' => 'LinePosition' - ]; - - if (!empty($conf->multicurrency->enabled)) { - $this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency'; - $this->import_fields_array[$r]['cd.multicurrency_subprice'] = 'CurrencyRate'; - $this->import_fields_array[$r]['cd.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; - $this->import_fields_array[$r]['cd.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; - $this->import_fields_array[$r]['cd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; - } - - // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commandedet' AND entity IN (0, ".$conf->entity.")"; - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - } - } - // End add extra fields - - $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commandedet']; - $this->import_regex_array[$r] = [ - 'cd.product_type' => '[0|1]$', - 'cd.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product', - 'cd.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency' - ]; - $this->import_updatekeys_array[$r] = ['cd.fk_commande' => 'Sales Order Id', 'cd.fk_product' => 'Product Id']; - $this->import_convertvalue_array[$r] = [ - 'cd.fk_commande' => [ - 'rule' => 'fetchidfromref', - 'file' => '/commande/class/commande.class.php', - 'class' => 'Commande', - 'method' => 'fetch', - 'element' => 'commande' - ], - ]; } @@ -427,7 +270,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modComptabilite.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modComptabilite.class.php @@ -35,11 +35,11 @@ class modComptabilite extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ public function __construct($db) { global $conf; @@ -57,7 +57,7 @@ $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->picto = 'accounting'; + $this->picto = 'accounting'; // Config pages $this->config_page_url = array("compta.php"); @@ -72,12 +72,12 @@ $this->const = array(); // Data directories to create when module is enabled - $this->dirs = array( - "/comptabilite/temp", - "/comptabilite/rapport", - "/comptabilite/export", - "/comptabilite/bordereau" - ); + $this->dirs = array( + "/comptabilite/temp", + "/comptabilite/rapport", + "/comptabilite/export", + "/comptabilite/bordereau" + ); // Boxes $this->boxes = array(); @@ -102,16 +102,16 @@ } - /** - * Function called when module is enabled. + /** + * Function called when module is enabled. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { global $conf; // Nettoyage avant activation --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modContrat.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modContrat.class.php @@ -215,7 +215,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') @@ -232,20 +232,20 @@ if (file_exists($src) && !file_exists($dest)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_mkdir($dirodt); - $result = dol_copy($src, $dest, 0, 0); - if ($result < 0) - { - $langs->load("errors"); - $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); - return 0; - } + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result = dol_copy($src, $dest, 0, 0); + if ($result < 0) + { + $langs->load("errors"); + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); + return 0; + } } $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'contract' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','contract',".$conf->entity.")" + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'contract' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','contract',".$conf->entity.")" ); return $this->_init($sql, $options); --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modCron.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modCron.class.php @@ -32,37 +32,37 @@ class modCron extends DolibarrModules { - /** + /** * Constructor. Define names, constants, directories, boxes, permissions * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs, $conf; + */ + public function __construct($db) + { + global $langs, $conf; - $this->db = $db; - $this->numero = 2300; + $this->db = $db; + $this->numero = 2300; // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "base"; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "Enable the Dolibarr cron service"; + $this->family = "base"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "Enable the Dolibarr cron service"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - $this->picto = 'technic'; + $this->version = 'dolibarr'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + $this->picto = 'technic'; - // Data directories to create when module is enabled - $this->dirs = array(); + // Data directories to create when module is enabled + $this->dirs = array(); - // Config pages - //------------- - $this->config_page_url = array("cron.php@cron"); + // Config pages + //------------- + $this->config_page_url = array("cron.php@cron"); // Dependancies //------------- @@ -85,24 +85,22 @@ 0 ),); - // New pages on tabs - // ----------------- - $this->tabs = array(); + // New pages on tabs + // ----------------- + $this->tabs = array(); - // Boxes - //------ - $this->boxes = array( - 0 => array('file' => 'box_scheduled_jobs.php', 'enabledbydefaulton' => 'Home') - ); + // Boxes + //------ + $this->boxes = array(); // Cronjobs $this->cronjobs = array( 0=>array('entity'=>0, 'label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true), - 1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>in_array($this->db->type, array('mysql', 'mysqli'))), + 1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>in_array($db->type, array('mysql', 'mysqli'))), // 1=>array('entity'=>0, 'label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24) ); - // Permissions + // Permissions $this->rights = array(); // Permission array used by this module $this->rights_class = 'cron'; $r = 0; @@ -131,18 +129,18 @@ $this->rights[$r][4] = 'execute'; $r++; - // Main menu entries - $r = 0; - $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'CronList', - 'url'=>'/cron/list.php?leftmenu=admintools', - 'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>200, - 'enabled'=>'$conf->cron->enabled && preg_match(\'/^(admintools|all)/\', $leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - $r++; - } + // Main menu entries + $r = 0; + $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'CronList', + 'url'=>'/cron/list.php?leftmenu=admintools', + 'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>200, + 'enabled'=>'$conf->cron->enabled && preg_match(\'/^(admintools|all)/\', $leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + $r++; + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modDataPolicy.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modDataPolicy.class.php @@ -37,187 +37,187 @@ */ class modDataPolicy extends DolibarrModules { - // @codingStandardsIgnoreEnd - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs, $conf; - - $this->db = $db; - - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 4100; - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'datapolicy'; - - // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' - // It is used to group modules by family in module setup page - $this->family = "technic"; - // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '78'; - // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) - //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); - // Module label (no space allowed), used if translation string 'ModuledatapolicyName' not found (MyModue is name of module). - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuledatapolicyDesc' not found (MyModue is name of module). - $this->description = "Module to manage Data policy (for compliance with GDPR in Europe or other Data policy rules)"; - // Used only if file README.md and README-LL.md not found. - $this->descriptionlong = ""; - - // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = 'experimental'; - // Key used in llx_const table to save module status enabled/disabled (where datapolicy is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto = 'generic'; - - // Defined all module parts (triggers, login, substitutions, menus, css, etc...) - // for default path (eg: /datapolicy/core/xxxxx) (0=disable, 1=enable) - // for specific path of parts (eg: /datapolicy/core/modules/barcode) - // for specific css file (eg: /datapolicy/css/datapolicy.css.php) - $this->module_parts = array( - 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) - 'login' => 0, // Set this to 1 if module has its own login method file (core/login) - 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) - 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) - 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) - 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) - 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) - 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - 'hooks' => array('data' => array('membercard', 'contactcard', 'thirdpartycard'), 'entity' => $conf->entity) // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' - ); - - // Data directories to create when module is enabled. - // Example: this->dirs = array("/datapolicy/temp","/datapolicy/subdir"); - $this->dirs = array("/datapolicy/temp"); - - // Config pages. Put here list of php page, stored into datapolicy/admin directory, to use to setup module. - $this->config_page_url = array("setup.php@datapolicy"); - - // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array('always'=>'modCron'); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array(); // List of module ids to disable if this one is disabled - $this->conflictwith = array(); // List of module class names as string this module is in conflict with - $this->langfiles = array("datapolicy@datapolicy"); - $this->phpmin = array(5, 3); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(4, 0); // Minimum version of Dolibarr required by module - $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - //$this->automatic_activation = array('FR'=>'datapolicyWasAutomaticallyActivatedBecauseOfYourCountryChoice'); - //$this->always_enabled = true; // If true, can't be disabled - // Constants - // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) - // Example: $this->const=array(0=>array('datapolicy_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), - // 1=>array('datapolicy_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) - // ); - $this->const = array( - array('DATAPOLICY_TIERS_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), - array('DATAPOLICY_TIERS_PROSPECT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), - array('DATAPOLICY_TIERS_PROSPECT_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), - array('DATAPOLICY_TIERS_NIPROSPECT_NICLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), - array('DATAPOLICY_TIERS_FOURNISSEUR', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), - array('DATAPOLICY_CONTACT_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), - array('DATAPOLICY_CONTACT_PROSPECT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), - array('DATAPOLICY_CONTACT_PROSPECT_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), - array('DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), - array('DATAPOLICY_CONTACT_FOURNISSEUR', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), - array('DATAPOLICY_ADHERENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), - ); - - $country = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); - - // Some keys to add into the overwriting translation tables - /* $this->overwrite_translation = array( + // @codingStandardsIgnoreEnd + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs, $conf; + + $this->db = $db; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 4100; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'datapolicy'; + + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' + // It is used to group modules by family in module setup page + $this->family = "technic"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '78'; + // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); + // Module label (no space allowed), used if translation string 'ModuledatapolicyName' not found (MyModue is name of module). + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuledatapolicyDesc' not found (MyModue is name of module). + $this->description = "Module to manage Data policy (for compliance with GDPR in Europe or other Data policy rules)"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = ""; + + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = 'experimental'; + // Key used in llx_const table to save module status enabled/disabled (where datapolicy is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto = 'generic'; + + // Defined all module parts (triggers, login, substitutions, menus, css, etc...) + // for default path (eg: /datapolicy/core/xxxxx) (0=disable, 1=enable) + // for specific path of parts (eg: /datapolicy/core/modules/barcode) + // for specific css file (eg: /datapolicy/css/datapolicy.css.php) + $this->module_parts = array( + 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) + 'login' => 0, // Set this to 1 if module has its own login method file (core/login) + 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) + 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) + 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) + 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) + 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) + 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) + 'hooks' => array('data' => array('membercard', 'contactcard', 'thirdpartycard'), 'entity' => $conf->entity) // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' + ); + + // Data directories to create when module is enabled. + // Example: this->dirs = array("/datapolicy/temp","/datapolicy/subdir"); + $this->dirs = array("/datapolicy/temp"); + + // Config pages. Put here list of php page, stored into datapolicy/admin directory, to use to setup module. + $this->config_page_url = array("setup.php@datapolicy"); + + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array('always'=>'modCron'); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->langfiles = array("datapolicy@datapolicy"); + $this->phpmin = array(5, 3); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(4, 0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + //$this->automatic_activation = array('FR'=>'datapolicyWasAutomaticallyActivatedBecauseOfYourCountryChoice'); + //$this->always_enabled = true; // If true, can't be disabled + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(0=>array('datapolicy_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), + // 1=>array('datapolicy_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) + // ); + $this->const = array( + array('DATAPOLICY_TIERS_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), + array('DATAPOLICY_TIERS_PROSPECT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), + array('DATAPOLICY_TIERS_PROSPECT_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), + array('DATAPOLICY_TIERS_NIPROSPECT_NICLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), + array('DATAPOLICY_TIERS_FOURNISSEUR', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), + array('DATAPOLICY_CONTACT_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), + array('DATAPOLICY_CONTACT_PROSPECT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), + array('DATAPOLICY_CONTACT_PROSPECT_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), + array('DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), + array('DATAPOLICY_CONTACT_FOURNISSEUR', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), + array('DATAPOLICY_ADHERENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0), + ); + + $country = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); + + // Some keys to add into the overwriting translation tables + /* $this->overwrite_translation = array( 'en_US:ParentCompany'=>'Parent company or reseller', 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' ) */ - if (!isset($conf->datapolicy) || !isset($conf->datapolicy->enabled)) { - $conf->datapolicy = new stdClass(); - $conf->datapolicy->enabled = 0; - } - - - // Array to add new pages in new tabs - $this->tabs = array(); - // Example: - // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@datapolicy:$user->rights->datapolicy->read:/datapolicy/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 - // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@datapolicy:$user->rights->othermodule->read:/datapolicy/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. - // $this->tabs[] = array('data'=>'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) - // 'contact' to add a tab in contact view - // 'contract' to add a tab in contract view - // 'group' to add a tab in group view - // 'intervention' to add a tab in intervention view - // 'invoice' to add a tab in customer invoice view - // 'invoice_supplier' to add a tab in supplier invoice view - // 'member' to add a tab in fundation member view - // 'opensurveypoll' to add a tab in opensurvey poll view - // 'order' to add a tab in customer order view - // 'order_supplier' to add a tab in supplier order view - // 'payment' to add a tab in payment view - // 'payment_supplier' to add a tab in supplier payment view - // 'product' to add a tab in product view - // 'propal' to add a tab in propal view - // 'project' to add a tab in project view - // 'stock' to add a tab in stock view - // 'thirdparty' to add a tab in third party view - // 'user' to add a tab in user view - - - // Dictionaries - $this->dictionaries = array(); - - - // Boxes/Widgets - // Add here list of php file(s) stored in datapolicy/core/boxes that contains class to show a widget. - $this->boxes = array(); - - - // Cronjobs (List of cron jobs entries to add when module is enabled) - // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week - $this->cronjobs = array( - 0 => array('label' => 'DATAPOLICYJob', 'jobtype' => 'method', 'class' => 'datapolicy/class/datapolicycron.class.php', 'objectname' => 'DataPolicyCron', 'method' => 'cleanDataForDataPolicy', 'parameters' => '', 'comment' => 'Clean data', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => '$conf->datapolicy->enabled'), - ); - // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true) - // ); - // Permissions - $this->rights = array(); // Permission array used by this module - // Main menu entries - $this->menu = array(); // List of menus to add - $r = 0; - } - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - global $langs; - - $this->_load_tables('/datapolicy/sql/'); - - // Create extrafields - include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); - - /* + if (!isset($conf->datapolicy) || !isset($conf->datapolicy->enabled)) { + $conf->datapolicy = new stdClass(); + $conf->datapolicy->enabled = 0; + } + + + // Array to add new pages in new tabs + $this->tabs = array(); + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@datapolicy:$user->rights->datapolicy->read:/datapolicy/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@datapolicy:$user->rights->othermodule->read:/datapolicy/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'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) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view + + + // Dictionaries + $this->dictionaries = array(); + + + // Boxes/Widgets + // Add here list of php file(s) stored in datapolicy/core/boxes that contains class to show a widget. + $this->boxes = array(); + + + // Cronjobs (List of cron jobs entries to add when module is enabled) + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week + $this->cronjobs = array( + 0 => array('label' => 'DATAPOLICYJob', 'jobtype' => 'method', 'class' => 'datapolicy/class/datapolicycron.class.php', 'objectname' => 'DataPolicyCron', 'method' => 'cleanDataForDataPolicy', 'parameters' => '', 'comment' => 'Clean data', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => '$conf->datapolicy->enabled'), + ); + // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true) + // ); + // Permissions + $this->rights = array(); // Permission array used by this module + // Main menu entries + $this->menu = array(); // List of menus to add + $r = 0; + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $langs; + + $this->_load_tables('/datapolicy/sql/'); + + // Create extrafields + include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + + /* // Extrafield contact $result1 = $extrafields->addExtraField('datapolicy_consentement', $langs->trans("DATAPOLICY_consentement"), 'boolean', 101, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); $result1 = $extrafields->addExtraField('datapolicy_opposition_traitement', $langs->trans("DATAPOLICY_opposition_traitement"), 'boolean', 102, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); @@ -240,23 +240,23 @@ $result1 = $extrafields->addExtraField('datapolicy_send', $langs->trans("DATAPOLICY_send"), 'date', 105, 3, 'adherent', 0, 0, '', '', 0, '', '0', 0); */ - $sql = array(); - - return $this->_init($sql, $options); - } - - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function remove($options = '') - { - $sql = array(); - - return $this->_remove($sql, $options); - } + $sql = array(); + + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + $sql = array(); + + return $this->_remove($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modDebugBar.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modDebugBar.class.php @@ -32,77 +32,77 @@ class modDebugBar extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - $this->numero = 43; + $this->numero = 43; - $this->rights_class = 'debugbar'; + $this->rights_class = 'debugbar'; - $this->family = "base"; - $this->module_position = '75'; + $this->family = "base"; + $this->module_position = '75'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "A tool for developper adding a debug bar in your browser."; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->picto = 'bug'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "A tool for developper adding a debug bar in your browser."; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + $this->picto = 'bug'; - $this->module_parts = array('moduleforexternal' => 0); + $this->module_parts = array('moduleforexternal' => 0); - // Data directories to create when module is enabled - $this->dirs = array(); + // Data directories to create when module is enabled + $this->dirs = array(); - // Dependencies - $this->depends = array(); // May be used for product or service or third party module - $this->requiredby = array(); + // Dependencies + $this->depends = array(); // May be used for product or service or third party module + $this->requiredby = array(); - // Config pages - $this->config_page_url = array("debugbar.php"); + // Config pages + $this->config_page_url = array("debugbar.php"); - // Constants - // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), - // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); - $this->const = array(); + // Constants + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); + $this->const = array(); - // Boxes - $this->boxes = array(); + // Boxes + $this->boxes = array(); - // Permissions - $this->rights = array(); + // Permissions + $this->rights = array(); - $this->rights[1][0] = 430; // id de la permission - $this->rights[1][1] = 'Use Debug Bar'; // libelle de la permission - $this->rights[1][2] = 'u'; // type de la permission (deprecie a ce jour) - $this->rights[1][3] = 1; // La permission est-elle une permission par defaut - $this->rights[1][4] = 'read'; - } + $this->rights[1][0] = 430; // id de la permission + $this->rights[1][1] = 'Use Debug Bar'; // libelle de la permission + $this->rights[1][2] = 'u'; // type de la permission (deprecie a ce jour) + $this->rights[1][3] = 1; // La permission est-elle une permission par defaut + $this->rights[1][4] = 'read'; + } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories. - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - // Permissions - $this->remove($options); + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories. + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + // Permissions + $this->remove($options); - $sql = array( - ); + $sql = array( + ); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modDeplacement.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modDeplacement.class.php @@ -45,7 +45,7 @@ $this->numero = 75; $this->family = "hr"; - $this->module_position = '43'; + $this->module_position = '41'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Gestion des notes de frais et deplacements"; // Si traduction Module75Desc non trouvee @@ -89,13 +89,13 @@ $this->rights[2][3] = 0; $this->rights[2][4] = 'creer'; - $this->rights[3][0] = 173; + $this->rights[3][0] = 173; $this->rights[3][1] = 'Supprimer les notes de frais et deplacements'; $this->rights[3][2] = 'd'; $this->rights[3][3] = 0; $this->rights[3][4] = 'supprimer'; - $this->rights[4][0] = 174; + $this->rights[4][0] = 174; $this->rights[4][1] = 'Lire toutes les notes de frais'; $this->rights[4][2] = 'd'; $this->rights[4][3] = 0; @@ -120,10 +120,10 @@ $this->export_code[$r] = 'trips_'.$r; $this->export_label[$r] = 'ListTripsAndExpenses'; $this->export_permission[$r] = array(array("deplacement", "export")); - $this->export_fields_array[$r] = array('u.login'=>'Login', 'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'd.rowid'=>"TripId", 'd.type'=>"Type", 'd.km'=>"FeesKilometersOrAmout", 'd.dated'=>"Date", 'd.note_private'=>'NotePrivate', 'd.note_public'=>'NotePublic', 's.nom'=>'ThirdParty'); - $this->export_TypeFields_array[$r] = array('u.rowid'=>'List:user:name', 'u.login'=>'Text', 'u.lastname'=>'Text', 'u.firstname'=>'Text', 'd.type'=>"Text", 'd.km'=>"Numeric", 'd.dated'=>"Date", 'd.note_private'=>'Text', 'd.note_public'=>'Text', 's.rowid'=>"List:societe:CompanyName", 's.nom'=>'Text'); - $this->export_entities_array[$r] = array('u.login'=>'user', 'u.lastname'=>'user', 'u.firstname'=>'user', 'd.rowid'=>"trip", 'd.type'=>"trip", 'd.km'=>"trip", 'd.dated'=>"trip", 'd.note_private'=>'trip', 'd.note_public'=>'trip', 's.nom'=>'company'); - $this->export_dependencies_array[$r] = array('trip'=>'d.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them + $this->export_fields_array[$r] = array('u.login'=>'Login', 'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'd.rowid'=>"TripId", 'd.type'=>"Type", 'd.km'=>"FeesKilometersOrAmout", 'd.dated'=>"Date", 'd.note_private'=>'NotePrivate', 'd.note_public'=>'NotePublic', 's.nom'=>'ThirdParty'); + $this->export_TypeFields_array[$r] = array('u.rowid'=>'List:user:name', 'u.login'=>'Text', 'u.lastname'=>'Text', 'u.firstname'=>'Text', 'd.type'=>"Text", 'd.km'=>"Numeric", 'd.dated'=>"Date", 'd.note_private'=>'Text', 'd.note_public'=>'Text', 's.rowid'=>"List:societe:CompanyName", 's.nom'=>'Text'); + $this->export_entities_array[$r] = array('u.login'=>'user', 'u.lastname'=>'user', 'u.firstname'=>'user', 'd.rowid'=>"trip", 'd.type'=>"trip", 'd.km'=>"trip", 'd.dated'=>"trip", 'd.note_private'=>'trip', 'd.note_public'=>'trip', 's.nom'=>'company'); + $this->export_dependencies_array[$r] = array('trip'=>'d.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'user as u'; @@ -136,10 +136,10 @@ if (!empty($user)) // Not defined during migration process { - $childids = $user->getAllChildIds(); - $childids[] = $user->id; + $childids = $user->getAllChildIds(); + $childids[] = $user->id; - if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $this->export_sql_end[$r] .= ' AND d.fk_user IN ('.join(',', $childids).')'; + if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $this->export_sql_end[$r] .= ' AND d.fk_user IN ('.join(',', $childids).')'; } } @@ -149,7 +149,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modDocumentGeneration.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modDocumentGeneration.class.php @@ -100,11 +100,11 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { global $conf; // Permissions --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modDon.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modDon.class.php @@ -148,7 +148,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modDynamicPrices.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modDynamicPrices.class.php @@ -31,57 +31,57 @@ class modDynamicPrices extends DolibarrModules { - /** + /** * Constructor. Define names, constants, directories, boxes, permissions * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - $this->numero = 2200; + */ + public function __construct($db) + { + $this->db = $db; + $this->numero = 2200; - $this->family = "products"; - $this->module_position = '85'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "Enable the usage of math expressions for prices"; + $this->family = "products"; + $this->module_position = '85'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "Enable the usage of math expressions for prices"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'experimental'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - $this->picto = 'dynamicprice'; + $this->version = 'experimental'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + $this->picto = 'dynamicprice'; - // Data directories to create when module is enabled - $this->dirs = array(); + // Data directories to create when module is enabled + $this->dirs = array(); - // Config pages - //------------- + // Config pages + //------------- $this->config_page_url = array("dynamic_prices.php@product"); - // Dependancies - //------------- - $this->depends = array(); - $this->requiredby = array(); - $this->langfiles = array("other"); + // Dependancies + //------------- + $this->depends = array(); + $this->requiredby = array(); + $this->langfiles = array("other"); - // Constants - //----------- - $this->const = array(); + // Constants + //----------- + $this->const = array(); - // New pages on tabs - // ----------------- - $this->tabs = array(); + // New pages on tabs + // ----------------- + $this->tabs = array(); - // Boxes - //------ - $this->boxes = array(); + // Boxes + //------ + $this->boxes = array(); - // Permissions - //------------ - $this->rights = array(); - $this->rights_class = 'dynamicprices'; - $r = 0; - } + // Permissions + //------------ + $this->rights = array(); + $this->rights_class = 'dynamicprices'; + $r = 0; + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modECM.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modECM.class.php @@ -32,12 +32,12 @@ class modECM extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) { $this->db = $db; @@ -86,10 +86,10 @@ // Add here list of php file(s) stored in core/boxes that contains class to show a box. // Example: - //$this->boxes[$r][1] = "myboxa.php"; - //$r++; - //$this->boxes[$r][1] = "myboxb.php"; - //$r++; + //$this->boxes[$r][1] = "myboxa.php"; + //$r++; + //$this->boxes[$r][1] = "myboxb.php"; + //$r++; // Permissions $this->rights_class = 'ecm'; // Permission key @@ -117,7 +117,7 @@ $this->rights[$r][4] = 'setup'; - // Menus + // Menus //------ $this->menus = array(); // List of menus to add $r = 0; --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modEmailCollector.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modEmailCollector.class.php @@ -38,9 +38,9 @@ */ public function __construct($db) { - global $langs, $conf; - - $this->db = $db; + global $langs, $conf; + + $this->db = $db; // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). @@ -52,7 +52,7 @@ // It is used to group modules by family in module setup page $this->family = "interface"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '23'; + $this->module_position = '12'; // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); @@ -116,13 +116,13 @@ // Array to add new pages in new tabs - $this->tabs = array(); + $this->tabs = array(); // Example: // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@dav:$user->rights->dav->read:/dav/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 - // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@dav:$user->rights->othermodule->read:/dav/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. - // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname - // - // Where objecttype can be + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@dav:$user->rights->othermodule->read:/dav/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'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) // 'contact' to add a tab in contact view // 'contract' to add a tab in contract view @@ -144,9 +144,9 @@ // 'user' to add a tab in user view - // Dictionaries + // Dictionaries $this->dictionaries = array(); - /* Example: + /* Example: $this->dictionaries=array( 'langs'=>'mylangfile@dav', 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor @@ -162,13 +162,13 @@ */ - // Boxes/Widgets + // Boxes/Widgets // Add here list of php file(s) stored in dav/core/boxes that contains class to show a widget. - $this->boxes = array( - //0=>array('file'=>'davwidget1.php@dav','note'=>'Widget provided by dav','enabledbydefaulton'=>'Home'), - //1=>array('file'=>'davwidget2.php@dav','note'=>'Widget provided by dav'), - //2=>array('file'=>'davwidget3.php@dav','note'=>'Widget provided by dav') - ); + $this->boxes = array( + //0=>array('file'=>'davwidget1.php@dav','note'=>'Widget provided by dav','enabledbydefaulton'=>'Home'), + //1=>array('file'=>'davwidget2.php@dav','note'=>'Widget provided by dav'), + //2=>array('file'=>'davwidget3.php@dav','note'=>'Widget provided by dav') + ); // Cronjobs (List of cron jobs entries to add when module is enabled) @@ -259,7 +259,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') @@ -278,70 +278,38 @@ $sql = array(); - $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity; + $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity; $tmpresql = $this->db->query($tmpsql); if ($tmpresql) { if ($this->db->num_rows($tmpresql) == 0) { $descriptionA1 = 'This collector will scan your mailbox to find emails that match some rules and create automatically a ticket (Module Ticket must be enabled) with the email informations. You can use this collector if you provide some support by email, so your ticket request will be automatically generated.'; $descriptionA1 .= ' If the collector Collect_Responses is also enabled, when you send an email from the ticket, you may also see answers of your customers or partners directly on the ticket view.'; - $sqlforexampleA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)"; $sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Ticket_Requets', 'Example to collect ticket requests', '".$this->db->escape($descriptionA1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)"; - - $sqlforexampleFilterA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'isnotanswer', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - $sqlforexampleFilterA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - $sqlforexampleFilterA3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterA3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'to', 'support@example.com', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - + $sqlforexampleA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; + $sqlforexampleA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; + $sqlforexampleA3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)"; + $sqlforexampleA3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'to', 'support@example.com', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; $sqlforexampleA4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)"; $sqlforexampleA4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'ticket', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - $sql[] = $sqlforexampleA1; - $sql[] = $sqlforexampleFilterA1; - $sql[] = $sqlforexampleFilterA2; - $sql[] = $sqlforexampleFilterA3; + $sql[] = $sqlforexampleA2; + $sql[] = $sqlforexampleA3; $sql[] = $sqlforexampleA4; } } else dol_print_error($this->db); - $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".$conf->entity; + $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses' and entity = ".$conf->entity; $tmpresql = $this->db->query($tmpsql); if ($tmpresql) { if ($this->db->num_rows($tmpresql) == 0) { - $descriptionA1 = 'This collector will scan your mailbox "Sent" directory to find emails that was sent as an answer of another email directly from your email software and not from Dolibarr. If such an email is found, the event of answer is recorded into Dolibarr.'; - - $sqlforexampleA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)"; - $sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Responses_Out', 'Example to collect answers to emails done from your external email software', '".$this->db->escape($descriptionA1)."', 'Sent', '".$this->db->idate(dol_now())."', ".$user->id.", 0)"; - - $sqlforexampleFilterA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".$conf->entity."), 'isanswer', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - $sqlforexampleFilterA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".$conf->entity."), 'withouttrackingidinmsgid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - $sqlforexampleActionA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleActionA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".$conf->entity."), 'recordevent', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - - $sql[] = $sqlforexampleA1; - $sql[] = $sqlforexampleFilterA1; - $sql[] = $sqlforexampleFilterA2; - $sql[] = $sqlforexampleActionA1; - } - } - - $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_In' and entity = ".$conf->entity; - $tmpresql = $this->db->query($tmpsql); - if ($tmpresql) { - if ($this->db->num_rows($tmpresql) == 0) { - $descriptionB1 = 'This collector will scan your mailbox to find all emails that are an answer of an email sent from your application. An event (Module Agenda must be enabled) with the email response will be recorded at the good place. For example, if your send a commercial proposal, order, invoice or message for a ticket by email from the application, and your customer answers your email, the system will automatically catch the answer and add it into your ERP.'; - + $descriptionB1 = 'This collector will scan your mailbox to find all emails that are an answer of an email sent from your application. An event with the email response will be recorded at the good place (Module Agenda must be enabled). For example, if your send a commercial proposal, order or invoice by email and your customer answers your email, the system will automatically find the answer and add it into your ERP.'; $sqlforexampleB1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)"; - $sqlforexampleB1 .= " VALUES (".$conf->entity.", 'Collect_Responses_In', 'Example to collect any received email that is a response of an email sent from Dolibarr', '".$this->db->escape($descriptionB1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)"; + $sqlforexampleB1 .= " VALUES (".$conf->entity.", 'Collect_Responses', 'Example to collect any email responses', '".$this->db->escape($descriptionB1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)"; $sqlforexampleB2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleB2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_In' and entity = ".$conf->entity."), 'isanswer', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; + $sqlforexampleB2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses' and entity = ".$conf->entity."), 'withtrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; $sqlforexampleB3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleB3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_In' and entity = ".$conf->entity."), 'recordevent', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - + $sqlforexampleB3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses' and entity = ".$conf->entity."), 'recordevent', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; $sql[] = $sqlforexampleB1; $sql[] = $sqlforexampleB2; $sql[] = $sqlforexampleB3; @@ -355,52 +323,17 @@ $descriptionC1 = "This collector will scan your mailbox to find emails that match some rules and create automatically a lead (Module Project must be enabled) with the email informations. You can use this collector if you want to follow your lead using the module Project (1 lead = 1 project), so your leads will be automatically generated."; $descriptionC1 .= " If the collector Collect_Responses is also enabled, when you send an email from your leads, proposals or any other object, you may also see answers of your customers or partners directly on the application.
"; $descriptionC1 .= "Note: With this initial example, the title of the lead is generated including the email. If the thirdparty can't be found in database (new customer), the lead will be attached to the thirdparty with ID 1."; - $sqlforexampleC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)"; $sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Leads', 'Example to collect leads', '".$this->db->escape($descriptionC1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)"; - - $sqlforexampleFilterC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterC1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity."), 'isnotanswer', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - $sqlforexampleFilterC2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterC2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - $sqlforexampleFilterC3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterC3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity."), 'to', 'sales@example.com', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - + $sqlforexampleC2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; + $sqlforexampleC2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; + $sqlforexampleC3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)"; + $sqlforexampleC3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity."), 'to', 'sales@example.com', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; $sqlforexampleC4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, actionparam, date_creation, fk_user_creat, status)"; $sqlforexampleC4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity."), 'project', 'tmp_from=EXTRACT:HEADER:^From:(.*);socid=SETIFEMPTY:1;usage_opportunity=SET:1;description=EXTRACT:BODY:(.*);title=SET:Lead or message from __tmp_from__ received by email', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - $sql[] = $sqlforexampleC1; - $sql[] = $sqlforexampleFilterC1; - $sql[] = $sqlforexampleFilterC2; - $sql[] = $sqlforexampleFilterC3; - $sql[] = $sqlforexampleC4; - } - } else dol_print_error($this->db); - - $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".$conf->entity; - $tmpresql = $this->db->query($tmpsql); - if ($tmpresql) { - if ($this->db->num_rows($tmpresql) == 0) { - $descriptionC1 = "This collector will scan your mailbox to find emails send for a recruitment (Module Recruitment must be enabled). You can complete this collector if you want to automaticallycreate a candidature for a job request."; - $descriptionC1 .= "Note: With this initial example, the title of the candidature is generated including the email."; - - $sqlforexampleC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)"; - $sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Candidatures', 'Example to collect email for job candidatures', '".$this->db->escape($descriptionC1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)"; - - $sqlforexampleFilterC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterC1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".$conf->entity."), 'isnotanswer', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - $sqlforexampleFilterC2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterC2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - $sqlforexampleFilterC3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterC3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".$conf->entity."), 'to', 'jobs@example.com', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - - $sqlforexampleC4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, actionparam, date_creation, fk_user_creat, status)"; - $sqlforexampleC4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".$conf->entity."), 'candidature', 'tmp_from=EXTRACT:HEADER:^From:(.*)(<.*>)?;fk_recruitmentjobposition=EXTRACT:HEADER:^To:[^\n]*\+([^\n]*);description=EXTRACT:BODY:(.*);lastname=SET:__tmp_from__', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - - $sql[] = $sqlforexampleC1; - $sql[] = $sqlforexampleFilterC1; - $sql[] = $sqlforexampleFilterC2; - $sql[] = $sqlforexampleFilterC3; + $sql[] = $sqlforexampleC2; + $sql[] = $sqlforexampleC3; $sql[] = $sqlforexampleC4; } } else dol_print_error($this->db); --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modExpedition.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modExpedition.class.php @@ -62,12 +62,12 @@ // Data directories to create when module is enabled $this->dirs = array("/expedition/temp", "/expedition/sending", - "/expedition/sending/temp", - "/expedition/receipt", - "/expedition/receipt/temp", + "/expedition/sending/temp", + "/expedition/receipt", + "/expedition/receipt/temp", "/doctemplates/shipments", "/doctemplates/deliveries" - ); + ); // Config pages $this->config_page_url = array("confexped.php"); @@ -103,21 +103,21 @@ $this->const[$r][4] = 0; $r++; - $this->const[$r][0] = "DELIVERY_ADDON_PDF"; + $this->const[$r][0] = "LIVRAISON_ADDON_PDF"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "typhon"; $this->const[$r][3] = 'Nom du gestionnaire de generation des bons de reception en PDF'; $this->const[$r][4] = 0; $r++; - $this->const[$r][0] = "DELIVERY_ADDON_NUMBER"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "mod_delivery_jade"; + $this->const[$r][0] = "LIVRAISON_ADDON_NUMBER"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "mod_livraison_jade"; $this->const[$r][3] = 'Nom du gestionnaire de numerotation des bons de reception'; $this->const[$r][4] = 0; $r++; - $this->const[$r][0] = "DELIVERY_ADDON_PDF_ODT_PATH"; + $this->const[$r][0] = "LIVRAISON_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/deliveries"; $this->const[$r][3] = ""; @@ -169,7 +169,7 @@ $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'shipping_advance'; - $this->rights[$r][5] = 'send'; + $this->rights[$r][5] = 'send'; $r++; $this->rights[$r][0] = 106; @@ -191,7 +191,7 @@ $this->rights[$r][1] = 'Read delivery receipts'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'delivery'; + $this->rights[$r][4] = 'livraison'; $this->rights[$r][5] = 'lire'; $r++; @@ -199,7 +199,7 @@ $this->rights[$r][1] = 'Create/modify delivery receipts'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'delivery'; + $this->rights[$r][4] = 'livraison'; $this->rights[$r][5] = 'creer'; $r++; @@ -207,7 +207,7 @@ $this->rights[$r][1] = 'Validate delivery receipts'; $this->rights[$r][2] = 'd'; $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'delivery_advance'; + $this->rights[$r][4] = 'livraison_advance'; $this->rights[$r][5] = 'validate'; $r++; @@ -215,7 +215,7 @@ $this->rights[$r][1] = 'Delete delivery receipts'; $this->rights[$r][2] = 'd'; $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'delivery'; + $this->rights[$r][4] = 'livraison'; $this->rights[$r][5] = 'supprimer'; @@ -277,8 +277,8 @@ $this->export_dependencies_array[$r] = array('shipment_line'=>'ed.rowid', 'product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { - $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra3'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra3'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; } $keyforselect = 'expedition'; $keyforelement = 'shipment'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; @@ -291,7 +291,7 @@ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'expedition as c'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s'; - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; + if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'expeditiondet as ed'; @@ -300,13 +300,13 @@ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extraprod ON p.rowid = extraprod.fk_object'; if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; } $this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid'; $this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('expedition').')'; - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id); + if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; } @@ -315,7 +315,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modExpenseReport.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modExpenseReport.class.php @@ -180,35 +180,35 @@ $this->export_label[$r] = 'ListTripsAndExpenses'; $this->export_icon[$r] = 'trip'; $this->export_permission[$r] = array(array("expensereport", "export")); - $this->export_fields_array[$r] = array( + $this->export_fields_array[$r] = array( 'd.rowid'=>"TripId", 'd.ref'=>'Ref', 'd.date_debut'=>'DateStart', 'd.date_fin'=>'DateEnd', 'd.date_create'=>'DateCreation', 'd.date_approve'=>'DateApprove', 'd.total_ht'=>"TotalHT", 'd.total_tva'=>'TotalVAT', 'd.total_ttc'=>'TotalTTC', - 'd.fk_statut'=>'Status', 'd.paid'=>'Paid', - 'd.note_private'=>'NotePrivate', 'd.note_public'=>'NotePublic', 'd.detail_cancel'=>'MOTIF_CANCEL', 'd.detail_refuse'=>'MOTIF_REFUS', + 'd.fk_statut'=>'Status', 'd.paid'=>'Paid', + 'd.note_private'=>'NotePrivate', 'd.note_public'=>'NotePublic', 'd.detail_cancel'=>'MOTIF_CANCEL', 'd.detail_refuse'=>'MOTIF_REFUS', 'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'u.login'=>"Login", 'ed.rowid'=>'LineId', 'tf.code'=>'Type', 'ed.date'=>'Date', 'ed.tva_tx'=>'VATRate', 'ed.total_ht'=>'TotalHT', 'ed.total_tva'=>'TotalVAT', 'ed.total_ttc'=>'TotalTTC', 'ed.comments'=>'Comment', 'p.rowid'=>'ProjectId', 'p.ref'=>'Ref', - 'user_rib.iban_prefix' => 'IBAN', 'user_rib.bic' => 'BIC', 'user_rib.code_banque' => 'BankCode', 'user_rib.bank' => 'BankName', 'user_rib.proprio' => 'BankAccountOwner', - 'user_rib.owner_address' => 'BankAccountOwnerAddress' + 'user_rib.iban_prefix' => 'IBAN', 'user_rib.bic' => 'BIC', 'user_rib.code_banque' => 'BankCode', 'user_rib.bank' => 'BankName', 'user_rib.proprio' => 'BankAccountOwner', + 'user_rib.owner_address' => 'BankAccountOwnerAddress' ); - $this->export_TypeFields_array[$r] = array( - 'd.rowid'=>"Numeric", 'd.ref'=>'Text', 'd.date_debut'=>'Date', 'd.date_fin'=>'Date', 'd.date_create'=>'Date', 'd.date_approve'=>'Date', - 'd.total_ht'=>"Numeric", 'd.total_tva'=>'Numeric', 'd.total_ttc'=>'Numeric', - 'd.fk_statut'=>"Numeric", 'd.paid'=>'Numeric', - 'd.note_private'=>'Text', 'd.note_public'=>'Text', 'd.detail_cancel'=>'Text', 'd.detail_refuse'=>'Text', - 'u.lastname'=>'Text', 'u.firstname'=>'Text', 'u.login'=>"Text", 'ed.rowid'=>'Numeric', 'tf.code'=>'Code', 'ed.date'=>'Date', 'ed.tva_tx'=>'Numeric', - 'ed.total_ht'=>'Numeric', 'ed.total_tva'=>'Numeric', 'ed.total_ttc'=>'Numeric', 'ed.comments'=>'Text', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', - 'user_rib.iban_prefix' => 'Text', 'user_rib.bic' => 'Text', 'user_rib.code_banque' => 'Text', 'user_rib.bank' => 'Text', 'user_rib.proprio' => 'Text', - 'user_rib.owner_address' => 'Text' - ); - $this->export_entities_array[$r] = array( + $this->export_TypeFields_array[$r] = array( + 'd.rowid'=>"Numeric", 'd.ref'=>'Text', 'd.date_debut'=>'Date', 'd.date_fin'=>'Date', 'd.date_create'=>'Date', 'd.date_approve'=>'Date', + 'd.total_ht'=>"Numeric", 'd.total_tva'=>'Numeric', 'd.total_ttc'=>'Numeric', + 'd.fk_statut'=>"Numeric", 'd.paid'=>'Numeric', + 'd.note_private'=>'Text', 'd.note_public'=>'Text', 'd.detail_cancel'=>'Text', 'd.detail_refuse'=>'Text', + 'u.lastname'=>'Text', 'u.firstname'=>'Text', 'u.login'=>"Text", 'ed.rowid'=>'Numeric', 'tf.code'=>'Code', 'ed.date'=>'Date', 'ed.tva_tx'=>'Numeric', + 'ed.total_ht'=>'Numeric', 'ed.total_tva'=>'Numeric', 'ed.total_ttc'=>'Numeric', 'ed.comments'=>'Text', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', + 'user_rib.iban_prefix' => 'Text', 'user_rib.bic' => 'Text', 'user_rib.code_banque' => 'Text', 'user_rib.bank' => 'Text', 'user_rib.proprio' => 'Text', + 'user_rib.owner_address' => 'Text' + ); + $this->export_entities_array[$r] = array( 'u.lastname'=>'user', 'u.firstname'=>'user', 'u.login'=>'user', 'ed.rowid'=>'expensereport_line', 'ed.date'=>'expensereport_line', 'ed.tva_tx'=>'expensereport_line', 'ed.total_ht'=>'expensereport_line', 'ed.total_tva'=>'expensereport_line', 'ed.total_ttc'=>'expensereport_line', 'ed.comments'=>'expensereport_line', 'tf.code'=>'expensereport_line', 'p.project_ref'=>'expensereport_line', 'p.rowid'=>'project', 'p.ref'=>'project', - 'user_rib.iban_prefix' => 'user', 'user_rib.bic' => 'user', 'user_rib.code_banque' => 'user', 'user_rib.bank' => 'user', 'user_rib.proprio' => 'user', - 'user_rib.owner_address' => 'user' + 'user_rib.iban_prefix' => 'user', 'user_rib.bic' => 'user', 'user_rib.code_banque' => 'user', 'user_rib.bank' => 'user', 'user_rib.proprio' => 'user', + 'user_rib.owner_address' => 'user' ); - $this->export_alias_array[$r] = array('d.rowid'=>"idtrip", 'd.type'=>"type", 'd.note_private'=>'note_private', 'd.note_public'=>'note_public', 'u.lastname'=>'name', 'u.firstname'=>'firstname', 'u.login'=>'login'); + $this->export_alias_array[$r] = array('d.rowid'=>"idtrip", 'd.type'=>"type", 'd.note_private'=>'note_private', 'd.note_public'=>'note_public', 'u.lastname'=>'name', 'u.firstname'=>'firstname', 'u.login'=>'login'); $this->export_dependencies_array[$r] = array('expensereport_line'=>'ed.rowid', 'type_fees'=>'tf.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $keyforselect = 'expensereport'; $keyforelement = 'expensereport'; $keyforaliasextra = 'extra'; --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modExternalRss.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modExternalRss.class.php @@ -83,7 +83,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') @@ -118,21 +118,21 @@ return $this->_init($sql, $options); } - /** + /** * Function called when module is disabled. * Remove from database constants, boxes and permissions from Dolibarr database. * Data directories are not deleted * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO - */ - public function remove($options = '') - { + */ + public function remove($options = '') + { $sql = array(); // Delete old declarations of RSS box $this->boxes[0]['file'] = "box_external_rss.php"; return $this->_remove($sql, $options); - } + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modExternalSite.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modExternalSite.class.php @@ -34,11 +34,11 @@ class modExternalSite extends DolibarrModules { - /** + /** * Constructor. Define names, constants, directories, boxes, permissions * * @param DoliDB $db Database handler - */ + */ public function __construct($db) { $this->db = $db; @@ -86,16 +86,16 @@ // Add here list of php file(s) stored in core/boxes that contains class to show a box. // Example: - //$this->boxes[$r][1] = "myboxa.php"; - //$r++; - //$this->boxes[$r][1] = "myboxb.php"; - //$r++; + //$this->boxes[$r][1] = "myboxa.php"; + //$r++; + //$this->boxes[$r][1] = "myboxb.php"; + //$r++; // Permissions $this->rights_class = 'externalsite'; // Permission key $this->rights = array(); // Permission array used by this module - // Menus + // Menus //------ $r = 0; --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modFTP.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modFTP.class.php @@ -33,11 +33,11 @@ class modFTP extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ public function __construct($db) { $this->db = $db; @@ -75,8 +75,8 @@ // Constants $this->const = array( - 1=>array('FTP_CONNECT_WITH_SSL', 'chaine', '0', 'Use FTPS for FTP module', 1, 'current', 1), - 2=>array('FTP_CONNECT_WITH_SFTP', 'chaine', '0', 'Use SFTP for FTP module', 1, 'current', 1) + 1=>array('FTP_CONNECT_WITH_SSL', 'chaine', '0', 'Use FTPS for FTP module', 1, 'current', 1), + 2=>array('FTP_CONNECT_WITH_SFTP', 'chaine', '0', 'Use SFTP for FTP module', 1, 'current', 1) ); // List of parameters // Boxes @@ -85,10 +85,10 @@ // Add here list of php file(s) stored in core/boxes that contains class to show a box. // Example: - //$this->boxes[$r][1] = "myboxa.php"; - //$r++; - //$this->boxes[$r][1] = "myboxb.php"; - //$r++; + //$this->boxes[$r][1] = "myboxa.php"; + //$r++; + //$this->boxes[$r][1] = "myboxb.php"; + //$r++; // Permissions $this->rights_class = 'ftp'; // Permission key @@ -118,8 +118,8 @@ 'url'=>'/ftp/index.php', 'langs'=>'ftp', 'position'=>100, - 'enabled'=>'$conf->ftp->enabled', - 'perms'=>'$user->rights->ftp->read || $user->rights->ftp->write || $user->rights->ftp->setup', + 'enabled'=>'$conf->ftp->enabled', + 'perms'=>'$user->rights->ftp->read || $user->rights->ftp->write || $user->rights->ftp->setup', 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both $r++; --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modFacture.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modFacture.class.php @@ -111,8 +111,7 @@ $this->boxes = array( 0=>array('file'=>'box_factures_imp.php', 'enabledbydefaulton'=>'Home'), 1=>array('file'=>'box_factures.php', 'enabledbydefaulton'=>'Home'), - 2=>array('file'=>'box_graph_invoices_permonth.php', 'enabledbydefaulton'=>'Home'), - 3=>array('file'=>'box_customers_outstanding_bill_reached.php', 'enabledbydefaulton'=>'Home') + 2=>array('file'=>'box_graph_invoices_permonth.php', 'enabledbydefaulton'=>'Home') ); // Cronjobs @@ -147,7 +146,7 @@ $this->rights[$r][1] = 'Devalidate invoices'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'invoice_advance'; + $this->rights[$r][4] = 'invoice_advance'; $this->rights[$r][5] = 'unvalidate'; $r++; @@ -164,7 +163,7 @@ $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'invoice_advance'; - $this->rights[$r][5] = 'send'; + $this->rights[$r][5] = 'send'; $r++; $this->rights[$r][0] = 16; @@ -211,8 +210,8 @@ $this->export_icon[$r] = 'invoice'; $this->export_permission[$r] = array(array("facture", "facture", "export", "other")); $this->export_fields_array[$r] = array( - 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 'cd.nom'=>'State', - 's.phone'=>'Phone', + 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 'cd.nom'=>'State', + 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', @@ -230,11 +229,11 @@ ); if (!empty($conf->multicurrency->enabled)) { - $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; - $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; - $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; - $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; - $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; + $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; + $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; + $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; + $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; + $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; } if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS)) { @@ -291,7 +290,7 @@ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')'; - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id); + if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; $r++; @@ -300,8 +299,8 @@ $this->export_icon[$r] = 'invoice'; $this->export_permission[$r] = array(array("facture", "facture", "export")); $this->export_fields_array[$r] = array( - 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 'cd.nom'=>'State', - 's.phone'=>'Phone', + 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 'cd.nom'=>'State', + 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra', 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', @@ -316,12 +315,12 @@ $this->export_help_array[$r] = array('f.paye'=>'InvoicePaidCompletelyHelp'); if (!empty($conf->multicurrency->enabled)) { - $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; - $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; - $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; - $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; - $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; - $this->export_examplevalues_array[$r]['f.multicurrency_code'] = 'EUR'; + $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; + $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; + $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; + $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; + $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; + $this->export_examplevalues_array[$r]['f.multicurrency_code'] = 'EUR'; } if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS)) { @@ -329,7 +328,7 @@ $this->export_fields_array[$r]['f.pos_source'] = 'POSTerminal'; } $this->export_TypeFields_array[$r] = array( - 's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', + 's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'f.rowid'=>"Numeric", 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", 'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.close_code'=>'Text', 'f.close_note'=>'Text', @@ -371,7 +370,7 @@ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account'; $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid'; $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')'; - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id); + if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; $r++; } @@ -381,7 +380,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modFckeditor.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modFckeditor.class.php @@ -69,12 +69,12 @@ // Constants $this->const = array(); - $this->const[0] = array("FCKEDITOR_ENABLE_SOCIETE", "yesno", "1", "WYSIWIG for description and note (except products/services)"); - $this->const[1] = array("FCKEDITOR_ENABLE_PRODUCTDESC", "yesno", "1", "WYSIWIG for products/services description and note"); - $this->const[2] = array("FCKEDITOR_ENABLE_MAILING", "yesno", "1", "WYSIWIG for mass emailings"); - $this->const[3] = array("FCKEDITOR_ENABLE_DETAILS", "yesno", "1", "WYSIWIG for products details lines for all entities"); - $this->const[4] = array("FCKEDITOR_ENABLE_USERSIGN", "yesno", "1", "WYSIWIG for user signature"); - $this->const[5] = array("FCKEDITOR_ENABLE_MAIL", "yesno", "1", "WYSIWIG for products details lines for all entities"); + $this->const[0] = array("FCKEDITOR_ENABLE_SOCIETE", "yesno", "1", "WYSIWIG for description and note (except products/services)"); + $this->const[1] = array("FCKEDITOR_ENABLE_PRODUCTDESC", "yesno", "1", "WYSIWIG for products/services description and note"); + $this->const[2] = array("FCKEDITOR_ENABLE_MAILING", "yesno", "1", "WYSIWIG for mass emailings"); + $this->const[3] = array("FCKEDITOR_ENABLE_DETAILS", "yesno", "1", "WYSIWIG for products details lines for all entities"); + $this->const[4] = array("FCKEDITOR_ENABLE_USERSIGN", "yesno", "1", "WYSIWIG for user signature"); + $this->const[5] = array("FCKEDITOR_ENABLE_MAIL", "yesno", "1", "WYSIWIG for products details lines for all entities"); $this->const[6] = array("FCKEDITOR_SKIN", "string", "moono-lisa", "Skin by default for fckeditor"); // Boxes --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modFicheinter.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modFicheinter.class.php @@ -37,200 +37,200 @@ class modFicheinter extends DolibarrModules { - /** + /** * Constructor. Define names, constants, directories, boxes, permissions * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $conf; - - $this->db = $db; - $this->numero = 70; - - $this->family = "crm"; - $this->module_position = '41'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "Gestion des fiches d'intervention"; - - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; - - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->picto = "intervention"; - - // Data directories to create when module is enabled - $this->dirs = array("/ficheinter/temp"); - - // Dependencies - $this->depends = array("modSociete"); - $this->requiredby = array(); - $this->conflictwith = array(); - $this->langfiles = array("bills", "companies", "interventions"); - - // Config pages - $this->config_page_url = array("fichinter.php"); - - // Constants - $this->const = array(); - $r = 0; - - $this->const[$r][0] = "FICHEINTER_ADDON_PDF"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "soleil"; - $r++; - - $this->const[$r][0] = "FICHEINTER_ADDON"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "pacific"; - $r++; - - // Boxes - $this->boxes = array(0=>array('file'=>'box_ficheinter.php', 'enabledbydefaulton'=>'Home')); - - // Permissions - $this->rights = array(); - $this->rights_class = 'ficheinter'; - $r = 0; - - $r++; - $this->rights[$r][0] = 61; - $this->rights[$r][1] = 'Lire les fiches d\'intervention'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'lire'; - - $r++; - $this->rights[$r][0] = 62; - $this->rights[$r][1] = 'Creer/modifier les fiches d\'intervention'; - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'creer'; - - $r++; - $this->rights[$r][0] = 64; - $this->rights[$r][1] = 'Supprimer les fiches d\'intervention'; - $this->rights[$r][2] = 'd'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'supprimer'; - - $r++; - $this->rights[$r][0] = 67; - $this->rights[$r][1] = 'Exporter les fiches interventions'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'export'; - - $r++; - $this->rights[$r][0] = 68; - $this->rights[$r][1] = 'Envoyer les fiches d\'intervention par courriel'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on - $this->rights[$r][5] = 'send'; - - $r++; - $this->rights[$r][0] = 69; - $this->rights[$r][1] = 'Valider les fiches d\'intervention '; - $this->rights[$r][2] = 'a'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on - $this->rights[$r][5] = 'validate'; - - $r++; - $this->rights[$r][0] = 70; - $this->rights[$r][1] = 'Dévalider les fiches d\'intervention'; - $this->rights[$r][2] = 'a'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on - $this->rights[$r][5] = 'unvalidate'; - - - // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - - //Exports - //-------- - $r = 1; - - $this->export_code[$r] = $this->rights_class.'_'.$r; - $this->export_label[$r] = 'InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r] = array(array("ficheinter", "export")); - $this->export_fields_array[$r] = array( + */ + public function __construct($db) + { + global $conf; + + $this->db = $db; + $this->numero = 70; + + $this->family = "crm"; + $this->module_position = '41'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "Gestion des fiches d'intervention"; + + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; + + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + $this->picto = "intervention"; + + // Data directories to create when module is enabled + $this->dirs = array("/ficheinter/temp"); + + // Dependencies + $this->depends = array("modSociete"); + $this->requiredby = array(); + $this->conflictwith = array(); + $this->langfiles = array("bills", "companies", "interventions"); + + // Config pages + $this->config_page_url = array("fichinter.php"); + + // Constants + $this->const = array(); + $r = 0; + + $this->const[$r][0] = "FICHEINTER_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "soleil"; + $r++; + + $this->const[$r][0] = "FICHEINTER_ADDON"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "pacific"; + $r++; + + // Boxes + $this->boxes = array(0=>array('file'=>'box_ficheinter.php', 'enabledbydefaulton'=>'Home')); + + // Permissions + $this->rights = array(); + $this->rights_class = 'ficheinter'; + $r = 0; + + $r++; + $this->rights[$r][0] = 61; + $this->rights[$r][1] = 'Lire les fiches d\'intervention'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'lire'; + + $r++; + $this->rights[$r][0] = 62; + $this->rights[$r][1] = 'Creer/modifier les fiches d\'intervention'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'creer'; + + $r++; + $this->rights[$r][0] = 64; + $this->rights[$r][1] = 'Supprimer les fiches d\'intervention'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'supprimer'; + + $r++; + $this->rights[$r][0] = 67; + $this->rights[$r][1] = 'Exporter les fiches interventions'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'export'; + + $r++; + $this->rights[$r][0] = 68; + $this->rights[$r][1] = 'Envoyer les fiches d\'intervention par courriel'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on + $this->rights[$r][5] = 'send'; + + $r++; + $this->rights[$r][0] = 69; + $this->rights[$r][1] = 'Valider les fiches d\'intervention '; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on + $this->rights[$r][5] = 'validate'; + + $r++; + $this->rights[$r][0] = 70; + $this->rights[$r][1] = 'Dévalider les fiches d\'intervention'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on + $this->rights[$r][5] = 'unvalidate'; + + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + + //Exports + //-------- + $r = 1; + + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = 'InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("ficheinter", "export")); + $this->export_fields_array[$r] = array( 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 's.fk_pays'=>'Country', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 'f.rowid'=>"InterId", 'f.ref'=>"InterRef", 'f.datec'=>"InterDateCreation", 'f.duree'=>"InterDuration", 'f.fk_statut'=>'InterStatus', 'f.description'=>"InterNote"); - $keyforselect = 'fichinter'; $keyforelement = 'intervention'; $keyforaliasextra = 'extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_fields_array[$r] += array( - 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel', - 'fd.rowid'=>'InterLineId', + $keyforselect = 'fichinter'; $keyforelement = 'intervention'; $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $this->export_fields_array[$r] += array( + 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel', + 'fd.rowid'=>'InterLineId', 'fd.date'=>"InterLineDate", 'fd.duree'=>"InterLineDuration", 'fd.description'=>"InterLineDesc" ); - //$this->export_TypeFields_array[$r]=array( + //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label', // 's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text', // 's.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text", // 'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean",'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text", // 'fd.total_ht'=>"Numeric" //); - $this->export_TypeFields_array[$r] = array( - 's.rowid'=>"Numeric", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label', 's.phone'=>'Text', 's.siren'=>'Text', + $this->export_TypeFields_array[$r] = array( + 's.rowid'=>"Numeric", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', - 'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.datec'=>"Date", + 'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.datec'=>"Date", 'f.duree'=>"Duree", 'f.fk_statut'=>'Numeric', 'f.description'=>"Text", 'f.datee'=>"Date", 'f.dateo'=>"Date", 'f.fulldayevent'=>"Boolean", - 'pj.ref'=>'Text', 'pj.title'=>'Text', - 'fd.rowid'=>"Numeric", 'fd.date'=>"Date", 'fd.duree'=>"Duree", 'fd.description'=>"Text", 'fd.total_ht'=>"Numeric" + 'pj.ref'=>'Text', 'pj.title'=>'Text', + 'fd.rowid'=>"Numeric", 'fd.date'=>"Date", 'fd.duree'=>"Duree", 'fd.description'=>"Text", 'fd.total_ht'=>"Numeric" ); - $this->export_entities_array[$r] = array( + $this->export_entities_array[$r] = array( 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 's.fk_pays'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 'f.rowid'=>"intervention", 'f.ref'=>"intervention", 'f.datec'=>"intervention", 'f.duree'=>"intervention", - 'f.fk_statut'=>"intervention", 'f.description'=>"intervention", 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>"inter_line", 'fd.date'=>"inter_line", + 'f.fk_statut'=>"intervention", 'f.description'=>"intervention", 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>"inter_line", 'fd.date'=>"inter_line", 'fd.duree'=>'inter_line', 'fd.description'=>'inter_line' ); - $this->export_dependencies_array[$r] = array('inter_line'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - $keyforselect = 'fichinterdet'; $keyforelement = 'inter_line'; $keyforaliasextra = 'extradet'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'fichinter as f'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter_extrafields as extra ON f.rowid = extra.fk_object'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet_extrafields as extradet ON fd.rowid = extradet.fk_object,'; - $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s'; - $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid'; - $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('intervention').')'; - $r++; - } - - - /** + $this->export_dependencies_array[$r] = array('inter_line'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them + $keyforselect = 'fichinterdet'; $keyforelement = 'inter_line'; $keyforaliasextra = 'extradet'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'fichinter as f'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter_extrafields as extra ON f.rowid = extra.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet_extrafields as extradet ON fd.rowid = extradet.fk_object,'; + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s'; + $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('intervention').')'; + $r++; + } + + + /** * Function called when module is enabled. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - global $conf; - - // Permissions - $this->remove($options); - - $sql = array( + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $conf; + + // Permissions + $this->remove($options); + + $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'ficheinter' AND entity = ".$conf->entity, "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','ficheinter',".$conf->entity.")", - ); - - return $this->_init($sql, $options); - } + ); + + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modFournisseur.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modFournisseur.class.php @@ -4,7 +4,6 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013-2015 Philippe Grand - * Copyright (C) 2020 Ahmad Jamaly Rabib * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -63,12 +62,12 @@ // Data directories to create when module is enabled $this->dirs = array( - "/fournisseur/temp", - "/fournisseur/commande", - "/fournisseur/commande/temp", - "/fournisseur/facture", - "/fournisseur/facture/temp" - ); + "/fournisseur/temp", + "/fournisseur/commande", + "/fournisseur/commande/temp", + "/fournisseur/facture", + "/fournisseur/facture/temp" + ); // Dependencies $this->depends = array("modSociete"); @@ -121,13 +120,13 @@ // Boxes $this->boxes = array( - 0=>array('file'=>'box_graph_invoices_supplier_permonth.php', 'enabledbydefaulton'=>'Home'), - 1=>array('file'=>'box_graph_orders_supplier_permonth.php', 'enabledbydefaulton'=>'Home'), - 2=>array('file'=>'box_fournisseurs.php', 'enabledbydefaulton'=>'Home'), - 3=>array('file'=>'box_factures_fourn_imp.php', 'enabledbydefaulton'=>'Home'), - 4=>array('file'=>'box_factures_fourn.php', 'enabledbydefaulton'=>'Home'), - 5=>array('file'=>'box_supplier_orders.php', 'enabledbydefaulton'=>'Home'), - 6=>array('file'=>'box_supplier_orders_awaiting_reception.php', 'enabledbydefaulton'=>'Home'), + 0=>array('file'=>'box_graph_invoices_supplier_permonth.php', 'enabledbydefaulton'=>'Home'), + 1=>array('file'=>'box_graph_orders_supplier_permonth.php', 'enabledbydefaulton'=>'Home'), + 2=>array('file'=>'box_fournisseurs.php', 'enabledbydefaulton'=>'Home'), + 3=>array('file'=>'box_factures_fourn_imp.php', 'enabledbydefaulton'=>'Home'), + 4=>array('file'=>'box_factures_fourn.php', 'enabledbydefaulton'=>'Home'), + 5=>array('file'=>'box_supplier_orders.php', 'enabledbydefaulton'=>'Home'), + 6=>array('file'=>'box_supplier_orders_awaiting_reception.php', 'enabledbydefaulton'=>'Home'), ); // Permissions @@ -191,12 +190,12 @@ $this->rights[$r][5] = 'receptionner'; $r++; - $this->rights[$r][0] = 1189; - $this->rights[$r][1] = 'Check/Uncheck a supplier order reception'; - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'commande_advance'; - $this->rights[$r][5] = 'check'; + $this->rights[$r][0] = 1189; + $this->rights[$r][1] = 'Check/Uncheck a supplier order reception'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'commande_advance'; + $this->rights[$r][5] = 'check'; $r++; $this->rights[$r][0] = 1188; @@ -274,9 +273,9 @@ $this->rights[$r][5] = 'export'; - // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. // Exports @@ -299,7 +298,7 @@ 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'p.accountancy_code_buy'=>'ProductAccountancyBuyCode', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel' ); - if (!empty($conf->multicurrency->enabled)) + if (! empty($conf->multicurrency->enabled)) { $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; @@ -434,7 +433,7 @@ 'f.fk_statut'=>'InvoiceStatus', 'f.note_public'=>"InvoiceNote", 'p.rowid'=>'PaymentId', 'pf.amount'=>'AmountPayment', 'p.datep'=>'DatePayment', 'p.num_paiement'=>'PaymentNumber', 'p.fk_bank'=>'IdTransaction', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel' ); - if (!empty($conf->multicurrency->enabled)) + if (! empty($conf->multicurrency->enabled)) { $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; @@ -460,7 +459,7 @@ 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company', 'f.rowid'=>"invoice", 'f.ref'=>"invoice", 'f.ref_supplier'=>"invoice", 'f.datec'=>"invoice", 'f.datef'=>"invoice", 'f.total_ht'=>"invoice", 'f.total_ttc'=>"invoice", 'f.total_tva'=>"invoice", 'f.paye'=>"invoice", 'f.fk_statut'=>'invoice', 'f.note_public'=>"invoice", 'p.rowid'=>'payment', 'pf.amount'=>'payment', - 'p.datep'=>'payment', 'p.num_paiement'=>'payment', 'p.fk_bank'=>'account', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project'); + 'p.datep'=>'payment', 'p.num_paiement'=>'payment', 'p.fk_bank'=>'account', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project'); $this->export_dependencies_array[$r] = array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them // Add extra fields object $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")"; @@ -509,7 +508,7 @@ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid'; $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid'; - $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')'; + $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')'; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; // Order @@ -528,7 +527,7 @@ 'fd.total_tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.ref'=>'RefSupplier', 'fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel' ); - if (!empty($conf->multicurrency->enabled)) + if (! empty($conf->multicurrency->enabled)) { $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; @@ -651,334 +650,6 @@ $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande'; $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_order').')'; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; - - //Import Supplier Invoice - //-------- - $r = 0; - - $r++; - $this->import_code[$r] = $this->rights_class.'_'.$r; - $this->import_label[$r] = "Supplier Invoice"; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = ['f' => MAIN_DB_PREFIX.'facture_fourn', 'extra' => MAIN_DB_PREFIX.'facture_fourn_extrafields']; - $this->import_tables_creator_array[$r] = ['f' => 'fk_user_author']; // Fields to store import user id - $this->import_fields_array[$r] = [ - 'f.ref' => 'InvoiceRef*', - 'f.ref_supplier' => 'RefSupplier', - 'f.type' => 'Type*', - 'f.fk_soc' => 'Supplier/Vendor*', - 'f.datec' => 'InvoiceDateCreation', - 'f.datef' => 'DateInvoice', - 'f.date_lim_reglement' => 'DateMaxPayment', - 'f.total_ht' => 'TotalHT', - 'f.total_ttc' => 'TotalTTC', - 'f.total_tva' => 'TotalVAT', - 'f.paye' => 'InvoicePaid', - 'f.fk_statut' => 'InvoiceStatus', - 'f.fk_user_modif' => 'Modifier Id', - 'f.fk_user_valid' => 'Validator Id', - 'f.fk_facture_source' => 'Invoice Source Id', - 'f.fk_projet' => 'Project Id', - 'f.fk_account' => 'Bank Account*', - 'f.note_public' => 'InvoiceNote', - 'f.note_private' => 'NotePrivate', - 'f.fk_cond_reglement' => 'Payment Condition', - 'f.fk_mode_reglement' => 'Payment Mode', - 'f.model_pdf' => 'Model', - 'f.date_valid' => 'Validation Date' - ]; - if (!empty($conf->multicurrency->enabled)) { - $this->import_fields_array[$r]['f.multicurrency_code'] = 'Currency'; - $this->import_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; - $this->import_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; - $this->import_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; - $this->import_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; - } - // Add extra fields - $import_extrafield_sample = []; - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")"; - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - $import_extrafield_sample[$fieldname] = $fieldlabel; - } - } - // End add extra fields - $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'facture_fourn']; - $this->import_regex_array[$r] = ['f.ref' => '(SI\d{4}-\d{4}|PROV.{1,32}$)', 'f.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency']; - $import_sample = [ - 'f.ref' => '(PROV001)', - 'f.ref_supplier' => 'Supplier1', - 'f.type' => '0', - 'f.fk_soc' => 'Vendor1', - 'f.datec' => '2021-01-01', - 'f.datef' => '', - 'f.date_lim_reglement' => '2021-01-30', - 'f.total_ht' => '1000', - 'f.total_ttc' => '1000', - 'f.total_tva' => '0', - 'f.paye' => '0', - 'f.fk_statut' => '0', - 'f.fk_user_modif' => '', - 'f.fk_user_valid' => '', - 'f.fk_facture_source' => '', - 'f.fk_projet' => '', - 'f.fk_account' => 'BANK1', - 'f.note_public' => 'Note: ', - 'f.note_private' => '', - 'f.fk_cond_reglement' => '1', - 'f.fk_mode_reglement' => '2', - 'f.model_pdf' => 'crab', - 'f.date_valid' => '', - 'f.multicurrency_code' => 'USD', - 'f.multicurrency_tx' => '1', - 'f.multicurrency_total_ht' => '1000', - 'f.multicurrency_total_tva' => '0', - 'f.multicurrency_total_ttc' => '1000' - ]; - $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); - $this->import_updatekeys_array[$r] = ['f.ref' => 'Ref']; - $this->import_convertvalue_array[$r] = [ - //'c.ref'=>array('rule'=>'getrefifauto'), - 'f.fk_soc' => ['rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'], - 'f.fk_account' => ['rule' => 'fetchidfromref', 'file' => '/compta/bank/class/account.class.php', 'class' => 'Account', 'method' => 'fetch', 'element' => 'bank_account'], - ]; - - //Import Supplier Invoice Lines - $r++; - $this->import_code[$r] = $this->rights_class.'_'.$r; - $this->import_label[$r] = "Supplier Invoice Lines"; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = ['fd' => MAIN_DB_PREFIX.'facture_fourn_det', 'extra' => MAIN_DB_PREFIX.'facture_fourn_det_extrafields']; - $this->import_fields_array[$r] = [ - 'fd.fk_facture_fourn' => 'InvoiceRef*', - 'fd.fk_parent_line' => 'FacParentLine', - 'fd.fk_product' => 'IdProduct', - 'fd.label' => 'Label', - 'fd.description' => 'LineDescription', - 'fd.pu_ht' => 'PriceUHT', - 'fd.pu_ttc' => 'PriceUTTC', - 'fd.qty' => 'LineQty', - 'fd.remise_percent' => 'Reduc.', - 'fd.vat_src_code' => 'Vat Source Code', - 'fd.product_type' => 'TypeOfLineServiceOrProduct', - 'fd.tva_tx' => 'LineVATRate', - 'fd.total_ht' => 'LineTotalHT', - 'fd.tva' => 'LineTotalVAT', - 'fd.total_ttc' => 'LineTotalTTC', - 'fd.date_start' => 'Start Date', - 'fd.date_end' => 'End Date', - 'fd.fk_unit' => 'Unit' - ]; - if (!empty($conf->multicurrency->enabled)) { - $this->import_fields_array[$r]['fd.multicurrency_code'] = 'Currency'; - $this->import_fields_array[$r]['fd.multicurrency_subprice'] = 'CurrencyRate'; - $this->import_fields_array[$r]['fd.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; - $this->import_fields_array[$r]['fd.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; - $this->import_fields_array[$r]['fd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; - } - // Add extra fields - $import_extrafield_sample = []; - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.")"; - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - $import_extrafield_sample[$fieldname] = $fieldlabel; - } - } - // End add extra fields - $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'facture_fourn_det']; - $this->import_regex_array[$r] = ['fd.product_type' => '[0|1]$', 'fd.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product', 'fd.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency']; - $import_sample = [ - 'fd.fk_facture_fourn' => '(PROV001)', - 'fd.fk_parent_line' => '', - 'fd.fk_product' => '', - 'fd.label' => '', - 'fd.description' => 'Test Product', - 'fd.pu_ht' => '50000', - 'fd.pu_ttc' => '50000', - 'fd.qty' => '1', - 'fd.remise_percent' => '0', - 'fd.vat_src_code' => '', - 'fd.product_type' => '0', - 'fd.tva_tx' => '0', - 'fd.total_ht' => '50000', - 'fd.tva' => '0', - 'fd.total_ttc' => '50000', - 'fd.date_start' => '', - 'fd.date_end' => '', - 'fd.fk_unit' => '', - 'fd.multicurrency_code' => 'USD', - 'fd.multicurrency_tx' => '0', - 'fd.multicurrency_total_ht' => '50000', - 'fd.multicurrency_total_tva' => '0', - 'fd.multicurrency_total_ttc' => '50000' - ]; - $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); - $this->import_updatekeys_array[$r] = ['fd.rowid' => 'Row Id', 'fd.fk_facture_fourn' => 'Invoice Id', 'fd.fk_product' => 'Product Id']; - $this->import_convertvalue_array[$r] = [ - 'fd.fk_facture_fourn' => ['rule' => 'fetchidfromref', 'file' => '/fourn/class/fournisseur.facture.class.php', 'class' => 'FactureFournisseur', 'method' => 'fetch'], - ]; - - //Import Purchase Orders - $r++; - $this->import_code[$r] = 'commande_fournisseur_'.$r; - $this->import_label[$r] = 'Purchase Orders'; - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = []; - $this->import_tables_array[$r] = ['c' => MAIN_DB_PREFIX.'commande_fournisseur', 'extra' => MAIN_DB_PREFIX.'commande_fournisseur_extrafields']; - $this->import_tables_creator_array[$r] = ['c' => 'fk_user_author']; // Fields to store import user id - $this->import_fields_array[$r] = [ - 'c.ref' => 'Document Ref*', - 'c.ref_supplier' => 'RefSupplier', - 'c.fk_soc' => 'ThirdPartyName*', - 'c.fk_projet' => 'ProjectId', - 'c.date_creation' => 'DateCreation', - 'c.date_valid' => 'DateValid', - 'c.date_approve' => 'DateApprove', - 'c.date_commande' => 'DateOrder', - 'c.fk_user_modif' => 'ModifiedById', - 'c.fk_user_valid' => 'ValidatedById', - 'c.fk_user_approve' => 'ApprovedById', - 'c.source' => 'Source', - 'c.fk_statut' => 'Status*', - 'c.billed' => 'Billed(0/1)', - 'c.remise_percent' => 'GlobalDiscount', - 'c.tva' => 'TotalTVA', - 'c.total_ht' => 'TotalHT', - 'c.total_ttc' => 'TotalTTC', - 'c.note_private' => 'NotePrivate', - 'c.note_public' => 'Note', - 'c.date_livraison' => 'DeliveryDate', - 'c.fk_cond_reglement' => 'Payment Condition', - 'c.fk_mode_reglement' => 'Payment Mode', - 'c.model_pdf' => 'Model' - ]; - - if (!empty($conf->multicurrency->enabled)) { - $this->import_fields_array[$r]['c.multicurrency_code'] = 'Currency'; - $this->import_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate'; - $this->import_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; - $this->import_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; - $this->import_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; - } - - // Add extra fields - $import_extrafield_sample = []; - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.")"; - $resql = $this->db->query($sql); - - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - $import_extrafield_sample[$fieldname] = $fieldlabel; - } - } - // End add extra fields - - $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande_fournisseur']; - $this->import_regex_array[$r] = [ - 'c.ref' => '(PO\d{4}-\d{4}|PORDER.{1,32}$|PROV.{1,32}$)', - 'c.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency' - ]; - - $this->import_updatekeys_array[$r] = ['c.ref' => 'Ref']; - $this->import_convertvalue_array[$r] = [ - 'c.fk_soc' => [ - 'rule' => 'fetchidfromref', - 'file' => '/societe/class/societe.class.php', - 'class' => 'Societe', - 'method' => 'fetch', - 'element' => 'ThirdParty' - ], - 'c.fk_mode_reglement' => [ - 'rule' => 'fetchidfromcodeorlabel', - 'file' => '/compta/paiement/class/cpaiement.class.php', - 'class' => 'Cpaiement', - 'method' => 'fetch', - 'element' => 'cpayment' - ], - 'c.source' => ['rule' => 'zeroifnull'], - ]; - - //Import PO Lines - $r++; - $this->import_code[$r] = 'commande_fournisseurdet_'.$r; - $this->import_label[$r] = 'PO Lines'; - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = []; - $this->import_tables_array[$r] = ['cd' => MAIN_DB_PREFIX.'commande_fournisseurdet', 'extra' => MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields']; - $this->import_fields_array[$r] = [ - 'cd.fk_commande' => 'Document Ref*', - 'cd.fk_parent_line' => 'PrParentLine', - 'cd.fk_product' => 'IdProduct', - 'cd.label' => 'Label', - 'cd.description' => 'LineDescription', - 'cd.tva_tx' => 'LineVATRate', - 'cd.qty' => 'LineQty', - 'cd.remise_percent' => 'Reduc. Percent', - 'cd.remise' => 'Reduc.', - 'cd.subprice' => 'Sub Price', - 'cd.total_ht' => 'LineTotalHT', - 'cd.total_tva' => 'LineTotalVAT', - 'cd.total_ttc' => 'LineTotalTTC', - 'cd.product_type' => 'TypeOfLineServiceOrProduct', - 'cd.date_start' => 'Start Date', - 'cd.date_end' => 'End Date', - 'cd.info_bits' => 'InfoBits', - 'cd.special_code' => 'Special Code', - 'cd.rang' => 'LinePosition', - 'cd.fk_unit' => 'Unit' - ]; - - if (!empty($conf->multicurrency->enabled)) { - $this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency'; - $this->import_fields_array[$r]['cd.multicurrency_subprice'] = 'CurrencyRate'; - $this->import_fields_array[$r]['cd.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; - $this->import_fields_array[$r]['cd.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; - $this->import_fields_array[$r]['cd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; - } - - // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.")"; - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - } - } - // End add extra fields - - $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande_fournisseurdet']; - $this->import_regex_array[$r] = [ - 'cd.product_type' => '[0|1]$', - 'cd.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product', - 'cd.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency' - ]; - $this->import_updatekeys_array[$r] = ['cd.fk_commande' => 'Purchase Order Id']; - $this->import_convertvalue_array[$r] = [ - 'cd.fk_commande' => [ - 'rule' => 'fetchidfromref', - 'file' => '/fourn/class/fournisseur.commande.class.php', - 'class' => 'CommandeFournisseur', - 'method' => 'fetch', - 'element' => 'order_supplier' - ], - 'cd.info_bits' => ['rule' => 'zeroifnull'], - 'cd.special_code' => ['rule' => 'zeroifnull'], - ]; } @@ -987,7 +658,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modHRM.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modHRM.class.php @@ -43,13 +43,12 @@ $this->rights_class = 'hrm'; $this->family = "hr"; - $this->module_position = '50'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Management of employees carrier and feelings (department, employment contract)"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'experimental'; + $this->version = 'development'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modHoliday.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modHoliday.class.php @@ -140,14 +140,14 @@ $r = 0; $this->rights[$r][0] = 20001; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read leave requests (yours and your subordinates)'; // Permission label + $this->rights[$r][1] = 'Read your own leave requests'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20002; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/modify leave requests'; // Permission label + $this->rights[$r][1] = 'Create/modify your own leave requests'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) @@ -170,14 +170,14 @@ $this->rights[$r][0] = 20004; // Permission id (must not be already used) $this->rights[$r][1] = 'Read leave requests for everybody'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'readall'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][4] = 'read_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20005; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/modify leave requests for everybody'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'writeall_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; @@ -201,7 +201,7 @@ $this->export_code[$r] = 'leaverequest_'.$r; $this->export_label[$r] = 'ListeCP'; $this->export_icon[$r] = 'holiday'; - $this->export_permission[$r] = array(array("holiday", "readall")); + $this->export_permission[$r] = array(array("holiday", "read_all")); $this->export_fields_array[$r] = array( 'd.rowid'=>"LeaveId", 'd.fk_type'=>'TypeOfLeaveId', 't.code'=>'TypeOfLeaveCode', 't.label'=>'TypeOfLeaveLabel', 'd.fk_user'=>'UserID', 'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'u.login'=>"Login", 'd.date_debut'=>'DateStart', 'd.date_fin'=>'DateEnd', 'd.halfday'=>'HalfDay', 'none.num_open_days'=>'NbUseDaysCP', --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modIncoterm.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modIncoterm.class.php @@ -37,11 +37,11 @@ * * @param DoliDB $db Database handler */ - public function __construct($db) - { - global $langs, $conf; + public function __construct($db) + { + global $langs, $conf; - $this->db = $db; + $this->db = $db; // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). @@ -76,28 +76,28 @@ array('INCOTERM_ACTIVATE', 'chaine', 0, 'Description de INCOTERM_ACTIVATE') ); - $this->tabs = array(); + $this->tabs = array(); - // Dictionaries + // Dictionaries if (!isset($conf->incoterm->enabled)) - { - $conf->incoterm = new stdClass(); - $conf->incoterm->enabled = 0; - } + { + $conf->incoterm = new stdClass(); + $conf->incoterm->enabled = 0; + } $this->dictionaries = array( 'langs'=>'incoterm', - 'tabname'=>array(MAIN_DB_PREFIX."c_incoterms"), // List of tables we want to see into dictonnary editor - 'tablib'=>array("Incoterms"), // Label of tables - 'tabsql'=>array('SELECT rowid, code, libelle, active FROM '.MAIN_DB_PREFIX.'c_incoterms'), // Request to select fields - 'tabsqlsort'=>array("rowid ASC"), // Sort order - 'tabfield'=>array("code,libelle"), // List of fields (result of select to show dictionary) - 'tabfieldvalue'=>array("code,libelle"), // List of fields (list of fields to edit a record) - 'tabfieldinsert'=>array("code,libelle"), // List of fields (list of fields for insert) - 'tabrowid'=>array("rowid"), // Name of columns with primary key (try to always name it 'rowid') - 'tabcond'=>array($conf->incoterm->enabled) + 'tabname'=>array(MAIN_DB_PREFIX."c_incoterms"), // List of tables we want to see into dictonnary editor + 'tablib'=>array("Incoterms"), // Label of tables + 'tabsql'=>array('SELECT rowid, code, libelle, active FROM '.MAIN_DB_PREFIX.'c_incoterms'), // Request to select fields + 'tabsqlsort'=>array("rowid ASC"), // Sort order + 'tabfield'=>array("code,libelle"), // List of fields (result of select to show dictionary) + 'tabfieldvalue'=>array("code,libelle"), // List of fields (list of fields to edit a record) + 'tabfieldinsert'=>array("code,libelle"), // List of fields (list of fields for insert) + 'tabrowid'=>array("rowid"), // Name of columns with primary key (try to always name it 'rowid') + 'tabcond'=>array($conf->incoterm->enabled) ); - $this->boxes = array(); // List of boxes + $this->boxes = array(); // List of boxes $r = 0; // Permissions --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modLabel.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modLabel.class.php @@ -97,16 +97,16 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - public function init($options = '') - { + public function init($options = '') + { // Permissions $this->remove($options); $sql = array(); return $this->_init($sql, $options); - } + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modLoan.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modLoan.class.php @@ -153,7 +153,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modMailing.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modMailing.class.php @@ -48,7 +48,7 @@ // It is used to group modules by family in module setup page $this->family = "interface"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '22'; + $this->module_position = '11'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); @@ -146,7 +146,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modModuleBuilder.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modModuleBuilder.class.php @@ -30,89 +30,89 @@ */ class modModuleBuilder extends DolibarrModules { - /** + /** * Constructor. Define names, constants, directories, boxes, permissions * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs, $conf; + */ + public function __construct($db) + { + global $langs, $conf; - $this->db = $db; - $this->numero = 3300; + $this->db = $db; + $this->numero = 3300; // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "technic"; - $this->module_position = '90'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "A RAD (Rapid Application Development) tool to help developers to build their own module."; + $this->family = "technic"; + $this->module_position = '90'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "A RAD (Rapid Application Development) tool to help developers to build their own module."; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - $this->picto = 'bug'; + $this->version = 'dolibarr'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + $this->picto = 'bug'; - // Data directories to create when module is enabled - $this->dirs = array(); + // Data directories to create when module is enabled + $this->dirs = array(); - // Config pages - //------------- - $this->config_page_url = array('setup.php@modulebuilder'); + // Config pages + //------------- + $this->config_page_url = array('setup.php@modulebuilder'); - // Dependencies - //------------- - $this->hidden = false; // A condition to disable module - $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->langfiles = array(); + // Dependencies + //------------- + $this->hidden = false; // A condition to disable module + $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->langfiles = array(); - // Constants - //----------- + // Constants + //----------- - // New pages on tabs - // ----------------- - $this->tabs = array(); + // New pages on tabs + // ----------------- + $this->tabs = array(); - // Boxes - //------ - $this->boxes = array(); + // Boxes + //------ + $this->boxes = array(); - // Permissions - //------------ - $this->rights = array(); // Permission array used by this module - $this->rights_class = 'modulebuilder'; + // Permissions + //------------ + $this->rights = array(); // Permission array used by this module + $this->rights_class = 'modulebuilder'; - $r = 0; + $r = 0; - $r++; - $this->rights[$r][0] = 3301; - $this->rights[$r][1] = 'Generate new modules'; - $this->rights[$r][2] = 'a'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'run'; + $r++; + $this->rights[$r][0] = 3301; + $this->rights[$r][1] = 'Generate new modules'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'run'; - // Main menu entries - //------------------ - $this->menu = array(); + // Main menu entries + //------------------ + $this->menu = array(); - $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', - 'type'=>'left', - 'titre'=>'ModuleBuilder', - 'mainmenu'=>'home', - 'leftmenu'=>'admintools_modulebuilder', - 'url'=>'/modulebuilder/index.php?mainmenu=home&leftmenu=admintools', - 'langs'=>'modulebuilder', - 'position'=>100, - 'perms'=>'1', - 'enabled'=>'$conf->modulebuilder->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu) && ($user->admin || $conf->global->MODULEBUILDER_FOREVERYONE)', - 'target'=>'_modulebuilder', - 'user'=>0); - } + $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', + 'type'=>'left', + 'titre'=>'ModuleBuilder', + 'mainmenu'=>'home', + 'leftmenu'=>'admintools_modulebuilder', + 'url'=>'/modulebuilder/index.php?mainmenu=home&leftmenu=admintools', + 'langs'=>'modulebuilder', + 'position'=>100, + 'perms'=>'1', + 'enabled'=>'$conf->modulebuilder->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu) && ($user->admin || $conf->global->MODULEBUILDER_FOREVERYONE)', + 'target'=>'_modulebuilder', + 'user'=>0); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modMrp.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modMrp.class.php @@ -33,155 +33,155 @@ */ class modMrp extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs, $conf; - $this->db = $db; - - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 660; - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'mrp'; - // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' - // It is used to group modules by family in module setup page - $this->family = "products"; - // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '66'; - // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) - //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); - // Module label (no space allowed), used if translation string 'ModuleMrpName' not found (Mrp is name of module). - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuleMrpDesc' not found (Mrp is name of module). - $this->description = "Module to Manage Manufacturing Orders (MO)"; - // Used only if file README.md and README-LL.md not found. - $this->descriptionlong = "Module to Manage Manufacturing Orders (MO)"; - // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = 'dolibarr'; - // Url to the file with your last numberversion of this module - //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; - - // Key used in llx_const table to save module status enabled/disabled (where MRP is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto = 'mrp'; - // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) - $this->module_parts = array( - // Set this to 1 if module has its own trigger directory (core/triggers) - 'triggers' => 0, - // Set this to 1 if module has its own login method file (core/login) - 'login' => 0, - // Set this to 1 if module has its own substitution function file (core/substitutions) - 'substitutions' => 0, - // Set this to 1 if module has its own menus handler directory (core/menus) - 'menus' => 0, - // Set this to 1 if module overwrite template dir (core/tpl) - 'tpl' => 0, - // Set this to 1 if module has its own barcode directory (core/modules/barcode) - 'barcode' => 0, - // Set this to 1 if module has its own models directory (core/modules/xxx) - 'models' => 0, - // Set this to 1 if module has its own theme directory (theme) - 'theme' => 0, - // Set this to relative path of css file if module has its own css file - 'css' => array( - // '/mrp/css/mrp.css.php', - ), - // Set this to relative path of js file if module must load a js on all pages - 'js' => array( - // '/mrp/js/mrp.js.php', - ), - // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all' - 'hooks' => array( - // 'data' => array( - // 'hookcontext1', - // 'hookcontext2', - // ), - // 'entity' => '0', - ), - // Set this to 1 if features of module are opened to external users - 'moduleforexternal' => 0, - ); - // Data directories to create when module is enabled. - // Example: this->dirs = array("/mrp/temp","/mrp/subdir"); - $this->dirs = array("/mrp/temp"); - // Config pages. Put here list of php page, stored into mrp/admin directory, to use to setup module. - $this->config_page_url = array("mrp.php"); - // Dependencies - // A condition to hide module - $this->hidden = false; - // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) - $this->depends = array('modBom'); - $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) - $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) - $this->langfiles = array("mrp"); - $this->phpmin = array(5, 5); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(8, 0); // Minimum version of Dolibarr required by module - $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - //$this->automatic_activation = array('FR'=>'MrpWasAutomaticallyActivatedBecauseOfYourCountryChoice'); - //$this->always_enabled = true; // If true, can't be disabled - - // Constants - // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) - // Example: $this->const=array(1 => array('MRP_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), - // 2 => array('MRP_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) - // ); - $this->const = array( - 1=>array('MRP_MO_ADDON_PDF', 'chaine', 'alpha', 'Name of PDF model of MO', 0), - 2=>array('MRP_MO_ADDON', 'chaine', 'mod_mo_standard', 'Name of numbering rules of MO', 0), - 3=>array('MRP_MO_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/mrps', '', 0) - ); - - // Some keys to add into the overwriting translation tables - /*$this->overwrite_translation = array( + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs, $conf; + $this->db = $db; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 660; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'mrp'; + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' + // It is used to group modules by family in module setup page + $this->family = "products"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '62'; + // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); + // Module label (no space allowed), used if translation string 'ModuleMrpName' not found (Mrp is name of module). + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleMrpDesc' not found (Mrp is name of module). + $this->description = "Module to Manage Manufacturing Orders (MO)"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = "Module to Manage Manufacturing Orders (MO)"; + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = 'dolibarr'; + // Url to the file with your last numberversion of this module + //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; + + // Key used in llx_const table to save module status enabled/disabled (where MRP is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto = 'mrp'; + // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) + $this->module_parts = array( + // Set this to 1 if module has its own trigger directory (core/triggers) + 'triggers' => 0, + // Set this to 1 if module has its own login method file (core/login) + 'login' => 0, + // Set this to 1 if module has its own substitution function file (core/substitutions) + 'substitutions' => 0, + // Set this to 1 if module has its own menus handler directory (core/menus) + 'menus' => 0, + // Set this to 1 if module overwrite template dir (core/tpl) + 'tpl' => 0, + // Set this to 1 if module has its own barcode directory (core/modules/barcode) + 'barcode' => 0, + // Set this to 1 if module has its own models directory (core/modules/xxx) + 'models' => 0, + // Set this to 1 if module has its own theme directory (theme) + 'theme' => 0, + // Set this to relative path of css file if module has its own css file + 'css' => array( + // '/mrp/css/mrp.css.php', + ), + // Set this to relative path of js file if module must load a js on all pages + 'js' => array( + // '/mrp/js/mrp.js.php', + ), + // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all' + 'hooks' => array( + // 'data' => array( + // 'hookcontext1', + // 'hookcontext2', + // ), + // 'entity' => '0', + ), + // Set this to 1 if features of module are opened to external users + 'moduleforexternal' => 0, + ); + // Data directories to create when module is enabled. + // Example: this->dirs = array("/mrp/temp","/mrp/subdir"); + $this->dirs = array("/mrp/temp"); + // Config pages. Put here list of php page, stored into mrp/admin directory, to use to setup module. + $this->config_page_url = array("mrp.php"); + // Dependencies + // A condition to hide module + $this->hidden = false; + // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) + $this->depends = array('modBom'); + $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + $this->langfiles = array("mrp"); + $this->phpmin = array(5, 5); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(8, 0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + //$this->automatic_activation = array('FR'=>'MrpWasAutomaticallyActivatedBecauseOfYourCountryChoice'); + //$this->always_enabled = true; // If true, can't be disabled + + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(1 => array('MRP_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), + // 2 => array('MRP_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) + // ); + $this->const = array( + 1=>array('MRP_MO_ADDON_PDF', 'chaine', 'alpha', 'Name of PDF model of MO', 0), + 2=>array('MRP_MO_ADDON', 'chaine', 'mod_mo_standard', 'Name of numbering rules of MO', 0), + 3=>array('MRP_MO_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/mrps', '', 0) + ); + + // Some keys to add into the overwriting translation tables + /*$this->overwrite_translation = array( 'en_US:ParentCompany'=>'Parent company or reseller', 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' )*/ - if (!isset($conf->mrp) || !isset($conf->mrp->enabled)) { - $conf->mrp = new stdClass(); - $conf->mrp->enabled = 0; - } - - // Array to add new pages in new tabs - $this->tabs = array(); - // Example: - // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mrp:$user->rights->mrp->read:/mrp/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 - // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mrp:$user->rights->othermodule->read:/mrp/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. - // $this->tabs[] = array('data'=>'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) - // 'contact' to add a tab in contact view - // 'contract' to add a tab in contract view - // 'group' to add a tab in group view - // 'intervention' to add a tab in intervention view - // 'invoice' to add a tab in customer invoice view - // 'invoice_supplier' to add a tab in supplier invoice view - // 'member' to add a tab in fundation member view - // 'opensurveypoll' to add a tab in opensurvey poll view - // 'order' to add a tab in customer order view - // 'order_supplier' to add a tab in supplier order view - // 'payment' to add a tab in payment view - // 'payment_supplier' to add a tab in supplier payment view - // 'product' to add a tab in product view - // 'propal' to add a tab in propal view - // 'project' to add a tab in project view - // 'stock' to add a tab in stock view - // 'thirdparty' to add a tab in third party view - // 'user' to add a tab in user view - - // Dictionaries - $this->dictionaries = array(); - /* Example: + if (!isset($conf->mrp) || !isset($conf->mrp->enabled)) { + $conf->mrp = new stdClass(); + $conf->mrp->enabled = 0; + } + + // Array to add new pages in new tabs + $this->tabs = array(); + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mrp:$user->rights->mrp->read:/mrp/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mrp:$user->rights->othermodule->read:/mrp/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'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) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view + + // Dictionaries + $this->dictionaries = array(); + /* Example: $this->dictionaries=array( 'langs'=>'mylangfile@mrp', // List of tables we want to see into dictonnary editor @@ -205,68 +205,68 @@ ); */ - // Boxes/Widgets - // Add here list of php file(s) stored in mrp/core/boxes that contains a class to show a widget. - $this->boxes = array( - 0 => array('file' => 'box_mos.php', 'note' => '', 'enabledbydefaulton' => 'Home') - ); - - // Cronjobs (List of cron jobs entries to add when module is enabled) - // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week - $this->cronjobs = array( - // 0 => array( - // 'label' => 'MyJob label', - // 'jobtype' => 'method', - // 'class' => '/mrp/class/mo.class.php', - // 'objectname' => 'Mo', - // 'method' => 'doScheduledJob', - // 'parameters' => '', - // 'comment' => 'Comment', - // 'frequency' => 2, - // 'unitfrequency' => 3600, - // 'status' => 0, - // 'test' => '$conf->mrp->enabled', - // 'priority' => 50, - // ), - ); - // Example: $this->cronjobs=array( - // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50) - // ); - - // Permissions provided by this module - $this->rights = array(); - $r = 0; - // Add here entries to declare new permissions - /* BEGIN MODULEBUILDER PERMISSIONS */ - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read Manufacturing Order'; // Permission label - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) - $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/Update Manufacturing Order'; // Permission label - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) - $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Delete Manufacturing Order'; // Permission label - $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) - $r++; - /* END MODULEBUILDER PERMISSIONS */ - - // Main menu entries to add - $this->menu = array(); - $r = 0; - // Add here entries to declare new menus - /* BEGIN MODULEBUILDER TOPMENU */ + // Boxes/Widgets + // Add here list of php file(s) stored in mrp/core/boxes that contains a class to show a widget. + $this->boxes = array( + 0 => array('file' => 'box_mos.php', 'note' => '', 'enabledbydefaulton' => 'Home') + ); + + // Cronjobs (List of cron jobs entries to add when module is enabled) + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week + $this->cronjobs = array( + // 0 => array( + // 'label' => 'MyJob label', + // 'jobtype' => 'method', + // 'class' => '/mrp/class/mo.class.php', + // 'objectname' => 'Mo', + // 'method' => 'doScheduledJob', + // 'parameters' => '', + // 'comment' => 'Comment', + // 'frequency' => 2, + // 'unitfrequency' => 3600, + // 'status' => 0, + // 'test' => '$conf->mrp->enabled', + // 'priority' => 50, + // ), + ); + // Example: $this->cronjobs=array( + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50) + // ); + + // Permissions provided by this module + $this->rights = array(); + $r = 0; + // Add here entries to declare new permissions + /* BEGIN MODULEBUILDER PERMISSIONS */ + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read Manufacturing Order'; // Permission label + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Create/Update Manufacturing Order'; // Permission label + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Delete Manufacturing Order'; // Permission label + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $r++; + /* END MODULEBUILDER PERMISSIONS */ + + // Main menu entries to add + $this->menu = array(); + $r = 0; + // Add here entries to declare new menus + /* BEGIN MODULEBUILDER TOPMENU */ /* END MODULEBUILDER LEFTMENU MO */ - // Exports profiles provided by this module - $r = 1; - /* BEGIN MODULEBUILDER EXPORT MO */ - /* + // Exports profiles provided by this module + $r = 1; + /* BEGIN MODULEBUILDER EXPORT MO */ + /* $langs->load("mrp"); $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]='MoLines'; // Translation key (used only if key ExportDataset_xxx_z not found) @@ -281,12 +281,12 @@ $this->export_sql_end[$r] .=' WHERE 1 = 1'; $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')'; $r++; */ - /* END MODULEBUILDER EXPORT MO */ - - // Imports profiles provided by this module - $r = 1; - /* BEGIN MODULEBUILDER IMPORT MO */ - /* + /* END MODULEBUILDER EXPORT MO */ + + // Imports profiles provided by this module + $r = 1; + /* BEGIN MODULEBUILDER IMPORT MO */ + /* $langs->load("mrp"); $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]='MoLines'; // Translation key (used only if key ExportDataset_xxx_z not found) @@ -301,75 +301,75 @@ $this->export_sql_end[$r] .=' WHERE 1 = 1'; $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')'; $r++; */ - /* END MODULEBUILDER IMPORT MO */ - } - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - global $conf, $langs; - - $result = $this->_load_tables('/mrp/sql/'); - if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') - - // Create extrafields during init - //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - //$extrafields = new ExtraFields($this->db); - //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); - //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); - //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); - //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); - //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); - - // Permissions - $this->remove($options); - - $sql = array(); - - // ODT template - $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mrps/template_mo.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/mrps'; - $dest = $dirodt.'/template_mo.odt'; - - if (file_exists($src) && !file_exists($dest)) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_mkdir($dirodt); - $result = dol_copy($src, $dest, 0, 0); - if ($result < 0) - { - $langs->load("errors"); - $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); - return 0; - } - } - - $sql = array( - //"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'mo' AND entity = ".$conf->entity, - //"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'mo', ".$conf->entity.")" - ); - - return $this->_init($sql, $options); - } - - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function remove($options = '') - { - $sql = array(); - return $this->_remove($sql, $options); - } + /* END MODULEBUILDER IMPORT MO */ + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $conf, $langs; + + $result = $this->_load_tables('/mrp/sql/'); + if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') + + // Create extrafields during init + //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + //$extrafields = new ExtraFields($this->db); + //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + + // Permissions + $this->remove($options); + + $sql = array(); + + // ODT template + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mrps/template_mo.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/mrps'; + $dest = $dirodt.'/template_mo.odt'; + + if (file_exists($src) && !file_exists($dest)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result = dol_copy($src, $dest, 0, 0); + if ($result < 0) + { + $langs->load("errors"); + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); + return 0; + } + } + + $sql = array( + //"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'mo' AND entity = ".$conf->entity, + //"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'mo', ".$conf->entity.")" + ); + + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + $sql = array(); + return $this->_remove($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modMultiCurrency.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modMultiCurrency.class.php @@ -38,11 +38,11 @@ * * @param DoliDB $db Database handler */ - public function __construct($db) - { - global $langs, $conf; - - $this->db = $db; + public function __construct($db) + { + global $langs, $conf; + + $this->db = $db; // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). @@ -101,8 +101,8 @@ // Array to add new pages in new tabs // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@multicurrency:$user->rights->multicurrency->read:/multicurrency/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 - // 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@multicurrency:$user->rights->othermodule->read:/multicurrency/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. - // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@multicurrency:$user->rights->othermodule->read:/multicurrency/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // '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) // 'contact' to add a tab in contact view @@ -123,16 +123,16 @@ // 'stock' to add a tab in stock view // 'thirdparty' to add a tab in third party view // 'user' to add a tab in user view - $this->tabs = array(); - - // Dictionaries - if (!isset($conf->multicurrency->enabled)) - { - $conf->multicurrency = new stdClass(); - $conf->multicurrency->enabled = 0; - } + $this->tabs = array(); + + // Dictionaries + if (!isset($conf->multicurrency->enabled)) + { + $conf->multicurrency = new stdClass(); + $conf->multicurrency->enabled = 0; + } $this->dictionaries = array(); - /* Example: + /* Example: if (! isset($conf->multicurrency->enabled)) $conf->multicurrency->enabled=0; // This is to avoid warnings $this->dictionaries=array( 'langs'=>'mylangfile@multicurrency', @@ -149,9 +149,9 @@ ); */ - // Boxes + // Boxes // Add here list of php file(s) stored in core/boxes that contains class to show a box. - $this->boxes = array(); // List of boxes + $this->boxes = array(); // List of boxes // Example: //$this->boxes=array( // 0=>array('file'=>'myboxa.php@multicurrency','note'=>'','enabledbydefaulton'=>'Home'), @@ -215,8 +215,8 @@ // Example: // $this->export_code[$r]=$this->rights_class.'_'.$r; // $this->export_label[$r]='MyModule'; // Translation key (used only if key ExportDataset_xxx_z not found) - // $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled. - // $this->export_icon[$r]='generic:MyModule'; + // $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled. + // $this->export_icon[$r]='generic:MyModule'; // $this->export_permission[$r]=array(array("multicurrency","level1","level2")); // $this->export_fields_array[$r]=array( // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', @@ -259,7 +259,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modNotification.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modNotification.class.php @@ -49,9 +49,9 @@ // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "EMail notifications (push) on business Dolibarr events"; - $this->descriptionlong = 'Module600Long'; + $this->descriptionlong = 'Module600Long'; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto = 'email'; @@ -86,7 +86,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modOauth.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modOauth.class.php @@ -35,110 +35,110 @@ class modOauth extends DolibarrModules { - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - $this->numero = 66000; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page - $this->family = "interface"; - $this->module_position = '31'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "Enable OAuth authentication"; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version - $this->version = 'dolibarr'; - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto = 'technic'; + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + $this->numero = 66000; + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "interface"; + $this->module_position = '31'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "Enable OAuth authentication"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version + $this->version = 'dolibarr'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto = 'technic'; - // Data directories to create when module is enabled. - $this->dirs = array(); + // Data directories to create when module is enabled. + $this->dirs = array(); - // Config pages - $this->config_page_url = array("oauth.php"); + // Config pages + $this->config_page_url = array("oauth.php"); - // Dependencies - $this->hidden = false; // A condition to hide module + // Dependencies + $this->hidden = false; // A condition to hide module $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(5, 4); // Minimum version of PHP required by module // Minimum version of PHP required by module - $this->need_dolibarr_version = array(3, 7, -2); // Minimum version of Dolibarr required by module - $this->conflictwith = array(); - $this->langfiles = array("oauth"); + $this->need_dolibarr_version = array(3, 7, -2); // Minimum version of Dolibarr required by module + $this->conflictwith = array(); + $this->langfiles = array("oauth"); - // Constants - $this->const = array(); + // Constants + $this->const = array(); - // Boxes - $this->boxes = array(); + // Boxes + $this->boxes = array(); - // Permissions - $this->rights = array(); - $this->rights_class = 'oauth'; + // Permissions + $this->rights = array(); + $this->rights_class = 'oauth'; - $r = 0; - // $this->rights[$r][0] Id permission (unique tous modules confondus) - // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) - // $this->rights[$r][2] Non utilise - // $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut - // $this->rights[$r][4] Niveau 1 pour nommer permission dans code - // $this->rights[$r][5] Niveau 2 pour nommer permission dans code + $r = 0; + // $this->rights[$r][0] Id permission (unique tous modules confondus) + // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) + // $this->rights[$r][2] Non utilise + // $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut + // $this->rights[$r][4] Niveau 1 pour nommer permission dans code + // $this->rights[$r][5] Niveau 2 pour nommer permission dans code - /*$r++; + /*$r++; $this->rights[$r][0] = 66000; $this->rights[$r][1] = 'OauthAccess'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read';*/ - // Main menu entries - $this->menus = array(); // List of menus to add - $r = 0; + // Main menu entries + $this->menus = array(); // List of menus to add + $r = 0; - // This is to declare the Top Menu entry: - //$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu - // 'type'=>'left', // This is a Top menu entry - // 'titre'=>'MenuOauth', - // 'mainmenu'=>'oauth', - // 'url'=>'/oauth/index.php', - // 'langs'=>'oauth', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - // 'position'=>300, - // 'enabled'=>'$conf->oauth->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', - // 'perms'=>'$user->rights->oauth->read', // Use 'perms'=>'1' if you want your menu with no permission rules - // 'target'=>'', - // 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both + // This is to declare the Top Menu entry: + //$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu + // 'type'=>'left', // This is a Top menu entry + // 'titre'=>'MenuOauth', + // 'mainmenu'=>'oauth', + // 'url'=>'/oauth/index.php', + // 'langs'=>'oauth', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>300, + // 'enabled'=>'$conf->oauth->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', + // 'perms'=>'$user->rights->oauth->read', // Use 'perms'=>'1' if you want your menu with no permission rules + // 'target'=>'', + // 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both - //$r++; - } + //$r++; + } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - global $conf; + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $conf; - // Clean before activation - $this->remove($options); + // Clean before activation + $this->remove($options); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modOpenSurvey.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modOpenSurvey.class.php @@ -37,8 +37,8 @@ * * @param DoliDB $db Database handler */ - public function __construct($db) - { + public function __construct($db) + { global $langs, $conf; $this->db = $db; @@ -64,7 +64,7 @@ // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto = 'poll'; + $this->picto = '^date@opensurvey'; // Data directories to create when module is enabled $this->dirs = array(); @@ -83,7 +83,7 @@ $this->const = array(); // List of parameters // Dictionaries - $this->dictionaries = array(); + $this->dictionaries = array(); // Boxes $this->boxes = array(); // List of boxes @@ -119,73 +119,73 @@ $r++; - // Menus - //------- - $r = 0; - $this->menu[$r] = array( - 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', - 'titre'=>'Survey', - 'mainmenu'=>'tools', - 'leftmenu'=>'opensurvey', - 'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey', - 'langs'=>'opensurvey', - 'position'=>200, - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->opensurvey->read', - 'target'=>'', - 'user'=>0, - ); - $r++; + // Menus + //------- + $r = 0; + $this->menu[$r] = array( + 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', + 'titre'=>'Survey', + 'mainmenu'=>'tools', + 'leftmenu'=>'opensurvey', + 'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey', + 'langs'=>'opensurvey', + 'position'=>200, + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->opensurvey->read', + 'target'=>'', + 'user'=>0, + ); + $r++; - $this->menu[$r] = array( - 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', - 'titre'=>'NewSurvey', - 'mainmenu'=>'tools', - 'leftmenu'=>'opensurvey_new', - 'url'=>'/opensurvey/wizard/index.php', - 'langs'=>'opensurvey', - 'position'=>210, - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->opensurvey->write', - 'target'=>'', - 'user'=>0, - ); - $r++; + $this->menu[$r] = array( + 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', + 'titre'=>'NewSurvey', + 'mainmenu'=>'tools', + 'leftmenu'=>'opensurvey_new', + 'url'=>'/opensurvey/wizard/index.php', + 'langs'=>'opensurvey', + 'position'=>210, + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->opensurvey->write', + 'target'=>'', + 'user'=>0, + ); + $r++; - $this->menu[$r] = array( - 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', - 'titre'=>'List', - 'mainmenu'=>'tools', - 'leftmenu'=>'opensurvey_list', - 'url'=>'/opensurvey/list.php', - 'langs'=>'opensurvey', - 'position'=>220, - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->opensurvey->read', - 'target'=>'', - 'user'=>0, - ); - $r++; - } + $this->menu[$r] = array( + 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', + 'titre'=>'List', + 'mainmenu'=>'tools', + 'leftmenu'=>'opensurvey_list', + 'url'=>'/opensurvey/list.php', + 'langs'=>'opensurvey', + 'position'=>220, + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->opensurvey->read', + 'target'=>'', + 'user'=>0, + ); + $r++; + } /** * Function called when module is enabled. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - public function init($options = '') - { - // Permissions - $this->remove($options); + public function init($options = '') + { + // Permissions + $this->remove($options); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modPaybox.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modPaybox.class.php @@ -31,161 +31,161 @@ */ class modPayBox extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 50000; - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'paybox'; + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 50000; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'paybox'; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page - $this->family = "interface"; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "Module to offer an online payment page by credit card with PayBox"; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png' - $this->picto = 'paybox@paybox'; + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "interface"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "Module to offer an online payment page by credit card with PayBox"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png' + $this->picto = 'paybox@paybox'; - // Data directories to create when module is enabled. - $this->dirs = array('/paybox/temp'); + // Data directories to create when module is enabled. + $this->dirs = array('/paybox/temp'); - // Config pages. Put here list of php page names stored in admmin directory used to setup module. - $this->config_page_url = array("paybox.php@paybox"); + // Config pages. Put here list of php page names stored in admmin directory used to setup module. + $this->config_page_url = array("paybox.php@paybox"); - // Dependencies - $this->hidden = false; // A condition to hide module + // Dependencies + $this->hidden = false; // A condition to hide module $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(5, 4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(2, 6); // Minimum version of Dolibarr required by module - $this->langfiles = array("paybox"); + $this->need_dolibarr_version = array(2, 6); // Minimum version of Dolibarr required by module + $this->langfiles = array("paybox"); - // Constants - $this->const = array(); // List of particular constants to add when module is enabled - //Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0), - // 1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) ); + // Constants + $this->const = array(); // List of particular constants to add when module is enabled + //Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0), + // 1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) ); - // New pages on tabs - $this->tabs = array(); + // New pages on tabs + $this->tabs = array(); - // Boxes - $this->boxes = array(); // List of boxes - $r = 0; + // Boxes + $this->boxes = array(); // List of boxes + $r = 0; - // Add here list of php file(s) stored in core/boxes that contains class to show a box. - // Example: - //$this->boxes[$r][1] = "myboxa.php"; - //$r++; - //$this->boxes[$r][1] = "myboxb.php"; - //$r++; + // Add here list of php file(s) stored in core/boxes that contains class to show a box. + // Example: + //$this->boxes[$r][1] = "myboxa.php"; + //$r++; + //$this->boxes[$r][1] = "myboxb.php"; + //$r++; - // Permissions - $this->rights = array(); // Permission array used by this module - $r = 0; + // Permissions + $this->rights = array(); // Permission array used by this module + $r = 0; - // Add here list of permission defined by an id, a label, a boolean and two constant strings. - // Example: - // $this->rights[$r][0] = 2000; // Permission id (must not be already used) - // $this->rights[$r][1] = 'Permision label'; // Permission label - // $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - // $r++; + // Add here list of permission defined by an id, a label, a boolean and two constant strings. + // Example: + // $this->rights[$r][0] = 2000; // Permission id (must not be already used) + // $this->rights[$r][1] = 'Permision label'; // Permission label + // $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + // $r++; - // Main menu entries - $this->menus = array(); // List of menus to add - $r = 0; + // Main menu entries + $this->menus = array(); // List of menus to add + $r = 0; - // Add here entries to declare new menus - // Example to declare the Top Menu entry: - // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu - // 'type'=>'top', // This is a Top menu entry - // 'titre'=>'MyModule top menu', - // 'mainmenu'=>'mymodule', - // 'url'=>'/mymodule/pagetop.php', - // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - // 'position'=>100, - // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - // 'target'=>'', - // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - // $r++; - // - // Example to declare a Left Menu entry: - // $this->menu[$r]=array( 'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) - // 'type'=>'left', // This is a Left menu entry - // 'titre'=>'MyModule left menu 1', - // 'mainmenu'=>'mymodule', - // 'url'=>'/mymodule/pagelevel1.php', - // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - // 'position'=>100, - // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - // 'target'=>'', - // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - // $r++; - // - // Example to declare another Left Menu entry: - // $this->menu[$r]=array( 'fk_menu'=>'r=1', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) - // 'type'=>'left', // This is a Left menu entry - // 'titre'=>'MyModule left menu 2', - // 'mainmenu'=>'mymodule', - // 'url'=>'/mymodule/pagelevel2.php', - // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - // 'position'=>100, - // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - // 'target'=>'', - // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - // $r++; + // Add here entries to declare new menus + // Example to declare the Top Menu entry: + // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu + // 'type'=>'top', // This is a Top menu entry + // 'titre'=>'MyModule top menu', + // 'mainmenu'=>'mymodule', + // 'url'=>'/mymodule/pagetop.php', + // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + // + // Example to declare a Left Menu entry: + // $this->menu[$r]=array( 'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) + // 'type'=>'left', // This is a Left menu entry + // 'titre'=>'MyModule left menu 1', + // 'mainmenu'=>'mymodule', + // 'url'=>'/mymodule/pagelevel1.php', + // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + // + // Example to declare another Left Menu entry: + // $this->menu[$r]=array( 'fk_menu'=>'r=1', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) + // 'type'=>'left', // This is a Left menu entry + // 'titre'=>'MyModule left menu 2', + // 'mainmenu'=>'mymodule', + // 'url'=>'/mymodule/pagelevel2.php', + // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; - // Exports - $r = 1; + // Exports + $r = 1; - // Example: - // $this->export_code[$r]=$this->rights_class.'_'.$r; - // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - // $this->export_permission[$r]=array(array("facture","facture","export")); - // $this->export_fields_array[$r]=array( - // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town', - // 's.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3', - // 's.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode', - // 'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT", - // 'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId', - // 'fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT", - // 'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef', - // ); - // $this->export_entities_array[$r]=array( - // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company', - // 's.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company', - // 's.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice", - // 'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice', - // 'f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line", - // 'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line", - // 'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product', - // ); - // $this->export_sql_start[$r]='SELECT DISTINCT '; - // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; - // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; - // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; - // $r++; - } + // Example: + // $this->export_code[$r]=$this->rights_class.'_'.$r; + // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + // $this->export_permission[$r]=array(array("facture","facture","export")); + // $this->export_fields_array[$r]=array( + // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town', + // 's.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3', + // 's.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode', + // 'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT", + // 'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId', + // 'fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT", + // 'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef', + // ); + // $this->export_entities_array[$r]=array( + // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company', + // 's.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company', + // 's.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice", + // 'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice', + // 'f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line", + // 'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line", + // 'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product', + // ); + // $this->export_sql_start[$r]='SELECT DISTINCT '; + // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; + // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; + // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; + // $r++; + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modPaymentByBankTransfer.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modPaymentByBankTransfer.class.php @@ -54,7 +54,7 @@ $this->description = "Management of payment by bank transfer"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; + $this->version = 'development'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of png file (without png) used for this module @@ -120,29 +120,29 @@ $this->rights[$r][3] = 0; $this->rights[$r][4] = 'debit'; - // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. - } + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - global $conf; + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $conf; - // Permissions - $this->remove($options); + // Permissions + $this->remove($options); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modPaypal.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modPaypal.class.php @@ -32,82 +32,82 @@ */ class modPaypal extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 50200; - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'paypal'; + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 50200; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'paypal'; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page - $this->family = "interface"; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "Module to offer an online payment page with PayPal"; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png' - $this->picto = 'paypal@paypal'; + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "interface"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "Module to offer an online payment page with PayPal"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png' + $this->picto = 'paypal@paypal'; - // Data directories to create when module is enabled. - $this->dirs = array('/paypal/temp'); + // Data directories to create when module is enabled. + $this->dirs = array('/paypal/temp'); - // Config pages. Put here list of php page names stored in admmin directory used to setup module. - $this->config_page_url = array("paypal.php@paypal"); + // Config pages. Put here list of php page names stored in admmin directory used to setup module. + $this->config_page_url = array("paypal.php@paypal"); - // Dependencies - $this->hidden = false; // A condition to hide module + // Dependencies + $this->hidden = false; // A condition to hide module $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled $this->requiredby = array('modPaypalPlus'); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(5, 4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module - $this->langfiles = array("paypal"); + $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module + $this->langfiles = array("paypal"); - // Constants - $this->const = array(); // List of particular constants to add when module is enabled - //Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0), - // 1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) ); + // Constants + $this->const = array(); // List of particular constants to add when module is enabled + //Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0), + // 1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) ); - // New pages on tabs - $this->tabs = array(); + // New pages on tabs + $this->tabs = array(); - // Boxes - $this->boxes = array(); // List of boxes - $r = 0; + // Boxes + $this->boxes = array(); // List of boxes + $r = 0; - // Add here list of php file(s) stored in core/boxes that contains class to show a box. - // Example: - //$this->boxes[$r][1] = "myboxa.php"; - //$r++; - //$this->boxes[$r][1] = "myboxb.php"; - //$r++; + // Add here list of php file(s) stored in core/boxes that contains class to show a box. + // Example: + //$this->boxes[$r][1] = "myboxa.php"; + //$r++; + //$this->boxes[$r][1] = "myboxb.php"; + //$r++; - // Permissions - $this->rights = array(); // Permission array used by this module - $r = 0; + // Permissions + $this->rights = array(); // Permission array used by this module + $r = 0; - // Main menu entries - $this->menus = array(); // List of menus to add - $r = 0; - /*$this->menu[$r]=array( + // Main menu entries + $this->menus = array(); // List of menus to add + $r = 0; + /*$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'mainmenu'=>'billing', 'leftmenu'=>'customers_bills_payment_paypal', @@ -123,75 +123,75 @@ ); // 0=Menu for internal users, 1=external users, 2=both $r++;*/ - // Add here entries to declare new menus - // Example to declare the Top Menu entry: - // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu - // 'type'=>'top', // This is a Top menu entry - // 'titre'=>'MyModule top menu', - // 'mainmenu'=>'mymodule', - // 'url'=>'/mymodule/pagetop.php', - // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - // 'position'=>100, - // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - // 'target'=>'', - // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - // $r++; - // - // Example to declare a Left Menu entry: - // $this->menu[$r]=array( 'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) - // 'type'=>'left', // This is a Left menu entry - // 'titre'=>'MyModule left menu 1', - // 'mainmenu'=>'mymodule', - // 'url'=>'/mymodule/pagelevel1.php', - // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - // 'position'=>100, - // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - // 'target'=>'', - // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - // $r++; - // - // Example to declare another Left Menu entry: - // $this->menu[$r]=array( 'fk_menu'=>'r=1', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) - // 'type'=>'left', // This is a Left menu entry - // 'titre'=>'MyModule left menu 2', - // 'mainmenu'=>'mymodule', - // 'url'=>'/mymodule/pagelevel2.php', - // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - // 'position'=>100, - // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - // 'target'=>'', - // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - // $r++; + // Add here entries to declare new menus + // Example to declare the Top Menu entry: + // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu + // 'type'=>'top', // This is a Top menu entry + // 'titre'=>'MyModule top menu', + // 'mainmenu'=>'mymodule', + // 'url'=>'/mymodule/pagetop.php', + // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + // + // Example to declare a Left Menu entry: + // $this->menu[$r]=array( 'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) + // 'type'=>'left', // This is a Left menu entry + // 'titre'=>'MyModule left menu 1', + // 'mainmenu'=>'mymodule', + // 'url'=>'/mymodule/pagelevel1.php', + // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + // + // Example to declare another Left Menu entry: + // $this->menu[$r]=array( 'fk_menu'=>'r=1', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) + // 'type'=>'left', // This is a Left menu entry + // 'titre'=>'MyModule left menu 2', + // 'mainmenu'=>'mymodule', + // 'url'=>'/mymodule/pagelevel2.php', + // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; - // Exports - $r = 1; + // Exports + $r = 1; - // Example: - // $this->export_code[$r]=$this->rights_class.'_'.$r; - // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - // $this->export_permission[$r]=array(array("facture","facture","export")); - // $this->export_fields_array[$r]=array( - // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', - // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', - // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", - // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', - // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate", - // 'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart", - // 'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' - // ); - // $this->export_entities_array[$r]=array( - // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', - // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice", - // 'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line", - // 'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line", - // 'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' - // ); - // $this->export_sql_start[$r]='SELECT DISTINCT '; - // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; - // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; - // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; - // $r++; - } + // Example: + // $this->export_code[$r]=$this->rights_class.'_'.$r; + // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + // $this->export_permission[$r]=array(array("facture","facture","export")); + // $this->export_fields_array[$r]=array( + // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', + // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', + // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", + // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', + // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate", + // 'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart", + // 'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' + // ); + // $this->export_entities_array[$r]=array( + // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', + // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', + // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice", + // 'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line", + // 'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line", + // 'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' + // ); + // $this->export_sql_start[$r]='SELECT DISTINCT '; + // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; + // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; + // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; + // $r++; + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modPrelevement.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modPrelevement.class.php @@ -123,32 +123,32 @@ $this->rights[$r][4] = 'bons'; $this->rights[$r][5] = 'credit'; - // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. - } + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - global $conf; + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $conf; - // Permissions - $this->remove($options); + // Permissions + $this->remove($options); - $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")", - ); + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")", + ); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modPrinting.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modPrinting.class.php @@ -35,87 +35,87 @@ class modPrinting extends DolibarrModules { - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - $this->numero = 64000; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page - $this->family = "interface"; - $this->module_position = '52'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "Enable Direct Printing System."; - $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto = 'printer'; + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + $this->numero = 64000; + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "interface"; + $this->module_position = '52'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "Enable Direct Printing System."; + $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto = 'printer'; - // Data directories to create when module is enabled. - $this->dirs = array(); + // Data directories to create when module is enabled. + $this->dirs = array(); - // Config pages - $this->config_page_url = array("printing.php@printing"); + // Config pages + $this->config_page_url = array("printing.php@printing"); - // Dependencies - $this->hidden = false; // A condition to hide module + // Dependencies + $this->hidden = false; // A condition to hide module $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(5, 4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(3, 7, -2); // Minimum version of Dolibarr required by module - $this->conflictwith = array(); - $this->langfiles = array("printing"); + $this->need_dolibarr_version = array(3, 7, -2); // Minimum version of Dolibarr required by module + $this->conflictwith = array(); + $this->langfiles = array("printing"); - // Constants - $this->const = array(); + // Constants + $this->const = array(); - // Boxes - $this->boxes = array(); + // Boxes + $this->boxes = array(); - // Permissions - $this->rights = array(); - $this->rights_class = 'printing'; + // Permissions + $this->rights = array(); + $this->rights_class = 'printing'; - $r = 0; - // $this->rights[$r][0] Id permission (unique tous modules confondus) - // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) - // $this->rights[$r][2] Non utilise - // $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut - // $this->rights[$r][4] Niveau 1 pour nommer permission dans code - // $this->rights[$r][5] Niveau 2 pour nommer permission dans code + $r = 0; + // $this->rights[$r][0] Id permission (unique tous modules confondus) + // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) + // $this->rights[$r][2] Non utilise + // $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut + // $this->rights[$r][4] Niveau 1 pour nommer permission dans code + // $this->rights[$r][5] Niveau 2 pour nommer permission dans code - $r++; - $this->rights[$r][0] = 64001; - $this->rights[$r][1] = 'DirectPrint'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'read'; + $r++; + $this->rights[$r][0] = 64001; + $this->rights[$r][1] = 'DirectPrint'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'read'; - // Main menu entries - $this->menus = array(); // List of menus to add - $r = 0; + // Main menu entries + $this->menus = array(); // List of menus to add + $r = 0; - // This is to declare the Top Menu entry: - $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu - 'type'=>'left', // This is a Top menu entry - 'titre'=>'MenuDirectPrinting', - 'url'=>'/printing/index.php?mainmenu=home&leftmenu=admintools', - 'langs'=>'printing', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>300, - 'enabled'=>'$conf->printing->enabled && preg_match(\'/^(admintools|all)/\', $leftmenu)', - 'perms'=>'$user->rights->printing->read', // Use 'perms'=>'1' if you want your menu with no permission rules - 'target'=>'', - 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both + // This is to declare the Top Menu entry: + $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu + 'type'=>'left', // This is a Top menu entry + 'titre'=>'MenuDirectPrinting', + 'url'=>'/printing/index.php?mainmenu=home&leftmenu=admintools', + 'langs'=>'printing', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>300, + 'enabled'=>'$conf->printing->enabled && preg_match(\'/^(admintools|all)/\', $leftmenu)', + 'perms'=>'$user->rights->printing->read', // Use 'perms'=>'1' if you want your menu with no permission rules + 'target'=>'', + 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both - $r++; - } + $r++; + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modProduct.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modProduct.class.php @@ -51,7 +51,7 @@ $this->numero = 50; $this->family = "products"; - $this->module_position = '26'; + $this->module_position = '25'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Product management"; @@ -132,26 +132,26 @@ $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'supprimer'; - $r++; + $r++; $this->rights[$r][0] = 38; // Must be same permission than in service module $this->rights[$r][1] = 'Export products'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'export'; - $r++; + $r++; $this->rights[$r][0] = 39; $this->rights[$r][1] = 'Ignore minimum price'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'ignore_price_min_advance'; - $r++; - - // Menus - //------- - - $this->menu = 1; // This module adds menu entries. They are coded into menu manager. + $r++; + + // Menus + //------- + + $this->menu = 1; // This module adds menu entries. They are coded into menu manager. /* We can't enable this here because it must be enabled in both product and service module and this creates duplicate inserts $r=0; $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode @@ -166,9 +166,6 @@ 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both $r++; */ - - $usenpr = 0; - if (is_object($mysoc)) $usenpr = $mysoc->useNPR(); // Exports //-------- @@ -195,9 +192,9 @@ 'p.tva_tx'=>'VATRate', 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' ); - if (is_object($mysoc) && $usenpr) $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); - if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('e.ref'=>'DefaultWarehouse', 'p.tobatch'=>'ManageLotSerial', 'p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; @@ -219,7 +216,7 @@ 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.datec'=>'Date', 'p.tms'=>'Date' ); - if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('e.ref'=>'Text', 'p.tobatch'=>'Numeric', 'p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); if (!empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric')); if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text', 'l.description'=>'Text', 'l.note'=>'Text')); @@ -242,7 +239,6 @@ if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; if (!empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; - if (!empty($conf->stock->enabled)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON e.rowid = p.fk_default_warehouse'; $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" @@ -259,7 +255,7 @@ 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation'); - if (is_object($mysoc) && $usenpr) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; //$this->export_TypeFields_array[$r]=array( // 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", // 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', @@ -281,90 +277,90 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - // Exports product multiprice - $r++; - $this->export_code[$r] = $this->rights_class.'_'.$r; - $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r] = array(array("produit", "export")); - $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", - 's.nom'=>'ThirdParty', - 'pr.price_base_type'=>"PriceBase", - 'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC", - 'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", - 'pr.tva_tx'=>'PriceVATRate', - 'pr.default_vat_code'=>'PriceVATCode', - 'pr.datec'=>'DateCreation'); - if (is_object($mysoc) && $usenpr) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; - $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", - 's.nom'=>'company', - 'pr.price_base_type'=>"product", 'pr.price'=>"product", - 'pr.price_ttc'=>"product", - 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", - 'pr.tva_tx'=>'product', - 'pr.default_vat_code'=>'product', - 'pr.recuperableonly'=>'product', - 'pr.datec'=>"product"); - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; - $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + // Exports product multiprice + $r++; + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", + 's.nom'=>'ThirdParty', + 'pr.price_base_type'=>"PriceBase", + 'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC", + 'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", + 'pr.tva_tx'=>'PriceVATRate', + 'pr.default_vat_code'=>'PriceVATCode', + 'pr.datec'=>'DateCreation'); + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; + $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", + 's.nom'=>'company', + 'pr.price_base_type'=>"product", 'pr.price'=>"product", + 'pr.price_ttc'=>"product", + 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", + 'pr.tva_tx'=>'product', + 'pr.default_vat_code'=>'product', + 'pr.recuperableonly'=>'product', + 'pr.datec'=>"product"); + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) { // Exports virtual products - $r++; - $this->export_code[$r] = $this->rights_class.'_'.$r; - $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r] = array(array("produit", "export")); - $this->export_fields_array[$r] = array( + $r++; + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array( 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", - 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", - 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', - 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode', + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", + 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode', 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' ); - if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); - if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); - $this->export_TypeFields_array[$r] = array( + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); + $this->export_TypeFields_array[$r] = array( 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", - 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", - 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", - 'p.note'=>"Text", 'p.note_public'=>"Text", - 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', + 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", + 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", + 'p.note'=>"Text", 'p.note_public'=>"Text", + 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.datec'=>'Date', 'p.tms'=>'Date' ); - if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); - if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); - $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); - $this->export_entities_array[$r] = array( + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); + $this->export_entities_array[$r] = array( 'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", 'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct', - 'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct', + 'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct', 'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct", 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", 'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct" ); - if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct')); - if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); - $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct')); - $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description")); - $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; - $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; - $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile - $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct')); + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description")); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; } // Imports @@ -381,34 +377,34 @@ $this->import_tables_array[$r] = array('p'=>MAIN_DB_PREFIX.'product', 'extra'=>MAIN_DB_PREFIX.'product_extrafields'); $this->import_tables_creator_array[$r] = array('p'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r] = array( - 'p.ref' => "Ref*", - 'p.label' => "Label*", + 'p.ref' => "Ref*", + 'p.label' => "Label*", 'p.fk_product_type' => "Type*", 'p.tosell' => "OnSell*", 'p.tobuy' => "OnBuy*", 'p.description' => "Description", 'p.url' => "PublicUrl", 'p.customcode' => 'CustomCode', - 'p.fk_country' => 'CountryCode', - 'p.accountancy_code_sell' => "ProductAccountancySellCode", - 'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode", - 'p.accountancy_code_buy' => "ProductAccountancyBuyCode", + 'p.fk_country' => 'CountryCode', + 'p.accountancy_code_sell' => "ProductAccountancySellCode", + 'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode", + 'p.accountancy_code_buy' => "ProductAccountancyBuyCode", 'p.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode", 'p.note_public' => "NotePublic", 'p.note' => "NotePrivate", 'p.weight' => "Weight", - 'p.weight_units' => "WeightUnits", - 'p.length' => "Length", + 'p.weight_units' => "WeightUnits", + 'p.length' => "Length", 'p.length_units' => "LengthUnits", - 'p.width' => "Width", + 'p.width' => "Width", 'p.width_units' => "WidthUnits", - 'p.height' => "Height", - 'p.height_units' => "HeightUnits", - 'p.surface' => "Surface", - 'p.surface_units' => "SurfaceUnits", - 'p.volume' => "Volume", + 'p.height' => "Height", + 'p.height_units' => "HeightUnits", + 'p.surface' => "Surface", + 'p.surface_units' => "SurfaceUnits", + 'p.volume' => "Volume", 'p.volume_units' => "VolumeUnits", 'p.duration' => "Duration", //duration of service 'p.finished' => 'Nature', @@ -421,10 +417,17 @@ 'p.datec' => 'DateCreation', 'p.cost_price' => "CostPrice", ); - - $this->import_convertvalue_array[$r] = array( - 'p.weight_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + if (!empty($conf->stock->enabled)) {//if Stock module enabled + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning + 'p.pmp' => 'PMPValue', //weighted average price + 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature + )); + } + + $this->import_convertvalue_array[$r] = array( + 'p.weight_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -471,141 +474,109 @@ 'units' => 'volume', 'dict' => 'DictionaryMeasuringUnits' ), - 'p.fk_country' => array( - 'rule' => 'fetchidfromcodeid', - 'classfile' => '/core/class/ccountry.class.php', - 'class' => 'Ccountry', - 'method' => 'fetch', - 'dict' => 'DictionaryCountry' - ), - 'p.finished'=> array( - 'rule' => 'fetchidfromcodeorlabel', - 'classfile' => '/core/class/cproductnature.class.php', - 'class' => 'CProductNature', - 'method' => 'fetch', - 'dict' => 'DictionaryProductNature' - ), + 'p.fk_country' => array( + 'rule' => 'fetchidfromcodeid', + 'classfile' => '/core/class/ccountry.class.php', + 'class' => 'Ccountry', + 'method' => 'fetch', + 'dict' => 'DictionaryCountry' + ) ); - $this->import_regex_array[$r] = array( - 'p.ref' => '[^ ]', - 'p.price_base_type' => '\AHT\z|\ATTC\z', - 'p.tosell' => '^[0|1]$', - 'p.tobuy' => '^[0|1]$', - 'p.fk_product_type' => '^[0|1]$', - 'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', - 'p.recuperableonly' => '^[0|1]$', - ); - - if (!empty($conf->stock->enabled)) {//if Stock module enabled - $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( - 'p.fk_default_warehouse'=>'DefaultWarehouse', - 'p.tobatch'=>'ManageLotSerial', - 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning - 'p.pmp' => 'PMPValue', //weighted average price - 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature - )); - - $this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array( - 'p.tobatch' => '^[0|1]$' - )); - - $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( - 'p.fk_default_warehouse' => array( - 'rule' => 'fetchidfromref', - 'classfile' => '/product/stock/class/entrepot.class.php', - 'class' => 'Entrepot', - 'method' => 'fetch', - 'element'=> 'Warehouse' - ) - )); - } - if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); - if (is_object($mysoc) && $usenpr) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; - // Add extra fields $import_extrafield_sample = array(); $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { - while ($obj = $this->db->fetch_object($resql)) - { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - $import_extrafield_sample[$fieldname] = $fieldlabel; - } + while ($obj = $this->db->fetch_object($resql)) + { + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + $import_extrafield_sample[$fieldname] = $fieldlabel; + } } // End add extra fields $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_regex_array[$r] = array( + 'p.ref' => '[^ ]', + 'p.price_base_type' => '\AHT\z|\ATTC\z', + 'p.tosell' => '^[0|1]$', + 'p.tobuy' => '^[0|1]$', + 'p.fk_product_type' => '^[0|1]$', + 'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', + 'p.recuperableonly' => '^[0|1]$', + 'p.finished' => '^[0|1]$' + ); // field order as per structure of table llx_product $import_sample = array( - 'p.ref' => "ref:PREF123456", - 'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'), - 'p.label' => "Product name in default language", - 'p.description' => "Product description in default language", - 'p.note_public' => "a public note (free text)", - 'p.note' => "a private note (free text)", - 'p.customcode' => 'customs code', - 'p.fk_country' => 'FR', - 'p.price' => "100", + 'p.ref' => "PREF123456", + 'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'), + 'p.label' => "Product name in default language", + 'p.description' => "Product description in default language", + 'p.note_public' => "a public note (free text)", + 'p.note' => "a private note (free text)", + 'p.customcode' => 'customs code', + 'p.fk_country' => 'FR', + 'p.price' => "100", 'p.price_min' => "100", - 'p.price_ttc' => "110", + 'p.price_ttc' => "110", 'p.price_min_ttc' => "110", - 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", - 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' - 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", - 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)", - 'p.fk_product_type' => "0 (product) / 1 (service)", - 'p.duration' => "eg. 365d/12m/1y", - 'p.url' => 'link to product (no https)', - 'p.accountancy_code_sell' => "", - 'p.accountancy_code_sell_intra' => "", - 'p.accountancy_code_sell_export' => "", - 'p.accountancy_code_buy' => "", - 'p.accountancy_code_buy_intra' => "", - 'p.accountancy_code_buy_export' => "", - 'p.weight' => "", + 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", + 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' + 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", + 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)", + 'p.fk_product_type' => "0 (product) / 1 (service)", + 'p.duration' => "eg. 365d/12m/1y", + 'p.url' => 'link to product (no https)', + 'p.accountancy_code_sell' => "", + 'p.accountancy_code_sell_intra' => "", + 'p.accountancy_code_sell_export' => "", + 'p.accountancy_code_buy' => "", + 'p.accountancy_code_buy_intra' => "", + 'p.accountancy_code_buy_export' => "", + 'p.weight' => "", 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', - 'p.length' => "", + 'p.length' => "", 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', - 'p.width' => "", + 'p.width' => "", 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', - 'p.height' => "", + 'p.height' => "", 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', - 'p.surface' => "", + 'p.surface' => "", 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', - 'p.volume' => "", + 'p.volume' => "", 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', - 'p.finished' => '0 (raw material) / 1 (finished goods), matches field "code" in dictionary table "'.MAIN_DB_PREFIX.'c_product_nature"' - ); - //clauses copied from import_fields_array - if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array( - 'p.tobatch'=>"0 (don't use) / 1 (use batch/serial number)", - 'p.seuil_stock_alerte' => '', - 'p.pmp' => '0', - 'p.desiredstock' => '' - )); - if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array('p.cost_price'=>'90')); - if (is_object($mysoc) && $usenpr) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); - if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>'')); - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - $import_sample = array_merge( - $import_sample, - array( - 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "'.MAIN_DB_PREFIX.'c_units"' - ) - ); - + 'p.finished' => '0 (raw material) / 1 (finished goods)' + ); + //clauses copied from import_fields_array + if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array( + 'p.seuil_stock_alerte' => '', + 'p.pmp' => '0', + 'p.desiredstock' => '' + )); + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array('p.cost_price'=>'90')); + if (is_object($mysoc) && $mysoc->useNPR()) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); + if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>'')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $import_sample = array_merge( + $import_sample, + array( + 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "'.MAIN_DB_PREFIX.'c_units"' + ) + ); + + if (!is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array(); $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( 'p.fk_unit' => array( 'rule' => 'fetchidfromcodeorlabel', @@ -617,8 +588,8 @@ )); } $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); - $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); - if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled + $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); + if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled if (!empty($conf->fournisseur->enabled)) { @@ -628,58 +599,37 @@ $this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price', 'extra'=>MAIN_DB_PREFIX.'product_fournisseur_price_extrafields'); + $this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); $this->import_tables_creator_array[$r] = array('sp'=>'fk_user'); $this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields - 'sp.fk_product'=>"ProductOrService*", - 'sp.fk_soc' => "Supplier*", - 'sp.ref_fourn' => 'SupplierRef*', - 'sp.quantity' => "QtyMin*", - 'sp.tva_tx' => 'VATRate', - 'sp.default_vat_code' => 'VATCode', - 'sp.delivery_time_days' => 'DeliveryDelay', - 'sp.supplier_reputation' => 'SupplierReputation' + 'sp.fk_product'=>"ProductOrService*", + 'sp.fk_soc' => "Supplier*", + 'sp.ref_fourn' => 'SupplierRef*', + 'sp.quantity' => "QtyMin*", + 'sp.tva_tx' => 'VATRate', + 'sp.default_vat_code' => 'VATCode', + 'sp.delivery_time_days' => 'DeliveryDelay', + 'sp.supplier_reputation' => 'SupplierReputation' ); - if (is_object($mysoc) && $usenpr) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); - $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( 'sp.price'=>"PriceQtyMinHT*", 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty 'sp.remise_percent'=>'DiscountQtyMin' )); - if (!empty($conf->multicurrency->enabled)) - { - $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( - 'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line - 'sp.multicurrency_code'=>'CurrencyCode', - 'sp.multicurrency_tx'=>'CurrencyRate', - 'sp.multicurrency_unitprice'=>'CurrencyUnitPrice', - 'sp.multicurrency_price'=>'CurrencyPrice', - )); - } - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.packaging' => 'PackagingForThisProduct')); - } - - // Add extra fields - $import_extrafield_sample = array(); - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product_fournisseur_price' AND entity IN (0, ".$conf->entity.")"; - $resql = $this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj = $this->db->fetch_object($resql)) - { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - $import_extrafield_sample[$fieldname] = $fieldlabel; - } - } - // End add extra fields - $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product_fournisseur_price'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + if ($conf->multicurrency->enabled) + { + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + 'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line + 'sp.multicurrency_code'=>'CurrencyCode', + 'sp.multicurrency_tx'=>'CurrencyRate', + 'sp.multicurrency_unitprice'=>'CurrencyUnitPrice', + 'sp.multicurrency_price'=>'CurrencyPrice', + )); + } $this->import_convertvalue_array[$r] = array( 'sp.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'), @@ -687,43 +637,38 @@ ); $this->import_examplevalues_array[$r] = array( - 'sp.fk_product' => "ref:PRODUCT_REF or id:123456", - 'sp.fk_soc' => "My Supplier", - 'sp.ref_fourn' => "XYZ-F123456", - 'sp.quantity' => "5", - 'sp.tva_tx' => '10', - 'sp.price'=>"50", - 'sp.unitprice'=>'50', - 'sp.remise_percent'=>'0', - 'sp.default_vat_code' => '', - 'sp.delivery_time_days' => '5', - 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' + 'sp.fk_product' => "PRODUCT_REF or id:123456", + 'sp.fk_soc' => "My Supplier", + 'sp.ref_fourn' => "XYZ-F123456", + 'sp.quantity' => "5", + 'sp.tva_tx' => '10', + 'sp.price'=>"50", + 'sp.unitprice'=>'50', + 'sp.remise_percent'=>'0', + 'sp.default_vat_code' => '', + 'sp.delivery_time_days' => '5', + 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' ); - if (is_object($mysoc) && $usenpr) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); - $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( - 'sp.price' => "50.00", - 'sp.unitprice' => '10', - // TODO Make this field not required and calculate it from price and qty - 'sp.remise_percent' => '20' - )); - if (!empty($conf->multicurrency->enabled)) - { - $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( - 'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency', - 'sp.multicurrency_code'=>'GBP', - 'sp.multicurrency_tx'=>'1.12345', - 'sp.multicurrency_unitprice'=>'', - // TODO Make this field not required and calculate it from price and qty - 'sp.multicurrency_price'=>'' - )); - } - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( - 'sp.packagning'=>'1', - )); - } + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); + $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( + 'sp.price' => "50.00", + 'sp.unitprice' => '10', + // TODO Make this field not required and calculate it from price and qty + 'sp.remise_percent' => '20' + )); + if ($conf->multicurrency->enabled) + { + $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( + 'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency', + 'sp.multicurrency_code'=>'GBP', + 'sp.multicurrency_tx'=>'1.12345', + 'sp.multicurrency_unitprice'=>'', + // TODO Make this field not required and calculate it from price and qty + 'sp.multicurrency_price'=>'' + )); + } $this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier'); } @@ -744,29 +689,29 @@ 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.date_price'=>'DateCreation*'); if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx'] = 'VATRate'; - if (is_object($mysoc) && $usenpr) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); $this->import_regex_array[$r] = array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'pr.recuperableonly'=>'^[0|1]$'); $this->import_convertvalue_array[$r] = array( - 'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') + 'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"ref:PRODUCT_REF or id:123456", + $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"PRODUCT_REF or id:123456", 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)", 'pr.price_level'=>"1", 'pr.price'=>"100", 'pr.price_ttc'=>"110", 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110", 'pr.tva_tx'=>'20', - 'pr.recuperableonly'=>'0', - 'pr.date_price'=>'2020-12-31'); + 'pr.recuperableonly'=>'0', + 'pr.date_price'=>'2013-04-10'); } if (!empty($conf->global->MAIN_MULTILANGS)) { - // Import translations of product names and descriptions - $r++; - $this->import_code[$r] = $this->rights_class.'_languages'; - $this->import_label[$r] = "ProductsOrServicesTranslations"; + // Import translations of product names and descriptions + $r++; + $this->import_code[$r] = $this->rights_class.'_languages'; + $this->import_label[$r] = "ProductsOrServicesTranslations"; $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang'); + $this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang'); // multiline translation, one line per translation $this->import_fields_array[$r] = array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); //$this->import_fields_array[$r]['l.note']='TranslatedNote'; @@ -779,20 +724,20 @@ } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - $this->remove($options); - - $sql = array(); - - return $this->_init($sql, $options); - } + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + $this->remove($options); + + $sql = array(); + + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modProductBatch.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modProductBatch.class.php @@ -40,9 +40,9 @@ */ public function __construct($db) { - global $langs, $conf; + global $langs, $conf; - $this->db = $db; + $this->db = $db; $this->numero = 39000; $this->family = "products"; @@ -79,18 +79,18 @@ // Constants $this->const = array(); - $this->tabs = array(); + $this->tabs = array(); - // Dictionaries - if (!isset($conf->productbatch->enabled)) - { - $conf->productbatch = new stdClass(); - $conf->productbatch->enabled = 0; - } + // Dictionaries + if (!isset($conf->productbatch->enabled)) + { + $conf->productbatch = new stdClass(); + $conf->productbatch->enabled = 0; + } $this->dictionaries = array(); - // Boxes - $this->boxes = array(); // List of boxes + // Boxes + $this->boxes = array(); // List of boxes // Permissions $this->rights = array(); // Permission array used by this module @@ -111,20 +111,20 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') { - global $db, $conf; + global $db, $conf; $sql = array(); if (!empty($conf->cashdesk->enabled)) { - if (empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity); - } + if (empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity); + } } return $this->_init($sql, $options); --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modProjet.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modProjet.class.php @@ -138,12 +138,12 @@ $r++; // Boxes - $this->boxes = array( - 0=>array('file'=>'box_project.php', 'enabledbydefaulton'=>'Home'), - 1=>array('file'=>'box_task.php', 'enabledbydefaulton'=>'Home'), - 2=>array('file'=>'box_validated_projects.php', 'enabledbydefaulton'=>'Home'), - 3=>array('file'=>'box_funnel_of_prospection.php', 'enabledbydefaulton'=>'Home'), - ); + $this->boxes = array(); + $r = 0; + $this->boxes[$r][1] = "box_project.php"; + $r++; + $this->boxes[$r][1] = "box_task.php"; + $r++; // Permissions $this->rights = array(); @@ -237,17 +237,17 @@ 'p.usage_opportunity'=>'ProjectFollowOpportunity', 'p.usage_task'=>'ProjectFollowTasks', 'p.usage_bill_time'=>'BillTime', 'p.datec'=>"DateCreation", 'p.dateo'=>"DateStart", 'p.datee'=>"DateEnd", 'p.fk_statut'=>'ProjectStatus', 'cls.code'=>'OpportunityStatus', 'p.opp_percent'=>'OpportunityProbability', 'p.opp_amount'=>'OpportunityAmount', 'p.description'=>"Description" ); - // Add multicompany field - if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) - { - $nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1 - if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('p.entity'=>'Entity'); - } + // Add multicompany field + if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) + { + $nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1 + if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('p.entity'=>'Entity'); + } if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - unset($this->export_fields_array[$r]['p.opp_percent']); - unset($this->export_fields_array[$r]['p.opp_amount']); - unset($this->export_fields_array[$r]['cls.code']); + unset($this->export_fields_array[$r]['p.opp_percent']); + unset($this->export_fields_array[$r]['p.opp_amount']); + unset($this->export_fields_array[$r]['cls.code']); } // Add fields for project @@ -258,22 +258,22 @@ // Add fields for tasks $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pt.rowid'=>'TaskId', 'pt.ref'=>'RefTask', 'pt.label'=>'LabelTask', 'pt.dateo'=>"TaskDateStart", 'pt.datee'=>"TaskDateEnd", 'pt.duration_effective'=>"DurationEffective", 'pt.planned_workload'=>"PlannedWorkload", 'pt.progress'=>"Progress", 'pt.description'=>"TaskDescription")); $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask', 'pt.ref'=>'projecttask', 'pt.label'=>'projecttask', 'pt.dateo'=>"projecttask", 'pt.datee'=>"projecttask", 'pt.duration_effective'=>"projecttask", 'pt.planned_workload'=>"projecttask", 'pt.progress'=>"projecttask", 'pt.description'=>"projecttask")); - // Add extra fields for task + // Add extra fields for task $keyforselect = 'projet_task'; $keyforelement = 'projecttask'; $keyforaliasextra = 'extra2'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - // End add extra fields + // End add extra fields $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime', 'ptt.task_date'=>'TaskTimeDate', 'ptt.task_duration'=>"TimesSpent", 'ptt.fk_user'=>"TaskTimeUser", 'ptt.note'=>"TaskTimeNote")); $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time', 'ptt.task_date'=>'task_time', 'ptt.task_duration'=>"task_time", 'ptt.fk_user'=>"task_time", 'ptt.note'=>"task_time")); if (empty($conf->global->PROJECT_HIDE_TASKS)) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('f.ref'=>"Billed")); $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('f.ref'=>"task_time")); } - $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'projet as p'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet"; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet"; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task"; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid'; if (empty($conf->global->PROJECT_HIDE_TASKS)) { @@ -285,34 +285,34 @@ // Import list of tasks if (empty($conf->global->PROJECT_HIDE_TASKS)) { - $r++; - $this->import_code[$r] = 'tasksofprojects'; - $this->import_label[$r] = 'ImportDatasetTasks'; - $this->import_icon[$r] = 'task'; - $this->import_entities_array[$r] = array('t.fk_projet'=>'project'); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet_task', 'extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order) - $this->import_fields_array[$r] = array('t.fk_projet'=>'ProjectRef*', 't.ref'=>'RefTask*', 't.label'=>'LabelTask*', 't.dateo'=>"DateStart", 't.datee'=>"DateEnd", 't.planned_workload'=>"PlannedWorkload", 't.progress'=>"Progress", 't.note_private'=>"NotePrivate", 't.note_public'=>"NotePublic", 't.datec'=>"DateCreation"); - // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")"; - $resql = $this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj = $this->db->fetch_object($resql)) - { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - } - } - // End add extra fields - $this->import_fieldshidden_array[$r] = array('t.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_convertvalue_array[$r] = array( - 't.fk_projet'=>array('rule'=>'fetchidfromref', 'classfile'=>'/projet/class/project.class.php', 'class'=>'Project', 'method'=>'fetch', 'element'=>'Project'), - 't.ref'=>array('rule'=>'getrefifauto') - ); - //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); - $this->import_regex_array[$r] = array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); - $this->import_examplevalues_array[$r] = array('t.fk_projet'=>'MyProjectRef', 't.ref'=>"auto or TK2010-1234", 't.label'=>"My task", 't.progress'=>"0 (not started) to 100 (finished)", 't.datec'=>'1972-10-10', 't.note_private'=>"My private note", 't.note_public'=>"My public note"); + $r++; + $this->import_code[$r] = 'tasksofprojects'; + $this->import_label[$r] = 'ImportDatasetTasks'; + $this->import_icon[$r] = 'task'; + $this->import_entities_array[$r] = array('t.fk_projet'=>'project'); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet_task', 'extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order) + $this->import_fields_array[$r] = array('t.fk_projet'=>'ProjectRef*', 't.ref'=>'RefTask*', 't.label'=>'LabelTask*', 't.dateo'=>"DateStart", 't.datee'=>"DateEnd", 't.planned_workload'=>"PlannedWorkload", 't.progress'=>"Progress", 't.note_private'=>"NotePrivate", 't.note_public'=>"NotePublic", 't.datec'=>"DateCreation"); + // Add extra fields + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")"; + $resql = $this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj = $this->db->fetch_object($resql)) + { + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + } + } + // End add extra fields + $this->import_fieldshidden_array[$r] = array('t.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_convertvalue_array[$r] = array( + 't.fk_projet'=>array('rule'=>'fetchidfromref', 'classfile'=>'/projet/class/project.class.php', 'class'=>'Project', 'method'=>'fetch', 'element'=>'Project'), + 't.ref'=>array('rule'=>'getrefifauto') + ); + //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); + $this->import_regex_array[$r] = array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); + $this->import_examplevalues_array[$r] = array('t.fk_projet'=>'MyProjectRef', 't.ref'=>"auto or TK2010-1234", 't.label'=>"My task", 't.progress'=>"0 (not started) to 100 (finished)", 't.datec'=>'1972-10-10', 't.note_private'=>"My private note", 't.note_public'=>"My public note"); } } @@ -322,7 +322,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modPropale.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modPropale.class.php @@ -5,7 +5,6 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Juanjo Menent - * Copyright (C) 2020 Ahmad Jamaly Rabib * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -113,8 +112,8 @@ // Boxes $this->boxes = array( - 0=>array('file'=>'box_graph_propales_permonth.php', 'enabledbydefaulton'=>'Home'), - 1=>array('file'=>'box_propales.php', 'enabledbydefaulton'=>'Home'), + 0=>array('file'=>'box_graph_propales_permonth.php', 'enabledbydefaulton'=>'Home'), + 1=>array('file'=>'box_propales.php', 'enabledbydefaulton'=>'Home'), ); // Permissions @@ -150,7 +149,7 @@ $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'propal_advance'; - $this->rights[$r][5] = 'send'; + $this->rights[$r][5] = 'send'; $r++; $this->rights[$r][0] = 26; // id de la permission @@ -199,11 +198,11 @@ ); if (!empty($conf->multicurrency->enabled)) { - $this->export_fields_array[$r]['c.multicurrency_code'] = 'Currency'; - $this->export_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate'; - $this->export_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; - $this->export_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; - $this->export_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; + $this->export_fields_array[$r]['c.multicurrency_code'] = 'Currency'; + $this->export_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate'; + $this->export_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; + $this->export_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; + $this->export_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; } //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text', @@ -241,7 +240,7 @@ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s '; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra4 ON s.rowid = extra4.fk_object'; - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; + if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'propal as c'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid'; @@ -254,175 +253,7 @@ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; $this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal'; $this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('propal').')'; - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id); - - // Imports - //-------- - $r = 0; - - $r++; - $this->import_code[$r] = $this->rights_class.'_'.$r; - $this->import_label[$r] = 'Proposals'; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = ['c' => MAIN_DB_PREFIX.'propal', 'extra' => MAIN_DB_PREFIX.'propal_extrafields']; - $this->import_tables_creator_array[$r] = ['c'=>'fk_user_author']; // Fields to store import user id - $this->import_fields_array[$r] = [ - 'c.ref' => 'Document Ref*', - 'c.ref_client' => 'RefCustomer', - 'c.fk_soc' => 'ThirdPartyName*', - 'c.datec' => 'DateCreation', - 'c.datep' => 'DatePropal', - 'c.fin_validite' => 'DateEndPropal', - 'c.remise_percent' => 'GlobalDiscount', - 'c.total_ht' => 'TotalHT', - 'c.total' => 'TotalTTC', - 'c.fk_statut' => 'Status*', - 'c.note_public' => 'Note', - 'c.date_livraison' => 'DeliveryDate', - 'c.fk_user_valid' => 'ValidatedById' - ]; - if (!empty($conf->multicurrency->enabled)) { - $this->import_fields_array[$r]['c.multicurrency_code'] = 'Currency'; - $this->import_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate'; - $this->import_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; - $this->import_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; - $this->import_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; - } - // Add extra fields - $import_extrafield_sample = []; - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'propal' AND entity IN (0, ".$conf->entity.")"; - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - $import_extrafield_sample[$fieldname] = $fieldlabel; - } - } - // End add extra fields - $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'propal']; - $this->import_regex_array[$r] = ['c.ref' => '[^ ]']; - $import_sample = [ - 'c.ref' => 'PROV0077', - 'c.ref_client' => 'Client1', - 'c.fk_soc' => 'MyBigCompany', - 'c.datec' => '2020-01-01', - 'c.datep' => '2020-01-01', - 'c.fin_validite' => '2020-01-01', - 'c.remise_percent' => '', - 'c.total_ht' => '0', - 'c.total' => '0', - 'c.fk_statut' => '1', - 'c.note_public' => '', - 'c.date_livraison' => '2020-01-01', - 'c.fk_user_valid' => '1', - 'c.multicurrency_code' => '', - 'c.multicurrency_tx' => '1', - 'c.multicurrency_total_ht' => '0', - 'c.multicurrency_total_tva' => '0', - 'c.multicurrency_total_ttc' => '0' - ]; - $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); - $this->import_updatekeys_array[$r] = ['c.ref'=>'Ref']; - $this->import_convertvalue_array[$r] = [ - 'c.fk_soc' => [ - 'rule' => 'fetchidfromref', - 'file' => '/societe/class/societe.class.php', - 'class' => 'Societe', - 'method' => 'fetch', - 'element' => 'ThirdParty' - ] - ]; - - //Import Proposal Lines - $r++; - $this->import_code[$r] = $this->rights_class.'line_'.$r; - $this->import_label[$r] = "ProposalLine"; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = [ - 'cd' => MAIN_DB_PREFIX.'propaldet', - 'extra' => MAIN_DB_PREFIX.'propaldet_extrafields' - ]; - $this->import_fields_array[$r] = [ - 'cd.fk_propal' => 'Document Ref*', - 'cd.fk_parent_line' => 'PrParentLine', - 'cd.fk_product' => 'IdProduct', - 'cd.label' => 'Label', - 'cd.description' => 'LineDescription', - 'cd.product_type' => 'TypeOfLineServiceOrProduct', - 'cd.tva_tx' => 'LineVATRate', - 'cd.qty' => 'LineQty', - 'cd.remise_percent' => 'Reduc. Percent', - 'cd.remise' => 'Reduc.', - 'cd.price' => 'Price', - 'cd.subprice' => 'Sub Price', - 'cd.total_ht' => 'LineTotalHT', - 'cd.total_tva' => 'LineTotalVAT', - 'cd.total_ttc' => 'LineTotalTTC', - 'cd.date_start' => 'Start Date', - 'cd.date_end' => 'End Date', - 'cd.buy_price_ht' => 'LineBuyPriceHT' - ]; - if (!empty($conf->multicurrency->enabled)) { - $this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency'; - $this->import_fields_array[$r]['cd.multicurrency_subprice'] = 'CurrencyRate'; - $this->import_fields_array[$r]['cd.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; - $this->import_fields_array[$r]['cd.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; - $this->import_fields_array[$r]['cd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; - } - // Add extra fields - $import_extrafield_sample = []; - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'propaldet' AND entity IN (0, ".$conf->entity.")"; - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - $import_extrafield_sample[$fieldname] = $fieldlabel; - } - } - // End add extra fields - $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'propaldet']; - $this->import_regex_array[$r] = ['cd.product_type' => '[0|1]$']; - $import_sample = [ - 'cd.fk_propal' => 'PROV(0001)', - 'cd.fk_parent_line' => '', - 'cd.fk_product' => '', - 'cd.label' => '', - 'cd.description' => 'Line description', - 'cd.product_type' => '1', - 'cd.tva_tx' => '0', - 'cd.qty' => '2', - 'cd.remise_percent' => '0', - 'cd.remise' => '0', - 'cd.price' => '', - 'cd.subprice' => '5000', - 'cd.total_ht' => '10000', - 'cd.total_tva' => '0', - 'cd.total_ttc' => '10100', - 'cd.date_start' => '', - 'cd.date_end' => '', - 'cd.buy_price_ht' => '7000', - 'cd.multicurrency_code' => 'JPY', - 'cd.multicurrency_tx' => '1', - 'cd.multicurrency_total_ht' => '10000', - 'cd.multicurrency_total_tva' => '0', - 'cd.multicurrency_total_ttc' => '10100' - ]; - $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); - $this->import_updatekeys_array[$r] = ['cd.fk_propal' => 'Quotation Id', 'cd.fk_product' => 'Product Id']; - $this->import_convertvalue_array[$r] = [ - 'cd.fk_propal' => [ - 'rule'=>'fetchidfromref', - 'file'=>'/comm/propal/class/propal.class.php', - 'class'=>'Propal', - 'method'=>'fetch' - ] - ]; + if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; } @@ -431,7 +262,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modReceiptPrinter.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modReceiptPrinter.class.php @@ -35,114 +35,114 @@ class modReceiptPrinter extends DolibarrModules { - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - $this->numero = 67000; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page - $this->family = "interface"; - $this->module_position = '53'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "ReceiptPrinterDesc"; + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + $this->numero = 67000; + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "interface"; + $this->module_position = '53'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "ReceiptPrinterDesc"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version - $this->version = 'dolibarr'; - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto = 'printer'; + $this->version = 'experimental'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto = 'printer'; - // Data directories to create when module is enabled. - $this->dirs = array(); + // Data directories to create when module is enabled. + $this->dirs = array(); - // Config pages - $this->config_page_url = array("receiptprinter.php"); + // Config pages + $this->config_page_url = array("receiptprinter.php"); - // Dependencies - $this->hidden = false; // A condition to hide module + // Dependencies + $this->hidden = false; // A condition to hide module $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(5, 4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(3, 9, -2); // Minimum version of Dolibarr required by module - $this->conflictwith = array(); - $this->langfiles = array("receiptprinter"); + $this->need_dolibarr_version = array(3, 9, -2); // Minimum version of Dolibarr required by module + $this->conflictwith = array(); + $this->langfiles = array("receiptprinter"); - // Constants - $this->const = array(); + // Constants + $this->const = array(); - // Boxes - $this->boxes = array(); + // Boxes + $this->boxes = array(); - // Permissions - $this->rights = array(); - $this->rights_class = 'receiptprinter'; + // Permissions + $this->rights = array(); + $this->rights_class = 'receiptprinter'; - $r = 0; - // $this->rights[$r][0] Id permission (unique tous modules confondus) - // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) - // $this->rights[$r][2] Non utilise - // $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut - // $this->rights[$r][4] Niveau 1 pour nommer permission dans code - // $this->rights[$r][5] Niveau 2 pour nommer permission dans code + $r = 0; + // $this->rights[$r][0] Id permission (unique tous modules confondus) + // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) + // $this->rights[$r][2] Non utilise + // $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut + // $this->rights[$r][4] Niveau 1 pour nommer permission dans code + // $this->rights[$r][5] Niveau 2 pour nommer permission dans code - $r++; - $this->rights[$r][0] = 67000; - $this->rights[$r][1] = 'ReceiptPrinter'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'read'; + $r++; + $this->rights[$r][0] = 67000; + $this->rights[$r][1] = 'ReceiptPrinter'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'read'; - // Main menu entries - $this->menus = array(); // List of menus to add - $r = 0; + // Main menu entries + $this->menus = array(); // List of menus to add + $r = 0; - // This is to declare the Top Menu entry: - //$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu - // 'type'=>'left', // This is a Top menu entry - // 'titre'=>'MenuDirectPrinting', - // 'mainmenu'=>'printing', - // 'url'=>'/printing/index.php', - // 'langs'=>'printing', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - // 'position'=>300, - // 'enabled'=>'$conf->printing->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', - // 'perms'=>'$user->rights->printing->read', // Use 'perms'=>'1' if you want your menu with no permission rules - // 'target'=>'', - // 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both + // This is to declare the Top Menu entry: + //$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu + // 'type'=>'left', // This is a Top menu entry + // 'titre'=>'MenuDirectPrinting', + // 'mainmenu'=>'printing', + // 'url'=>'/printing/index.php', + // 'langs'=>'printing', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>300, + // 'enabled'=>'$conf->printing->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', + // 'perms'=>'$user->rights->printing->read', // Use 'perms'=>'1' if you want your menu with no permission rules + // 'target'=>'', + // 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both - $r++; - } + $r++; + } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - global $conf, $langs; - // Clean before activation - $this->remove($options); + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $conf, $langs; + // Clean before activation + $this->remove($options); - $templateexample = '{dol_align_center}\r\n{dol_print_text}{dol_value_mysoc_name}\r\n{dol_print_text}{dol_value_mysoc_address}\r\n{dol_print_text}{dol_value_mysoc_zip}{dol_value_mysoc_town}\r\n{dol_line_feed}\r\n{dol_print_text}Facture {dol_value_object_ref}\r\n{dol_line_feed}\r\n{dol_align_left}\r\n{dol_print_object_lines}\r\n{dol_line_feed}\r\n{dol_print_object_tax}\r\n{dol_line_feed}\r\n{dol_print_object_total}\r\n{dol_line_feed}\r\n{dol_cut_paper_full}'; - $sql = array( - "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), fk_type integer, fk_profile integer, parameter varchar(128), entity integer) ENGINE=innodb;", - "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt_template (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), template text, entity integer) ENGINE=innodb;", - "DELETE FROM ".MAIN_DB_PREFIX."printer_receipt_template WHERE name = '".$langs->trans('Example')."';", + $templateexample = '\r\n\r\n\r\n\r\n\r\nFacture \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n'; + $sql = array( + "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), fk_type integer, fk_profile integer, parameter varchar(128), entity integer) ENGINE=innodb;", + "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt_template (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), template text, entity integer) ENGINE=innodb;", + "DELETE FROM ".MAIN_DB_PREFIX."printer_receipt_template WHERE name = '".$langs->trans('Example')."';", "INSERT INTO ".MAIN_DB_PREFIX."printer_receipt_template (name,template,entity) VALUES ('".$langs->trans('Example')."', '".$templateexample."', 1);", ); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modReception.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modReception.class.php @@ -50,16 +50,16 @@ $this->description = "Gestion des réceptions fournisseurs"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; + $this->version = 'experimental'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto = "dollyrevert"; // Data directories to create when module is enabled $this->dirs = array("/reception/receipt", - "/reception/receipt/temp", - "/doctemplates/receptions" - ); + "/reception/receipt/temp", + "/doctemplates/receptions" + ); // Config pages $this->config_page_url = array("reception_setup.php"); @@ -138,7 +138,7 @@ $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'reception_advance'; - $this->rights[$r][5] = 'send'; + $this->rights[$r][5] = 'send'; $r++; $this->rights[$r][0] = $this->numero.$r; @@ -205,8 +205,8 @@ $this->export_dependencies_array[$r] = array('reception_line'=>'ed.rowid', 'product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them if ($idcontacts && !empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) { - $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra3'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra3'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; } $keyforselect = 'reception'; $keyforelement = 'reception'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; @@ -217,7 +217,7 @@ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'reception as c'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'reception_extrafields as extra ON c.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s'; - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; + if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as ed'; @@ -225,13 +225,13 @@ $this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; if ($idcontacts && !empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) { - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; } $this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_commandefourndet = cd.rowid'; $this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('reception').')'; - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id); + if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; } @@ -240,7 +240,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modResource.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modResource.class.php @@ -246,9 +246,9 @@ $this->export_dependencies_array[$r] = array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'resource as r'; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'resource as r '; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = r.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .= ' AND r.entity IN ('.getEntity('resource').')'; --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modSalaries.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modSalaries.class.php @@ -101,7 +101,7 @@ $r++; $this->rights[$r][0] = 511; - $this->rights[$r][1] = 'Read payments of employee salaries (yours and your subordinates)'; + $this->rights[$r][1] = 'Read payments of employee salaries'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read'; @@ -125,19 +125,11 @@ $r++; $this->rights[$r][0] = 517; - $this->rights[$r][1] = 'Read payments of salariests of every employee'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'readall'; - - $r++; - $this->rights[$r][0] = 519; $this->rights[$r][1] = 'Export payments of employee salaries'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'export'; $this->rights[$r][5] = ''; - // Menus --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modService.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modService.class.php @@ -93,28 +93,28 @@ $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; - $r++; + $r++; $this->rights[$r][0] = 532; // id de la permission $this->rights[$r][1] = 'Create/modify services'; // libelle de la permission $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'creer'; - $r++; + $r++; $this->rights[$r][0] = 534; // id de la permission $this->rights[$r][1] = 'Delete les services'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'supprimer'; - $r++; + $r++; $this->rights[$r][0] = 538; // Must be same permission than in product module $this->rights[$r][1] = 'Export services'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'export'; - $r++; + $r++; // Menus //------- @@ -134,10 +134,7 @@ $r++; */ - $usenpr = 0; - if (is_object($mysoc)) $usenpr = $mysoc->useNPR(); - - // Exports + // Exports //-------- $r = 0; @@ -161,7 +158,7 @@ 'p.tva_tx'=>'VATRate', 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' ); - if (is_object($mysoc) && $usenpr) $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); @@ -208,8 +205,8 @@ if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; if (!empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; - $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')'; - if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" + $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')'; + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" if (empty($conf->product->enabled)) // We enable next import templates only if module product not already enabled (to avoid duplicate entries) { @@ -226,7 +223,7 @@ 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation'); - if (is_object($mysoc) && $usenpr) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; //$this->export_TypeFields_array[$r]=array( // 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", // 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', @@ -238,8 +235,8 @@ 'pr.price_ttc'=>"product", 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", 'pr.tva_tx'=>'product', - 'pr.recuperableonly'=>'product', - 'pr.date_price'=>"product"); + 'pr.recuperableonly'=>'product', + 'pr.date_price'=>"product"); $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity @@ -248,90 +245,90 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - // Exports product multiprice - $r++; - $this->export_code[$r] = $this->rights_class.'_'.$r; - $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r] = array(array("produit", "export")); - $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", - 's.nom'=>'ThirdParty', - 'pr.price_base_type'=>"PriceBase", - 'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC", - 'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", - 'pr.tva_tx'=>'PriceVATRate', - 'pr.default_vat_code'=>'PriceVATCode', - 'pr.datec'=>'DateCreation'); - if (is_object($mysoc) && $usenpr) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; - $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", - 's.nom'=>'company', - 'pr.price_base_type'=>"product", 'pr.price'=>"product", - 'pr.price_ttc'=>"product", - 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", - 'pr.tva_tx'=>'product', - 'pr.default_vat_code'=>'product', - 'pr.recuperableonly'=>'product', - 'pr.datec'=>"product"); - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; - $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + // Exports product multiprice + $r++; + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", + 's.nom'=>'ThirdParty', + 'pr.price_base_type'=>"PriceBase", + 'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC", + 'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", + 'pr.tva_tx'=>'PriceVATRate', + 'pr.default_vat_code'=>'PriceVATCode', + 'pr.datec'=>'DateCreation'); + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; + $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", + 's.nom'=>'company', + 'pr.price_base_type'=>"product", 'pr.price'=>"product", + 'pr.price_ttc'=>"product", + 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", + 'pr.tva_tx'=>'product', + 'pr.default_vat_code'=>'product', + 'pr.recuperableonly'=>'product', + 'pr.datec'=>"product"); + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) { - // Exports virtual products - $r++; - $this->export_code[$r] = $this->rights_class.'_'.$r; - $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r] = array(array("produit", "export")); - $this->export_fields_array[$r] = array( - 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", - 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + // Exports virtual products + $r++; + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array( + 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", + 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", - 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', - 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode', - 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", - 'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' - ); - if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); - if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); - $this->export_TypeFields_array[$r] = array( - 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", - 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", + 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode', + 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", + 'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' + ); + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); + $this->export_TypeFields_array[$r] = array( + 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", + 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", - 'p.note'=>"Text", 'p.note_public'=>"Text", - 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', - 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", - 'p.datec'=>'Date', 'p.tms'=>'Date' - ); - if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); - if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); - $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); - $this->export_entities_array[$r] = array( - 'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", - 'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct', - 'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct', + 'p.note'=>"Text", 'p.note_public'=>"Text", + 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', + 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", + 'p.datec'=>'Date', 'p.tms'=>'Date' + ); + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); + $this->export_entities_array[$r] = array( + 'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", + 'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct', + 'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct', 'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct", - 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', - 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", - 'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct" - ); - if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct')); - if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); - $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct')); - $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description")); - $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; - $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; - $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile - $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; + 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', + 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", + 'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct" + ); + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct')); + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description")); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; } } @@ -348,141 +345,141 @@ $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon $this->import_tables_array[$r] = array('p'=>MAIN_DB_PREFIX.'product', 'extra'=>MAIN_DB_PREFIX.'product_extrafields'); $this->import_tables_creator_array[$r] = array('p'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r] = array( - 'p.ref' => "Ref*", - 'p.label' => "Label*", - 'p.fk_product_type' => "Type*", - 'p.tosell' => "OnSell*", - 'p.tobuy' => "OnBuy*", - 'p.description' => "Description", - 'p.url' => "PublicUrl", - 'p.customcode' => 'CustomCode', - 'p.fk_country' => 'CountryCode', - 'p.accountancy_code_sell' => "ProductAccountancySellCode", - 'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode", - 'p.accountancy_code_buy' => "ProductAccountancyBuyCode", - 'p.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode", - 'p.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode", - 'p.note_public' => "NotePublic", - 'p.note' => "NotePrivate", - 'p.weight' => "Weight", - 'p.weight_units' => "WeightUnits", - 'p.length' => "Length", - 'p.length_units' => "LengthUnit", - 'p.width' => "Width", - 'p.width_units' => "WidthUnits", - 'p.height' => "Height", - 'p.height_units' => "HeightUnit", - 'p.surface' => "Surface", - 'p.surface_units' => "SurfaceUnit", - 'p.volume' => "Volume", - 'p.volume_units' => "VolumeUnits", - 'p.duration' => "Duration", //duration of service - 'p.finished' => 'Nature', - 'p.price' => "SellingPriceHT", //without - 'p.price_min' => "MinPrice", - 'p.price_ttc' => "SellingPriceTTC", //with tax - 'p.price_min_ttc' => "SellingMinPriceTTC", - 'p.price_base_type' => "PriceBaseType", //price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card - 'p.tva_tx' => 'VATRate', - 'p.datec' => 'DateCreation', - 'p.cost_price' => "CostPrice", + $this->import_fields_array[$r] = array( + 'p.ref' => "Ref*", + 'p.label' => "Label*", + 'p.fk_product_type' => "Type*", + 'p.tosell' => "OnSell*", + 'p.tobuy' => "OnBuy*", + 'p.description' => "Description", + 'p.url' => "PublicUrl", + 'p.customcode' => 'CustomCode', + 'p.fk_country' => 'CountryCode', + 'p.accountancy_code_sell' => "ProductAccountancySellCode", + 'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode", + 'p.accountancy_code_buy' => "ProductAccountancyBuyCode", + 'p.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode", + 'p.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode", + 'p.note_public' => "NotePublic", + 'p.note' => "NotePrivate", + 'p.weight' => "Weight", + 'p.weight_units' => "WeightUnits", + 'p.length' => "Length", + 'p.length_units' => "LengthUnit", + 'p.width' => "Width", + 'p.width_units' => "WidthUnits", + 'p.height' => "Height", + 'p.height_units' => "HeightUnit", + 'p.surface' => "Surface", + 'p.surface_units' => "SurfaceUnit", + 'p.volume' => "Volume", + 'p.volume_units' => "VolumeUnits", + 'p.duration' => "Duration", //duration of service + 'p.finished' => 'Nature', + 'p.price' => "SellingPriceHT", //without + 'p.price_min' => "MinPrice", + 'p.price_ttc' => "SellingPriceTTC", //with tax + 'p.price_min_ttc' => "SellingMinPriceTTC", + 'p.price_base_type' => "PriceBaseType", //price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card + 'p.tva_tx' => 'VATRate', + 'p.datec' => 'DateCreation', + 'p.cost_price' => "CostPrice", ); - if (!empty($conf->stock->enabled)) {//if Stock module enabled - $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( - 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning - 'p.pmp' => 'PMPValue', //weighted average price - 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature - )); - } - - $this->import_convertvalue_array[$r] = array( - 'p.weight_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table - 'classfile' => '/core/class/cunits.class.php', - 'class' => 'CUnits', - 'method' => 'fetch', - 'units' => 'weight', - 'dict' => 'DictionaryMeasuringUnits' - ), - 'p.length_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table - 'classfile' => '/core/class/cunits.class.php', - 'class' => 'CUnits', - 'method' => 'fetch', - 'units' => 'size', - 'dict' => 'DictionaryMeasuringUnits' - ), - 'p.width_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table - 'classfile' => '/core/class/cunits.class.php', - 'class' => 'CUnits', - 'method' => 'fetch', - 'units' => 'size', - 'dict' => 'DictionaryMeasuringUnits' - ), - 'p.height_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table - 'classfile' => '/core/class/cunits.class.php', - 'class' => 'CUnits', - 'method' => 'fetch', - 'units' => 'size', - 'dict' => 'DictionaryMeasuringUnits' - ), - 'p.surface_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table - 'classfile' => '/core/class/cunits.class.php', - 'class' => 'CUnits', - 'method' => 'fetch', - 'units' => 'surface', - 'dict' => 'DictionaryMeasuringUnits' - ), - 'p.volume_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table - 'classfile' => '/core/class/cunits.class.php', - 'class' => 'CUnits', - 'method' => 'fetch', - 'units' => 'volume', - 'dict' => 'DictionaryMeasuringUnits' - ), - 'p.fk_country' => array( - 'rule' => 'fetchidfromcodeid', - 'classfile' => '/core/class/ccountry.class.php', - 'class' => 'Ccountry', - 'method' => 'fetch', - 'dict' => 'DictionaryCountry' - ) - ); - if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); - if (is_object($mysoc) && $usenpr) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); - if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); + if (!empty($conf->stock->enabled)) {//if Stock module enabled + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning + 'p.pmp' => 'PMPValue', //weighted average price + 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature + )); + } + + $this->import_convertvalue_array[$r] = array( + 'p.weight_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'weight', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.length_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'size', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.width_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'size', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.height_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'size', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.surface_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'surface', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.volume_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'volume', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.fk_country' => array( + 'rule' => 'fetchidfromcodeid', + 'classfile' => '/core/class/ccountry.class.php', + 'class' => 'Ccountry', + 'method' => 'fetch', + 'dict' => 'DictionaryCountry' + ) + ); + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); + if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; - // Add extra fields + // Add extra fields $import_extrafield_sample = array(); $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { - while ($obj = $this->db->fetch_object($resql)) - { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - $import_extrafield_sample[$fieldname] = $fieldlabel; - } + while ($obj = $this->db->fetch_object($resql)) + { + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + $import_extrafield_sample[$fieldname] = $fieldlabel; + } } // End add extra fields $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r] = array( - 'p.ref'=>'[^ ]', + 'p.ref'=>'[^ ]', 'p.price_base_type' => '\AHT\z|\ATTC\z', 'p.tosell'=>'^[0|1]$', - 'p.tobuy'=>'^[0|1]$', - 'p.fk_product_type'=>'^[0|1]$', - 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', + 'p.tobuy'=>'^[0|1]$', + 'p.fk_product_type'=>'^[0|1]$', + 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'p.recuperableonly' => '^[0|1]$', 'p.finished' => '^[0|1]$' ); @@ -534,7 +531,7 @@ 'p.desiredstock' => '' )); if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array('p.cost_price'=>'90')); - if (is_object($mysoc) && $usenpr) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0')); + if (is_object($mysoc) && $mysoc->useNPR()) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>'')); @@ -565,7 +562,7 @@ { if (!empty($conf->fournisseur->enabled)) { - // Import suppliers prices (note: this code is duplicated in module Service) + // Import suppliers prices (note: this code is duplicated in module Service) $r++; $this->import_code[$r] = $this->rights_class.'_supplierprices'; $this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key @@ -574,16 +571,16 @@ $this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); $this->import_tables_creator_array[$r] = array('sp'=>'fk_user'); $this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields - 'sp.fk_product'=>"ProductOrService*", - 'sp.fk_soc' => "Supplier*", - 'sp.ref_fourn' => 'SupplierRef*', - 'sp.quantity' => "QtyMin*", - 'sp.tva_tx' => 'VATRate', - 'sp.default_vat_code' => 'VATCode', - 'sp.delivery_time_days' => 'DeliveryDelay', - 'sp.supplier_reputation' => 'SupplierReputation' + 'sp.fk_product'=>"ProductOrService*", + 'sp.fk_soc' => "Supplier*", + 'sp.ref_fourn' => 'SupplierRef*', + 'sp.quantity' => "QtyMin*", + 'sp.tva_tx' => 'VATRate', + 'sp.default_vat_code' => 'VATCode', + 'sp.delivery_time_days' => 'DeliveryDelay', + 'sp.supplier_reputation' => 'SupplierReputation' ); - if (is_object($mysoc) && $usenpr) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( @@ -594,13 +591,13 @@ if (!empty($conf->multicurrency->enabled)) { - $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( - 'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line - 'sp.multicurrency_code'=>'CurrencyCode', - 'sp.multicurrency_tx'=>'CurrencyRate', - 'sp.multicurrency_unitprice'=>'CurrencyUnitPrice', - 'sp.multicurrency_price'=>'CurrencyPrice', - )); + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + 'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line + 'sp.multicurrency_code'=>'CurrencyCode', + 'sp.multicurrency_tx'=>'CurrencyRate', + 'sp.multicurrency_unitprice'=>'CurrencyUnitPrice', + 'sp.multicurrency_price'=>'CurrencyPrice', + )); } $this->import_convertvalue_array[$r] = array( @@ -620,7 +617,7 @@ 'sp.delivery_time_days' => '5', 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' ); - if (is_object($mysoc) && $usenpr) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( @@ -646,7 +643,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - // Import products multiprices + // Import products multiprices $r++; $this->import_code[$r] = $this->rights_class.'_multiprice'; $this->import_label[$r] = "ProductsOrServiceMultiPrice"; // Translation key @@ -660,23 +657,23 @@ 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.date_price'=>'DateCreation*'); if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx'] = 'VATRate'; - if (is_object($mysoc) && $usenpr) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); $this->import_regex_array[$r] = array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'pr.recuperableonly'=>'^[0|1]$'); $this->import_convertvalue_array[$r] = array( - 'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') + 'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"SERVICE_REF or id:123456", 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)", 'pr.price_level'=>"1", 'pr.price'=>"100", 'pr.price_ttc'=>"110", 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110", 'pr.tva_tx'=>'20', - 'pr.recuperableonly'=>'0', + 'pr.recuperableonly'=>'0', 'pr.date_price'=>'2013-04-10'); } if (!empty($conf->global->MAIN_MULTILANGS)) { - // Import translations of product names and descriptions + // Import translations of product names and descriptions $r++; $this->import_code[$r] = $this->rights_class.'_languages'; $this->import_label[$r] = "ProductsOrServicesTranslations"; @@ -701,7 +698,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modSocialNetworks.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modSocialNetworks.class.php @@ -31,57 +31,57 @@ class modSocialNetworks extends DolibarrModules { - /** + /** * Constructor. Define names, constants, directories, boxes, permissions * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs, $conf; + */ + public function __construct($db) + { + global $langs, $conf; - $this->db = $db; - $this->numero = 3400; + $this->db = $db; + $this->numero = 3400; // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "interface"; - // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '20'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)"; + $this->family = "interface"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '20'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - $this->picto = 'share-alt'; + $this->version = 'dolibarr'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + $this->picto = 'email'; - // Data directories to create when module is enabled - $this->dirs = array(); + // Data directories to create when module is enabled + $this->dirs = array(); - // Config pages + // Config pages $this->config_page_url = array(DOL_URL_ROOT.'/admin/dict.php?id=38'); - // Dependencies - $this->hidden = !empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + // Dependencies + $this->hidden = !empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module + $this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(5, 4); // Minimum version of PHP required by module - $this->langfiles = array(); + $this->langfiles = array(); - // Constants + // Constants - // New pages on tabs - $this->tabs = array(); + // New pages on tabs + $this->tabs = array(); - // Boxes - $this->boxes = array(); + // Boxes + $this->boxes = array(); - // Main menu entries - $this->menu = array(); - } + // Main menu entries + $this->menu = array(); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modSociete.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modSociete.class.php @@ -122,14 +122,20 @@ $r++; // Boxes - $this->boxes = array( - 0=>array('file'=>'box_clients.php', 'enabledbydefaulton'=>'Home'), - 1=>array('file'=>'box_prospect.php', 'enabledbydefaulton'=>'Home'), - 2=>array('file'=>'box_contacts.php', 'enabledbydefaulton'=>'Home'), - 3=>array('file'=>'box_activity.php', 'enabledbydefaulton'=>'Home', 'note'=>'(WarningUsingThisBoxSlowDown)'), - 4=>array('file'=>'box_goodcustomers.php', 'enabledbydefaulton'=>'Home', 'note'=>'(WarningUsingThisBoxSlowDown)'), - ); - + $this->boxes = array(); + $r = 0; + $this->boxes[$r][1] = "box_clients.php"; + $r++; + $this->boxes[$r][1] = "box_prospect.php"; + $r++; + $this->boxes[$r][1] = "box_contacts.php"; + $r++; + $this->boxes[$r][1] = "box_activity.php"; + $this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)'; + $r++; + $this->boxes[$r][1] = "box_goodcustomers.php"; + $this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)'; + $r++; // Permissions $this->rights = array(); $this->rights_class = 'societe'; @@ -255,15 +261,13 @@ $this->export_icon[$r] = 'company'; $this->export_permission[$r] = array(array("societe", "export")); $this->export_fields_array[$r] = array( - 's.rowid'=>"Id", 's.nom'=>"Name", 's.name_alias'=>"AliasNameShort", 'ps.nom'=>"ParentCompany", - 's.status'=>"Status", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", + 's.rowid'=>"Id", 's.nom'=>"Name", 's.name_alias'=>"AliasNameShort", 's.status'=>"Status", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode", - 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'd.nom'=>'State', 'r.nom'=>'Region', 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", - 's.url'=>"Url", 's.email'=>"Email", 's.default_lang'=>"DefaultLang", 's.canvas' => "Canvas", 's.siren'=>"ProfId1", 's.siret'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", + 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'd.nom'=>'State', 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", + 's.url'=>"Url", 's.email'=>"Email", 's.default_lang'=>"DefaultLang", 's.siren'=>"ProfId1", 's.siret'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.idprof5'=>"ProfId5", 's.idprof6'=>"ProfId6", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_private'=>"NotePrivate", 's.note_public'=>"NotePublic", 't.libelle'=>"ThirdPartyType", 'ce.code'=>"Staff", "cfj.libelle"=>"JuridicalStatus", 's.fk_prospectlevel'=>'ProspectLevel', - 'st.code'=>'ProspectStatus', 'payterm.libelle'=>'PaymentConditions', 'paymode.libelle'=>'PaymentMode', - 's.outstanding_limit'=>'OutstandingBill', 'pbacc.ref'=>'PaymentBankAccount', 'incoterm.code'=>'IncotermLabel' + 'st.code'=>'ProspectStatus', 'payterm.libelle'=>'PaymentConditions', 'paymode.libelle'=>'PaymentMode' ); if (!empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix'] = 'Prefix'; if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->export_fields_array[$r]['s.price_level'] = 'PriceLevel'; @@ -276,31 +280,24 @@ $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_fields_array[$r] += array('u.login'=>'SaleRepresentativeLogin', 'u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname'); - //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date", // 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label", - // 'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.default_lang'=>"Text",'s.canvas' => "Canvas",'s.siret'=>"Text",'s.siren'=>"Text", + // 'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text", // 's.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note'=>"Text", // 't.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code', // 's.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid' //); $this->export_TypeFields_array[$r] = array( - 's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 'ps.nom'=>"Text", - 's.status'=>"Numeric", 's.client'=>"Numeric", 's.fournisseur'=>"Boolean", 's.datec'=>"Date", 's.tms'=>"Date", - 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text", - 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", - 'd.nom'=>'Text', 'r.nom'=>'Text', 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", - 's.phone'=>"Text", 's.fax'=>"Text", - 's.url'=>"Text", 's.email'=>"Text", 's.default_lang'=>"Text", 's.canvas' => "Canvas", - 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.idprof5'=>"Text", 's.idprof6'=>"Text", - 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_private'=>"Text", 's.note_public'=>"Text", - 't.libelle'=>"Text", 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code', - 'st.code'=>'List:c_stcomm:libelle:code', - 'payterm.libelle'=>'Text', 'paymode.libelle'=>'Text', - 's.outstanding_limit'=>'Numeric', 'pbacc.ref'=>'Text', 'incoterm.code'=>'Text', - 'u.login'=>'Text', 'u.firstname'=>'Text', 'u.lastname'=>'Text', - 's.entity'=>'Numeric', 's.price_level'=>'Numeric' + 's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Numeric", 's.client'=>"Numeric", 's.fournisseur'=>"Boolean", 's.datec'=>"Date", 's.tms'=>"Date", + 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", + 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", + 's.default_lang'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.idprof5'=>"Text", 's.idprof6'=>"Text", + 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_private'=>"Text", 's.note_public'=>"Text", 't.libelle'=>"Text", + 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code', + 'st.code'=>'List:c_stcomm:libelle:code', 'd.nom'=>'Text', 'u.login'=>'Text', 'u.firstname'=>'Text', 'u.lastname'=>'Text', 'payterm.libelle'=>'Text', + 'paymode.libelle'=>'Text', 's.entity'=>'Numeric', + 's.price_level'=>'Numeric' ); $this->export_entities_array[$r] = array('u.login'=>'user', 'u.firstname'=>'user', 'u.lastname'=>'user'); // We define here only fields that use another picto @@ -308,19 +305,15 @@ $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON s.parent = ps.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_regions as r ON r.code_region = d.fk_region AND r.fk_pays = s.fk_pays'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as pbacc ON s.fk_account = pbacc.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as incoterm ON s.fk_incoterms = incoterm.rowid'; $this->export_sql_end[$r] .= ' WHERE s.entity IN ('.getEntity('societe').')'; if (is_object($user) && empty($user->rights->societe->client->voir)) { $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' '; @@ -340,7 +333,7 @@ $this->export_fields_array[$r] = array( 'c.rowid'=>"IdContact", 'c.civility'=>"CivilityCode", 'c.lastname'=>'Lastname', 'c.firstname'=>'Firstname', 'c.poste'=>'PostOrFunction', 'c.datec'=>"DateCreation", 'c.tms'=>"DateLastModification", 'c.priv'=>"ContactPrivate", 'c.address'=>"Address", 'c.zip'=>"Zip", 'c.town'=>"Town", - 'd.nom'=>'State', 'r.nom'=>'Region', 'co.label'=>"Country", 'co.code'=>"CountryCode", 'c.phone'=>"Phone", 'c.fax'=>"Fax", 'c.phone_mobile'=>"Mobile", 'c.email'=>"EMail", + 'd.nom'=>'State', 'co.label'=>"Country", 'co.code'=>"CountryCode", 'c.phone'=>"Phone", 'c.fax'=>"Fax", 'c.phone_mobile'=>"Mobile", 'c.email'=>"EMail", 'c.statut'=>"Status", 's.rowid'=>"IdCompany", 's.nom'=>"CompanyName", 's.status'=>"Status", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode", @@ -351,7 +344,7 @@ $this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); $this->export_TypeFields_array[$r] = array( 'c.civility'=>"List:c_civility:label:code", 'c.lastname'=>'Text', 'c.firstname'=>'Text', 'c.poste'=>'Text', 'c.datec'=>"Date", 'c.priv'=>"Boolean", - 'c.address'=>"Text", 'c.zip'=>"Text", 'c.town'=>"Text", 'd.nom'=>'Text', 'r.nom'=>'Text', 'co.label'=>"List:c_country:label:rowid", 'co.code'=>"Text", 'c.phone'=>"Text", + 'c.address'=>"Text", 'c.zip'=>"Text", 'c.town'=>"Text", 'd.nom'=>'Text', 'co.label'=>"List:c_country:label:rowid", 'co.code'=>"Text", 'c.phone'=>"Text", 'c.fax'=>"Text", 'c.email'=>"Text", 'c.statut'=>"Status", 's.rowid'=>"List:societe:nom::thirdparty", 's.nom'=>"Text", 's.status'=>"Status", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", @@ -382,7 +375,6 @@ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object'; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_regions as r ON r.code_region = d.fk_region AND r.fk_pays = c.fk_pays'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; @@ -415,7 +407,6 @@ $this->import_fields_array[$r] = array(//field order as per structure of table llx_societe 's.nom' => "Name*", 's.name_alias' => "AliasNameShort", - 's.parent' => "ParentCompany", 's.status' => "Status", 's.code_client' => "CustomerCode", 's.code_fournisseur' => "SupplierCode", @@ -452,9 +443,6 @@ 's.cond_reglement' => "PaymentTermsCustomer", 's.mode_reglement_supplier' => 'PaymentTypeSupplier', 's.cond_reglement_supplier' => "PaymentTermsSupplier", - 's.outstanding_limit'=>'OutstandingBill', - 's.fk_account'=>'PaymentBankAccount', - 's.fk_incoterms'=>'IncotermLabel', 's.tva_assuj' => 'VATIsUsed', 's.barcode' => 'BarCode', 's.default_lang' => 'DefaultLanguage', @@ -490,7 +478,7 @@ 'classfile' => '/core/class/cstate.class.php', 'class' => 'Cstate', 'method' => 'fetch', - 'dict' => 'DictionaryStateCode' + 'dict' => 'DictionaryState' ), 's.fk_pays' => array( 'rule' => 'fetchidfromcodeid', @@ -508,29 +496,6 @@ ), 's.capital' => array('rule' => 'numeric'), 's.fk_stcomm' => array('rule' => 'zeroifnull'), - 's.parent' => array( - 'rule' => 'fetchidfromref', - 'file' => '/societe/class/societe.class.php', - 'class' => 'Societe', - 'method' => 'fetch', - 'element' => 'ThirdParty' - ), - 's.outstanding_limit' => array('rule' => 'numeric'), - 's.fk_account' => array( - 'rule' => 'fetchidfromcodeid', - 'classfile' => '/compta/bank/class/account.class.php', - 'class' => 'Account', - 'method' => 'fetch', - 'element' => 'BankAccount' - // ), - // TODO - // 's.fk_incoterms' => array( - // 'rule' => 'fetchidfromcodeid', - // 'classfile' => '/core/class/cincoterm.class.php', - // 'class' => 'Cincoterm', - // 'method' => 'fetch', - // 'dict' => 'IncotermLabel' - ) ); //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); $this->import_regex_array[$r] = array(//field order as per structure of table llx_societe @@ -542,7 +507,6 @@ 's.cond_reglement' => 'rowid@'.MAIN_DB_PREFIX.'c_payment_term', 's.mode_reglement_supplier' => 'id@'.MAIN_DB_PREFIX.'c_paiement', 's.cond_reglement_supplier' => 'rowid@'.MAIN_DB_PREFIX.'c_payment_term', - 's.fk_incoterms' => 'rowid@'.MAIN_DB_PREFIX.'c_incoterms', 's.tva_assuj' => '^[0|1]', 's.fk_multicurrency' => '^[0|1]', 's.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$', @@ -552,7 +516,6 @@ $this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe 's.nom' => "TPBigCompany", 's.name_alias' => "Alias for TPBigCompany", - 's.parent' => "TPMotherCompany", 's.status' => "0 (closed) / 1 (active)", 's.code_client' => 'eg. CU01-0001 / empty / "auto"', 's.code_fournisseur' => 'eg. SU01-0001 / empty / "auto"', @@ -589,9 +552,6 @@ 's.cond_reglement' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_payment_term"', 's.mode_reglement_supplier' => '1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.'c_paiement"', 's.cond_reglement_supplier' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_payment_term"', - 's.outstanding_limit' => "5000", - 's.fk_account' => "rowid or ref", - 's.fk_incoterms' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_incoterms"', 's.tva_assuj' => '0 (VAT not used) / 1 (VAT used)', 's.barcode' => '123456789', 's.default_lang' => 'en_US / es_ES etc...matches a language directory in htdocs/langs/', @@ -630,7 +590,7 @@ 's.town' => "Town", 's.fk_departement' => "StateCode", 's.fk_pays' => "CountryCode", - 's.birthday' => "DateOfBirth", + 's.birthday' => "BirthdayDate", 's.poste' => "Role", 's.phone' => "Phone", 's.phone_perso' => "PhonePerso", @@ -670,7 +630,7 @@ 'classfile' => '/core/class/cstate.class.php', 'class' => 'Cstate', 'method' => 'fetch', - 'dict' => 'DictionaryStateCode' + 'dict' => 'DictionaryState' ), 's.fk_pays' => array( 'rule' => 'fetchidfromcodeid', --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modStock.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modStock.class.php @@ -81,14 +81,14 @@ $r++; $this->const[$r][0] = "STOCK_ADDON_PDF"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "standard"; + $this->const[$r][2] = "Standard"; $this->const[$r][3] = 'Name of PDF model of stock'; $this->const[$r][4] = 0; $r++; $this->const[$r][0] = "MOUVEMENT_ADDON_PDF"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "stdmovement"; + $this->const[$r][2] = "StdMouvement"; $this->const[$r][3] = 'Name of PDF model of stock mouvement'; $this->const[$r][4] = 0; @@ -150,29 +150,29 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - $this->rights[5][0] = 1011; - $this->rights[5][1] = 'inventoryReadPermission'; // Permission label - $this->rights[5][3] = 0; // Permission by default for new user (0/1) - $this->rights[5][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[5][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - - $this->rights[6][0] = 1012; - $this->rights[6][1] = 'inventoryCreatePermission'; // Permission label - $this->rights[6][3] = 0; // Permission by default for new user (0/1) - $this->rights[6][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[6][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - - $this->rights[8][0] = 1014; - $this->rights[8][1] = 'inventoryValidatePermission'; // Permission label - $this->rights[8][3] = 0; // Permission by default for new user (0/1) - $this->rights[8][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[8][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - - $this->rights[9][0] = 1015; - $this->rights[9][1] = 'inventoryChangePMPPermission'; // Permission label - $this->rights[9][3] = 0; // Permission by default for new user (0/1) - $this->rights[9][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[5][0] = 1011; + $this->rights[5][1] = 'inventoryReadPermission'; // Permission label + $this->rights[5][3] = 0; // Permission by default for new user (0/1) + $this->rights[5][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[5][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + + $this->rights[6][0] = 1012; + $this->rights[6][1] = 'inventoryCreatePermission'; // Permission label + $this->rights[6][3] = 0; // Permission by default for new user (0/1) + $this->rights[6][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[6][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + + $this->rights[8][0] = 1014; + $this->rights[8][1] = 'inventoryValidatePermission'; // Permission label + $this->rights[8][3] = 0; // Permission by default for new user (0/1) + $this->rights[8][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[8][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + + $this->rights[9][0] = 1015; + $this->rights[9][1] = 'inventoryChangePMPPermission'; // Permission label + $this->rights[9][3] = 0; // Permission by default for new user (0/1) + $this->rights[9][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) } // Main menu entries @@ -188,60 +188,28 @@ //-------- $r = 0; - // Export warehouses - $r++; - $this->export_code[$r] = $this->rights_class.'_emplacement'; - $this->export_label[$r] = "Warehouses"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r] = "warehouse"; + $r++; + $this->export_code[$r] = $this->rights_class; + $this->export_label[$r] = "WarehousesAndProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r] = array(array("stock", "lire")); $this->export_fields_array[$r] = array( - 'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', 'e.zip'=>'Zip', 'e.town'=>'Town', - 'd.code_departement'=>'Departement', 'c.code'=>'CountryCode', - 'e.phone'=>'Phone', 'e.fax'=>'Fax', 'e.statut'=>'Status', 'pe.rowid'=>'ParentWarehouse', 'pe.ref'=>'LocationSummary' + 'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', + 'e.zip'=>'Zip', 'e.town'=>'Town', 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", + 'p.note'=>"Note", 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", 'p.datec'=>'DateCreation', + 'p.tms'=>'DateModification', 'p.pmp'=>'PMPValue', 'p.cost_price'=>'CostPrice' ); $this->export_TypeFields_array[$r] = array( - 'e.ref'=>'Text', 'e.description'=>'Text', 'e.lieu'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text', - 'd.code_departement'=>'List:c_departements:code_departement:code_departement:', 'c.code'=>'List:c_country:code:code:', - 'e.phone'=>'Text', 'e.fax'=>'Text', 'e.statut'=>'Text', 'pe.rowid'=>'List:entrepot:ref:rowid:stock', 'pe.ref'=>'Text' - ); - $this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into export_icon - $this->export_aggregate_array[$r] = array(); - $keyforselect = 'warehouse'; $keyforelement = 'warehouse'; $keyforaliasextra = 'extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'entrepot as e'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON d.rowid = e.fk_departement'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON c.rowid = e.fk_pays'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as pe ON pe.rowid = e.fk_parent'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot_extrafields as extra ON extra.fk_object = e.rowid'; - $this->export_sql_end[$r] .= ' WHERE e.entity IN ('.getEntity('stock').')'; - - // Export stock (without batch number) - $r++; - $this->export_code[$r] = $this->rights_class.'_emplacement_product'; - $this->export_label[$r] = "Stocks"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r] = "warehouse"; - $this->export_permission[$r] = array(array("stock", "lire")); - $this->export_fields_array[$r] = array( - 'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', 'e.zip'=>'Zip', 'e.town'=>'Town', - 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", 'p.note'=>"Note", - 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", - 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification', 'p.pmp'=>'PMPValue', 'p.cost_price'=>'CostPrice', - ); - $this->export_TypeFields_array[$r] = array( - 'e.rowid'=>'List:entrepot:ref::stock', 'e.ref'=>'Text', 'e.lieu'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text', - 'p.rowid'=>"List:product:label::product", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text", - 'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", - 'p.datec'=>'Date', 'p.tms'=>'Date', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric', + 'e.rowid'=>'List:entrepot:ref::stock', 'e.ref'=>'Text', 'e.lieu'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text', 'p.rowid'=>"List:product:label::product", + 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text", 'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', + 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric', 'ps.reel'=>'Numeric' ); $this->export_entities_array[$r] = array( - 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", 'p.note'=>"product", - 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product", - 'p.datec'=>'product', 'p.tms'=>'product', 'p.pmp'=>'product', 'p.cost_price'=>'product', - 'ps.reel'=>'stock' - ); // We define here only fields that use another icon that the one defined into export_icon + 'e.rowid'=>'warehouse', 'e.ref'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse', + 'e.town'=>'warehouse', 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", + 'p.note'=>"product", 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product", + 'p.datec'=>'product', 'p.tms'=>'product', 'p.pmp'=>'product', 'p.cost_price'=>'product', 'ps.reel'=>'stock' + ); $this->export_aggregate_array[$r] = array('ps.reel'=>'SUM'); // TODO Not used yet $this->export_dependencies_array[$r] = array('stock'=>array('p.rowid', 'e.rowid')); // We must keep this until the aggregate_array is used. To have a unique key, if we ask a field of a child, to avoid the DISTINCT to discard them. $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; @@ -252,81 +220,73 @@ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON extra.fk_object = p.rowid, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e'; $this->export_sql_end[$r] .= ' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid'; $this->export_sql_end[$r] .= ' AND e.entity IN ('.getEntity('stock').')'; - - // Export stock including batch number if ($conf->productbatch->enabled) { + // Export of stock including lot number $langs->load("productbatch"); // This request is same than previous but without field ps.stock (real stock in warehouse) and with link to subtable productbatch $r++; - $this->export_code[$r] = $this->rights_class.'_emplacement_product_lot'; - $this->export_label[$r] = "StocksWithBatch"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r] = "warehouse"; + $this->export_code[$r] = $this->rights_class.'_lot'; + $this->export_label[$r] = "WarehousesAndProductsBatchDetail"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r] = array(array("stock", "lire")); $this->export_fields_array[$r] = array( - 'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', 'e.zip'=>'Zip', 'e.town'=>'Town', - 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", 'p.note'=>"Note", - 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", - 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification', 'p.pmp'=>'PMPValue', 'p.cost_price'=>'CostPrice', - 'pb.rowid'=>'Id', 'pb.batch'=>'Batch', 'pb.qty'=>'Qty', - 'pl.eatby'=>'EatByDate', 'pl.sellby'=>'SellByDate' + 'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', + 'e.zip'=>'Zip', 'e.town'=>'Town', 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", + 'p.note'=>"Note", 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", 'p.datec'=>'DateCreation', + 'p.tms'=>'DateModification', 'pb.rowid'=>'Id', 'pb.batch'=>'Batch', 'pb.qty'=>'Qty', 'pl.eatby'=>'EatByDate', 'pl.sellby'=>'SellByDate' ); $this->export_TypeFields_array[$r] = array( 'e.rowid'=>'List:entrepot:ref::stock', 'e.ref'=>'Text', 'e.lieu'=>'Text', 'e.description'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text', 'p.rowid'=>"List:product:label::product", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text", - 'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", - 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification', 'p.pmp'=>'PMPValue', 'p.cost_price'=>'CostPrice', - 'pb.batch'=>'Text', 'pb.qty'=>'Numeric', - 'pl.eatby'=>'Date', 'pl.sellby'=>'Date' + 'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date', + 'pb.batch'=>'Text', 'pb.qty'=>'Numeric', 'pl.eatby'=>'Date', 'pl.sellby'=>'Date' ); $this->export_entities_array[$r] = array( - 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", 'p.note'=>"product", - 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product", - 'p.datec'=>'product', 'p.tms'=>'product', 'p.pmp'=>'product', 'p.cost_price'=>'product', - 'pb.rowid'=>'batch', 'pb.batch'=>'batch', 'pb.qty'=>'batch', - 'pl.eatby'=>'batch', 'pl.sellby'=>'batch' - ); // We define here only fields that use another icon that the one defined into export_icon + 'e.rowid'=>'warehouse', 'e.ref'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse', + 'e.town'=>'warehouse', 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", + 'p.note'=>"product", 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product", + 'p.datec'=>'product', 'p.tms'=>'product', 'pb.rowid'=>'stockbatch', 'pb.batch'=>'stockbatch', 'pb.qty'=>'stockbatch', 'pl.eatby'=>'batch', + 'pl.sellby'=>'batch' + ); $this->export_aggregate_array[$r] = array('ps.reel'=>'SUM'); // TODO Not used yet $this->export_dependencies_array[$r] = array('stockbatch'=>array('pb.rowid'), 'batch'=>array('pb.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. $keyforselect = 'product_lot'; $keyforelement = 'batch'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product_batch as pb'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'product_stock as ps ON ps.rowid = pb.fk_product_stock'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'product as p ON p.rowid = ps.fk_product'; + $this->export_sql_end[$r] = ' FROM ('.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'product_batch as pb)'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl ON pl.fk_product = p.rowid AND pl.batch = pb.batch'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot_extrafields as extra ON extra.fk_object = pl.rowid,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'entrepot as e'; - $this->export_sql_end[$r] .= ' WHERE ps.fk_entrepot = e.rowid'; + $this->export_sql_end[$r] .= ' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid AND ps.rowid = pb.fk_product_stock'; $this->export_sql_end[$r] .= ' AND e.entity IN ('.getEntity('stock').')'; } - // Export of stock movements + // Export of stock movement $r++; $this->export_code[$r] = $this->rights_class.'_movement'; $this->export_label[$r] = "StockMovements"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r] = "movement"; $this->export_permission[$r] = array(array("stock", "lire")); $this->export_fields_array[$r] = array( - 'sm.rowid'=>'MovementId', 'sm.value'=>'Qty', 'sm.datem'=>'DateMovement', 'sm.label'=>'MovementLabel', 'sm.inventorycode'=>'InventoryCode', - 'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', 'e.zip'=>'Zip', 'e.town'=>'Town', - 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", 'p.note'=>"Note", - 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' + 'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', 'e.zip'=>'Zip', + 'e.town'=>'Town', 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", 'p.note'=>"Note", + 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", 'p.datec'=>'DateCreation', + 'p.tms'=>'DateModification', 'sm.rowid'=>'MovementId', 'sm.value'=>'Qty', 'sm.datem'=>'DateMovement', 'sm.label'=>'MovementLabel', + 'sm.inventorycode'=>'InventoryCode' ); $this->export_TypeFields_array[$r] = array( - 'sm.rowid'=>'Numeric', 'sm.value'=>'Numeric', 'sm.datem'=>'Date', 'sm.batch'=>'Text', 'sm.label'=>'Text', 'sm.inventorycode'=>'Text', 'e.rowid'=>'List:entrepot:ref::stock', 'e.ref'=>'Text', 'e.description'=>'Text', 'e.lieu'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text', 'p.rowid'=>"List:product:label::product", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text", - 'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date' + 'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date', + 'sm.rowid'=>'Numeric', 'sm.value'=>'Numeric', 'sm.datem'=>'Date', 'sm.batch'=>'Text', 'sm.label'=>'Text', 'sm.inventorycode'=>'Text' ); $this->export_entities_array[$r] = array( - 'e.rowid'=>'warehouse', 'e.ref'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse', 'e.town'=>'warehouse', - 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", 'p.note'=>"product", - 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product", 'p.datec'=>'product', 'p.tms'=>'product' - ); // We define here only fields that use another icon that the one defined into export_icon + 'e.rowid'=>'warehouse', 'e.ref'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse', + 'e.town'=>'warehouse', 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", + 'p.note'=>"product", 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product", 'p.datec'=>'product', + 'p.tms'=>'product', 'sm.rowid'=>'movement', 'sm.value'=>'movement', 'sm.datem'=>'movement', 'sm.label'=>'movement', 'sm.inventorycode'=>'movement' + ); if ($conf->productbatch->enabled) { $this->export_fields_array[$r]['sm.batch'] = 'Batch'; @@ -335,7 +295,6 @@ } $this->export_aggregate_array[$r] = array('sm.value'=>'SUM'); // TODO Not used yet $this->export_dependencies_array[$r] = array('movement'=>array('sm.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. - $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'stock_mouvement as sm, '.MAIN_DB_PREFIX.'entrepot as e'; $this->export_sql_end[$r] .= ' WHERE p.rowid = sm.fk_product AND sm.fk_entrepot = e.rowid'; @@ -350,48 +309,34 @@ $r++; $this->import_code[$r] = $this->rights_class.'_'.$r; $this->import_label[$r] = "Warehouses"; // Translation key - $this->import_icon[$r] = "warehouse"; + $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r] = array('e'=>MAIN_DB_PREFIX.'entrepot'); $this->import_tables_creator_array[$r] = array('e'=>'fk_user_author'); $this->import_fields_array[$r] = array('e.ref'=>"LocationSummary*", - 'e.description'=>"DescWareHouse", - 'e.lieu'=>"LieuWareHouse", - 'e.address'=>"Address", - 'e.zip'=>'Zip', - 'e.fk_departement'=>'StateCode', - 'e.fk_pays'=>'CountryCode', - 'e.phone'=>'Phone', - 'e.fax'=>'Fax', + 'e.description'=>"DescWareHouse", 'e.lieu'=>"LieuWareHouse", + 'e.address'=>"Address", 'e.zip'=>'Zip', 'e.fk_pays'=>'CountryCode', 'e.statut'=>'Status', - 'e.fk_parent'=>'ParentWarehouse' + 'e.fk_parent'=>'ParentWarehouse' ); $this->import_convertvalue_array[$r] = array( - 'e.fk_departement'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/cstate.class.php', 'class'=>'Cstate', 'method'=>'fetch', 'dict'=>'DictionaryStateCode'), 'e.fk_pays'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/ccountry.class.php', 'class'=>'Ccountry', 'method'=>'fetch', 'dict'=>'DictionaryCountry'), - 'e.fk_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/stock/class/entrepot.class.php', 'class'=>'Entrepot', 'method'=>'fetch', 'element'=>'ref') + 'e.fk_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/stock/class/entrepot.class.php', 'class'=>'Entrepot', 'method'=>'fetch', 'element'=>'ref') ); $this->import_regex_array[$r] = array('e.statut'=>'^[0|1]'); $this->import_examplevalues_array[$r] = array('e.ref'=>"ALM001", - 'e.description'=>"Central Warehouse", - 'e.lieu'=>"Central", - 'e.address'=>"Route 66", - 'e.zip'=>'28080', - 'e.fk_departement'=>'matches field "code_departement" in table "'.MAIN_DB_PREFIX.'c_departements"', - 'e.fk_pays'=>'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.'c_country"', - 'e.phone'=>'(+33)(0)123456789', - 'e.fax'=>'(+33)(0)123456790', + 'e.description'=>"Central Warehouse", 'e.lieu'=>"Central", + 'e.address'=>"Route 66", 'e.zip'=>'28080', 'e.fk_pays'=>'US', 'e.statut'=>'1', - 'e.fk_parent'=>'id or ref of warehouse' + 'e.fk_parent'=>'' ); - $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); // Import stocks $r++; $this->import_code[$r] = $this->rights_class.'_'.$r; $this->import_label[$r] = "Stocks"; // Translation key - $this->import_icon[$r] = "stock"; + $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r] = array('ps'=>MAIN_DB_PREFIX.'product_stock'); $this->import_fields_array[$r] = array('ps.fk_product'=>"Product*", 'ps.fk_entrepot'=>"Warehouse*", 'ps.reel'=>"Stock*"); @@ -401,11 +346,11 @@ 'ps.fk_entrepot'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/stock/class/entrepot.class.php', 'class'=>'Entrepot', 'method'=>'fetch', 'element'=>'ref') ); $this->import_examplevalues_array[$r] = array( - 'ps.fk_product'=>"id or ref of product", 'ps.fk_entrepot'=>"id or ref of warehouse", 'ps.reel'=>"10" + 'ps.fk_product'=>"PREF123456", 'ps.fk_entrepot'=>"ALM001", 'ps.reel'=>"10" ); $this->import_updatekeys_array[$r] = array('ps.fk_product'=>'Product', 'ps.fk_entrepot'=>"Warehouse"); $this->import_run_sql_after_array[$r] = array( // Because we may change data that are denormalized, we must update dernormalized data after. - 'UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);' + 'UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);' ); } @@ -426,9 +371,9 @@ $this->remove($options); //ODT template - $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/stocks/template_warehouse.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/stocks'; - $dest = $dirodt.'/template_warehouse.odt'; + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/stock/template_stock.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/stock'; + $dest = $dirodt.'/template_stock.odt'; if (file_exists($src) && !file_exists($dest)) { --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modStripe.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modStripe.class.php @@ -31,68 +31,68 @@ */ class modStripe extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 50300; - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'stripe'; + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 50300; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'stripe'; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page - $this->family = "interface"; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "Module to offer an online payment page by credit card with Stripe"; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png' - $this->picto = 'stripe'; + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "interface"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "Module to offer an online payment page by credit card with Stripe"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png' + $this->picto = 'stripe'; - // Data directories to create when module is enabled. - $this->dirs = array(); + // Data directories to create when module is enabled. + $this->dirs = array(); - // Config pages. Put here list of php page names stored in admin directory used to setup module. - $this->config_page_url = array("stripe.php@stripe"); + // Config pages. Put here list of php page names stored in admin directory used to setup module. + $this->config_page_url = array("stripe.php@stripe"); - // Dependencies - $this->hidden = false; // A condition to hide module - $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->phpmin = array(5, 4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(5, 0); // Minimum version of Dolibarr required by module - $this->langfiles = array("stripe"); + // Dependencies + $this->hidden = false; // A condition to hide module + $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->phpmin = array(5, 4); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(5, 0); // Minimum version of Dolibarr required by module + $this->langfiles = array("stripe"); - // Constants - $this->const = array(); // List of particular constants to add when module is enabled + // Constants + $this->const = array(); // List of particular constants to add when module is enabled - // New pages on tabs - $this->tabs = array(); + // New pages on tabs + $this->tabs = array(); - // List of boxes - $this->boxes = array(); - $r = 0; + // List of boxes + $this->boxes = array(); + $r = 0; - // Permissions - $this->rights = array(); // Permission array used by this module - $r = 0; + // Permissions + $this->rights = array(); // Permission array used by this module + $r = 0; - // Main menu entries - $r = 0; - /* $this->menu[$r]=array( + // Main menu entries + $r = 0; + /* $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'mainmenu'=>'billing', 'leftmenu'=>'customers_bills_payment_stripe', @@ -108,8 +108,8 @@ ); // 0=Menu for internal users, 1=external users, 2=both $r++;*/ - $this->menu[$r] = array( - 'fk_menu'=>'fk_mainmenu=bank', + $this->menu[$r] = array( + 'fk_menu'=>'fk_mainmenu=bank', 'type'=>'left', 'titre'=>'StripeAccount', 'mainmenu'=>'bank', @@ -123,7 +123,7 @@ 'user' => 0 ); - $r++; + $r++; $this->menu[$r] = array( 'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe', 'type' => 'left', @@ -137,7 +137,7 @@ 'user' => 0 ); - $r++; + $r++; $this->menu[$r] = array( 'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe', 'type' => 'left', @@ -151,8 +151,8 @@ 'user' => 0 ); - $r++; - $this->menu[$r] = array( + $r++; + $this->menu[$r] = array( 'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe', 'type' => 'left', 'titre' => 'StripePayoutList', @@ -165,7 +165,7 @@ 'user' => 0 ); - // Exports - $r = 1; - } + // Exports + $r = 1; + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modSupplierProposal.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modSupplierProposal.class.php @@ -63,7 +63,7 @@ $this->dirs = array(); // Config pages. Put here list of php page names stored in admin directory used to setup module. - $this->config_page_url = array("supplier_proposal.php"); + $this->config_page_url = array("supplier_proposal.php"); // Dependencies $this->hidden = false; // A condition to hide module @@ -127,7 +127,7 @@ $this->rights[$r][0] = $this->numero + $r; // id de la permission $this->rights[$r][1] = 'Envoyer les demandes fournisseurs'; // libelle de la permission $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'send_advance'; + $this->rights[$r][4] = 'send_advance'; $r++; $this->rights[$r][0] = $this->numero + $r; // id de la permission @@ -152,10 +152,10 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - public function init($options = '') + public function init($options = '') { global $conf, $langs; @@ -200,10 +200,10 @@ */ public function remove($options = '') { - $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'" // To delete/clean deprecated entries - ); - - return $this->_remove($sql, $options); + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'" // To delete/clean deprecated entries + ); + + return $this->_remove($sql, $options); } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modTakePos.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modTakePos.class.php @@ -39,9 +39,9 @@ */ public function __construct($db) { - global $langs, $conf; - - $this->db = $db; + global $langs, $conf; + + $this->db = $db; // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). @@ -78,16 +78,16 @@ // for specific path of parts (eg: /takepos/core/modules/barcode) // for specific css file (eg: /takepos/css/takepos.css.php) $this->module_parts = array( - 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) + 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) 'login' => 0, // Set this to 1 if module has its own login method file (core/login) 'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions) 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) - 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) + 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) 'hooks' => array() // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' - ); + ); // Data directories to create when module is enabled. // Example: this->dirs = array("/takepos/temp","/takepos/subdir"); @@ -127,13 +127,13 @@ // Array to add new pages in new tabs - $this->tabs = array(); + $this->tabs = array(); // Example: // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@takepos:$user->rights->takepos->read:/takepos/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 - // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@takepos:$user->rights->othermodule->read:/takepos/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. - // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname - // - // Where objecttype can be + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@takepos:$user->rights->othermodule->read:/takepos/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'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) // 'contact' to add a tab in contact view // 'contract' to add a tab in contract view @@ -155,9 +155,9 @@ // 'user' to add a tab in user view - // Dictionaries + // Dictionaries $this->dictionaries = array(); - /* Example: + /* Example: $this->dictionaries=array( 'langs'=>'mylangfile@takepos', 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor @@ -173,13 +173,13 @@ */ - // Boxes/Widgets + // Boxes/Widgets // Add here list of php file(s) stored in takepos/core/boxes that contains class to show a widget. - $this->boxes = array( - //0=>array('file'=>'takeposwidget1.php@takepos','note'=>'Widget provided by TakePos','enabledbydefaulton'=>'Home'), - //1=>array('file'=>'takeposwidget2.php@takepos','note'=>'Widget provided by TakePos'), - //2=>array('file'=>'takeposwidget3.php@takepos','note'=>'Widget provided by TakePos') - ); + $this->boxes = array( + //0=>array('file'=>'takeposwidget1.php@takepos','note'=>'Widget provided by TakePos','enabledbydefaulton'=>'Home'), + //1=>array('file'=>'takeposwidget2.php@takepos','note'=>'Widget provided by TakePos'), + //2=>array('file'=>'takeposwidget3.php@takepos','note'=>'Widget provided by TakePos') + ); // Cronjobs (List of cron jobs entries to add when module is enabled) @@ -260,7 +260,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modTax.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modTax.class.php @@ -147,14 +147,14 @@ $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'chargesociales'); $this->import_fields_array[$r] = array('t.libelle'=>"Label*", 't.fk_type'=>"Type", - 't.amount'=>"Amount*", 't.date_ech'=>"DateDue*", 't.periode'=>"PeriodEndDate*" + 't.amount'=>"Amount*", 't.date_ech'=>"DateDue*", 't.periode'=>"PeriodEndDate*" ); $this->import_convertvalue_array[$r] = array( - 't.fk_type'=>array('rule'=>'fetchidfromref', 'classfile'=>'/compta/sociales/class/cchargesociales.class.php', 'class'=>'Cchargesociales', 'method'=>'fetch', 'element'=>'Cchargesociales') + 't.fk_type'=>array('rule'=>'fetchidfromref', 'classfile'=>'/compta/sociales/class/cchargesociales.class.php', 'class'=>'Cchargesociales', 'method'=>'fetch', 'element'=>'Cchargesociales') ); $this->import_examplevalues_array[$r] = array('t.libelle'=>"Social/fiscal contribution", 't.fk_type'=>"TAXPRO (must be id or code found into dictionary)", - 't.date_ech'=>"2016-01-01", 't.periode'=>"2016-01-01" + 't.date_ech'=>"2016-01-01", 't.periode'=>"2016-01-01" ); // Import Taxes @@ -165,14 +165,14 @@ $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'tva'); $this->import_fields_array[$r] = array('t.datep'=>"DatePayment*", 't.datev'=>"DateValue*", 't.label'=>"Label*", 't.fk_typepayment'=>"PaymentMode*", - 't.amount'=>"Amount*", 't.num_payment'=>'Numero' + 't.amount'=>"Amount*", 't.num_payment'=>'Numero' ); $this->import_convertvalue_array[$r] = array( - 't.fk_typepayment'=>array('rule'=>'fetchidfromref', 'classfile'=>'/compta/paiement/class/cpaiement.class.php', 'class'=>'Cpaiement', 'method'=>'fetch', 'element'=>'Cpaiement') + 't.fk_typepayment'=>array('rule'=>'fetchidfromref', 'classfile'=>'/compta/paiement/class/cpaiement.class.php', 'class'=>'Cpaiement', 'method'=>'fetch', 'element'=>'Cpaiement') ); $this->import_examplevalues_array[$r] = array('t.label'=>"VAT Payment 1st quarter 2016", 't.fk_typepayment'=>"CHQ (must be id or code found into dictionary)", - 't.datep'=>"2016-04-02", 't.datev'=>"2016-03-31", 't.amount'=>1000, 't.num_payment'=>'123456' + 't.datep'=>"2016-04-02", 't.datev'=>"2016-03-31", 't.amount'=>1000, 't.num_payment'=>'123456' ); } @@ -182,7 +182,7 @@ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modTicket.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modTicket.class.php @@ -32,290 +32,267 @@ */ class modTicket extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs, $conf; - - $this->db = $db; - - // Id for module (must be unique). - // Use a free id here - // (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 56000; - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'ticket'; - - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page - $this->family = "crm"; - // Module position in the family - $this->module_position = '60'; - // Module label (no space allowed) - // used if translation string 'ModuleXXXName' not found - // (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description - // used if translation string 'ModuleXXXDesc' not found - // (where XXX is value of numeric property 'numero' of module) - $this->description = "Incident/support ticket management"; - // Possible values for version are: 'development', 'experimental' or version - $this->version = 'dolibarr'; - // Key used in llx_const table to save module status enabled/disabled - // (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png - // use this->picto='pictovalue' - // If file is in module/img directory under name object_pictovalue.png - // use this->picto='pictovalue@module' - $this->picto = 'ticket'; // mypicto@ticket - // Defined all module parts (triggers, login, substitutions, menus, css, etc...) - // for default path (eg: /ticket/core/xxxxx) (0=disable, 1=enable) - // for specific path of parts (eg: /ticket/core/modules/barcode) - // for specific css file (eg: /ticket/css/ticket.css.php) - $this->module_parts = array( - // Set this to 1 if module has its own trigger directory - 'triggers' => 1, - ); - - // Data directories to create when module is enabled. - // Example: this->dirs = array("/ticket/temp"); - $this->dirs = array(); - - // Config pages. Put here list of php pages - // stored into ticket/admin directory, used to setup module. - $this->config_page_url = array("ticket.php"); - - // Dependencies - $this->hidden = false; // A condition to hide module + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs, $conf; + + $this->db = $db; + + // Id for module (must be unique). + // Use a free id here + // (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 56000; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'ticket'; + + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "crm"; + // Module position in the family + $this->module_position = '60'; + // Module label (no space allowed) + // used if translation string 'ModuleXXXName' not found + // (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description + // used if translation string 'ModuleXXXDesc' not found + // (where XXX is value of numeric property 'numero' of module) + $this->description = "Incident/support ticket management"; + // Possible values for version are: 'development', 'experimental' or version + $this->version = 'dolibarr'; + // Key used in llx_const table to save module status enabled/disabled + // (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png + // use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png + // use this->picto='pictovalue@module' + $this->picto = 'ticket'; // mypicto@ticket + // Defined all module parts (triggers, login, substitutions, menus, css, etc...) + // for default path (eg: /ticket/core/xxxxx) (0=disable, 1=enable) + // for specific path of parts (eg: /ticket/core/modules/barcode) + // for specific css file (eg: /ticket/css/ticket.css.php) + $this->module_parts = array( + // Set this to 1 if module has its own trigger directory + 'triggers' => 1, + ); + + // Data directories to create when module is enabled. + // Example: this->dirs = array("/ticket/temp"); + $this->dirs = array(); + + // Config pages. Put here list of php pages + // stored into ticket/admin directory, used to setup module. + $this->config_page_url = array("ticket.php"); + + // Dependencies + $this->hidden = false; // A condition to hide module $this->depends = array('modAgenda'); // List of module class names as string that must be enabled if this module is enabled $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(5, 4); // Minimum version of PHP required by module - $this->langfiles = array("ticket"); - - // Constants - // List of particular constants to add when module is enabled - // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) - // Example: - $this->const = array( - 1 => array('TICKET_ENABLE_PUBLIC_INTERFACE', 'chaine', '0', 'Enable ticket public interface', 0), - 2 => array('TICKET_ADDON', 'chaine', 'mod_ticket_simple', 'Ticket ref module', 0), - 3 => array('TICKET_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/tickets', 'Ticket templates ODT/ODS directory for templates', 0) - ); - - - $this->tabs = array( - 'thirdparty:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?socid=__ID__', - 'project:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?projectid=__ID__', - ); - - // Dictionaries - if (!isset($conf->ticket->enabled)) { - $conf->ticket = new stdClass(); - $conf->ticket->enabled = 0; - } - $this->dictionaries = array( - 'langs' => 'ticket', - 'tabname' => array(MAIN_DB_PREFIX."c_ticket_type", MAIN_DB_PREFIX."c_ticket_severity", MAIN_DB_PREFIX."c_ticket_category", MAIN_DB_PREFIX."c_ticket_resolution"), - 'tablib' => array("TicketDictType", "TicketDictSeverity", "TicketDictCategory", "TicketDictResolution"), - 'tabsql' => array( - 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_type as f', - 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_severity as f', - 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_category as f', - 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_resolution as f' - ), - 'tabsqlsort' => array("pos ASC", "pos ASC", "pos ASC", "pos ASC"), - 'tabfield' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default"), - 'tabfieldvalue' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default"), - 'tabfieldinsert' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default"), - 'tabrowid' => array("rowid", "rowid", "rowid", "rowid"), - 'tabcond' => array($conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled), - 'tabhelp' => array(array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1"))), - ); - - // Boxes - // Add here list of php file(s) stored in core/boxes that contains class to show a box. - $this->boxes = array( - 0=>array('file'=>'box_last_ticket.php', 'enabledbydefaulton'=>'Home'), - 1=>array('file'=>'box_last_modified_ticket.php', 'enabledbydefaulton'=>'Home') - ); // Boxes list - - // Permissions - $this->rights = array(); // Permission array used by this module - - $r = 0; - $this->rights[$r][0] = 56001; // id de la permission - $this->rights[$r][1] = "Read ticket"; // libelle de la permission - $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'read'; - - $r++; - $this->rights[$r][0] = 56002; // id de la permission - $this->rights[$r][1] = "Create les tickets"; // libelle de la permission - $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'write'; - - $r++; - $this->rights[$r][0] = 56003; // id de la permission - $this->rights[$r][1] = "Delete les tickets"; // libelle de la permission - $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'delete'; - - $r++; - $this->rights[$r][0] = 56004; // id de la permission - $this->rights[$r][1] = "Manage tickets"; // libelle de la permission - //$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'manage'; - - /* Seems not used and in conflict with societe->client->voir (see all thirdparties) - $r++; - $this->rights[$r][0] = 56005; // id de la permission - $this->rights[$r][1] = 'See all tickets, even if not assigned to (not effective for external users, always restricted to the thirdpardy they depends on)'; // libelle de la permission - $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'view'; - $this->rights[$r][5] = 'all'; - */ - - // Main menu entries - $this->menus = array(); // List of menus to add - $r = 0; - - $this->menu[$r] = array('fk_menu' => 0, // Put 0 if this is a top menu - 'type' => 'top', // This is a Top menu entry - 'titre' => 'Ticket', - 'mainmenu' => 'ticket', - 'leftmenu' => '1', // Use 1 if you also want to add left menu entries using this descriptor. - 'url' => '/ticket/index.php', - 'langs' => 'ticket', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position' => 88, - 'enabled' => '$conf->ticket->enabled', // Define condition to show or hide menu entry. Use '$conf->ticket->enabled' if entry must be visible if module is enabled. - 'perms' => '$user->rights->ticket->read', // Use 'perms'=>'$user->rights->ticket->level1->level2' if you want your menu with a permission rules - 'target' => '', - 'user' => 2); // 0=Menu for internal users, 1=external users, 2=both - $r++; - - $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket', - 'type' => 'left', - 'titre' => 'Ticket', - 'mainmenu' => 'ticket', - 'leftmenu' => 'ticket', - 'url' => '/ticket/index.php', - 'langs' => 'ticket', - 'position' => 101, - 'enabled' => '$conf->ticket->enabled', - 'perms' => '$user->rights->ticket->read', - 'target' => '', - 'user' => 2); - $r++; - - $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket', - 'type' => 'left', - 'titre' => 'NewTicket', - 'mainmenu' => 'ticket', - 'url' => '/ticket/card.php?action=create', - 'langs' => 'ticket', - 'position' => 102, - 'enabled' => '$conf->ticket->enabled', - 'perms' => '$user->rights->ticket->write', - 'target' => '', - 'user' => 2); - $r++; - - $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket', - 'type' => 'left', - 'titre' => 'List', - 'mainmenu' => 'ticket', - 'leftmenu' => 'ticketlist', - 'url' => '/ticket/list.php?search_fk_status=non_closed', - 'langs' => 'ticket', - 'position' => 103, - 'enabled' => '$conf->ticket->enabled', - 'perms' => '$user->rights->ticket->read', - 'target' => '', - 'user' => 2); - $r++; - - $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket', - 'type' => 'left', - 'titre' => 'MenuTicketMyAssign', - 'mainmenu' => 'ticket', - 'leftmenu' => 'ticketmy', - 'url' => '/ticket/list.php?mode=mine&search_fk_status=non_closed', - 'langs' => 'ticket', - 'position' => 105, - 'enabled' => '$conf->ticket->enabled', - 'perms' => '$user->rights->ticket->read', - 'target' => '', - 'user' => 0); - $r++; - - $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket', - 'type' => 'left', - 'titre' => 'Statistics', - 'mainmenu' => 'ticket', - 'url' => '/ticket/stats/index.php', - 'langs' => 'ticket', - 'position' => 107, - 'enabled' => '$conf->ticket->enabled', - 'perms' => '$user->rights->ticket->read', - 'target' => '', - 'user' => 0); - $r++; - } - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - global $conf, $langs; - - // Permissions - $this->remove($options); - - //ODT template - $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/tickets/template_ticket.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/tickets'; - $dest = $dirodt.'/template_order.odt'; - - if (file_exists($src) && !file_exists($dest)) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_mkdir($dirodt); - $result = dol_copy($src, $dest, 0, 0); - if ($result < 0) - { - $langs->load("errors"); - $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); - return 0; - } - } - - $sql = array( - array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110120, 'ticket', 'internal', 'SUPPORTTEC', 'Utilisateur assigné au ticket', 1);", "ignoreerror" => 1), - array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110121, 'ticket', 'internal', 'CONTRIBUTOR', 'Intervenant', 1);", "ignoreerror" => 1), - array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110122, 'ticket', 'external', 'SUPPORTCLI', 'Contact client suivi incident', 1);", "ignoreerror" => 1), - array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110123, 'ticket', 'external', 'CONTRIBUTOR', 'Intervenant', 1);", "ignoreerror" => 1), - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'TICKET_ADDON_PDF_ODT_PATH' AND type = 'ticket' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('TICKET_ADDON_PDF_ODT_PATH','ticket',".$conf->entity.")" - ); - - return $this->_init($sql, $options); - } + $this->langfiles = array("ticket"); + + // Constants + // List of particular constants to add when module is enabled + // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: + $this->const = array( + 1 => array('TICKET_ENABLE_PUBLIC_INTERFACE', 'chaine', '0', 'Enable ticket public interface', 0), + 2 => array('TICKET_ADDON', 'chaine', 'mod_ticket_simple', 'Ticket ref module', 0) + ); + + $this->tabs = array( + 'thirdparty:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?socid=__ID__', + 'project:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?projectid=__ID__', + ); + + // Dictionaries + if (!isset($conf->ticket->enabled)) { + $conf->ticket = new stdClass(); + $conf->ticket->enabled = 0; + } + $this->dictionaries = array( + 'langs' => 'ticket', + 'tabname' => array(MAIN_DB_PREFIX."c_ticket_type", MAIN_DB_PREFIX."c_ticket_severity", MAIN_DB_PREFIX."c_ticket_category", MAIN_DB_PREFIX."c_ticket_resolution"), + 'tablib' => array("TicketDictType", "TicketDictSeverity", "TicketDictCategory", "TicketDictResolution"), + 'tabsql' => array( + 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_type as f', + 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_severity as f', + 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_category as f', + 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_resolution as f' + ), + 'tabsqlsort' => array("pos ASC", "pos ASC", "pos ASC", "pos ASC"), + 'tabfield' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"), + 'tabfieldvalue' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"), + 'tabfieldinsert' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"), + 'tabrowid' => array("rowid", "rowid", "rowid", "rowid"), + 'tabcond' => array($conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled), + 'tabhelp' => array(array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1"))), + ); + + // Boxes + // Add here list of php file(s) stored in core/boxes that contains class to show a box. + $this->boxes = array(); // Boxes list + $r = 0; + // Example: + + $this->boxes[$r][1] = "box_last_ticket"; + $r++; + + $this->boxes[$r][1] = "box_last_modified_ticket"; + $r++; + + // Permissions + $this->rights = array(); // Permission array used by this module + + $r = 0; + $this->rights[$r][0] = 56001; // id de la permission + $this->rights[$r][1] = "Read ticket"; // libelle de la permission + $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'read'; + + $r++; + $this->rights[$r][0] = 56002; // id de la permission + $this->rights[$r][1] = "Create les tickets"; // libelle de la permission + $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'write'; + + $r++; + $this->rights[$r][0] = 56003; // id de la permission + $this->rights[$r][1] = "Delete les tickets"; // libelle de la permission + $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'delete'; + + $r++; + $this->rights[$r][0] = 56004; // id de la permission + $this->rights[$r][1] = "Manage tickets"; // libelle de la permission + //$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'manage'; + + $r++; + $this->rights[$r][0] = 56005; // id de la permission + $this->rights[$r][1] = 'See all tickets, even if not assigned to (not effective for external users, always restricted to the thirdpardy they depends on)'; // libelle de la permission + $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'view'; + $this->rights[$r][5] = 'all'; + + // Main menu entries + $this->menus = array(); // List of menus to add + $r = 0; + + $this->menu[$r] = array('fk_menu' => 0, // Put 0 if this is a top menu + 'type' => 'top', // This is a Top menu entry + 'titre' => 'Ticket', + 'mainmenu' => 'ticket', + 'leftmenu' => '1', // Use 1 if you also want to add left menu entries using this descriptor. + 'url' => '/ticket/index.php', + 'langs' => 'ticket', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position' => 88, + 'enabled' => '$conf->ticket->enabled', // Define condition to show or hide menu entry. Use '$conf->ticket->enabled' if entry must be visible if module is enabled. + 'perms' => '$user->rights->ticket->read', // Use 'perms'=>'$user->rights->ticket->level1->level2' if you want your menu with a permission rules + 'target' => '', + 'user' => 2); // 0=Menu for internal users, 1=external users, 2=both + $r++; + + $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket', + 'type' => 'left', + 'titre' => 'Ticket', + 'mainmenu' => 'ticket', + 'leftmenu' => 'ticket', + 'url' => '/ticket/index.php', + 'langs' => 'ticket', + 'position' => 101, + 'enabled' => '$conf->ticket->enabled', + 'perms' => '$user->rights->ticket->read', + 'target' => '', + 'user' => 2); + $r++; + + $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket', + 'type' => 'left', + 'titre' => 'NewTicket', + 'mainmenu' => 'ticket', + 'url' => '/ticket/card.php?action=create', + 'langs' => 'ticket', + 'position' => 102, + 'enabled' => '$conf->ticket->enabled', + 'perms' => '$user->rights->ticket->write', + 'target' => '', + 'user' => 2); + $r++; + + $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket', + 'type' => 'left', + 'titre' => 'List', + 'mainmenu' => 'ticket', + 'leftmenu' => 'ticketlist', + 'url' => '/ticket/list.php?search_fk_status=non_closed', + 'langs' => 'ticket', + 'position' => 103, + 'enabled' => '$conf->ticket->enabled', + 'perms' => '$user->rights->ticket->read', + 'target' => '', + 'user' => 2); + $r++; + + $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket', + 'type' => 'left', + 'titre' => 'MenuTicketMyAssign', + 'mainmenu' => 'ticket', + 'leftmenu' => 'ticketmy', + 'url' => '/ticket/list.php?mode=mine&search_fk_status=non_closed', + 'langs' => 'ticket', + 'position' => 105, + 'enabled' => '$conf->ticket->enabled', + 'perms' => '$user->rights->ticket->read', + 'target' => '', + 'user' => 0); + $r++; + + $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket', + 'type' => 'left', + 'titre' => 'Statistics', + 'mainmenu' => 'ticket', + 'url' => '/ticket/stats/index.php', + 'langs' => 'ticket', + 'position' => 107, + 'enabled' => '$conf->ticket->enabled', + 'perms' => '$user->rights->ticket->read', + 'target' => '', + 'user' => 0); + $r++; + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + + $sql = array( + array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110120, 'ticket', 'internal', 'SUPPORTTEC', 'Utilisateur assigné au ticket', 1);", "ignoreerror" => 1), + array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110121, 'ticket', 'internal', 'CONTRIBUTOR', 'Intervenant', 1);", "ignoreerror" => 1), + array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110122, 'ticket', 'external', 'SUPPORTCLI', 'Contact client suivi incident', 1);", "ignoreerror" => 1), + array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110123, 'ticket', 'external', 'CONTRIBUTOR', 'Intervenant', 1);", "ignoreerror" => 1), + ); + + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modUser.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modUser.class.php @@ -77,8 +77,8 @@ // Boxes $this->boxes = array( - 0=>array('file'=>'box_lastlogin.php', 'enabledbydefaulton'=>'Home'), - 1=>array('file'=>'box_birthdays.php', 'enabledbydefaulton'=>'Home') + 0=>array('file'=>'box_lastlogin.php', 'enabledbydefaulton'=>'Home'), + 1=>array('file'=>'box_birthdays.php', 'enabledbydefaulton'=>'Home') ); // Permissions @@ -208,8 +208,8 @@ $this->rights[$r][5] = 'export'; - // Menus - $this->menu = 1; // This module add menu entries. They are coded into menu manager. + // Menus + $this->menu = 1; // This module add menu entries. They are coded into menu manager. // Exports @@ -220,51 +220,48 @@ $this->export_label[$r] = 'List of users and attributes'; $this->export_permission[$r] = array(array("user", "user", "export")); $this->export_fields_array[$r] = array( - 'u.rowid'=>"Id", 'u.login'=>"Login", 'u.lastname'=>"Lastname", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee", 'u.job'=>"PostOrFunction", 'u.gender'=>"Gender", - 'u.accountancy_code'=>"UserAccountancyCode", - 'u.address'=>"Address", 'u.zip'=>"Zip", 'u.town'=>"Town", - 'u.office_phone'=>'Phone', 'u.user_mobile'=>"Mobile", 'u.office_fax'=>'Fax', - 'u.email'=>"Email", 'u.note'=>"Note", 'u.signature'=>'Signature', - 'u.fk_user'=>'HierarchicalResponsible', 'u.thm'=>'THM', 'u.tjm'=>'TJM', 'u.weeklyhours'=>'WeeklyHours', - 'u.dateemployment'=>'DateEmployment', 'u.salary'=>'Salary', 'u.color'=>'Color', 'u.api_key'=>'ApiKey', - 'u.birth'=>'DateOfBirth', - 'u.datec'=>"DateCreation", 'u.tms'=>"DateLastModification", + 'u.rowid'=>"Id", 'u.login'=>"Login", 'u.lastname'=>"Lastname", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee", 'u.job'=>"PostOrFunction", 'u.gender'=>"Gender", + 'u.accountancy_code'=>"UserAccountancyCode", + 'u.address'=>"Address", 'u.zip'=>"Zip", 'u.town'=>"Town", + 'u.office_phone'=>'Phone', 'u.user_mobile'=>"Mobile", 'u.office_fax'=>'Fax', + 'u.email'=>"Email", 'u.note'=>"Note", 'u.signature'=>'Signature', + 'u.fk_user'=>'HierarchicalResponsible', 'u.thm'=>'THM', 'u.tjm'=>'TJM', 'u.weeklyhours'=>'WeeklyHours', + 'u.dateemployment'=>'DateEmployment', 'u.salary'=>'Salary', 'u.color'=>'Color', 'u.api_key'=>'ApiKey', + 'u.birth'=>'BirthdayDate', + 'u.datec'=>"DateCreation", 'u.tms'=>"DateLastModification", 'u.admin'=>"Administrator", 'u.statut'=>'Status', 'u.datelastlogin'=>'LastConnexion', 'u.datepreviouslogin'=>'PreviousConnexion', 'u.fk_socpeople'=>"IdContact", 'u.fk_soc'=>"IdCompany", 'u.fk_member'=>"MemberId" ); $this->export_TypeFields_array[$r] = array( 'u.rowid'=>'Numeric', 'u.login'=>"Text", 'u.lastname'=>"Text", 'u.firstname'=>"Text", 'u.employee'=>'Boolean', 'u.job'=>'Text', - 'u.accountancy_code'=>'Text', - 'u.address'=>"Text", 'u.zip'=>"Text", 'u.town'=>"Text", - 'u.office_phone'=>'Text', 'u.user_mobile'=>'Text', 'u.office_fax'=>'Text', + 'u.accountancy_code'=>'Text', + 'u.address'=>"Text", 'u.zip'=>"Text", 'u.town'=>"Text", + 'u.office_phone'=>'Text', 'u.user_mobile'=>'Text', 'u.office_fax'=>'Text', 'u.email'=>'Text', 'u.datec'=>"Date", 'u.tms'=>"Date", 'u.admin'=>"Boolean", 'u.statut'=>'Status', 'u.note'=>"Text", 'u.datelastlogin'=>'Date', - 'u.fk_user'=>"List:user:login", - 'u.birth'=>'Date', - 'u.datepreviouslogin'=>'Date', 'u.fk_soc'=>"List:societe:nom:rowid", 'u.fk_member'=>"List:adherent:firstname" + 'u.fk_user'=>"List:user:login", + 'u.birth'=>'Date', + 'u.datepreviouslogin'=>'Date', 'u.fk_soc'=>"List:societe:nom:rowid", 'u.fk_member'=>"List:adherent:firstname" ); $this->export_entities_array[$r] = array( 'u.rowid'=>"user", 'u.login'=>"user", 'u.lastname'=>"user", 'u.firstname'=>"user", 'u.employee'=>'user', 'u.job'=>'user', 'u.gender'=>'user', - 'u.accountancy_code'=>'user', - 'u.address'=>"user", 'u.zip'=>"user", 'u.town'=>"user", - 'u.office_phone'=>'user', 'u.user_mobile'=>'user', 'u.office_fax'=>'user', - 'u.email'=>'user', 'u.note'=>"user", 'u.signature'=>'user', - 'u.fk_user'=>'user', 'u.thm'=>'user', 'u.tjm'=>'user', 'u.weeklyhours'=>'user', - 'u.dateemployment'=>'user', 'u.salary'=>'user', 'u.color'=>'user', 'u.api_key'=>'user', - 'u.birth'=>'user', - 'u.datec'=>"user", 'u.tms'=>"user", - 'u.admin'=>"user", 'u.statut'=>'user', 'u.datelastlogin'=>'user', 'u.datepreviouslogin'=>'user', - 'u.fk_socpeople'=>"contact", 'u.fk_soc'=>"company", 'u.fk_member'=>"member" - ); - $keyforselect = 'user'; $keyforelement = 'user'; $keyforaliasextra = 'extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - if (empty($conf->adherent->enabled)) - { - unset($this->export_fields_array[$r]['u.fk_member']); - unset($this->export_entities_array[$r]['u.fk_member']); - } + 'u.accountancy_code'=>'user', + 'u.address'=>"user", 'u.zip'=>"user", 'u.town'=>"user", + 'u.office_phone'=>'user', 'u.user_mobile'=>'user', 'u.office_fax'=>'user', + 'u.email'=>'user', 'u.note'=>"user", 'u.signature'=>'user', + 'u.fk_user'=>'user', 'u.thm'=>'user', 'u.tjm'=>'user', 'u.weeklyhours'=>'user', + 'u.dateemployment'=>'user', 'u.salary'=>'user', 'u.color'=>'user', 'u.api_key'=>'user', + 'u.birth'=>'user', + 'u.datec'=>"user", 'u.tms'=>"user", + 'u.admin'=>"user", 'u.statut'=>'user', 'u.datelastlogin'=>'user', 'u.datepreviouslogin'=>'user', + 'u.fk_socpeople'=>"contact", 'u.fk_soc'=>"company", 'u.fk_member'=>"member" + ); + if (empty($conf->adherent->enabled)) + { + unset($this->export_fields_array[$r]['u.fk_member']); + unset($this->export_entities_array[$r]['u.fk_member']); + } $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'user as u'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user_extrafields as extra ON u.rowid = extra.fk_object'; $this->export_sql_end[$r] .= ' WHERE u.entity IN ('.getEntity('user').')'; // Imports @@ -278,43 +275,43 @@ $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r] = array('u'=>MAIN_DB_PREFIX.'user', 'extra'=>MAIN_DB_PREFIX.'user_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r] = array( - 'u.login'=>"Login*", 'u.lastname'=>"Name*", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee*", 'u.job'=>"PostOrFunction", 'u.gender'=>"Gender", - 'u.accountancy_code'=>"UserAccountancyCode", + 'u.login'=>"Login*", 'u.lastname'=>"Name*", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee*", 'u.job'=>"PostOrFunction", 'u.gender'=>"Gender", + 'u.accountancy_code'=>"UserAccountancyCode", 'u.pass_crypted'=>"Password", 'u.admin'=>"Administrator", 'u.fk_soc'=>"Company*", 'u.address'=>"Address", 'u.zip'=>"Zip", 'u.town'=>"Town", 'u.fk_state'=>"StateId", 'u.fk_country'=>"CountryCode", - 'u.office_phone'=>"Phone", 'u.user_mobile'=>"Mobile", 'u.office_fax'=>"Fax", - 'u.email'=>"Email", 'u.note'=>"Note", 'u.signature'=>'Signature', - 'u.fk_user'=>'HierarchicalResponsible', 'u.thm'=>'THM', 'u.tjm'=>'TJM', 'u.weeklyhours'=>'WeeklyHours', + 'u.office_phone'=>"Phone", 'u.user_mobile'=>"Mobile", 'u.office_fax'=>"Fax", + 'u.email'=>"Email", 'u.note'=>"Note", 'u.signature'=>'Signature', + 'u.fk_user'=>'HierarchicalResponsible', 'u.thm'=>'THM', 'u.tjm'=>'TJM', 'u.weeklyhours'=>'WeeklyHours', 'u.dateemployment'=>'DateEmployment', 'u.salary'=>'Salary', 'u.color'=>'Color', 'u.api_key'=>'ApiKey', - 'u.birth'=>'DateOfBirth', - 'u.datec'=>"DateCreation", - 'u.statut'=>'Status' + 'u.birth'=>'BirthdayDate', + 'u.datec'=>"DateCreation", + 'u.statut'=>'Status' ); // Add extra fields $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { - while ($obj = $this->db->fetch_object($resql)) - { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - } + while ($obj = $this->db->fetch_object($resql)) + { + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + } } // End add extra fields $this->import_fieldshidden_array[$r] = array('u.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'user'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_convertvalue_array[$r] = array( 'u.fk_state'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/cstate.class.php', 'class'=>'Cstate', 'method'=>'fetch', 'dict'=>'DictionaryState'), - 'u.fk_country'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/ccountry.class.php', 'class'=>'Ccountry', 'method'=>'fetch', 'dict'=>'DictionaryCountry'), - 'u.salary'=>array('rule'=>'numeric') + 'u.fk_country'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/ccountry.class.php', 'class'=>'Ccountry', 'method'=>'fetch', 'dict'=>'DictionaryCountry'), + 'u.salary'=>array('rule'=>'numeric') ); //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); $this->import_regex_array[$r] = array( 'u.employee'=>'^[0|1]', 'u.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$', - 'u.dateemployment'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', - 'u.birth'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$' + 'u.dateemployment'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', + 'u.birth'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$' ); $this->import_examplevalues_array[$r] = array( 'u.lastname'=>"Doe", 'u.firstname'=>'John', 'u.login'=>'jdoe', 'u.employee'=>'0 or 1', 'u.job'=>'CTO', 'u.gender'=>'0 or 1', @@ -322,22 +319,22 @@ 'u.fk_soc'=>'0 (internal user) or company name (external user)', 'u.datec'=>dol_print_date(dol_now(), '%Y-%m-%d'), 'u.address'=>"61 jump street", 'u.zip'=>"123456", 'u.town'=>"Big town", 'u.fk_country'=>'US, FR, DE...', 'u.office_phone'=>"0101010101", 'u.office_fax'=>"0101010102", 'u.email'=>"test@mycompany.com", 'u.salary'=>"10000", 'u.note'=>"This is an example of note for record", 'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00", - 'u.statut'=>"0 (closed) or 1 (active)", + 'u.statut'=>"0 (closed) or 1 (active)", ); $this->import_updatekeys_array[$r] = array('u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'u.login'=>'Login'); } - /** + /** * Function called when module is enabled. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { + */ + public function init($options = '') + { global $conf; // Permissions @@ -346,5 +343,5 @@ $sql = array(); return $this->_init($sql, $options); - } + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modVariants.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modVariants.class.php @@ -92,7 +92,7 @@ // Array to add new pages in new tabs $this->tabs = array( - // 'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__' + // 'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__' ); // Dictionaries --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modWebServices.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modWebServices.class.php @@ -30,54 +30,54 @@ class modWebServices extends DolibarrModules { - /** + /** * Constructor. Define names, constants, directories, boxes, permissions * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - $this->numero = 2600; + */ + public function __construct($db) + { + $this->db = $db; + $this->numero = 2600; - $this->family = "interface"; - $this->module_position = '25'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "Enable the Dolibarr web services server"; + $this->family = "interface"; + $this->module_position = '25'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "Enable the Dolibarr web services server"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - $this->picto = 'technic'; + $this->version = 'dolibarr'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + $this->picto = 'technic'; - // Data directories to create when module is enabled - $this->dirs = array(); + // Data directories to create when module is enabled + $this->dirs = array(); - // Config pages - $this->config_page_url = array("index.php@webservices"); + // Config pages + $this->config_page_url = array("index.php@webservices"); - // Dependencies - $this->hidden = false; // A condition to hide module + // Dependencies + $this->hidden = false; // A condition to hide module $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(5, 4); // Minimum version of PHP required by module - $this->langfiles = array("other"); + $this->langfiles = array("other"); - // Constants - $this->const = array(); + // Constants + $this->const = array(); - // New pages on tabs - $this->tabs = array(); + // New pages on tabs + $this->tabs = array(); - // Boxes - $this->boxes = array(); + // Boxes + $this->boxes = array(); - // Permissions - $this->rights = array(); - $this->rights_class = 'webservices'; - $r = 0; - } + // Permissions + $this->rights = array(); + $this->rights_class = 'webservices'; + $r = 0; + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modWebServicesClient.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modWebServicesClient.class.php @@ -30,54 +30,54 @@ class modWebServicesClient extends DolibarrModules { - /** + /** * Constructor. Define names, constants, directories, boxes, permissions * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - $this->numero = 2660; + */ + public function __construct($db) + { + $this->db = $db; + $this->numero = 2660; - $this->family = "interface"; - $this->module_position = '25'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "Enable the web service client to call external supplier web services"; + $this->family = "interface"; + $this->module_position = '26'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "Enable the web service client to call external supplier web services"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'experimental'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - $this->picto = 'technic'; + $this->version = 'experimental'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + $this->picto = 'technic'; - // Data directories to create when module is enabled - $this->dirs = array(); + // Data directories to create when module is enabled + $this->dirs = array(); - // Config pages - //$this->config_page_url = array(); + // Config pages + //$this->config_page_url = array(); - // Dependencies - $this->hidden = false; // A condition to hide module + // Dependencies + $this->hidden = false; // A condition to hide module $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(5, 4); // Minimum version of PHP required by module - $this->langfiles = array("other"); + $this->langfiles = array("other"); - // Constants - $this->const = array(); + // Constants + $this->const = array(); - // New pages on tabs - $this->tabs = array(); + // New pages on tabs + $this->tabs = array(); - // Boxes - $this->boxes = array(); + // Boxes + $this->boxes = array(); - // Permissions - $this->rights = array(); - $this->rights_class = 'syncsupplierwebservices'; - $r = 0; - } + // Permissions + $this->rights = array(); + $this->rights_class = 'syncsupplierwebservices'; + $r = 0; + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modWebsite.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modWebsite.class.php @@ -31,54 +31,54 @@ class modWebsite extends DolibarrModules { - /** + /** * Constructor. Define names, constants, directories, boxes, permissions * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs, $conf; - - $this->db = $db; - $this->numero = 10000; + */ + public function __construct($db) + { + global $langs, $conf; + + $this->db = $db; + $this->numero = 10000; // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "portal"; - $this->module_position = '50'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "Enable to build and serve public web sites with CMS features"; + $this->family = "portal"; + $this->module_position = '50'; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "Enable to build and serve public web sites with CMS features"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - $this->picto = 'website'; + $this->version = 'dolibarr'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + $this->picto = 'website'; // Data directories to create when module is enabled $this->dirs = array("/website/temp"); - // Config pages - $this->config_page_url = array('website.php'); - - // Dependencies + // Config pages + $this->config_page_url = array('website.php'); + + // Dependencies $this->hidden = !empty($conf->global->MODULE_WEBSITE_DISABLED); // A condition to disable module $this->depends = array('modFckeditor'); // 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->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(5, 4); // Minimum version of PHP required by module - $this->langfiles = array("website"); - - // Constants - $this->const = array(); - - // New pages on tabs - //$this->tabs[] = array(); // To add a new tab identified by code tabname1 - - // Boxes - $this->boxes = array(); + $this->langfiles = array("website"); + + // Constants + $this->const = array(); + + // New pages on tabs + //$this->tabs[] = array(); // To add a new tab identified by code tabname1 + + // Boxes + $this->boxes = array(); // Permissions $this->rights = array(); // Permission array used by this module @@ -109,95 +109,95 @@ $this->rights[$r][4] = 'delete'; $r++; - // Main menu entries - $r = 0; - $this->menu[$r] = array('fk_menu'=>'0', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'top', // This is a Left menu entry - 'titre'=>'WebSites', - 'mainmenu'=>'website', - 'url'=>'/website/index.php', - 'langs'=>'website', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>100, - 'enabled'=>'$conf->website->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->rights->website->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - $r++; - - // Exports - $r = 1; - - $this->export_code[$r] = $this->rights_class.'_'.$r; - $this->export_label[$r] = 'MyWebsitePages'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r] = 'globe'; - $keyforclass = 'WebsitePage'; $keyforclassfile = '/website/class/websitepage.class.php'; $keyforelement = 'Website'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - //$keyforselect='myobject'; $keyforelement='myobject'; $keyforaliasextra='extra'; - //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'website_page as t, '.MAIN_DB_PREFIX.'website as p'; - $this->export_sql_end[$r] .= ' WHERE t.fk_website = p.rowid'; - $this->export_sql_end[$r] .= ' AND p.entity IN ('.getEntity('website').')'; - $r++; - } - - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - global $conf, $langs; - - // Remove permissions and default values - $this->remove($options); - - // Copy flags and octicons directory - $dirarray = array('common/flags'=>'flags', 'common/octicons/build/svg'=>'octicons'); - foreach ($dirarray as $dirfrom => $dirtarget) - { - $src = DOL_DOCUMENT_ROOT.'/theme/'.$dirfrom; - $dest = DOL_DATA_ROOT.'/medias/image/'.$dirtarget; - - if (is_dir($src)) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_mkdir($dest); - $result = dolCopyDir($src, $dest, 0, 0); - if ($result < 0) - { - $langs->load("errors"); - $this->error = $langs->trans('ErrorFailToCopyDir', $src, $dest); - return 0; - } - } - } - - // Website templates - $srcroot = DOL_DOCUMENT_ROOT.'/install/doctemplates/websites'; - $destroot = DOL_DATA_ROOT.'/doctemplates/websites'; - - dol_mkdir($destroot); - - $docs = dol_dir_list($srcroot, 'files', 0, 'website_.*(\.zip|\.jpg)$'); - foreach ($docs as $cursorfile) { - $src = $srcroot.'/'.$cursorfile['name']; - $dest = $destroot.'/'.$cursorfile['name']; - - $result = dol_copy($src, $dest, 0, 1); // For full zip templates, we overwrite old existing files - if ($result < 0) { - $langs->load("errors"); - $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); - } - } - - $sql = array(); - - return $this->_init($sql, $options); - } + // Main menu entries + $r = 0; + $this->menu[$r] = array('fk_menu'=>'0', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'top', // This is a Left menu entry + 'titre'=>'WebSites', + 'mainmenu'=>'website', + 'url'=>'/website/index.php', + 'langs'=>'website', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>100, + 'enabled'=>'$conf->website->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'$user->rights->website->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + $r++; + + // Exports + $r = 1; + + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = 'MyWebsitePages'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r] = 'globe'; + $keyforclass = 'WebsitePage'; $keyforclassfile = '/website/class/websitepage.class.php'; $keyforelement = 'Website'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + //$keyforselect='myobject'; $keyforelement='myobject'; $keyforaliasextra='extra'; + //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'website_page as t, '.MAIN_DB_PREFIX.'website as p'; + $this->export_sql_end[$r] .= ' WHERE t.fk_website = p.rowid'; + $this->export_sql_end[$r] .= ' AND p.entity IN ('.getEntity('website').')'; + $r++; + } + + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $conf, $langs; + + // Remove permissions and default values + $this->remove($options); + + // Copy flags and octicons directory + $dirarray = array('common/flags'=>'flags', 'common/octicons/build/svg'=>'octicons'); + foreach ($dirarray as $dirfrom => $dirtarget) + { + $src = DOL_DOCUMENT_ROOT.'/theme/'.$dirfrom; + $dest = DOL_DATA_ROOT.'/medias/image/'.$dirtarget; + + if (is_dir($src)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dest); + $result = dolCopyDir($src, $dest, 0, 0); + if ($result < 0) + { + $langs->load("errors"); + $this->error = $langs->trans('ErrorFailToCopyDir', $src, $dest); + return 0; + } + } + } + + // Website templates + $srcroot = DOL_DOCUMENT_ROOT.'/install/doctemplates/websites'; + $destroot = DOL_DATA_ROOT.'/doctemplates/websites'; + + dol_mkdir($destroot); + + $docs = dol_dir_list($srcroot, 'files', 0, 'website_.*(\.zip|\.jpg)$'); + foreach ($docs as $cursorfile) { + $src = $srcroot.'/'.$cursorfile['name']; + $dest = $destroot.'/'.$cursorfile['name']; + + $result = dol_copy($src, $dest, 0, 1); // For full zip templates, we overwrite old existing files + if ($result < 0) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); + } + } + + $sql = array(); + + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modWorkflow.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modWorkflow.class.php @@ -32,75 +32,75 @@ class modWorkflow extends DolibarrModules { - /** + /** * Constructor. Define names, constants, directories, boxes, permissions * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; + */ + public function __construct($db) + { + $this->db = $db; - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 6000; - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'workflow'; + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 6000; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'workflow'; - $this->family = "technic"; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "Workflow management"; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of png file (without png) used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto = 'technic'; + $this->family = "technic"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "Workflow management"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of png file (without png) used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto = 'technic'; - // Data directories to create when module is enabled - $this->dirs = array("/workflow/temp"); + // Data directories to create when module is enabled + $this->dirs = array("/workflow/temp"); - // Config pages. Put here list of php page names stored in admmin directory used to setup module. - $this->config_page_url = array('workflow.php'); + // Config pages. Put here list of php page names stored in admmin directory used to setup module. + $this->config_page_url = array('workflow.php'); - // Dependencies - $this->hidden = false; // A condition to hide module + // Dependencies + $this->hidden = false; // A condition to hide module $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(5, 4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(2, 8); // Minimum version of Dolibarr required by module - $this->langfiles = array("@workflow"); + $this->need_dolibarr_version = array(2, 8); // Minimum version of Dolibarr required by module + $this->langfiles = array("@workflow"); - // Constants - // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) - // Example: $this->const=array(1 => array('MYMODULE_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), - // 2 => array('MYMODULE_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) - // ); - $this->const = array( - //0=>array('WORKFLOW_PROPAL_AUTOCREATE_ORDER', 'chaine', '1', 'WORKFLOW_PROPAL_AUTOCREATE_ORDER', 0, 'current', 0), - //0=>array('WORKFLOW_ORDER_AUTOCREATE_INVOICE', 'chaine', '1', 'WORKFLOW_ORDER_AUTOCREATE_INVOICE', 0, 'current', 0), - 0=>array('WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL', 0, 'current', 0), - 1=>array('WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL', 'chaine', '1', 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL', 0, 'current', 0), - 2=>array('WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING', 0, 'current', 0), - 4=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER', 0, 'current', 0), - 5=>array('WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL', 0, 'current', 0), - 6=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 0, 'current', 0), - 7=>array('WORKFLOW_BILL_ON_RECEPTION', 'chaine', '1', 'WORKFLOW_BILL_ON_RECEPTION', 0, 'current', 0) - ); + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(1 => array('MYMODULE_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), + // 2 => array('MYMODULE_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) + // ); + $this->const = array( + //0=>array('WORKFLOW_PROPAL_AUTOCREATE_ORDER', 'chaine', '1', 'WORKFLOW_PROPAL_AUTOCREATE_ORDER', 0, 'current', 0), + //0=>array('WORKFLOW_ORDER_AUTOCREATE_INVOICE', 'chaine', '1', 'WORKFLOW_ORDER_AUTOCREATE_INVOICE', 0, 'current', 0), + 0=>array('WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL', 0, 'current', 0), + 1=>array('WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL', 'chaine', '1', 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL', 0, 'current', 0), + 2=>array('WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING', 0, 'current', 0), + 4=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER', 0, 'current', 0), + 5=>array('WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL', 0, 'current', 0), + 6=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 0, 'current', 0), + 7=>array('WORKFLOW_BILL_ON_RECEPTION', 'chaine', '1', 'WORKFLOW_BILL_ON_RECEPTION', 0, 'current', 0) + ); - // Boxes - $this->boxes = array(); + // Boxes + $this->boxes = array(); - // Permissions - $this->rights = array(); - $r = 0; + // Permissions + $this->rights = array(); + $r = 0; - /* + /* $r++; $this->rights[$r][0] = 6001; // id de la permission $this->rights[$r][1] = "Lire les workflow"; // libelle de la permission @@ -109,10 +109,10 @@ $this->rights[$r][4] = 'read'; */ - // Main menu entries - $this->menus = array(); // List of menus to add - $r = 0; - /* + // Main menu entries + $this->menus = array(); // List of menus to add + $r = 0; + /* $this->menu[$r]=array('fk_menu'=>0, 'type'=>'top', 'titre'=>'Workflow', @@ -139,24 +139,24 @@ 'user'=>0); $r++; */ - } + } - /** + /** * Function called when module is enabled. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { + */ + public function init($options = '') + { // Permissions $this->remove($options); $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } --- /tmp/dsg/dolibarr/htdocs/core/modules/github_modZapier.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modZapier.class.php @@ -30,159 +30,159 @@ */ class modZapier extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs, $conf; - - $this->db = $db; - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 50330; - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'zapier'; - // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' - // It is used to group modules by family in module setup page - $this->family = "interface"; - // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '26'; - // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) - //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); - // Module label (no space allowed), used if translation string 'ModuleZapierName' not found (Zapier is name of module). - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuleZapierDesc' not found (Zapier is name of module). - $this->description = "ZapierDescription"; - // Used only if file README.md and README-LL.md not found. - $this->descriptionlong = "Zapier description (Long)"; - // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = 'development'; - //Url to the file with your last numberversion of this module - //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; - // Key used in llx_const table to save module status enabled/disabled (where ZAPIERFORDOLIBARR is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto = 'zapier'; - // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) - $this->module_parts = array( - // Set this to 1 if module has its own trigger directory (core/triggers) - 'triggers' => 1, - // Set this to 1 if module has its own login method file (core/login) - 'login' => 0, - // Set this to 1 if module has its own substitution function file (core/substitutions) - 'substitutions' => 0, - // Set this to 1 if module has its own menus handler directory (core/menus) - 'menus' => 0, - // Set this to 1 if module overwrite template dir (core/tpl) - 'tpl' => 0, - // Set this to 1 if module has its own barcode directory (core/modules/barcode) - 'barcode' => 0, - // Set this to 1 if module has its own models directory (core/modules/xxx) - 'models' => 0, - // Set this to 1 if module has its own theme directory (theme) - 'theme' => 0, - // Set this to relative path of css file if module has its own css file - 'css' => array( - // '/zapier/css/zapier.css.php', - ), - // Set this to relative path of js file if module must load a js on all pages - 'js' => array( - // '/zapier/js/zapier.js.php', - ), - // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' - 'hooks' => array( - // 'data' => array( - // 'hookcontext1', - // 'hookcontext2', - // ), - // 'entity' => '0', - ), - // Set this to 1 if feature of module are opened to external users - 'moduleforexternal' => 0, - ); - // Data directories to create when module is enabled. - // Example: this->dirs = array("/zapier/temp","/zapier/subdir"); - $this->dirs = array("/zapier/temp"); - // Config pages. Put here list of php page, stored into zapier/admin directory, to use to setup module. - $this->config_page_url = array( - // "setup.php@zapier" - ); - // Dependencies - // A condition to hide module - $this->hidden = false; - // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) - $this->depends = array('modApi'); - // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) - $this->requiredby = array(); - // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) - $this->conflictwith = array(); - $this->langfiles = array("zapier"); - // Minimum version of PHP required by module - //$this->phpmin = array(5, 5); - // Minimum version of Dolibarr required by module - $this->need_dolibarr_version = array(10, 0); - // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_activation = array(); - // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_activation_ext = array(); - // $this->automatic_activation = array( - // 'FR'=>'ZapierWasAutomaticallyActivatedBecauseOfYourCountryChoice', - // ); - // If true, can't be disabled - // $this->always_enabled = true; - // Constants - // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) - // Example: $this->const=array( - // 1 => array('ZAPIERFORDOLIBARR_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), - // 2 => array('ZAPIERFORDOLIBARR_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) - // ); - $this->const = array( - // 1 => array('ZAPIERFORDOLIBARR_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) - ); - // Some keys to add into the overwriting translation tables - /*$this->overwrite_translation = array( + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs, $conf; + + $this->db = $db; + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 50330; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'zapier'; + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' + // It is used to group modules by family in module setup page + $this->family = "interface"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '22'; + // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); + // Module label (no space allowed), used if translation string 'ModuleZapierName' not found (Zapier is name of module). + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleZapierDesc' not found (Zapier is name of module). + $this->description = "ZapierDescription"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = "Zapier description (Long)"; + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = 'development'; + //Url to the file with your last numberversion of this module + //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; + // Key used in llx_const table to save module status enabled/disabled (where ZAPIERFORDOLIBARR is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto = 'zapier'; + // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) + $this->module_parts = array( + // Set this to 1 if module has its own trigger directory (core/triggers) + 'triggers' => 1, + // Set this to 1 if module has its own login method file (core/login) + 'login' => 0, + // Set this to 1 if module has its own substitution function file (core/substitutions) + 'substitutions' => 0, + // Set this to 1 if module has its own menus handler directory (core/menus) + 'menus' => 0, + // Set this to 1 if module overwrite template dir (core/tpl) + 'tpl' => 0, + // Set this to 1 if module has its own barcode directory (core/modules/barcode) + 'barcode' => 0, + // Set this to 1 if module has its own models directory (core/modules/xxx) + 'models' => 0, + // Set this to 1 if module has its own theme directory (theme) + 'theme' => 0, + // Set this to relative path of css file if module has its own css file + 'css' => array( + // '/zapier/css/zapier.css.php', + ), + // Set this to relative path of js file if module must load a js on all pages + 'js' => array( + // '/zapier/js/zapier.js.php', + ), + // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' + 'hooks' => array( + // 'data' => array( + // 'hookcontext1', + // 'hookcontext2', + // ), + // 'entity' => '0', + ), + // Set this to 1 if feature of module are opened to external users + 'moduleforexternal' => 0, + ); + // Data directories to create when module is enabled. + // Example: this->dirs = array("/zapier/temp","/zapier/subdir"); + $this->dirs = array("/zapier/temp"); + // Config pages. Put here list of php page, stored into zapier/admin directory, to use to setup module. + $this->config_page_url = array( + // "setup.php@zapier" + ); + // Dependencies + // A condition to hide module + $this->hidden = false; + // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) + $this->depends = array(); + // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->requiredby = array(); + // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); + $this->langfiles = array("zapier"); + // Minimum version of PHP required by module + //$this->phpmin = array(5, 5); + // Minimum version of Dolibarr required by module + $this->need_dolibarr_version = array(10, 0); + // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation = array(); + // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); + // $this->automatic_activation = array( + // 'FR'=>'ZapierWasAutomaticallyActivatedBecauseOfYourCountryChoice', + // ); + // If true, can't be disabled + // $this->always_enabled = true; + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array( + // 1 => array('ZAPIERFORDOLIBARR_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), + // 2 => array('ZAPIERFORDOLIBARR_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) + // ); + $this->const = array( + // 1 => array('ZAPIERFORDOLIBARR_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) + ); + // Some keys to add into the overwriting translation tables + /*$this->overwrite_translation = array( 'en_US:ParentCompany'=>'Parent company or reseller', 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' )*/ - if (!isset($conf->zapier) || !isset($conf->zapier->enabled)) { - $conf->zapier = new stdClass(); - $conf->zapier->enabled = 0; - } - // Array to add new pages in new tabs - $this->tabs = array(); - // Example: - // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@zapier:$user->rights->zapier->read:/zapier/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 - // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@zapier:$user->rights->othermodule->read:/zapier/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. - // $this->tabs[] = array('data'=>'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) - // 'contact' to add a tab in contact view - // 'contract' to add a tab in contract view - // 'group' to add a tab in group view - // 'intervention' to add a tab in intervention view - // 'invoice' to add a tab in customer invoice view - // 'invoice_supplier' to add a tab in supplier invoice view - // 'member' to add a tab in fundation member view - // 'opensurveypoll' to add a tab in opensurvey poll view - // 'order' to add a tab in customer order view - // 'order_supplier' to add a tab in supplier order view - // 'payment' to add a tab in payment view - // 'payment_supplier' to add a tab in supplier payment view - // 'product' to add a tab in product view - // 'propal' to add a tab in propal view - // 'project' to add a tab in project view - // 'stock' to add a tab in stock view - // 'thirdparty' to add a tab in third party view - // 'user' to add a tab in user view - // Dictionaries - $this->dictionaries = array(); - /* Example: + if (!isset($conf->zapier) || !isset($conf->zapier->enabled)) { + $conf->zapier = new stdClass(); + $conf->zapier->enabled = 0; + } + // Array to add new pages in new tabs + $this->tabs = array(); + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@zapier:$user->rights->zapier->read:/zapier/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@zapier:$user->rights->othermodule->read:/zapier/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'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) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view + // Dictionaries + $this->dictionaries = array(); + /* Example: $this->dictionaries=array( 'langs'=>'mylangfile@zapier', // List of tables we want to see into dictonnary editor @@ -205,88 +205,88 @@ 'tabcond'=>array($conf->zapier->enabled,$conf->zapier->enabled,$conf->zapier->enabled) ); */ - // Boxes/Widgets - // Add here list of php file(s) stored in zapier/core/boxes that contains class to show a widget. - $this->boxes = array( - // 0 => array( - // 'file' => 'zapierwidget1.php@zapier', - // 'note' => 'Widget provided by Zapier', - // 'enabledbydefaulton' => 'Home', - // ), - //1=>array('file'=>'zapierwidget2.php@zapier','note'=>'Widget provided by Zapier'), - //2=>array('file'=>'zapierwidget3.php@zapier','note'=>'Widget provided by Zapier') - ); - // Cronjobs (List of cron jobs entries to add when module is enabled) - // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week - $this->cronjobs = array( - // 0 => array( - // 'label' => 'MyJob label', - // 'jobtype' => 'method', - // 'class' => '/zapier/class/myobject.class.php', - // 'objectname' => 'MyObject', - // 'method' => 'doScheduledJob', - // 'parameters' => '', - // 'comment' => 'Comment', - // 'frequency' => 2, - // 'unitfrequency' => 3600, - // 'status' => 0, - // 'test' => '$conf->zapier->enabled', - // 'priority' => 50, - // ), - ); - // Example: $this->cronjobs=array( - // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->zapier->enabled', 'priority'=>50), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->zapier->enabled', 'priority'=>50) - // ); - // Permissions - // Permission array used by this module - $this->rights = array(); - - $r = 0; - // Permission id (must not be already used) - $this->rights[$r][0] = $this->numero + $r; - // Permission label - $this->rights[$r][1] = 'Read myobject of Zapier'; - // Permission by default for new user (0/1) - $this->rights[$r][3] = 1; - // In php code, permission will be checked by test if ($user->rights->zapier->level1->level2) - $this->rights[$r][4] = 'read'; - // In php code, permission will be checked by test if ($user->rights->zapier->level1->level2) - $this->rights[$r][5] = ''; - $r++; - $this->rights[$r][0] = $this->numero + $r; - $this->rights[$r][1] = 'Create/Update myobject of Zapier'; - $this->rights[$r][3] = 1; - $this->rights[$r][4] = 'write'; - $this->rights[$r][5] = ''; - $r++; - $this->rights[$r][0] = $this->numero + $r; - $this->rights[$r][1] = 'Delete myobject of Zapier'; - $this->rights[$r][3] = 1; - $this->rights[$r][4] = 'delete'; - $this->rights[$r][5] = ''; - - // Main menu entries - $this->menu = array(); // List of menus to add - $r = 0; - - // Add here entries to declare new menus - // $this->menu[$r++]=array( - // 'fk_menu' => '', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - // 'type' => 'top', // This is a Top menu entry - // 'titre' => 'Zapier', - // 'mainmenu' => 'zapier', - // 'leftmenu' => '', - // 'url' => '/zapier/zapierindex.php', - // 'langs' => 'zapier@zapier', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - // 'position' => 1000+$r, - // 'enabled' => '$conf->zapier->enabled', // Define condition to show or hide menu entry. Use '$conf->zapier->enabled' if entry must be visible if module is enabled. - // 'perms' => '1', // Use 'perms'=>'$user->rights->zapier->level1->level2' if you want your menu with a permission rules - // 'target' => '', - // 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both - // ); - - /* + // Boxes/Widgets + // Add here list of php file(s) stored in zapier/core/boxes that contains class to show a widget. + $this->boxes = array( + // 0 => array( + // 'file' => 'zapierwidget1.php@zapier', + // 'note' => 'Widget provided by Zapier', + // 'enabledbydefaulton' => 'Home', + // ), + //1=>array('file'=>'zapierwidget2.php@zapier','note'=>'Widget provided by Zapier'), + //2=>array('file'=>'zapierwidget3.php@zapier','note'=>'Widget provided by Zapier') + ); + // Cronjobs (List of cron jobs entries to add when module is enabled) + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week + $this->cronjobs = array( + // 0 => array( + // 'label' => 'MyJob label', + // 'jobtype' => 'method', + // 'class' => '/zapier/class/myobject.class.php', + // 'objectname' => 'MyObject', + // 'method' => 'doScheduledJob', + // 'parameters' => '', + // 'comment' => 'Comment', + // 'frequency' => 2, + // 'unitfrequency' => 3600, + // 'status' => 0, + // 'test' => '$conf->zapier->enabled', + // 'priority' => 50, + // ), + ); + // Example: $this->cronjobs=array( + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->zapier->enabled', 'priority'=>50), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->zapier->enabled', 'priority'=>50) + // ); + // Permissions + // Permission array used by this module + $this->rights = array(); + + $r = 0; + // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero + $r; + // Permission label + $this->rights[$r][1] = 'Read myobject of Zapier'; + // Permission by default for new user (0/1) + $this->rights[$r][3] = 1; + // In php code, permission will be checked by test if ($user->rights->zapier->level1->level2) + $this->rights[$r][4] = 'read'; + // In php code, permission will be checked by test if ($user->rights->zapier->level1->level2) + $this->rights[$r][5] = ''; + $r++; + $this->rights[$r][0] = $this->numero + $r; + $this->rights[$r][1] = 'Create/Update myobject of Zapier'; + $this->rights[$r][3] = 1; + $this->rights[$r][4] = 'write'; + $this->rights[$r][5] = ''; + $r++; + $this->rights[$r][0] = $this->numero + $r; + $this->rights[$r][1] = 'Delete myobject of Zapier'; + $this->rights[$r][3] = 1; + $this->rights[$r][4] = 'delete'; + $this->rights[$r][5] = ''; + + // Main menu entries + $this->menu = array(); // List of menus to add + $r = 0; + + // Add here entries to declare new menus + // $this->menu[$r++]=array( + // 'fk_menu' => '', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + // 'type' => 'top', // This is a Top menu entry + // 'titre' => 'Zapier', + // 'mainmenu' => 'zapier', + // 'leftmenu' => '', + // 'url' => '/zapier/zapierindex.php', + // 'langs' => 'zapier@zapier', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position' => 1000+$r, + // 'enabled' => '$conf->zapier->enabled', // Define condition to show or hide menu entry. Use '$conf->zapier->enabled' if entry must be visible if module is enabled. + // 'perms' => '1', // Use 'perms'=>'$user->rights->zapier->level1->level2' if you want your menu with a permission rules + // 'target' => '', + // 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both + // ); + + /* $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=zapier', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry @@ -316,44 +316,44 @@ 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); */ - } - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - $result = $this->_load_tables('/zapier/sql/'); - if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default') - - // Create extrafields - //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - //$extrafields = new ExtraFields($this->db); - //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); - //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); - //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); - //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); - //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); - $sql = array(); - return $this->_init($sql, $options); - } - - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function remove($options = '') - { - $sql = array(); - return $this->_remove($sql, $options); - } + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + $result = $this->_load_tables('/zapier/sql/'); + if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default') + + // Create extrafields + //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + //$extrafields = new ExtraFields($this->db); + //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); + //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); + //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); + //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); + //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); + $sql = array(); + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + $sql = array(); + return $this->_remove($sql, $options); + } }