| Conditions | 2 |
| Paths | 2 |
| Total Lines | 338 |
| Code Lines | 80 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 7 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 40 | public function __construct($db) |
||
| 41 | { |
||
| 42 | global $langs, $conf; |
||
| 43 | |||
| 44 | $this->db = $db; |
||
| 45 | |||
| 46 | $this->editor_name = 'ATM-Consulting'; |
||
| 47 | // Id for module (must be unique). |
||
| 48 | // Use a free id here |
||
| 49 | // (See in Home -> System information -> Dolibarr for list of used modules id). |
||
| 50 | $this->numero = 104777; // 104000 to 104999 for ATM CONSULTING |
||
| 51 | // Key text used to identify module (for permissions, menus, etc...) |
||
| 52 | $this->rights_class = 'subtotal'; |
||
| 53 | |||
| 54 | // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
||
| 55 | // It is used to group modules in module setup page |
||
| 56 | $this->family = "technic"; |
||
| 57 | // Module label (no space allowed) |
||
| 58 | // used if translation string 'ModuleXXXName' not found |
||
| 59 | // (where XXX is value of numeric property 'numero' of module) |
||
| 60 | $this->name = preg_replace('/^mod/i', '', get_class($this)); |
||
| 61 | // Module description |
||
| 62 | // used if translation string 'ModuleXXXDesc' not found |
||
| 63 | // (where XXX is value of numeric property 'numero' of module) |
||
| 64 | $this->description = "Module permettant l'ajout de sous-totaux et sous-totaux intermédiaires et le déplacement d'une ligne aisée de l'un dans l'autre"; |
||
| 65 | // Possible values for version are: 'development', 'experimental' or version |
||
| 66 | $this->version = '3.6.4'; |
||
| 67 | |||
| 68 | // Key used in llx_const table to save module status enabled/disabled |
||
| 69 | // (where MYMODULE is value of property name of module in uppercase) |
||
| 70 | $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); |
||
| 71 | // Where to store the module in setup page |
||
| 72 | // (0=common,1=interface,2=others,3=very specific) |
||
| 73 | $this->special = 2; |
||
|
|
|||
| 74 | // Name of image file used for this module. |
||
| 75 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png |
||
| 76 | // use this->picto='pictovalue' |
||
| 77 | // If file is in module/img directory under name object_pictovalue.png |
||
| 78 | // use this->picto='pictovalue@module' |
||
| 79 | $this->picto = 'subtotal@subtotal'; // mypicto@titre |
||
| 80 | // Defined all module parts (triggers, login, substitutions, menus, css, etc...) |
||
| 81 | // for default path (eg: /titre/core/xxxxx) (0=disable, 1=enable) |
||
| 82 | // for specific path of parts (eg: /titre/core/modules/barcode) |
||
| 83 | // for specific css file (eg: /titre/css/titre.css.php) |
||
| 84 | $this->module_parts = array( |
||
| 85 | // Set this to 1 if module has its own trigger directory |
||
| 86 | 'triggers' => 1, |
||
| 87 | // Set this to 1 if module has its own login method directory |
||
| 88 | //'login' => 0, |
||
| 89 | // Set this to 1 if module has its own substitution function file |
||
| 90 | //'substitutions' => 0, |
||
| 91 | // Set this to 1 if module has its own menus handler directory |
||
| 92 | //'menus' => 0, |
||
| 93 | // Set this to 1 if module has its own barcode directory |
||
| 94 | //'barcode' => 0, |
||
| 95 | // Set this to 1 if module has its own models directory |
||
| 96 | 'models' => 1, |
||
| 97 | // Set this to relative path of css if module has its own css file |
||
| 98 | //'css' => '/titre/css/mycss.css.php', |
||
| 99 | // Set here all hooks context managed by module |
||
| 100 | 'hooks' => array( |
||
| 101 | 'invoicecard' |
||
| 102 | ,'invoicesuppliercard' |
||
| 103 | ,'propalcard' |
||
| 104 | ,'supplier_proposalcard' |
||
| 105 | ,'ordercard' |
||
| 106 | ,'ordersuppliercard' |
||
| 107 | ,'odtgeneration' |
||
| 108 | ,'orderstoinvoice' |
||
| 109 | ,'orderstoinvoicesupplier' |
||
| 110 | ,'admin' |
||
| 111 | ,'invoicereccard' |
||
| 112 | ,'consumptionthirdparty' |
||
| 113 | ,'ordershipmentcard' |
||
| 114 | ,'expeditioncard' |
||
| 115 | ,'deliverycard' |
||
| 116 | ,'paiementcard' |
||
| 117 | ,'referencelettersinstacecard' |
||
| 118 | ,'shippableorderlist' |
||
| 119 | ,'propallist' |
||
| 120 | ,'orderlist' |
||
| 121 | ,'invoicelist' |
||
| 122 | ,'supplierorderlist' |
||
| 123 | ,'supplierinvoicelist' |
||
| 124 | ), |
||
| 125 | // Set here all workflow context managed by module |
||
| 126 | //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')), |
||
| 127 | 'tpl' => 1 |
||
| 128 | ); |
||
| 129 | |||
| 130 | // Data directories to create when module is enabled. |
||
| 131 | // Example: this->dirs = array("/titre/temp"); |
||
| 132 | $this->dirs = array(); |
||
| 133 | |||
| 134 | // Config pages. Put here list of php pages |
||
| 135 | // stored into titre/admin directory, used to setup module. |
||
| 136 | $this->config_page_url = array("subtotal_setup.php@subtotal"); |
||
| 137 | |||
| 138 | // Dependencies |
||
| 139 | // List of modules id that must be enabled if this module is enabled |
||
| 140 | $this->depends = array(); |
||
| 141 | |||
| 142 | $this->conflictwith=array('modMilestone'); |
||
| 143 | // List of modules id to disable if this one is disabled |
||
| 144 | $this->requiredby = array(); |
||
| 145 | // Minimum version of PHP required by module |
||
| 146 | $this->phpmin = array(5, 3); |
||
| 147 | // Minimum version of Dolibarr required by module |
||
| 148 | $this->need_dolibarr_version = array(3, 2); |
||
| 149 | $this->langfiles = array("subtotal@subtotal"); // langfiles@titre |
||
| 150 | // Constants |
||
| 151 | // List of particular constants to add when module is enabled |
||
| 152 | // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) |
||
| 153 | // Example: |
||
| 154 | $this->const = array( |
||
| 155 | 0=>array( |
||
| 156 | 'SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES', |
||
| 157 | 'chaine', |
||
| 158 | 'I', |
||
| 159 | 'Définit le style (B : gras, I : Italique, U : Souligné) des sous titres lorsque le détail des lignes et des ensembles est caché', |
||
| 160 | 1 |
||
| 161 | ) |
||
| 162 | ,1=>array('SUBTOTAL_ALLOW_ADD_BLOCK', 'chaine', '1', 'Permet l\'ajout de titres et sous-totaux') |
||
| 163 | ,2=>array('SUBTOTAL_ALLOW_EDIT_BLOCK', 'chaine', '1', 'Permet de modifier titres et sous-totaux') |
||
| 164 | ,3=>array('SUBTOTAL_ALLOW_REMOVE_BLOCK', 'chaine', '1', 'Permet de supprimer les titres et sous-totaux') |
||
| 165 | ,4=>array('SUBTOTAL_TITLE_STYLE', 'chaine', 'BU') |
||
| 166 | ,5=>array('SUBTOTAL_SUBTOTAL_STYLE', 'chaine', 'B') |
||
| 167 | // 1=>array( |
||
| 168 | // 'MYMODULE_MYNEWCONST2', |
||
| 169 | // 'chaine', |
||
| 170 | // 'myvalue', |
||
| 171 | // 'This is another constant to add', |
||
| 172 | // 0 |
||
| 173 | // ) |
||
| 174 | ); |
||
| 175 | |||
| 176 | |||
| 177 | |||
| 178 | |||
| 179 | // Array to add new pages in new tabs |
||
| 180 | // Example: |
||
| 181 | $this->tabs = array( |
||
| 182 | // // To add a new tab identified by code tabname1 |
||
| 183 | // 'objecttype:+tabname1:Title1:langfile@titre:$user->rights->titre->read:/titre/mynewtab1.php?id=__ID__', |
||
| 184 | // // To add another new tab identified by code tabname2 |
||
| 185 | // 'objecttype:+tabname2:Title2:langfile@titre:$user->rights->othermodule->read:/titre/mynewtab2.php?id=__ID__', |
||
| 186 | // // To remove an existing tab identified by code tabname |
||
| 187 | // 'objecttype:-tabname' |
||
| 188 | ); |
||
| 189 | // where objecttype can be |
||
| 190 | // 'thirdparty' to add a tab in third party view |
||
| 191 | // 'intervention' to add a tab in intervention view |
||
| 192 | // 'order_supplier' to add a tab in supplier order view |
||
| 193 | // 'invoice_supplier' to add a tab in supplier invoice view |
||
| 194 | // 'invoice' to add a tab in customer invoice view |
||
| 195 | // 'order' to add a tab in customer order view |
||
| 196 | // 'product' to add a tab in product view |
||
| 197 | // 'stock' to add a tab in stock view |
||
| 198 | // 'propal' to add a tab in propal view |
||
| 199 | // 'member' to add a tab in fundation member view |
||
| 200 | // 'contract' to add a tab in contract view |
||
| 201 | // 'user' to add a tab in user view |
||
| 202 | // 'group' to add a tab in group view |
||
| 203 | // 'contact' to add a tab in contact view |
||
| 204 | // 'categories_x' to add a tab in category view |
||
| 205 | // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) |
||
| 206 | // Dictionnaries |
||
| 207 | if (! isset($conf->subtotal->enabled)) { |
||
| 208 | $conf->subtotal=new stdClass(); |
||
| 209 | $conf->subtotal->enabled = 0; |
||
| 210 | } |
||
| 211 | $this->dictionaries = array( |
||
| 212 | 'langs'=>'subtotal@subtotal', |
||
| 213 | 'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'), // List of tables we want to see into dictonnary editor |
||
| 214 | 'tablib'=>array($langs->trans('subtotalFreeLineDictionary')), // Label of tables |
||
| 215 | 'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity), // Request to select fields |
||
| 216 | 'tabsqlsort'=>array('label ASC'), // Sort order |
||
| 217 | 'tabfield'=>array('label,content'), // List of fields (result of select to show dictionary) |
||
| 218 | 'tabfieldvalue'=>array('label,content'), // List of fields (list of fields to edit a record) |
||
| 219 | 'tabfieldinsert'=>array('label,content,entity'), // List of fields (list of fields for insert) |
||
| 220 | 'tabrowid'=>array('rowid'), // Name of columns with primary key (try to always name it 'rowid') |
||
| 221 | 'tabcond'=>array($conf->subtotal->enabled) |
||
| 222 | ); |
||
| 223 | /* Example: |
||
| 224 | // This is to avoid warnings |
||
| 225 | if (! isset($conf->titre->enabled)) $conf->titre->enabled=0; |
||
| 226 | $this->dictionnaries=array( |
||
| 227 | 'langs'=>'titre@titre', |
||
| 228 | // List of tables we want to see into dictonnary editor |
||
| 229 | 'tabname'=>array( |
||
| 230 | MAIN_DB_PREFIX."table1", |
||
| 231 | MAIN_DB_PREFIX."table2", |
||
| 232 | MAIN_DB_PREFIX."table3" |
||
| 233 | ), |
||
| 234 | // Label of tables |
||
| 235 | 'tablib'=>array("Table1","Table2","Table3"), |
||
| 236 | // Request to select fields |
||
| 237 | 'tabsql'=>array( |
||
| 238 | 'SELECT f.rowid as rowid, f.code, f.label, f.active' |
||
| 239 | . ' FROM ' . MAIN_DB_PREFIX . 'table1 as f', |
||
| 240 | 'SELECT f.rowid as rowid, f.code, f.label, f.active' |
||
| 241 | . ' FROM ' . MAIN_DB_PREFIX . 'table2 as f', |
||
| 242 | 'SELECT f.rowid as rowid, f.code, f.label, f.active' |
||
| 243 | . ' FROM ' . MAIN_DB_PREFIX . 'table3 as f' |
||
| 244 | ), |
||
| 245 | // Sort order |
||
| 246 | 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), |
||
| 247 | // List of fields (result of select to show dictionnary) |
||
| 248 | 'tabfield'=>array("code,label","code,label","code,label"), |
||
| 249 | // List of fields (list of fields to edit a record) |
||
| 250 | 'tabfieldvalue'=>array("code,label","code,label","code,label"), |
||
| 251 | // List of fields (list of fields for insert) |
||
| 252 | 'tabfieldinsert'=>array("code,label","code,label","code,label"), |
||
| 253 | // Name of columns with primary key (try to always name it 'rowid') |
||
| 254 | 'tabrowid'=>array("rowid","rowid","rowid"), |
||
| 255 | // Condition to show each dictionnary |
||
| 256 | 'tabcond'=>array( |
||
| 257 | $conf->titre->enabled, |
||
| 258 | $conf->titre->enabled, |
||
| 259 | $conf->titre->enabled |
||
| 260 | ) |
||
| 261 | ); |
||
| 262 | */ |
||
| 263 | |||
| 264 | // Boxes |
||
| 265 | // Add here list of php file(s) stored in core/boxes that contains class to show a box. |
||
| 266 | $this->boxes = array(); // Boxes list |
||
| 267 | |||
| 268 | /* |
||
| 269 | $this->boxes[$r][1] = "myboxb.php"; |
||
| 270 | $r++; |
||
| 271 | */ |
||
| 272 | |||
| 273 | // Permissions |
||
| 274 | $this->rights = array(); // Permission array used by this module |
||
| 275 | $r = 0; |
||
| 276 | |||
| 277 | // Add here list of permission defined by |
||
| 278 | // an id, a label, a boolean and two constant strings. |
||
| 279 | // Example: |
||
| 280 | //// Permission id (must not be already used) |
||
| 281 | //$this->rights[$r][0] = 2000; |
||
| 282 | //// Permission label |
||
| 283 | //$this->rights[$r][1] = 'Permision label'; |
||
| 284 | //// Permission by default for new user (0/1) |
||
| 285 | //$this->rights[$r][3] = 1; |
||
| 286 | //// In php code, permission will be checked by test |
||
| 287 | //// if ($user->rights->permkey->level1->level2) |
||
| 288 | //$this->rights[$r][4] = 'level1'; |
||
| 289 | //// In php code, permission will be checked by test |
||
| 290 | //// if ($user->rights->permkey->level1->level2) |
||
| 291 | //$this->rights[$r][5] = 'level2'; |
||
| 292 | //$r++; |
||
| 293 | // Main menu entries |
||
| 294 | $this->menus = array(); // List of menus to add |
||
| 295 | $r = 0; |
||
| 296 | |||
| 297 | // Add here entries to declare new menus |
||
| 298 | // |
||
| 299 | // Example to declare a new Top Menu entry and its Left menu entry: |
||
| 300 | //$this->menu[$r]=array( |
||
| 301 | // // Put 0 if this is a top menu |
||
| 302 | // 'fk_menu'=>0, |
||
| 303 | // // This is a Top menu entry |
||
| 304 | // 'type'=>'top', |
||
| 305 | // 'titre'=>'titre top menu', |
||
| 306 | // 'mainmenu'=>'titre', |
||
| 307 | // 'leftmenu'=>'titre', |
||
| 308 | // 'url'=>'/titre/pagetop.php', |
||
| 309 | // // Lang file to use (without .lang) by module. |
||
| 310 | // // File must be in langs/code_CODE/ directory. |
||
| 311 | // 'langs'=>'mylangfile', |
||
| 312 | // 'position'=>100, |
||
| 313 | // // Define condition to show or hide menu entry. |
||
| 314 | // // Use '$conf->titre->enabled' if entry must be visible if module is enabled. |
||
| 315 | // 'enabled'=>'$conf->titre->enabled', |
||
| 316 | // // Use 'perms'=>'$user->rights->titre->level1->level2' |
||
| 317 | // // if you want your menu with a permission rules |
||
| 318 | // 'perms'=>'1', |
||
| 319 | // 'target'=>'', |
||
| 320 | // // 0=Menu for internal users, 1=external users, 2=both |
||
| 321 | // 'user'=>2 |
||
| 322 | //); |
||
| 323 | //$r++; |
||
| 324 | //$this->menu[$r]=array( |
||
| 325 | // // Use r=value where r is index key used for the parent menu entry |
||
| 326 | // // (higher parent must be a top menu entry) |
||
| 327 | // 'fk_menu'=>'r=0', |
||
| 328 | // // This is a Left menu entry |
||
| 329 | // 'type'=>'left', |
||
| 330 | // 'titre'=>'titre left menu', |
||
| 331 | // 'mainmenu'=>'titre', |
||
| 332 | // 'leftmenu'=>'titre', |
||
| 333 | // 'url'=>'/titre/pagelevel1.php', |
||
| 334 | // // Lang file to use (without .lang) by module. |
||
| 335 | // // File must be in langs/code_CODE/ directory. |
||
| 336 | // 'langs'=>'mylangfile', |
||
| 337 | // 'position'=>100, |
||
| 338 | // // Define condition to show or hide menu entry. |
||
| 339 | // // Use '$conf->titre->enabled' if entry must be visible if module is enabled. |
||
| 340 | // 'enabled'=>'$conf->titre->enabled', |
||
| 341 | // // Use 'perms'=>'$user->rights->titre->level1->level2' |
||
| 342 | // // if you want your menu with a permission rules |
||
| 343 | // 'perms'=>'1', |
||
| 344 | // 'target'=>'', |
||
| 345 | // // 0=Menu for internal users, 1=external users, 2=both |
||
| 346 | // 'user'=>2 |
||
| 347 | //); |
||
| 348 | //$r++; |
||
| 349 | // |
||
| 350 | // Example to declare a Left Menu entry into an existing Top menu entry: |
||
| 351 | //$this->menu[$r]=array( |
||
| 352 | // // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' |
||
| 353 | // 'fk_menu'=>'fk_mainmenu=mainmenucode', |
||
| 354 | // // This is a Left menu entry |
||
| 355 | // 'type'=>'left', |
||
| 356 | // 'titre'=>'titre left menu', |
||
| 357 | // 'mainmenu'=>'mainmenucode', |
||
| 358 | // 'leftmenu'=>'titre', |
||
| 359 | // 'url'=>'/titre/pagelevel2.php', |
||
| 360 | // // Lang file to use (without .lang) by module. |
||
| 361 | // // File must be in langs/code_CODE/ directory. |
||
| 362 | // 'langs'=>'mylangfile', |
||
| 363 | // 'position'=>100, |
||
| 364 | // // Define condition to show or hide menu entry. |
||
| 365 | // // Use '$conf->titre->enabled' if entry must be visible if module is enabled. |
||
| 366 | // // Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
||
| 367 | // 'enabled'=>'$conf->titre->enabled', |
||
| 368 | // // Use 'perms'=>'$user->rights->titre->level1->level2' |
||
| 369 | // // if you want your menu with a permission rules |
||
| 370 | // 'perms'=>'1', |
||
| 371 | // 'target'=>'', |
||
| 372 | // // 0=Menu for internal users, 1=external users, 2=both |
||
| 373 | // 'user'=>2 |
||
| 374 | //); |
||
| 375 | //$r++; |
||
| 376 | // Exports |
||
| 377 | $r = 1; |
||
| 378 | |||
| 531 |