@@ -142,7 +142,7 @@ |
||
142 | 142 | /** |
143 | 143 | * Return next free ref |
144 | 144 | * |
145 | - * @param Societe $objsoc Object thirdparty |
|
145 | + * @param integer $objsoc Object thirdparty |
|
146 | 146 | * @param Object $object Objet livraison |
147 | 147 | * @return string Texte descripif |
148 | 148 | */ |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | var $nom = 'Saphir'; |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Renvoi la description du modele de numerotation |
|
41 | - * |
|
42 | - * @return string Texte descripif |
|
43 | - */ |
|
39 | + /** |
|
40 | + * Renvoi la description du modele de numerotation |
|
41 | + * |
|
42 | + * @return string Texte descripif |
|
43 | + */ |
|
44 | 44 | function info() |
45 | 45 | { |
46 | - global $conf,$langs; |
|
46 | + global $conf,$langs; |
|
47 | 47 | |
48 | 48 | $langs->load("bills"); |
49 | 49 | |
@@ -74,28 +74,28 @@ discard block |
||
74 | 74 | $texte.= '</form>'; |
75 | 75 | |
76 | 76 | return $texte; |
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * Return an example of number |
|
81 | - * |
|
82 | - * @return string Example |
|
83 | - */ |
|
84 | - function getExample() |
|
85 | - { |
|
86 | - global $conf,$langs,$mysoc; |
|
87 | - |
|
88 | - $old_code_client=$mysoc->code_client; |
|
89 | - $mysoc->code_client='CCCCCCCCCC'; |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * Return an example of number |
|
81 | + * |
|
82 | + * @return string Example |
|
83 | + */ |
|
84 | + function getExample() |
|
85 | + { |
|
86 | + global $conf,$langs,$mysoc; |
|
87 | + |
|
88 | + $old_code_client=$mysoc->code_client; |
|
89 | + $mysoc->code_client='CCCCCCCCCC'; |
|
90 | 90 | $numExample = $this->getNextValue($mysoc,''); |
91 | - $mysoc->code_client=$old_code_client; |
|
91 | + $mysoc->code_client=$old_code_client; |
|
92 | 92 | |
93 | 93 | if (! $numExample) |
94 | 94 | { |
95 | 95 | $numExample = $langs->trans('NotConfigured'); |
96 | 96 | } |
97 | 97 | return $numExample; |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | 100 | |
101 | 101 | /** |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @param Object $object Object delivery |
106 | 106 | * @return string Value if OK, 0 if KO |
107 | 107 | */ |
108 | - function getNextValue($objsoc,$object) |
|
109 | - { |
|
108 | + function getNextValue($objsoc,$object) |
|
109 | + { |
|
110 | 110 | global $db,$conf; |
111 | 111 | |
112 | 112 | require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
@@ -123,33 +123,33 @@ discard block |
||
123 | 123 | $numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc,$object->date_livraison); |
124 | 124 | |
125 | 125 | return $numFinal; |
126 | - } |
|
126 | + } |
|
127 | 127 | |
128 | 128 | |
129 | 129 | /** |
130 | 130 | * Return next free value |
131 | 131 | * |
132 | - * @param Societe $objsoc Object third party |
|
132 | + * @param Societe $objsoc Object third party |
|
133 | 133 | * @param string $objforref Object for number to search |
134 | - * @return string Next free value |
|
135 | - */ |
|
136 | - function getNumRef($objsoc,$objforref) |
|
137 | - { |
|
138 | - return $this->getNextValue($objsoc,$objforref); |
|
139 | - } |
|
134 | + * @return string Next free value |
|
135 | + */ |
|
136 | + function getNumRef($objsoc,$objforref) |
|
137 | + { |
|
138 | + return $this->getNextValue($objsoc,$objforref); |
|
139 | + } |
|
140 | 140 | |
141 | 141 | |
142 | 142 | /** |
143 | 143 | * Return next free ref |
144 | 144 | * |
145 | - * @param Societe $objsoc Object thirdparty |
|
146 | - * @param Object $object Objet livraison |
|
147 | - * @return string Texte descripif |
|
148 | - */ |
|
149 | - function livraison_get_num($objsoc=0,$object='') |
|
150 | - { |
|
151 | - return $this->getNextValue($objsoc,$object); |
|
152 | - } |
|
145 | + * @param Societe $objsoc Object thirdparty |
|
146 | + * @param Object $object Objet livraison |
|
147 | + * @return string Texte descripif |
|
148 | + */ |
|
149 | + function livraison_get_num($objsoc=0,$object='') |
|
150 | + { |
|
151 | + return $this->getNextValue($objsoc,$object); |
|
152 | + } |
|
153 | 153 | |
154 | 154 | } |
155 | 155 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \ingroup expedition |
24 | 24 | * \brief Fichier contenant la classe du modele de numerotation de reference de livraison Saphir |
25 | 25 | */ |
26 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/livraison/modules_livraison.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php'; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * \class mod_livraison_saphir |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class mod_livraison_saphir extends ModeleNumRefDeliveryOrder |
33 | 33 | { |
34 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
34 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
35 | 35 | var $error = ''; |
36 | 36 | var $nom = 'Saphir'; |
37 | 37 | |
@@ -43,35 +43,35 @@ discard block |
||
43 | 43 | */ |
44 | 44 | function info() |
45 | 45 | { |
46 | - global $conf,$langs; |
|
46 | + global $conf, $langs; |
|
47 | 47 | |
48 | 48 | $langs->load("bills"); |
49 | 49 | |
50 | 50 | $form = new Form($this->db); |
51 | 51 | |
52 | 52 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
53 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
54 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
55 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
56 | - $texte.= '<input type="hidden" name="maskconstdelivery" value="LIVRAISON_SAPHIR_MASK">'; |
|
57 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
58 | - |
|
59 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Delivery"),$langs->transnoentities("Delivery")); |
|
60 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
61 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
62 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Delivery"),$langs->transnoentities("Delivery")); |
|
63 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
53 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
54 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
55 | + $texte .= '<input type="hidden" name="action" value="updateMask">'; |
|
56 | + $texte .= '<input type="hidden" name="maskconstdelivery" value="LIVRAISON_SAPHIR_MASK">'; |
|
57 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
58 | + |
|
59 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Delivery"), $langs->transnoentities("Delivery")); |
|
60 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
61 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
62 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Delivery"), $langs->transnoentities("Delivery")); |
|
63 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
64 | 64 | |
65 | 65 | // Parametrage du prefix |
66 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
67 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdelivery" value="'.$conf->global->LIVRAISON_SAPHIR_MASK.'">',$tooltip,1,1).'</td>'; |
|
66 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
67 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdelivery" value="'.$conf->global->LIVRAISON_SAPHIR_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
68 | 68 | |
69 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
69 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
70 | 70 | |
71 | - $texte.= '</tr>'; |
|
71 | + $texte .= '</tr>'; |
|
72 | 72 | |
73 | - $texte.= '</table>'; |
|
74 | - $texte.= '</form>'; |
|
73 | + $texte .= '</table>'; |
|
74 | + $texte .= '</form>'; |
|
75 | 75 | |
76 | 76 | return $texte; |
77 | 77 | } |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | */ |
84 | 84 | function getExample() |
85 | 85 | { |
86 | - global $conf,$langs,$mysoc; |
|
86 | + global $conf, $langs, $mysoc; |
|
87 | 87 | |
88 | - $old_code_client=$mysoc->code_client; |
|
89 | - $mysoc->code_client='CCCCCCCCCC'; |
|
90 | - $numExample = $this->getNextValue($mysoc,''); |
|
91 | - $mysoc->code_client=$old_code_client; |
|
88 | + $old_code_client = $mysoc->code_client; |
|
89 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
90 | + $numExample = $this->getNextValue($mysoc, ''); |
|
91 | + $mysoc->code_client = $old_code_client; |
|
92 | 92 | |
93 | - if (! $numExample) |
|
93 | + if (!$numExample) |
|
94 | 94 | { |
95 | 95 | $numExample = $langs->trans('NotConfigured'); |
96 | 96 | } |
@@ -105,22 +105,22 @@ discard block |
||
105 | 105 | * @param Object $object Object delivery |
106 | 106 | * @return string Value if OK, 0 if KO |
107 | 107 | */ |
108 | - function getNextValue($objsoc,$object) |
|
108 | + function getNextValue($objsoc, $object) |
|
109 | 109 | { |
110 | - global $db,$conf; |
|
110 | + global $db, $conf; |
|
111 | 111 | |
112 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
112 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
113 | 113 | |
114 | 114 | // On defini critere recherche compteur |
115 | - $mask=$conf->global->LIVRAISON_SAPHIR_MASK; |
|
115 | + $mask = $conf->global->LIVRAISON_SAPHIR_MASK; |
|
116 | 116 | |
117 | - if (! $mask) |
|
117 | + if (!$mask) |
|
118 | 118 | { |
119 | - $this->error='NotConfigured'; |
|
119 | + $this->error = 'NotConfigured'; |
|
120 | 120 | return 0; |
121 | 121 | } |
122 | 122 | |
123 | - $numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc,$object->date_livraison); |
|
123 | + $numFinal = get_next_value($db, $mask, 'livraison', 'ref', '', $objsoc, $object->date_livraison); |
|
124 | 124 | |
125 | 125 | return $numFinal; |
126 | 126 | } |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | * @param string $objforref Object for number to search |
134 | 134 | * @return string Next free value |
135 | 135 | */ |
136 | - function getNumRef($objsoc,$objforref) |
|
136 | + function getNumRef($objsoc, $objforref) |
|
137 | 137 | { |
138 | - return $this->getNextValue($objsoc,$objforref); |
|
138 | + return $this->getNextValue($objsoc, $objforref); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | * @param Object $object Objet livraison |
147 | 147 | * @return string Texte descripif |
148 | 148 | */ |
149 | - function livraison_get_num($objsoc=0,$object='') |
|
149 | + function livraison_get_num($objsoc = 0, $object = '') |
|
150 | 150 | { |
151 | - return $this->getNextValue($objsoc,$object); |
|
151 | + return $this->getNextValue($objsoc, $object); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | } |
@@ -217,7 +217,7 @@ |
||
217 | 217 | * Get printer detail |
218 | 218 | * |
219 | 219 | * @param string $uri URI |
220 | - * @return array List of attributes |
|
220 | + * @return stdClass List of attributes |
|
221 | 221 | */ |
222 | 222 | function get_printer_detail($uri) |
223 | 223 | { |
@@ -30,280 +30,280 @@ |
||
30 | 30 | */ |
31 | 31 | class printing_printipp extends PrintingDriver |
32 | 32 | { |
33 | - var $name='printipp'; |
|
34 | - var $desc='PrintIPPDesc'; |
|
35 | - var $picto='printer'; |
|
36 | - var $active='PRINTING_PRINTIPP'; |
|
37 | - var $conf=array(); |
|
38 | - var $host; |
|
39 | - var $port; |
|
40 | - var $userid; /* user login */ |
|
41 | - var $user; |
|
42 | - var $password; |
|
43 | - var $error; |
|
44 | - var $errors = array(); |
|
45 | - var $db; |
|
33 | + var $name='printipp'; |
|
34 | + var $desc='PrintIPPDesc'; |
|
35 | + var $picto='printer'; |
|
36 | + var $active='PRINTING_PRINTIPP'; |
|
37 | + var $conf=array(); |
|
38 | + var $host; |
|
39 | + var $port; |
|
40 | + var $userid; /* user login */ |
|
41 | + var $user; |
|
42 | + var $password; |
|
43 | + var $error; |
|
44 | + var $errors = array(); |
|
45 | + var $db; |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Constructor |
|
50 | - * |
|
51 | - * @param DoliDB $db Database handler |
|
52 | - */ |
|
53 | - function __construct($db) |
|
54 | - { |
|
55 | - global $conf; |
|
48 | + /** |
|
49 | + * Constructor |
|
50 | + * |
|
51 | + * @param DoliDB $db Database handler |
|
52 | + */ |
|
53 | + function __construct($db) |
|
54 | + { |
|
55 | + global $conf; |
|
56 | 56 | |
57 | - $this->db=$db; |
|
58 | - $this->host=$conf->global->PRINTIPP_HOST; |
|
59 | - $this->port=$conf->global->PRINTIPP_PORT; |
|
60 | - $this->user=$conf->global->PRINTIPP_USER; |
|
61 | - $this->password=$conf->global->PRINTIPP_PASSWORD; |
|
62 | - $this->conf[] = array('varname'=>'PRINTIPP_HOST', 'required'=>1, 'example'=>'localhost', 'type'=>'text'); |
|
63 | - $this->conf[] = array('varname'=>'PRINTIPP_PORT', 'required'=>1, 'example'=>'631', 'type'=>'text'); |
|
64 | - $this->conf[] = array('varname'=>'PRINTIPP_USER', 'required'=>0, 'example'=>'', 'type'=>'text', 'moreattributes'=>'autocomplete="off"'); |
|
65 | - $this->conf[] = array('varname'=>'PRINTIPP_PASSWORD', 'required'=>0, 'example'=>'', 'type'=>'password', 'moreattributes'=>'autocomplete="off"'); |
|
66 | - $this->conf[] = array('enabled'=>1, 'type'=>'submit'); |
|
67 | - } |
|
57 | + $this->db=$db; |
|
58 | + $this->host=$conf->global->PRINTIPP_HOST; |
|
59 | + $this->port=$conf->global->PRINTIPP_PORT; |
|
60 | + $this->user=$conf->global->PRINTIPP_USER; |
|
61 | + $this->password=$conf->global->PRINTIPP_PASSWORD; |
|
62 | + $this->conf[] = array('varname'=>'PRINTIPP_HOST', 'required'=>1, 'example'=>'localhost', 'type'=>'text'); |
|
63 | + $this->conf[] = array('varname'=>'PRINTIPP_PORT', 'required'=>1, 'example'=>'631', 'type'=>'text'); |
|
64 | + $this->conf[] = array('varname'=>'PRINTIPP_USER', 'required'=>0, 'example'=>'', 'type'=>'text', 'moreattributes'=>'autocomplete="off"'); |
|
65 | + $this->conf[] = array('varname'=>'PRINTIPP_PASSWORD', 'required'=>0, 'example'=>'', 'type'=>'password', 'moreattributes'=>'autocomplete="off"'); |
|
66 | + $this->conf[] = array('enabled'=>1, 'type'=>'submit'); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Print selected file |
|
71 | - * |
|
72 | - * @param string $file file |
|
73 | - * @param string $module module |
|
74 | - * @param string $subdir subdirectory of document like for expedition subdir is sendings |
|
75 | - * |
|
76 | - * @return int 0 if OK, >0 if KO |
|
77 | - */ |
|
78 | - function print_file($file, $module, $subdir='') |
|
79 | - { |
|
80 | - global $conf, $user; |
|
81 | - $error = 0; |
|
69 | + /** |
|
70 | + * Print selected file |
|
71 | + * |
|
72 | + * @param string $file file |
|
73 | + * @param string $module module |
|
74 | + * @param string $subdir subdirectory of document like for expedition subdir is sendings |
|
75 | + * |
|
76 | + * @return int 0 if OK, >0 if KO |
|
77 | + */ |
|
78 | + function print_file($file, $module, $subdir='') |
|
79 | + { |
|
80 | + global $conf, $user; |
|
81 | + $error = 0; |
|
82 | 82 | |
83 | - include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
|
83 | + include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
|
84 | 84 | |
85 | - $ipp = new CupsPrintIPP(); |
|
86 | - $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
87 | - $ipp->setHost($this->host); |
|
88 | - $ipp->setPort($this->port); |
|
89 | - $ipp->setJobName($file,true); |
|
90 | - $ipp->setUserName($this->userid); |
|
91 | - if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
85 | + $ipp = new CupsPrintIPP(); |
|
86 | + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
87 | + $ipp->setHost($this->host); |
|
88 | + $ipp->setPort($this->port); |
|
89 | + $ipp->setJobName($file,true); |
|
90 | + $ipp->setUserName($this->userid); |
|
91 | + if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
92 | 92 | |
93 | - // select printer uri for module order, propal,... |
|
94 | - $sql = "SELECT rowid,printer_id,copy FROM ".MAIN_DB_PREFIX."printing WHERE module = '".$module."' AND driver = 'printipp' AND userid = ".$user->id; |
|
95 | - $result = $this->db->query($sql); |
|
96 | - if ($result) |
|
97 | - { |
|
98 | - $obj = $this->db->fetch_object($result); |
|
99 | - if ($obj) |
|
100 | - { |
|
101 | - dol_syslog("Found a default printer for user ".$user->id." = ".$obj->printer_id); |
|
102 | - $ipp->setPrinterURI($obj->printer_id); |
|
103 | - } |
|
104 | - else |
|
105 | - { |
|
106 | - if (! empty($conf->global->PRINTIPP_URI_DEFAULT)) |
|
107 | - { |
|
93 | + // select printer uri for module order, propal,... |
|
94 | + $sql = "SELECT rowid,printer_id,copy FROM ".MAIN_DB_PREFIX."printing WHERE module = '".$module."' AND driver = 'printipp' AND userid = ".$user->id; |
|
95 | + $result = $this->db->query($sql); |
|
96 | + if ($result) |
|
97 | + { |
|
98 | + $obj = $this->db->fetch_object($result); |
|
99 | + if ($obj) |
|
100 | + { |
|
101 | + dol_syslog("Found a default printer for user ".$user->id." = ".$obj->printer_id); |
|
102 | + $ipp->setPrinterURI($obj->printer_id); |
|
103 | + } |
|
104 | + else |
|
105 | + { |
|
106 | + if (! empty($conf->global->PRINTIPP_URI_DEFAULT)) |
|
107 | + { |
|
108 | 108 | dol_syslog("Will use default printer conf->global->PRINTIPP_URI_DEFAULT = ".$conf->global->PRINTIPP_URI_DEFAULT); |
109 | - $ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT); |
|
110 | - } |
|
111 | - else |
|
109 | + $ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT); |
|
110 | + } |
|
111 | + else |
|
112 | 112 | { |
113 | - $this->errors[] = 'NoDefaultPrinterDefined'; |
|
114 | - $error++; |
|
115 | - return $error; |
|
116 | - } |
|
117 | - } |
|
118 | - } |
|
119 | - else dol_print_error($this->db); |
|
113 | + $this->errors[] = 'NoDefaultPrinterDefined'; |
|
114 | + $error++; |
|
115 | + return $error; |
|
116 | + } |
|
117 | + } |
|
118 | + } |
|
119 | + else dol_print_error($this->db); |
|
120 | 120 | |
121 | - // Set number of copy |
|
122 | - $ipp->setCopies($obj->copy); |
|
123 | - $fileprint=$conf->{$module}->dir_output; |
|
124 | - if ($subdir!='') $fileprint.='/'.$subdir; |
|
125 | - $fileprint.='/'.$file; |
|
126 | - $ipp->setData($fileprint); |
|
127 | - try { |
|
128 | - $ipp->printJob(); |
|
129 | - } catch (Exception $e) { |
|
130 | - $this->errors[] = $e->getMessage(); |
|
131 | - $error++; |
|
132 | - } |
|
133 | - if ($error==0) $this->errors[] = 'PRINTIPP: Job added'; |
|
121 | + // Set number of copy |
|
122 | + $ipp->setCopies($obj->copy); |
|
123 | + $fileprint=$conf->{$module}->dir_output; |
|
124 | + if ($subdir!='') $fileprint.='/'.$subdir; |
|
125 | + $fileprint.='/'.$file; |
|
126 | + $ipp->setData($fileprint); |
|
127 | + try { |
|
128 | + $ipp->printJob(); |
|
129 | + } catch (Exception $e) { |
|
130 | + $this->errors[] = $e->getMessage(); |
|
131 | + $error++; |
|
132 | + } |
|
133 | + if ($error==0) $this->errors[] = 'PRINTIPP: Job added'; |
|
134 | 134 | |
135 | - return $error; |
|
136 | - } |
|
135 | + return $error; |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * Return list of available printers |
|
140 | - * |
|
141 | - * @return int 0 if OK, >0 if KO |
|
142 | - */ |
|
143 | - function listAvailablePrinters() |
|
144 | - { |
|
145 | - global $bc, $conf, $langs; |
|
146 | - $error = 0; |
|
147 | - $var=true; |
|
138 | + /** |
|
139 | + * Return list of available printers |
|
140 | + * |
|
141 | + * @return int 0 if OK, >0 if KO |
|
142 | + */ |
|
143 | + function listAvailablePrinters() |
|
144 | + { |
|
145 | + global $bc, $conf, $langs; |
|
146 | + $error = 0; |
|
147 | + $var=true; |
|
148 | 148 | |
149 | - $html = '<tr class="liste_titre">'; |
|
150 | - $html.= '<td>'.$langs->trans('IPP_Uri').'</td>'; |
|
151 | - $html.= '<td>'.$langs->trans('IPP_Name').'</td>'; |
|
152 | - $html.= '<td>'.$langs->trans('IPP_State').'</td>'; |
|
153 | - $html.= '<td>'.$langs->trans('IPP_State_reason').'</td>'; |
|
154 | - $html.= '<td>'.$langs->trans('IPP_State_reason1').'</td>'; |
|
155 | - $html.= '<td>'.$langs->trans('IPP_BW').'</td>'; |
|
156 | - $html.= '<td>'.$langs->trans('IPP_Color').'</td>'; |
|
157 | - //$html.= '<td>'.$langs->trans('IPP_Device').'</td>'; |
|
158 | - $html.= '<td>'.$langs->trans('IPP_Media').'</td>'; |
|
159 | - $html.= '<td>'.$langs->trans('IPP_Supported').'</td>'; |
|
160 | - $html.= '<td align="center">'.$langs->trans("Select").'</td>'; |
|
161 | - $html.= "</tr>\n"; |
|
162 | - $list = $this->getlist_available_printers(); |
|
163 | - $var = true; |
|
164 | - foreach ($list as $value) |
|
165 | - { |
|
149 | + $html = '<tr class="liste_titre">'; |
|
150 | + $html.= '<td>'.$langs->trans('IPP_Uri').'</td>'; |
|
151 | + $html.= '<td>'.$langs->trans('IPP_Name').'</td>'; |
|
152 | + $html.= '<td>'.$langs->trans('IPP_State').'</td>'; |
|
153 | + $html.= '<td>'.$langs->trans('IPP_State_reason').'</td>'; |
|
154 | + $html.= '<td>'.$langs->trans('IPP_State_reason1').'</td>'; |
|
155 | + $html.= '<td>'.$langs->trans('IPP_BW').'</td>'; |
|
156 | + $html.= '<td>'.$langs->trans('IPP_Color').'</td>'; |
|
157 | + //$html.= '<td>'.$langs->trans('IPP_Device').'</td>'; |
|
158 | + $html.= '<td>'.$langs->trans('IPP_Media').'</td>'; |
|
159 | + $html.= '<td>'.$langs->trans('IPP_Supported').'</td>'; |
|
160 | + $html.= '<td align="center">'.$langs->trans("Select").'</td>'; |
|
161 | + $html.= "</tr>\n"; |
|
162 | + $list = $this->getlist_available_printers(); |
|
163 | + $var = true; |
|
164 | + foreach ($list as $value) |
|
165 | + { |
|
166 | 166 | |
167 | - $printer_det = $this->get_printer_detail($value); |
|
168 | - $html.= "<tr ".$bc[$var].">"; |
|
169 | - $html.= '<td>'.$value.'</td>'; |
|
170 | - //$html.= '<td><pre>'.print_r($printer_det,true).'</pre></td>'; |
|
171 | - $html.= '<td>'.$printer_det->printer_name->_value0.'</td>'; |
|
172 | - $html.= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state->_value0).'</td>'; |
|
173 | - $html.= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value0).'</td>'; |
|
174 | - $html.= '<td>'.(! empty($printer_det->printer_state_reasons->_value1)?$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value1):'').'</td>'; |
|
175 | - $html.= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value2).'</td>'; |
|
176 | - $html.= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value3).'</td>'; |
|
177 | - //$html.= '<td>'.$printer_det->device_uri->_value0.'</td>'; |
|
178 | - $html.= '<td>'.$printer_det->media_default->_value0.'</td>'; |
|
179 | - $html.= '<td>'.$langs->trans('MEDIA_IPP_'.$printer_det->media_type_supported->_value1).'</td>'; |
|
180 | - // Defaut |
|
181 | - $html.= '<td align="center">'; |
|
182 | - if ($conf->global->PRINTIPP_URI_DEFAULT == $value) |
|
183 | - { |
|
184 | - $html.= img_picto($langs->trans("Default"),'on'); |
|
185 | - } |
|
186 | - else |
|
167 | + $printer_det = $this->get_printer_detail($value); |
|
168 | + $html.= "<tr ".$bc[$var].">"; |
|
169 | + $html.= '<td>'.$value.'</td>'; |
|
170 | + //$html.= '<td><pre>'.print_r($printer_det,true).'</pre></td>'; |
|
171 | + $html.= '<td>'.$printer_det->printer_name->_value0.'</td>'; |
|
172 | + $html.= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state->_value0).'</td>'; |
|
173 | + $html.= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value0).'</td>'; |
|
174 | + $html.= '<td>'.(! empty($printer_det->printer_state_reasons->_value1)?$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value1):'').'</td>'; |
|
175 | + $html.= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value2).'</td>'; |
|
176 | + $html.= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value3).'</td>'; |
|
177 | + //$html.= '<td>'.$printer_det->device_uri->_value0.'</td>'; |
|
178 | + $html.= '<td>'.$printer_det->media_default->_value0.'</td>'; |
|
179 | + $html.= '<td>'.$langs->trans('MEDIA_IPP_'.$printer_det->media_type_supported->_value1).'</td>'; |
|
180 | + // Defaut |
|
181 | + $html.= '<td align="center">'; |
|
182 | + if ($conf->global->PRINTIPP_URI_DEFAULT == $value) |
|
187 | 183 | { |
188 | - $html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTIPP_URI_DEFAULT&driver=printipp&value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
189 | - } |
|
184 | + $html.= img_picto($langs->trans("Default"),'on'); |
|
185 | + } |
|
186 | + else |
|
187 | + { |
|
188 | + $html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTIPP_URI_DEFAULT&driver=printipp&value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
189 | + } |
|
190 | 190 | $html.= '</td>'; |
191 | - $html.= '</tr>'."\n"; |
|
192 | - } |
|
193 | - $this->resprint = $html; |
|
194 | - return $error; |
|
195 | - } |
|
191 | + $html.= '</tr>'."\n"; |
|
192 | + } |
|
193 | + $this->resprint = $html; |
|
194 | + return $error; |
|
195 | + } |
|
196 | 196 | |
197 | - /** |
|
198 | - * Return list of available printers |
|
199 | - * |
|
200 | - * @return array list of printers |
|
201 | - */ |
|
202 | - function getlist_available_printers() |
|
203 | - { |
|
204 | - global $conf,$db; |
|
205 | - include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
|
206 | - $ipp = new CupsPrintIPP(); |
|
207 | - $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
208 | - $ipp->setHost($this->host); |
|
209 | - $ipp->setPort($this->port); |
|
210 | - $ipp->setUserName($this->userid); |
|
211 | - if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
212 | - $ipp->getPrinters(); |
|
213 | - return $ipp->available_printers; |
|
214 | - } |
|
197 | + /** |
|
198 | + * Return list of available printers |
|
199 | + * |
|
200 | + * @return array list of printers |
|
201 | + */ |
|
202 | + function getlist_available_printers() |
|
203 | + { |
|
204 | + global $conf,$db; |
|
205 | + include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
|
206 | + $ipp = new CupsPrintIPP(); |
|
207 | + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
208 | + $ipp->setHost($this->host); |
|
209 | + $ipp->setPort($this->port); |
|
210 | + $ipp->setUserName($this->userid); |
|
211 | + if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
212 | + $ipp->getPrinters(); |
|
213 | + return $ipp->available_printers; |
|
214 | + } |
|
215 | 215 | |
216 | - /** |
|
217 | - * Get printer detail |
|
218 | - * |
|
219 | - * @param string $uri URI |
|
220 | - * @return array List of attributes |
|
221 | - */ |
|
222 | - function get_printer_detail($uri) |
|
223 | - { |
|
224 | - global $conf,$db; |
|
216 | + /** |
|
217 | + * Get printer detail |
|
218 | + * |
|
219 | + * @param string $uri URI |
|
220 | + * @return array List of attributes |
|
221 | + */ |
|
222 | + function get_printer_detail($uri) |
|
223 | + { |
|
224 | + global $conf,$db; |
|
225 | 225 | |
226 | - include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
|
227 | - $ipp = new CupsPrintIPP(); |
|
228 | - $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
229 | - $ipp->setHost($this->host); |
|
230 | - $ipp->setPort($this->port); |
|
231 | - $ipp->setUserName($this->userid); |
|
232 | - if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
233 | - $ipp->setPrinterURI($uri); |
|
234 | - $ipp->getPrinterAttributes(); |
|
235 | - return $ipp->printer_attributes; |
|
236 | - } |
|
226 | + include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
|
227 | + $ipp = new CupsPrintIPP(); |
|
228 | + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
229 | + $ipp->setHost($this->host); |
|
230 | + $ipp->setPort($this->port); |
|
231 | + $ipp->setUserName($this->userid); |
|
232 | + if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
233 | + $ipp->setPrinterURI($uri); |
|
234 | + $ipp->getPrinterAttributes(); |
|
235 | + return $ipp->printer_attributes; |
|
236 | + } |
|
237 | 237 | |
238 | - /** |
|
239 | - * List jobs print |
|
240 | - * |
|
241 | - * @param string $module module |
|
242 | - * |
|
243 | - * @return int 0 if OK, >0 if KO |
|
244 | - */ |
|
245 | - function list_jobs($module) |
|
246 | - { |
|
247 | - global $conf, $db, $bc; |
|
248 | - $error = 0; |
|
249 | - $html = ''; |
|
250 | - include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
|
251 | - $ipp = new CupsPrintIPP(); |
|
252 | - $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
253 | - $ipp->setHost($this->host); |
|
254 | - $ipp->setPort($this->port); |
|
255 | - $ipp->setUserName($this->userid); |
|
256 | - if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
257 | - // select printer uri for module order, propal,... |
|
258 | - $sql = 'SELECT rowid,printer_uri,printer_name FROM '.MAIN_DB_PREFIX.'printer_ipp WHERE module="'.$module.'"'; |
|
259 | - $result = $this->db->query($sql); |
|
260 | - if ($result) |
|
261 | - { |
|
262 | - $obj = $this->db->fetch_object($result); |
|
263 | - if ($obj) |
|
264 | - { |
|
265 | - $ipp->setPrinterURI($obj->printer_uri); |
|
266 | - } |
|
267 | - else |
|
268 | - { |
|
269 | - // All printers |
|
270 | - $ipp->setPrinterURI("ipp://localhost:631/printers/"); |
|
271 | - } |
|
272 | - } |
|
273 | - // Getting Jobs |
|
274 | - try { |
|
275 | - $ipp->getJobs(false,0,'completed',false); |
|
276 | - } catch (Exception $e) { |
|
277 | - $this->errors[] = $e->getMessage(); |
|
278 | - $error++; |
|
279 | - } |
|
280 | - $html .= '<table width="100%" class="noborder">'; |
|
281 | - $html .= '<tr class="liste_titre">'; |
|
282 | - $html .= '<td>Id</td>'; |
|
283 | - $html .= '<td>Owner</td>'; |
|
284 | - $html .= '<td>Printer</td>'; |
|
285 | - $html .= '<td>File</td>'; |
|
286 | - $html .= '<td>Status</td>'; |
|
287 | - $html .= '<td>Cancel</td>'; |
|
288 | - $html .= '</tr>'."\n"; |
|
289 | - $jobs = $ipp->jobs_attributes; |
|
290 | - $var = True; |
|
291 | - //$html .= '<pre>'.print_r($jobs,true).'</pre>'; |
|
292 | - foreach ($jobs as $value ) |
|
293 | - { |
|
294 | - $var = !$var; |
|
295 | - $html .= '<tr '.$bc[$var].'>'; |
|
296 | - $html .= '<td>'.$value->job_id->_value0.'</td>'; |
|
297 | - $html .= '<td>'.$value->job_originating_user_name->_value0.'</td>'; |
|
298 | - $html .= '<td>'.$value->printer_uri->_value0.'</td>'; |
|
299 | - $html .= '<td>'.$value->job_name->_value0.'</td>'; |
|
300 | - $html .= '<td>'.$value->job_state->_value0.'</td>'; |
|
301 | - $html .= '<td>'.$value->job_uri->_value0.'</td>'; |
|
302 | - $html .= '</tr>'; |
|
303 | - } |
|
304 | - $html .= "</table>"; |
|
305 | - $this->resprint = $html; |
|
306 | - return $error; |
|
307 | - } |
|
238 | + /** |
|
239 | + * List jobs print |
|
240 | + * |
|
241 | + * @param string $module module |
|
242 | + * |
|
243 | + * @return int 0 if OK, >0 if KO |
|
244 | + */ |
|
245 | + function list_jobs($module) |
|
246 | + { |
|
247 | + global $conf, $db, $bc; |
|
248 | + $error = 0; |
|
249 | + $html = ''; |
|
250 | + include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
|
251 | + $ipp = new CupsPrintIPP(); |
|
252 | + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
253 | + $ipp->setHost($this->host); |
|
254 | + $ipp->setPort($this->port); |
|
255 | + $ipp->setUserName($this->userid); |
|
256 | + if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
257 | + // select printer uri for module order, propal,... |
|
258 | + $sql = 'SELECT rowid,printer_uri,printer_name FROM '.MAIN_DB_PREFIX.'printer_ipp WHERE module="'.$module.'"'; |
|
259 | + $result = $this->db->query($sql); |
|
260 | + if ($result) |
|
261 | + { |
|
262 | + $obj = $this->db->fetch_object($result); |
|
263 | + if ($obj) |
|
264 | + { |
|
265 | + $ipp->setPrinterURI($obj->printer_uri); |
|
266 | + } |
|
267 | + else |
|
268 | + { |
|
269 | + // All printers |
|
270 | + $ipp->setPrinterURI("ipp://localhost:631/printers/"); |
|
271 | + } |
|
272 | + } |
|
273 | + // Getting Jobs |
|
274 | + try { |
|
275 | + $ipp->getJobs(false,0,'completed',false); |
|
276 | + } catch (Exception $e) { |
|
277 | + $this->errors[] = $e->getMessage(); |
|
278 | + $error++; |
|
279 | + } |
|
280 | + $html .= '<table width="100%" class="noborder">'; |
|
281 | + $html .= '<tr class="liste_titre">'; |
|
282 | + $html .= '<td>Id</td>'; |
|
283 | + $html .= '<td>Owner</td>'; |
|
284 | + $html .= '<td>Printer</td>'; |
|
285 | + $html .= '<td>File</td>'; |
|
286 | + $html .= '<td>Status</td>'; |
|
287 | + $html .= '<td>Cancel</td>'; |
|
288 | + $html .= '</tr>'."\n"; |
|
289 | + $jobs = $ipp->jobs_attributes; |
|
290 | + $var = True; |
|
291 | + //$html .= '<pre>'.print_r($jobs,true).'</pre>'; |
|
292 | + foreach ($jobs as $value ) |
|
293 | + { |
|
294 | + $var = !$var; |
|
295 | + $html .= '<tr '.$bc[$var].'>'; |
|
296 | + $html .= '<td>'.$value->job_id->_value0.'</td>'; |
|
297 | + $html .= '<td>'.$value->job_originating_user_name->_value0.'</td>'; |
|
298 | + $html .= '<td>'.$value->printer_uri->_value0.'</td>'; |
|
299 | + $html .= '<td>'.$value->job_name->_value0.'</td>'; |
|
300 | + $html .= '<td>'.$value->job_state->_value0.'</td>'; |
|
301 | + $html .= '<td>'.$value->job_uri->_value0.'</td>'; |
|
302 | + $html .= '</tr>'; |
|
303 | + } |
|
304 | + $html .= "</table>"; |
|
305 | + $this->resprint = $html; |
|
306 | + return $error; |
|
307 | + } |
|
308 | 308 | |
309 | 309 | } |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class printing_printipp extends PrintingDriver |
32 | 32 | { |
33 | - var $name='printipp'; |
|
34 | - var $desc='PrintIPPDesc'; |
|
35 | - var $picto='printer'; |
|
36 | - var $active='PRINTING_PRINTIPP'; |
|
37 | - var $conf=array(); |
|
33 | + var $name = 'printipp'; |
|
34 | + var $desc = 'PrintIPPDesc'; |
|
35 | + var $picto = 'printer'; |
|
36 | + var $active = 'PRINTING_PRINTIPP'; |
|
37 | + var $conf = array(); |
|
38 | 38 | var $host; |
39 | 39 | var $port; |
40 | - var $userid; /* user login */ |
|
40 | + var $userid; /* user login */ |
|
41 | 41 | var $user; |
42 | 42 | var $password; |
43 | 43 | var $error; |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | { |
55 | 55 | global $conf; |
56 | 56 | |
57 | - $this->db=$db; |
|
58 | - $this->host=$conf->global->PRINTIPP_HOST; |
|
59 | - $this->port=$conf->global->PRINTIPP_PORT; |
|
60 | - $this->user=$conf->global->PRINTIPP_USER; |
|
61 | - $this->password=$conf->global->PRINTIPP_PASSWORD; |
|
57 | + $this->db = $db; |
|
58 | + $this->host = $conf->global->PRINTIPP_HOST; |
|
59 | + $this->port = $conf->global->PRINTIPP_PORT; |
|
60 | + $this->user = $conf->global->PRINTIPP_USER; |
|
61 | + $this->password = $conf->global->PRINTIPP_PASSWORD; |
|
62 | 62 | $this->conf[] = array('varname'=>'PRINTIPP_HOST', 'required'=>1, 'example'=>'localhost', 'type'=>'text'); |
63 | 63 | $this->conf[] = array('varname'=>'PRINTIPP_PORT', 'required'=>1, 'example'=>'631', 'type'=>'text'); |
64 | 64 | $this->conf[] = array('varname'=>'PRINTIPP_USER', 'required'=>0, 'example'=>'', 'type'=>'text', 'moreattributes'=>'autocomplete="off"'); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return int 0 if OK, >0 if KO |
77 | 77 | */ |
78 | - function print_file($file, $module, $subdir='') |
|
78 | + function print_file($file, $module, $subdir = '') |
|
79 | 79 | { |
80 | 80 | global $conf, $user; |
81 | 81 | $error = 0; |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
84 | 84 | |
85 | 85 | $ipp = new CupsPrintIPP(); |
86 | - $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
86 | + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log', 'file', 3); // logging very verbose |
|
87 | 87 | $ipp->setHost($this->host); |
88 | 88 | $ipp->setPort($this->port); |
89 | - $ipp->setJobName($file,true); |
|
89 | + $ipp->setJobName($file, true); |
|
90 | 90 | $ipp->setUserName($this->userid); |
91 | - if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
91 | + if (!empty($this->user)) $ipp->setAuthentication($this->user, $this->password); |
|
92 | 92 | |
93 | 93 | // select printer uri for module order, propal,... |
94 | 94 | $sql = "SELECT rowid,printer_id,copy FROM ".MAIN_DB_PREFIX."printing WHERE module = '".$module."' AND driver = 'printipp' AND userid = ".$user->id; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } |
104 | 104 | else |
105 | 105 | { |
106 | - if (! empty($conf->global->PRINTIPP_URI_DEFAULT)) |
|
106 | + if (!empty($conf->global->PRINTIPP_URI_DEFAULT)) |
|
107 | 107 | { |
108 | 108 | dol_syslog("Will use default printer conf->global->PRINTIPP_URI_DEFAULT = ".$conf->global->PRINTIPP_URI_DEFAULT); |
109 | 109 | $ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT); |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | |
121 | 121 | // Set number of copy |
122 | 122 | $ipp->setCopies($obj->copy); |
123 | - $fileprint=$conf->{$module}->dir_output; |
|
124 | - if ($subdir!='') $fileprint.='/'.$subdir; |
|
125 | - $fileprint.='/'.$file; |
|
123 | + $fileprint = $conf->{$module}->dir_output; |
|
124 | + if ($subdir != '') $fileprint .= '/'.$subdir; |
|
125 | + $fileprint .= '/'.$file; |
|
126 | 126 | $ipp->setData($fileprint); |
127 | 127 | try { |
128 | 128 | $ipp->printJob(); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $this->errors[] = $e->getMessage(); |
131 | 131 | $error++; |
132 | 132 | } |
133 | - if ($error==0) $this->errors[] = 'PRINTIPP: Job added'; |
|
133 | + if ($error == 0) $this->errors[] = 'PRINTIPP: Job added'; |
|
134 | 134 | |
135 | 135 | return $error; |
136 | 136 | } |
@@ -144,51 +144,51 @@ discard block |
||
144 | 144 | { |
145 | 145 | global $bc, $conf, $langs; |
146 | 146 | $error = 0; |
147 | - $var=true; |
|
147 | + $var = true; |
|
148 | 148 | |
149 | 149 | $html = '<tr class="liste_titre">'; |
150 | - $html.= '<td>'.$langs->trans('IPP_Uri').'</td>'; |
|
151 | - $html.= '<td>'.$langs->trans('IPP_Name').'</td>'; |
|
152 | - $html.= '<td>'.$langs->trans('IPP_State').'</td>'; |
|
153 | - $html.= '<td>'.$langs->trans('IPP_State_reason').'</td>'; |
|
154 | - $html.= '<td>'.$langs->trans('IPP_State_reason1').'</td>'; |
|
155 | - $html.= '<td>'.$langs->trans('IPP_BW').'</td>'; |
|
156 | - $html.= '<td>'.$langs->trans('IPP_Color').'</td>'; |
|
150 | + $html .= '<td>'.$langs->trans('IPP_Uri').'</td>'; |
|
151 | + $html .= '<td>'.$langs->trans('IPP_Name').'</td>'; |
|
152 | + $html .= '<td>'.$langs->trans('IPP_State').'</td>'; |
|
153 | + $html .= '<td>'.$langs->trans('IPP_State_reason').'</td>'; |
|
154 | + $html .= '<td>'.$langs->trans('IPP_State_reason1').'</td>'; |
|
155 | + $html .= '<td>'.$langs->trans('IPP_BW').'</td>'; |
|
156 | + $html .= '<td>'.$langs->trans('IPP_Color').'</td>'; |
|
157 | 157 | //$html.= '<td>'.$langs->trans('IPP_Device').'</td>'; |
158 | - $html.= '<td>'.$langs->trans('IPP_Media').'</td>'; |
|
159 | - $html.= '<td>'.$langs->trans('IPP_Supported').'</td>'; |
|
160 | - $html.= '<td align="center">'.$langs->trans("Select").'</td>'; |
|
161 | - $html.= "</tr>\n"; |
|
158 | + $html .= '<td>'.$langs->trans('IPP_Media').'</td>'; |
|
159 | + $html .= '<td>'.$langs->trans('IPP_Supported').'</td>'; |
|
160 | + $html .= '<td align="center">'.$langs->trans("Select").'</td>'; |
|
161 | + $html .= "</tr>\n"; |
|
162 | 162 | $list = $this->getlist_available_printers(); |
163 | 163 | $var = true; |
164 | 164 | foreach ($list as $value) |
165 | 165 | { |
166 | 166 | |
167 | 167 | $printer_det = $this->get_printer_detail($value); |
168 | - $html.= "<tr ".$bc[$var].">"; |
|
169 | - $html.= '<td>'.$value.'</td>'; |
|
168 | + $html .= "<tr ".$bc[$var].">"; |
|
169 | + $html .= '<td>'.$value.'</td>'; |
|
170 | 170 | //$html.= '<td><pre>'.print_r($printer_det,true).'</pre></td>'; |
171 | - $html.= '<td>'.$printer_det->printer_name->_value0.'</td>'; |
|
172 | - $html.= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state->_value0).'</td>'; |
|
173 | - $html.= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value0).'</td>'; |
|
174 | - $html.= '<td>'.(! empty($printer_det->printer_state_reasons->_value1)?$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value1):'').'</td>'; |
|
175 | - $html.= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value2).'</td>'; |
|
176 | - $html.= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value3).'</td>'; |
|
171 | + $html .= '<td>'.$printer_det->printer_name->_value0.'</td>'; |
|
172 | + $html .= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state->_value0).'</td>'; |
|
173 | + $html .= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value0).'</td>'; |
|
174 | + $html .= '<td>'.(!empty($printer_det->printer_state_reasons->_value1) ? $langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value1) : '').'</td>'; |
|
175 | + $html .= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value2).'</td>'; |
|
176 | + $html .= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value3).'</td>'; |
|
177 | 177 | //$html.= '<td>'.$printer_det->device_uri->_value0.'</td>'; |
178 | - $html.= '<td>'.$printer_det->media_default->_value0.'</td>'; |
|
179 | - $html.= '<td>'.$langs->trans('MEDIA_IPP_'.$printer_det->media_type_supported->_value1).'</td>'; |
|
178 | + $html .= '<td>'.$printer_det->media_default->_value0.'</td>'; |
|
179 | + $html .= '<td>'.$langs->trans('MEDIA_IPP_'.$printer_det->media_type_supported->_value1).'</td>'; |
|
180 | 180 | // Defaut |
181 | - $html.= '<td align="center">'; |
|
181 | + $html .= '<td align="center">'; |
|
182 | 182 | if ($conf->global->PRINTIPP_URI_DEFAULT == $value) |
183 | 183 | { |
184 | - $html.= img_picto($langs->trans("Default"),'on'); |
|
184 | + $html .= img_picto($langs->trans("Default"), 'on'); |
|
185 | 185 | } |
186 | 186 | else |
187 | 187 | { |
188 | - $html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTIPP_URI_DEFAULT&driver=printipp&value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
188 | + $html .= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTIPP_URI_DEFAULT&driver=printipp&value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; |
|
189 | 189 | } |
190 | - $html.= '</td>'; |
|
191 | - $html.= '</tr>'."\n"; |
|
190 | + $html .= '</td>'; |
|
191 | + $html .= '</tr>'."\n"; |
|
192 | 192 | } |
193 | 193 | $this->resprint = $html; |
194 | 194 | return $error; |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | */ |
202 | 202 | function getlist_available_printers() |
203 | 203 | { |
204 | - global $conf,$db; |
|
204 | + global $conf, $db; |
|
205 | 205 | include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
206 | 206 | $ipp = new CupsPrintIPP(); |
207 | - $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
207 | + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log', 'file', 3); // logging very verbose |
|
208 | 208 | $ipp->setHost($this->host); |
209 | 209 | $ipp->setPort($this->port); |
210 | 210 | $ipp->setUserName($this->userid); |
211 | - if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
211 | + if (!empty($this->user)) $ipp->setAuthentication($this->user, $this->password); |
|
212 | 212 | $ipp->getPrinters(); |
213 | 213 | return $ipp->available_printers; |
214 | 214 | } |
@@ -221,15 +221,15 @@ discard block |
||
221 | 221 | */ |
222 | 222 | function get_printer_detail($uri) |
223 | 223 | { |
224 | - global $conf,$db; |
|
224 | + global $conf, $db; |
|
225 | 225 | |
226 | 226 | include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
227 | 227 | $ipp = new CupsPrintIPP(); |
228 | - $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
228 | + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log', 'file', 3); // logging very verbose |
|
229 | 229 | $ipp->setHost($this->host); |
230 | 230 | $ipp->setPort($this->port); |
231 | 231 | $ipp->setUserName($this->userid); |
232 | - if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
232 | + if (!empty($this->user)) $ipp->setAuthentication($this->user, $this->password); |
|
233 | 233 | $ipp->setPrinterURI($uri); |
234 | 234 | $ipp->getPrinterAttributes(); |
235 | 235 | return $ipp->printer_attributes; |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | $html = ''; |
250 | 250 | include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; |
251 | 251 | $ipp = new CupsPrintIPP(); |
252 | - $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose |
|
252 | + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log', 'file', 3); // logging very verbose |
|
253 | 253 | $ipp->setHost($this->host); |
254 | 254 | $ipp->setPort($this->port); |
255 | 255 | $ipp->setUserName($this->userid); |
256 | - if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
256 | + if (!empty($this->user)) $ipp->setAuthentication($this->user, $this->password); |
|
257 | 257 | // select printer uri for module order, propal,... |
258 | 258 | $sql = 'SELECT rowid,printer_uri,printer_name FROM '.MAIN_DB_PREFIX.'printer_ipp WHERE module="'.$module.'"'; |
259 | 259 | $result = $this->db->query($sql); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | } |
273 | 273 | // Getting Jobs |
274 | 274 | try { |
275 | - $ipp->getJobs(false,0,'completed',false); |
|
275 | + $ipp->getJobs(false, 0, 'completed', false); |
|
276 | 276 | } catch (Exception $e) { |
277 | 277 | $this->errors[] = $e->getMessage(); |
278 | 278 | $error++; |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $jobs = $ipp->jobs_attributes; |
290 | 290 | $var = True; |
291 | 291 | //$html .= '<pre>'.print_r($jobs,true).'</pre>'; |
292 | - foreach ($jobs as $value ) |
|
292 | + foreach ($jobs as $value) |
|
293 | 293 | { |
294 | 294 | $var = !$var; |
295 | 295 | $html .= '<tr '.$bc[$var].'>'; |
@@ -88,7 +88,9 @@ discard block |
||
88 | 88 | $ipp->setPort($this->port); |
89 | 89 | $ipp->setJobName($file,true); |
90 | 90 | $ipp->setUserName($this->userid); |
91 | - if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
91 | + if (! empty($this->user)) { |
|
92 | + $ipp->setAuthentication($this->user,$this->password); |
|
93 | + } |
|
92 | 94 | |
93 | 95 | // select printer uri for module order, propal,... |
94 | 96 | $sql = "SELECT rowid,printer_id,copy FROM ".MAIN_DB_PREFIX."printing WHERE module = '".$module."' AND driver = 'printipp' AND userid = ".$user->id; |
@@ -100,28 +102,29 @@ discard block |
||
100 | 102 | { |
101 | 103 | dol_syslog("Found a default printer for user ".$user->id." = ".$obj->printer_id); |
102 | 104 | $ipp->setPrinterURI($obj->printer_id); |
103 | - } |
|
104 | - else |
|
105 | + } else |
|
105 | 106 | { |
106 | 107 | if (! empty($conf->global->PRINTIPP_URI_DEFAULT)) |
107 | 108 | { |
108 | 109 | dol_syslog("Will use default printer conf->global->PRINTIPP_URI_DEFAULT = ".$conf->global->PRINTIPP_URI_DEFAULT); |
109 | 110 | $ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT); |
110 | - } |
|
111 | - else |
|
111 | + } else |
|
112 | 112 | { |
113 | 113 | $this->errors[] = 'NoDefaultPrinterDefined'; |
114 | 114 | $error++; |
115 | 115 | return $error; |
116 | 116 | } |
117 | 117 | } |
118 | + } else { |
|
119 | + dol_print_error($this->db); |
|
118 | 120 | } |
119 | - else dol_print_error($this->db); |
|
120 | 121 | |
121 | 122 | // Set number of copy |
122 | 123 | $ipp->setCopies($obj->copy); |
123 | 124 | $fileprint=$conf->{$module}->dir_output; |
124 | - if ($subdir!='') $fileprint.='/'.$subdir; |
|
125 | + if ($subdir!='') { |
|
126 | + $fileprint.='/'.$subdir; |
|
127 | + } |
|
125 | 128 | $fileprint.='/'.$file; |
126 | 129 | $ipp->setData($fileprint); |
127 | 130 | try { |
@@ -130,7 +133,9 @@ discard block |
||
130 | 133 | $this->errors[] = $e->getMessage(); |
131 | 134 | $error++; |
132 | 135 | } |
133 | - if ($error==0) $this->errors[] = 'PRINTIPP: Job added'; |
|
136 | + if ($error==0) { |
|
137 | + $this->errors[] = 'PRINTIPP: Job added'; |
|
138 | + } |
|
134 | 139 | |
135 | 140 | return $error; |
136 | 141 | } |
@@ -182,8 +187,7 @@ discard block |
||
182 | 187 | if ($conf->global->PRINTIPP_URI_DEFAULT == $value) |
183 | 188 | { |
184 | 189 | $html.= img_picto($langs->trans("Default"),'on'); |
185 | - } |
|
186 | - else |
|
190 | + } else |
|
187 | 191 | { |
188 | 192 | $html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTIPP_URI_DEFAULT&driver=printipp&value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
189 | 193 | } |
@@ -208,7 +212,9 @@ discard block |
||
208 | 212 | $ipp->setHost($this->host); |
209 | 213 | $ipp->setPort($this->port); |
210 | 214 | $ipp->setUserName($this->userid); |
211 | - if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
215 | + if (! empty($this->user)) { |
|
216 | + $ipp->setAuthentication($this->user,$this->password); |
|
217 | + } |
|
212 | 218 | $ipp->getPrinters(); |
213 | 219 | return $ipp->available_printers; |
214 | 220 | } |
@@ -229,7 +235,9 @@ discard block |
||
229 | 235 | $ipp->setHost($this->host); |
230 | 236 | $ipp->setPort($this->port); |
231 | 237 | $ipp->setUserName($this->userid); |
232 | - if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
238 | + if (! empty($this->user)) { |
|
239 | + $ipp->setAuthentication($this->user,$this->password); |
|
240 | + } |
|
233 | 241 | $ipp->setPrinterURI($uri); |
234 | 242 | $ipp->getPrinterAttributes(); |
235 | 243 | return $ipp->printer_attributes; |
@@ -253,7 +261,9 @@ discard block |
||
253 | 261 | $ipp->setHost($this->host); |
254 | 262 | $ipp->setPort($this->port); |
255 | 263 | $ipp->setUserName($this->userid); |
256 | - if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); |
|
264 | + if (! empty($this->user)) { |
|
265 | + $ipp->setAuthentication($this->user,$this->password); |
|
266 | + } |
|
257 | 267 | // select printer uri for module order, propal,... |
258 | 268 | $sql = 'SELECT rowid,printer_uri,printer_name FROM '.MAIN_DB_PREFIX.'printer_ipp WHERE module="'.$module.'"'; |
259 | 269 | $result = $this->db->query($sql); |
@@ -263,8 +273,7 @@ discard block |
||
263 | 273 | if ($obj) |
264 | 274 | { |
265 | 275 | $ipp->setPrinterURI($obj->printer_uri); |
266 | - } |
|
267 | - else |
|
276 | + } else |
|
268 | 277 | { |
269 | 278 | // All printers |
270 | 279 | $ipp->setPrinterURI("ipp://localhost:631/printers/"); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * Return an example of result returned by getNextValue |
114 | 114 | * |
115 | 115 | * @param Translate $langs Object langs |
116 | - * @param product $objproduct Object product |
|
116 | + * @param integer $objproduct Object product |
|
117 | 117 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
118 | 118 | * @return string Return string example |
119 | 119 | */ |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | /** |
155 | 155 | * Return next value |
156 | 156 | * |
157 | - * @param Product $objproduct Object product |
|
157 | + * @param integer $objproduct Object product |
|
158 | 158 | * @param int $type Produit ou service (0:product, 1:service) |
159 | 159 | * @return string Value if OK, '' if module not configured, <0 if KO |
160 | 160 | */ |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | */ |
35 | 35 | class mod_codeproduct_elephant extends ModeleProductCode |
36 | 36 | { |
37 | - var $nom='Elephant'; // Nom du modele |
|
38 | - var $name='Elephant'; // Nom du modele |
|
39 | - var $code_modifiable; // Code modifiable |
|
40 | - var $code_modifiable_invalide; // Code modifiable si il est invalide |
|
41 | - var $code_modifiable_null; // Code modifiables si il est null |
|
42 | - var $code_null; // Code facultatif |
|
43 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
44 | - var $code_auto; // Numerotation automatique |
|
37 | + var $nom = 'Elephant'; // Nom du modele |
|
38 | + var $name = 'Elephant'; // Nom du modele |
|
39 | + var $code_modifiable; // Code modifiable |
|
40 | + var $code_modifiable_invalide; // Code modifiable si il est invalide |
|
41 | + var $code_modifiable_null; // Code modifiables si il est null |
|
42 | + var $code_null; // Code facultatif |
|
43 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
44 | + var $code_auto; // Numerotation automatique |
|
45 | 45 | |
46 | 46 | var $searchcode; // String de recherche |
47 | 47 | var $numbitcounter; // Nombre de chiffres du compteur |
@@ -74,36 +74,36 @@ discard block |
||
74 | 74 | |
75 | 75 | $langs->load("products"); |
76 | 76 | |
77 | - $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
77 | + $disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
78 | 78 | |
79 | 79 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
80 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
81 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
82 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
83 | - $texte.= '<input type="hidden" name="param1" value="PRODUCT_ELEPHANT_MASK_PRODUCT">'; |
|
84 | - $texte.= '<input type="hidden" name="param2" value="PRODUCT_ELEPHANT_MASK_SERVICE">'; |
|
85 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
86 | - |
|
87 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Product"),$langs->transnoentities("Product")); |
|
88 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
89 | - $tooltip.=$langs->trans("GenericMaskCodes4c"); |
|
90 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
80 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
81 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
82 | + $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
83 | + $texte .= '<input type="hidden" name="param1" value="PRODUCT_ELEPHANT_MASK_PRODUCT">'; |
|
84 | + $texte .= '<input type="hidden" name="param2" value="PRODUCT_ELEPHANT_MASK_SERVICE">'; |
|
85 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
86 | + |
|
87 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Product"), $langs->transnoentities("Product")); |
|
88 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
89 | + $tooltip .= $langs->trans("GenericMaskCodes4c"); |
|
90 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
91 | 91 | |
92 | 92 | // Parametrage du prefix customers |
93 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("ProductCodeModel").'):</td>'; |
|
94 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(! empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)?$conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT:'').'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
93 | + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("ProductCodeModel").'):</td>'; |
|
94 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(!empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT) ? $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT : '').'"'.$disabled.'>', $tooltip, 1, 1).'</td>'; |
|
95 | 95 | |
96 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
96 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
97 | 97 | |
98 | - $texte.= '</tr>'; |
|
98 | + $texte .= '</tr>'; |
|
99 | 99 | |
100 | 100 | // Parametrage du prefix suppliers |
101 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("ServiceCodeModel").'):</td>'; |
|
102 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.(! empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)?$conf->global->PRODUCT_ELEPHANT_MASK_SERVICE:'').'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
103 | - $texte.= '</tr>'; |
|
101 | + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("ServiceCodeModel").'):</td>'; |
|
102 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.(!empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE) ? $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE : '').'"'.$disabled.'>', $tooltip, 1, 1).'</td>'; |
|
103 | + $texte .= '</tr>'; |
|
104 | 104 | |
105 | - $texte.= '</table>'; |
|
106 | - $texte.= '</form>'; |
|
105 | + $texte .= '</table>'; |
|
106 | + $texte .= '</form>'; |
|
107 | 107 | |
108 | 108 | return $texte; |
109 | 109 | } |
@@ -117,32 +117,32 @@ discard block |
||
117 | 117 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
118 | 118 | * @return string Return string example |
119 | 119 | */ |
120 | - function getExample($langs,$objproduct=0,$type=-1) |
|
120 | + function getExample($langs, $objproduct = 0, $type = -1) |
|
121 | 121 | { |
122 | 122 | if ($type == 0 || $type == -1) |
123 | 123 | { |
124 | - $exampleproduct = $this->getNextValue($objproduct,0); |
|
125 | - if (! $exampleproduct) |
|
124 | + $exampleproduct = $this->getNextValue($objproduct, 0); |
|
125 | + if (!$exampleproduct) |
|
126 | 126 | { |
127 | 127 | $exampleproduct = $langs->trans('NotConfigured'); |
128 | 128 | } |
129 | - if($exampleproduct=="ErrorBadMask") |
|
129 | + if ($exampleproduct == "ErrorBadMask") |
|
130 | 130 | { |
131 | 131 | $langs->load("errors"); |
132 | - $exampleproduct=$langs->trans($exampleproduct); |
|
132 | + $exampleproduct = $langs->trans($exampleproduct); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | if ($type == 1 || $type == -1) |
136 | 136 | { |
137 | - $exampleservice = $this->getNextValue($objproduct,1); |
|
138 | - if (! $exampleservice) |
|
137 | + $exampleservice = $this->getNextValue($objproduct, 1); |
|
138 | + if (!$exampleservice) |
|
139 | 139 | { |
140 | 140 | $exampleservice = $langs->trans('NotConfigured'); |
141 | 141 | } |
142 | - if($exampleservice=="ErrorBadMask") |
|
142 | + if ($exampleservice == "ErrorBadMask") |
|
143 | 143 | { |
144 | 144 | $langs->load("errors"); |
145 | - $exampleservice=$langs->trans($exampleservice); |
|
145 | + $exampleservice = $langs->trans($exampleservice); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -158,26 +158,26 @@ discard block |
||
158 | 158 | * @param int $type Produit ou service (0:product, 1:service) |
159 | 159 | * @return string Value if OK, '' if module not configured, <0 if KO |
160 | 160 | */ |
161 | - function getNextValue($objproduct=0,$type=-1) |
|
161 | + function getNextValue($objproduct = 0, $type = -1) |
|
162 | 162 | { |
163 | - global $db,$conf; |
|
163 | + global $db, $conf; |
|
164 | 164 | |
165 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
165 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
166 | 166 | |
167 | 167 | // Get Mask value |
168 | 168 | $mask = ''; |
169 | - if ($type == 0 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)) |
|
169 | + if ($type == 0 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)) |
|
170 | 170 | $mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; |
171 | - else if ($type == 1 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)) |
|
171 | + else if ($type == 1 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)) |
|
172 | 172 | $mask = $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; |
173 | 173 | |
174 | 174 | if (empty($mask)) |
175 | 175 | { |
176 | - $this->error='NotConfigured'; |
|
176 | + $this->error = 'NotConfigured'; |
|
177 | 177 | return ''; |
178 | 178 | } |
179 | 179 | |
180 | - $field='';$where=''; |
|
180 | + $field = ''; $where = ''; |
|
181 | 181 | if ($type == 0) |
182 | 182 | { |
183 | 183 | $field = 'ref'; |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | } |
191 | 191 | else return -1; |
192 | 192 | |
193 | - $now=dol_now(); |
|
193 | + $now = dol_now(); |
|
194 | 194 | |
195 | - $numFinal=get_next_value($db,$mask,'product',$field,$where,'',$now); |
|
195 | + $numFinal = get_next_value($db, $mask, 'product', $field, $where, '', $now); |
|
196 | 196 | |
197 | 197 | return $numFinal; |
198 | 198 | } |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | global $conf; |
209 | 209 | |
210 | 210 | $mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; |
211 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
211 | + if (preg_match('/\{pre\}/i', $mask)) return 1; |
|
212 | 212 | |
213 | 213 | $mask = $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; |
214 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
214 | + if (preg_match('/\{pre\}/i', $mask)) return 1; |
|
215 | 215 | |
216 | 216 | return 0; |
217 | 217 | } |
@@ -234,32 +234,32 @@ discard block |
||
234 | 234 | { |
235 | 235 | global $conf; |
236 | 236 | |
237 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
237 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
238 | 238 | |
239 | - $result=0; |
|
239 | + $result = 0; |
|
240 | 240 | $code = strtoupper(trim($code)); |
241 | 241 | |
242 | 242 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
243 | 243 | { |
244 | - $result=0; |
|
244 | + $result = 0; |
|
245 | 245 | } |
246 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
246 | + else if (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) |
|
247 | 247 | { |
248 | - $result=-2; |
|
248 | + $result = -2; |
|
249 | 249 | } |
250 | 250 | else |
251 | 251 | { |
252 | 252 | // Get Mask value |
253 | 253 | $mask = ''; |
254 | - if ($type==0) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)?'':$conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; |
|
255 | - if ($type==1) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)?'':$conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; |
|
256 | - if (! $mask) |
|
254 | + if ($type == 0) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT) ? '' : $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; |
|
255 | + if ($type == 1) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE) ? '' : $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; |
|
256 | + if (!$mask) |
|
257 | 257 | { |
258 | - $this->error='NotConfigured'; |
|
258 | + $this->error = 'NotConfigured'; |
|
259 | 259 | return ''; |
260 | 260 | } |
261 | 261 | |
262 | - $result=check_value($mask,$code); |
|
262 | + $result = check_value($mask, $code); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | dol_syslog("mod_codeclient_elephant::verif type=".$type." result=".$result); |
@@ -278,10 +278,10 @@ discard block |
||
278 | 278 | function verif_dispo($db, $code, $product) |
279 | 279 | { |
280 | 280 | $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."product"; |
281 | - $sql.= " WHERE ref = '".$code."'"; |
|
282 | - if ($product->id > 0) $sql.= " AND rowid <> ".$product->id; |
|
281 | + $sql .= " WHERE ref = '".$code."'"; |
|
282 | + if ($product->id > 0) $sql .= " AND rowid <> ".$product->id; |
|
283 | 283 | |
284 | - $resql=$db->query($sql); |
|
284 | + $resql = $db->query($sql); |
|
285 | 285 | if ($resql) |
286 | 286 | { |
287 | 287 | if ($db->num_rows($resql) == 0) |
@@ -146,8 +146,12 @@ discard block |
||
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - if ($type == 0) return $exampleproduct; |
|
150 | - if ($type == 1) return $exampleservice; |
|
149 | + if ($type == 0) { |
|
150 | + return $exampleproduct; |
|
151 | + } |
|
152 | + if ($type == 1) { |
|
153 | + return $exampleservice; |
|
154 | + } |
|
151 | 155 | return $exampleproduct.'<br>'.$exampleservice; |
152 | 156 | } |
153 | 157 | |
@@ -166,10 +170,11 @@ discard block |
||
166 | 170 | |
167 | 171 | // Get Mask value |
168 | 172 | $mask = ''; |
169 | - if ($type == 0 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)) |
|
170 | - $mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; |
|
171 | - else if ($type == 1 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)) |
|
172 | - $mask = $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; |
|
173 | + if ($type == 0 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)) { |
|
174 | + $mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; |
|
175 | + } else if ($type == 1 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)) { |
|
176 | + $mask = $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; |
|
177 | + } |
|
173 | 178 | |
174 | 179 | if (empty($mask)) |
175 | 180 | { |
@@ -182,13 +187,13 @@ discard block |
||
182 | 187 | { |
183 | 188 | $field = 'ref'; |
184 | 189 | //$where = ' AND client in (1,2)'; |
185 | - } |
|
186 | - else if ($type == 1) |
|
190 | + } else if ($type == 1) |
|
187 | 191 | { |
188 | 192 | $field = 'ref'; |
189 | 193 | //$where = ' AND fournisseur = 1'; |
194 | + } else { |
|
195 | + return -1; |
|
190 | 196 | } |
191 | - else return -1; |
|
192 | 197 | |
193 | 198 | $now=dol_now(); |
194 | 199 | |
@@ -208,10 +213,14 @@ discard block |
||
208 | 213 | global $conf; |
209 | 214 | |
210 | 215 | $mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; |
211 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
216 | + if (preg_match('/\{pre\}/i',$mask)) { |
|
217 | + return 1; |
|
218 | + } |
|
212 | 219 | |
213 | 220 | $mask = $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; |
214 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
221 | + if (preg_match('/\{pre\}/i',$mask)) { |
|
222 | + return 1; |
|
223 | + } |
|
215 | 224 | |
216 | 225 | return 0; |
217 | 226 | } |
@@ -242,17 +251,19 @@ discard block |
||
242 | 251 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
243 | 252 | { |
244 | 253 | $result=0; |
245 | - } |
|
246 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
254 | + } else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
247 | 255 | { |
248 | 256 | $result=-2; |
249 | - } |
|
250 | - else |
|
257 | + } else |
|
251 | 258 | { |
252 | 259 | // Get Mask value |
253 | 260 | $mask = ''; |
254 | - if ($type==0) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)?'':$conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; |
|
255 | - if ($type==1) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)?'':$conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; |
|
261 | + if ($type==0) { |
|
262 | + $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)?'':$conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; |
|
263 | + } |
|
264 | + if ($type==1) { |
|
265 | + $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)?'':$conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; |
|
266 | + } |
|
256 | 267 | if (! $mask) |
257 | 268 | { |
258 | 269 | $this->error='NotConfigured'; |
@@ -279,7 +290,9 @@ discard block |
||
279 | 290 | { |
280 | 291 | $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."product"; |
281 | 292 | $sql.= " WHERE ref = '".$code."'"; |
282 | - if ($product->id > 0) $sql.= " AND rowid <> ".$product->id; |
|
293 | + if ($product->id > 0) { |
|
294 | + $sql.= " AND rowid <> ".$product->id; |
|
295 | + } |
|
283 | 296 | |
284 | 297 | $resql=$db->query($sql); |
285 | 298 | if ($resql) |
@@ -287,13 +300,11 @@ discard block |
||
287 | 300 | if ($db->num_rows($resql) == 0) |
288 | 301 | { |
289 | 302 | return 0; |
290 | - } |
|
291 | - else |
|
303 | + } else |
|
292 | 304 | { |
293 | 305 | return -1; |
294 | 306 | } |
295 | - } |
|
296 | - else |
|
307 | + } else |
|
297 | 308 | { |
298 | 309 | return -2; |
299 | 310 | } |
@@ -74,7 +74,7 @@ |
||
74 | 74 | /** |
75 | 75 | * Return next value available |
76 | 76 | * |
77 | - * @param Product $objproduct Object product |
|
77 | + * @param integer $objproduct Object product |
|
78 | 78 | * @param int $type Type |
79 | 79 | * @return string Value |
80 | 80 | */ |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * Return list of active generation modules |
46 | 46 | * |
47 | - * @param DoliDB $db Database handler |
|
48 | - * @param integer $maxfilenamelength Max length of value to show |
|
49 | - * @return array List of templates |
|
47 | + * @param DoliDB $db Database handler |
|
48 | + * @param integer $maxfilenamelength Max length of value to show |
|
49 | + * @return array List of templates |
|
50 | 50 | */ |
51 | 51 | static function liste_modeles($db,$maxfilenamelength=0) |
52 | 52 | { |
@@ -63,188 +63,188 @@ discard block |
||
63 | 63 | |
64 | 64 | abstract class ModeleProductCode |
65 | 65 | { |
66 | - var $error=''; |
|
67 | - |
|
68 | - /** Renvoi la description par defaut du modele de numerotation |
|
69 | - * |
|
70 | - * @param Translate $langs Object langs |
|
71 | - * @return string Texte descripif |
|
72 | - */ |
|
73 | - function info($langs) |
|
74 | - { |
|
75 | - $langs->load("bills"); |
|
76 | - return $langs->trans("NoDescription"); |
|
77 | - } |
|
78 | - |
|
79 | - /** Renvoi nom module |
|
80 | - * |
|
81 | - * @param Translate $langs Object langs |
|
82 | - * @return string Nom du module |
|
83 | - */ |
|
84 | - function getNom($langs) |
|
85 | - { |
|
86 | - return empty($this->name)?$this->nom:$this->name; |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** Renvoi un exemple de numerotation |
|
91 | - * |
|
92 | - * @param Translate $langs Object langs |
|
93 | - * @return string Example |
|
94 | - */ |
|
95 | - function getExample($langs) |
|
96 | - { |
|
97 | - $langs->load("bills"); |
|
98 | - return $langs->trans("NoExample"); |
|
99 | - } |
|
100 | - |
|
101 | - /** Test si les numeros deja en vigueur dans la base ne provoquent pas de |
|
102 | - * de conflits qui empechera cette numerotation de fonctionner. |
|
103 | - * |
|
104 | - * @return boolean false si conflit, true si ok |
|
105 | - */ |
|
106 | - function canBeActivated() |
|
107 | - { |
|
108 | - return true; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Return next value available |
|
113 | - * |
|
114 | - * @param Product $objproduct Object product |
|
115 | - * @param int $type Type |
|
116 | - * @return string Value |
|
117 | - */ |
|
118 | - function getNextValue($objproduct=0,$type=-1) |
|
119 | - { |
|
120 | - global $langs; |
|
121 | - return $langs->trans("Function_getNextValue_InModuleNotWorking"); |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** Return version of module |
|
126 | - * |
|
127 | - * @return string Version |
|
128 | - */ |
|
129 | - function getVersion() |
|
130 | - { |
|
131 | - global $langs; |
|
132 | - $langs->load("admin"); |
|
133 | - |
|
134 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
135 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
136 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
137 | - if ($this->version) return $this->version; |
|
138 | - return $langs->trans("NotAvailable"); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Renvoi la liste des modeles de numérotation |
|
143 | - * |
|
144 | - * @param DoliDB $db Database handler |
|
145 | - * @param integer $maxfilenamelength Max length of value to show |
|
146 | - * @return array List of numbers |
|
147 | - */ |
|
148 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
149 | - { |
|
150 | - $liste=array(); |
|
151 | - $sql =""; |
|
152 | - |
|
153 | - $resql = $db->query($sql); |
|
154 | - if ($resql) |
|
155 | - { |
|
156 | - $num = $db->num_rows($resql); |
|
157 | - $i = 0; |
|
158 | - while ($i < $num) |
|
159 | - { |
|
160 | - $row = $db->fetch_row($resql); |
|
161 | - $liste[$row[0]]=$row[1]; |
|
162 | - $i++; |
|
163 | - } |
|
164 | - } |
|
165 | - else |
|
166 | - { |
|
167 | - return -1; |
|
168 | - } |
|
169 | - return $liste; |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Return description of module parameters |
|
174 | - * |
|
175 | - * @param Translate $langs Output language |
|
176 | - * @param Product $product Product object |
|
177 | - * @param int $type -1=Nothing, 0=Customer, 1=Supplier |
|
178 | - * @return string HTML translated description |
|
179 | - */ |
|
180 | - function getToolTip($langs,$product,$type) |
|
181 | - { |
|
182 | - global $conf; |
|
183 | - |
|
184 | - $langs->load("admin"); |
|
185 | - |
|
186 | - $s=''; |
|
187 | - if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>'; |
|
188 | - if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
189 | - if ($type == 0) $s.=$langs->trans("ProductCodeDesc").'<br>'; |
|
190 | - if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'<br>'; |
|
191 | - if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
192 | - $s.='<br>'; |
|
193 | - $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
|
194 | - if ($type == 0) |
|
195 | - { |
|
196 | - $s.=$langs->trans("RequiredIfProduct").': '; |
|
197 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
198 | - $s.=yn(!$this->code_null,1,2); |
|
199 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
200 | - $s.='<br>'; |
|
201 | - } |
|
202 | - if ($type == 1) |
|
203 | - { |
|
204 | - $s.=$langs->trans("RequiredIfService").': '; |
|
205 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
206 | - $s.=yn(!$this->code_null,1,2); |
|
207 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
208 | - $s.='<br>'; |
|
209 | - } |
|
210 | - if ($type == -1) |
|
211 | - { |
|
212 | - $s.=$langs->trans("Required").': '; |
|
213 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
214 | - $s.=yn(!$this->code_null,1,2); |
|
215 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
216 | - $s.='<br>'; |
|
217 | - } |
|
218 | - $s.=$langs->trans("CanBeModifiedIfOk").': '; |
|
219 | - $s.=yn($this->code_modifiable,1,2); |
|
220 | - $s.='<br>'; |
|
221 | - $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>'; |
|
222 | - $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>'; |
|
223 | - $s.='<br>'; |
|
224 | - if ($type == 0 || $type == -1) |
|
225 | - { |
|
226 | - $nextval=$this->getNextValue($product,0); |
|
227 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
228 | - $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>'; |
|
229 | - } |
|
230 | - if ($type == 1 || $type == -1) |
|
231 | - { |
|
232 | - $nextval=$this->getNextValue($product,1); |
|
233 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
234 | - $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>'; |
|
235 | - } |
|
236 | - return $s; |
|
237 | - } |
|
66 | + var $error=''; |
|
67 | + |
|
68 | + /** Renvoi la description par defaut du modele de numerotation |
|
69 | + * |
|
70 | + * @param Translate $langs Object langs |
|
71 | + * @return string Texte descripif |
|
72 | + */ |
|
73 | + function info($langs) |
|
74 | + { |
|
75 | + $langs->load("bills"); |
|
76 | + return $langs->trans("NoDescription"); |
|
77 | + } |
|
78 | + |
|
79 | + /** Renvoi nom module |
|
80 | + * |
|
81 | + * @param Translate $langs Object langs |
|
82 | + * @return string Nom du module |
|
83 | + */ |
|
84 | + function getNom($langs) |
|
85 | + { |
|
86 | + return empty($this->name)?$this->nom:$this->name; |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** Renvoi un exemple de numerotation |
|
91 | + * |
|
92 | + * @param Translate $langs Object langs |
|
93 | + * @return string Example |
|
94 | + */ |
|
95 | + function getExample($langs) |
|
96 | + { |
|
97 | + $langs->load("bills"); |
|
98 | + return $langs->trans("NoExample"); |
|
99 | + } |
|
100 | + |
|
101 | + /** Test si les numeros deja en vigueur dans la base ne provoquent pas de |
|
102 | + * de conflits qui empechera cette numerotation de fonctionner. |
|
103 | + * |
|
104 | + * @return boolean false si conflit, true si ok |
|
105 | + */ |
|
106 | + function canBeActivated() |
|
107 | + { |
|
108 | + return true; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Return next value available |
|
113 | + * |
|
114 | + * @param Product $objproduct Object product |
|
115 | + * @param int $type Type |
|
116 | + * @return string Value |
|
117 | + */ |
|
118 | + function getNextValue($objproduct=0,$type=-1) |
|
119 | + { |
|
120 | + global $langs; |
|
121 | + return $langs->trans("Function_getNextValue_InModuleNotWorking"); |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** Return version of module |
|
126 | + * |
|
127 | + * @return string Version |
|
128 | + */ |
|
129 | + function getVersion() |
|
130 | + { |
|
131 | + global $langs; |
|
132 | + $langs->load("admin"); |
|
133 | + |
|
134 | + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
135 | + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
136 | + if ($this->version == 'dolibarr') return DOL_VERSION; |
|
137 | + if ($this->version) return $this->version; |
|
138 | + return $langs->trans("NotAvailable"); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Renvoi la liste des modeles de numérotation |
|
143 | + * |
|
144 | + * @param DoliDB $db Database handler |
|
145 | + * @param integer $maxfilenamelength Max length of value to show |
|
146 | + * @return array List of numbers |
|
147 | + */ |
|
148 | + static function liste_modeles($db,$maxfilenamelength=0) |
|
149 | + { |
|
150 | + $liste=array(); |
|
151 | + $sql =""; |
|
152 | + |
|
153 | + $resql = $db->query($sql); |
|
154 | + if ($resql) |
|
155 | + { |
|
156 | + $num = $db->num_rows($resql); |
|
157 | + $i = 0; |
|
158 | + while ($i < $num) |
|
159 | + { |
|
160 | + $row = $db->fetch_row($resql); |
|
161 | + $liste[$row[0]]=$row[1]; |
|
162 | + $i++; |
|
163 | + } |
|
164 | + } |
|
165 | + else |
|
166 | + { |
|
167 | + return -1; |
|
168 | + } |
|
169 | + return $liste; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Return description of module parameters |
|
174 | + * |
|
175 | + * @param Translate $langs Output language |
|
176 | + * @param Product $product Product object |
|
177 | + * @param int $type -1=Nothing, 0=Customer, 1=Supplier |
|
178 | + * @return string HTML translated description |
|
179 | + */ |
|
180 | + function getToolTip($langs,$product,$type) |
|
181 | + { |
|
182 | + global $conf; |
|
183 | + |
|
184 | + $langs->load("admin"); |
|
185 | + |
|
186 | + $s=''; |
|
187 | + if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>'; |
|
188 | + if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
189 | + if ($type == 0) $s.=$langs->trans("ProductCodeDesc").'<br>'; |
|
190 | + if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'<br>'; |
|
191 | + if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
192 | + $s.='<br>'; |
|
193 | + $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
|
194 | + if ($type == 0) |
|
195 | + { |
|
196 | + $s.=$langs->trans("RequiredIfProduct").': '; |
|
197 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
198 | + $s.=yn(!$this->code_null,1,2); |
|
199 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
200 | + $s.='<br>'; |
|
201 | + } |
|
202 | + if ($type == 1) |
|
203 | + { |
|
204 | + $s.=$langs->trans("RequiredIfService").': '; |
|
205 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
206 | + $s.=yn(!$this->code_null,1,2); |
|
207 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
208 | + $s.='<br>'; |
|
209 | + } |
|
210 | + if ($type == -1) |
|
211 | + { |
|
212 | + $s.=$langs->trans("Required").': '; |
|
213 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
214 | + $s.=yn(!$this->code_null,1,2); |
|
215 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
216 | + $s.='<br>'; |
|
217 | + } |
|
218 | + $s.=$langs->trans("CanBeModifiedIfOk").': '; |
|
219 | + $s.=yn($this->code_modifiable,1,2); |
|
220 | + $s.='<br>'; |
|
221 | + $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>'; |
|
222 | + $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>'; |
|
223 | + $s.='<br>'; |
|
224 | + if ($type == 0 || $type == -1) |
|
225 | + { |
|
226 | + $nextval=$this->getNextValue($product,0); |
|
227 | + if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
228 | + $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>'; |
|
229 | + } |
|
230 | + if ($type == 1 || $type == -1) |
|
231 | + { |
|
232 | + $nextval=$this->getNextValue($product,1); |
|
233 | + if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
234 | + $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>'; |
|
235 | + } |
|
236 | + return $s; |
|
237 | + } |
|
238 | 238 | |
239 | 239 | /** |
240 | 240 | * Check if mask/numbering use prefix |
241 | 241 | * |
242 | 242 | * @return int 0=no, 1=yes |
243 | 243 | */ |
244 | - function verif_prefixIsUsed() |
|
245 | - { |
|
246 | - return 0; |
|
247 | - } |
|
244 | + function verif_prefixIsUsed() |
|
245 | + { |
|
246 | + return 0; |
|
247 | + } |
|
248 | 248 | |
249 | 249 | } |
250 | 250 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | abstract class ModelePDFProduct extends CommonDocGenerator |
40 | 40 | { |
41 | - var $error=''; |
|
41 | + var $error = ''; |
|
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
@@ -48,22 +48,22 @@ discard block |
||
48 | 48 | * @param integer $maxfilenamelength Max length of value to show |
49 | 49 | * @return array List of templates |
50 | 50 | */ |
51 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
51 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
52 | 52 | { |
53 | 53 | global $conf; |
54 | 54 | |
55 | - $type='product'; |
|
56 | - $liste=array(); |
|
55 | + $type = 'product'; |
|
56 | + $liste = array(); |
|
57 | 57 | |
58 | 58 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
59 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
59 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
60 | 60 | return $liste; |
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | 64 | abstract class ModeleProductCode |
65 | 65 | { |
66 | - var $error=''; |
|
66 | + var $error = ''; |
|
67 | 67 | |
68 | 68 | /** Renvoi la description par defaut du modele de numerotation |
69 | 69 | * |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | function getNom($langs) |
85 | 85 | { |
86 | - return empty($this->name)?$this->nom:$this->name; |
|
86 | + return empty($this->name) ? $this->nom : $this->name; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param int $type Type |
116 | 116 | * @return string Value |
117 | 117 | */ |
118 | - function getNextValue($objproduct=0,$type=-1) |
|
118 | + function getNextValue($objproduct = 0, $type = -1) |
|
119 | 119 | { |
120 | 120 | global $langs; |
121 | 121 | return $langs->trans("Function_getNextValue_InModuleNotWorking"); |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | * @param integer $maxfilenamelength Max length of value to show |
146 | 146 | * @return array List of numbers |
147 | 147 | */ |
148 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
148 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
149 | 149 | { |
150 | - $liste=array(); |
|
151 | - $sql =""; |
|
150 | + $liste = array(); |
|
151 | + $sql = ""; |
|
152 | 152 | |
153 | 153 | $resql = $db->query($sql); |
154 | 154 | if ($resql) |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | while ($i < $num) |
159 | 159 | { |
160 | 160 | $row = $db->fetch_row($resql); |
161 | - $liste[$row[0]]=$row[1]; |
|
161 | + $liste[$row[0]] = $row[1]; |
|
162 | 162 | $i++; |
163 | 163 | } |
164 | 164 | } |
@@ -177,61 +177,61 @@ discard block |
||
177 | 177 | * @param int $type -1=Nothing, 0=Customer, 1=Supplier |
178 | 178 | * @return string HTML translated description |
179 | 179 | */ |
180 | - function getToolTip($langs,$product,$type) |
|
180 | + function getToolTip($langs, $product, $type) |
|
181 | 181 | { |
182 | 182 | global $conf; |
183 | 183 | |
184 | 184 | $langs->load("admin"); |
185 | 185 | |
186 | - $s=''; |
|
187 | - if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>'; |
|
188 | - if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
189 | - if ($type == 0) $s.=$langs->trans("ProductCodeDesc").'<br>'; |
|
190 | - if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'<br>'; |
|
191 | - if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
192 | - $s.='<br>'; |
|
193 | - $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
|
186 | + $s = ''; |
|
187 | + if ($type == -1) $s .= $langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>'; |
|
188 | + if ($type == -1) $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
189 | + if ($type == 0) $s .= $langs->trans("ProductCodeDesc").'<br>'; |
|
190 | + if ($type == 1) $s .= $langs->trans("ServiceCodeDesc").'<br>'; |
|
191 | + if ($type != -1) $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
192 | + $s .= '<br>'; |
|
193 | + $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
|
194 | 194 | if ($type == 0) |
195 | 195 | { |
196 | - $s.=$langs->trans("RequiredIfProduct").': '; |
|
197 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
198 | - $s.=yn(!$this->code_null,1,2); |
|
199 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
200 | - $s.='<br>'; |
|
196 | + $s .= $langs->trans("RequiredIfProduct").': '; |
|
197 | + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>'; |
|
198 | + $s .= yn(!$this->code_null, 1, 2); |
|
199 | + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; |
|
200 | + $s .= '<br>'; |
|
201 | 201 | } |
202 | 202 | if ($type == 1) |
203 | 203 | { |
204 | - $s.=$langs->trans("RequiredIfService").': '; |
|
205 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
206 | - $s.=yn(!$this->code_null,1,2); |
|
207 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
208 | - $s.='<br>'; |
|
204 | + $s .= $langs->trans("RequiredIfService").': '; |
|
205 | + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>'; |
|
206 | + $s .= yn(!$this->code_null, 1, 2); |
|
207 | + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; |
|
208 | + $s .= '<br>'; |
|
209 | 209 | } |
210 | 210 | if ($type == -1) |
211 | 211 | { |
212 | - $s.=$langs->trans("Required").': '; |
|
213 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
214 | - $s.=yn(!$this->code_null,1,2); |
|
215 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
216 | - $s.='<br>'; |
|
212 | + $s .= $langs->trans("Required").': '; |
|
213 | + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>'; |
|
214 | + $s .= yn(!$this->code_null, 1, 2); |
|
215 | + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; |
|
216 | + $s .= '<br>'; |
|
217 | 217 | } |
218 | - $s.=$langs->trans("CanBeModifiedIfOk").': '; |
|
219 | - $s.=yn($this->code_modifiable,1,2); |
|
220 | - $s.='<br>'; |
|
221 | - $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>'; |
|
222 | - $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>'; |
|
223 | - $s.='<br>'; |
|
218 | + $s .= $langs->trans("CanBeModifiedIfOk").': '; |
|
219 | + $s .= yn($this->code_modifiable, 1, 2); |
|
220 | + $s .= '<br>'; |
|
221 | + $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>'; |
|
222 | + $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>'; |
|
223 | + $s .= '<br>'; |
|
224 | 224 | if ($type == 0 || $type == -1) |
225 | 225 | { |
226 | - $nextval=$this->getNextValue($product,0); |
|
227 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
228 | - $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>'; |
|
226 | + $nextval = $this->getNextValue($product, 0); |
|
227 | + if (empty($nextval)) $nextval = $langs->trans("Undefined"); |
|
228 | + $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Product").')' : '').': <b>'.$nextval.'</b><br>'; |
|
229 | 229 | } |
230 | 230 | if ($type == 1 || $type == -1) |
231 | 231 | { |
232 | - $nextval=$this->getNextValue($product,1); |
|
233 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
234 | - $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>'; |
|
232 | + $nextval = $this->getNextValue($product, 1); |
|
233 | + if (empty($nextval)) $nextval = $langs->trans("Undefined"); |
|
234 | + $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Service").')' : '').': <b>'.$nextval.'</b>'; |
|
235 | 235 | } |
236 | 236 | return $s; |
237 | 237 | } |
@@ -131,10 +131,18 @@ discard block |
||
131 | 131 | global $langs; |
132 | 132 | $langs->load("admin"); |
133 | 133 | |
134 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
135 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
136 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
137 | - if ($this->version) return $this->version; |
|
134 | + if ($this->version == 'development') { |
|
135 | + return $langs->trans("VersionDevelopment"); |
|
136 | + } |
|
137 | + if ($this->version == 'experimental') { |
|
138 | + return $langs->trans("VersionExperimental"); |
|
139 | + } |
|
140 | + if ($this->version == 'dolibarr') { |
|
141 | + return DOL_VERSION; |
|
142 | + } |
|
143 | + if ($this->version) { |
|
144 | + return $this->version; |
|
145 | + } |
|
138 | 146 | return $langs->trans("NotAvailable"); |
139 | 147 | } |
140 | 148 | |
@@ -161,8 +169,7 @@ discard block |
||
161 | 169 | $liste[$row[0]]=$row[1]; |
162 | 170 | $i++; |
163 | 171 | } |
164 | - } |
|
165 | - else |
|
172 | + } else |
|
166 | 173 | { |
167 | 174 | return -1; |
168 | 175 | } |
@@ -184,35 +191,57 @@ discard block |
||
184 | 191 | $langs->load("admin"); |
185 | 192 | |
186 | 193 | $s=''; |
187 | - if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>'; |
|
188 | - if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
189 | - if ($type == 0) $s.=$langs->trans("ProductCodeDesc").'<br>'; |
|
190 | - if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'<br>'; |
|
191 | - if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
194 | + if ($type == -1) { |
|
195 | + $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>'; |
|
196 | + } |
|
197 | + if ($type == -1) { |
|
198 | + $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
199 | + } |
|
200 | + if ($type == 0) { |
|
201 | + $s.=$langs->trans("ProductCodeDesc").'<br>'; |
|
202 | + } |
|
203 | + if ($type == 1) { |
|
204 | + $s.=$langs->trans("ServiceCodeDesc").'<br>'; |
|
205 | + } |
|
206 | + if ($type != -1) { |
|
207 | + $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
208 | + } |
|
192 | 209 | $s.='<br>'; |
193 | 210 | $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
194 | 211 | if ($type == 0) |
195 | 212 | { |
196 | 213 | $s.=$langs->trans("RequiredIfProduct").': '; |
197 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
214 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
215 | + $s.='<strike>'; |
|
216 | + } |
|
198 | 217 | $s.=yn(!$this->code_null,1,2); |
199 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
218 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
219 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
220 | + } |
|
200 | 221 | $s.='<br>'; |
201 | 222 | } |
202 | 223 | if ($type == 1) |
203 | 224 | { |
204 | 225 | $s.=$langs->trans("RequiredIfService").': '; |
205 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
226 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
227 | + $s.='<strike>'; |
|
228 | + } |
|
206 | 229 | $s.=yn(!$this->code_null,1,2); |
207 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
230 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
231 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
232 | + } |
|
208 | 233 | $s.='<br>'; |
209 | 234 | } |
210 | 235 | if ($type == -1) |
211 | 236 | { |
212 | 237 | $s.=$langs->trans("Required").': '; |
213 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
238 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
239 | + $s.='<strike>'; |
|
240 | + } |
|
214 | 241 | $s.=yn(!$this->code_null,1,2); |
215 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
242 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
243 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
244 | + } |
|
216 | 245 | $s.='<br>'; |
217 | 246 | } |
218 | 247 | $s.=$langs->trans("CanBeModifiedIfOk").': '; |
@@ -224,13 +253,17 @@ discard block |
||
224 | 253 | if ($type == 0 || $type == -1) |
225 | 254 | { |
226 | 255 | $nextval=$this->getNextValue($product,0); |
227 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
256 | + if (empty($nextval)) { |
|
257 | + $nextval=$langs->trans("Undefined"); |
|
258 | + } |
|
228 | 259 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>'; |
229 | 260 | } |
230 | 261 | if ($type == 1 || $type == -1) |
231 | 262 | { |
232 | 263 | $nextval=$this->getNextValue($product,1); |
233 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
264 | + if (empty($nextval)) { |
|
265 | + $nextval=$langs->trans("Undefined"); |
|
266 | + } |
|
234 | 267 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>'; |
235 | 268 | } |
236 | 269 | return $s; |
@@ -143,7 +143,7 @@ |
||
143 | 143 | /** |
144 | 144 | * Return next reference not yet used as a reference |
145 | 145 | * |
146 | - * @param Societe $objsoc Object third party |
|
146 | + * @param integer $objsoc Object third party |
|
147 | 147 | * @param Project $project Object project |
148 | 148 | * @return string Next not used reference |
149 | 149 | */ |
@@ -86,8 +86,7 @@ discard block |
||
86 | 86 | if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
87 | 87 | { |
88 | 88 | return true; |
89 | - } |
|
90 | - else |
|
89 | + } else |
|
91 | 90 | { |
92 | 91 | $langs->load("errors"); |
93 | 92 | $this->error=$langs->trans('ErrorNumRefModel',$max); |
@@ -118,10 +117,12 @@ discard block |
||
118 | 117 | if ($resql) |
119 | 118 | { |
120 | 119 | $obj = $db->fetch_object($resql); |
121 | - if ($obj) $max = intval($obj->max); |
|
122 | - else $max=0; |
|
123 | - } |
|
124 | - else |
|
120 | + if ($obj) { |
|
121 | + $max = intval($obj->max); |
|
122 | + } else { |
|
123 | + $max=0; |
|
124 | + } |
|
125 | + } else |
|
125 | 126 | { |
126 | 127 | dol_syslog("mod_project_simple::getNextValue", LOG_DEBUG); |
127 | 128 | return -1; |
@@ -132,8 +133,13 @@ discard block |
||
132 | 133 | //$yymm = strftime("%y%m",time()); |
133 | 134 | $yymm = strftime("%y%m",$date); |
134 | 135 | |
135 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
136 | - else $num = sprintf("%04s",$max+1); |
|
136 | + if ($max >= (pow(10, 4) - 1)) { |
|
137 | + $num=$max+1; |
|
138 | + } |
|
139 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
140 | + else { |
|
141 | + $num = sprintf("%04s",$max+1); |
|
142 | + } |
|
137 | 143 | |
138 | 144 | dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num); |
139 | 145 | return $this->prefix.$yymm."-".$num; |
@@ -33,78 +33,78 @@ discard block |
||
33 | 33 | { |
34 | 34 | var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
35 | 35 | var $prefix='PJ'; |
36 | - var $error=''; |
|
36 | + var $error=''; |
|
37 | 37 | var $nom = "Simple"; |
38 | 38 | var $name = "Simple"; |
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Return description of numbering module |
|
43 | - * |
|
44 | - * @return string Text with description |
|
45 | - */ |
|
46 | - function info() |
|
47 | - { |
|
48 | - global $langs; |
|
49 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * Return an example of numbering module values |
|
55 | - * |
|
56 | - * @return string Example |
|
57 | - */ |
|
58 | - function getExample() |
|
59 | - { |
|
60 | - return $this->prefix."0501-0001"; |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** Test si les numeros deja en vigueur dans la base ne provoquent pas de |
|
65 | - * de conflits qui empechera cette numerotation de fonctionner. |
|
66 | - * |
|
67 | - * @return boolean false si conflit, true si ok |
|
68 | - */ |
|
69 | - function canBeActivated() |
|
70 | - { |
|
71 | - global $conf,$langs,$db; |
|
72 | - |
|
73 | - $coyymm=''; $max=''; |
|
41 | + /** |
|
42 | + * Return description of numbering module |
|
43 | + * |
|
44 | + * @return string Text with description |
|
45 | + */ |
|
46 | + function info() |
|
47 | + { |
|
48 | + global $langs; |
|
49 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * Return an example of numbering module values |
|
55 | + * |
|
56 | + * @return string Example |
|
57 | + */ |
|
58 | + function getExample() |
|
59 | + { |
|
60 | + return $this->prefix."0501-0001"; |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** Test si les numeros deja en vigueur dans la base ne provoquent pas de |
|
65 | + * de conflits qui empechera cette numerotation de fonctionner. |
|
66 | + * |
|
67 | + * @return boolean false si conflit, true si ok |
|
68 | + */ |
|
69 | + function canBeActivated() |
|
70 | + { |
|
71 | + global $conf,$langs,$db; |
|
72 | + |
|
73 | + $coyymm=''; $max=''; |
|
74 | 74 | |
75 | 75 | $posindice=8; |
76 | 76 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
77 | - $sql.= " FROM ".MAIN_DB_PREFIX."projet"; |
|
77 | + $sql.= " FROM ".MAIN_DB_PREFIX."projet"; |
|
78 | 78 | $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
79 | - $sql.= " AND entity = ".$conf->entity; |
|
80 | - $resql=$db->query($sql); |
|
81 | - if ($resql) |
|
82 | - { |
|
83 | - $row = $db->fetch_row($resql); |
|
84 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
85 | - } |
|
86 | - if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
87 | - { |
|
88 | - return true; |
|
89 | - } |
|
90 | - else |
|
91 | - { |
|
79 | + $sql.= " AND entity = ".$conf->entity; |
|
80 | + $resql=$db->query($sql); |
|
81 | + if ($resql) |
|
82 | + { |
|
83 | + $row = $db->fetch_row($resql); |
|
84 | + if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
85 | + } |
|
86 | + if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
87 | + { |
|
88 | + return true; |
|
89 | + } |
|
90 | + else |
|
91 | + { |
|
92 | 92 | $langs->load("errors"); |
93 | 93 | $this->error=$langs->trans('ErrorNumRefModel',$max); |
94 | - return false; |
|
95 | - } |
|
96 | - } |
|
94 | + return false; |
|
95 | + } |
|
96 | + } |
|
97 | 97 | |
98 | 98 | |
99 | 99 | /** |
100 | - * Return next value |
|
101 | - * |
|
102 | - * @param Societe $objsoc Object third party |
|
103 | - * @param Project $project Object project |
|
104 | - * @return string Value if OK, 0 if KO |
|
105 | - */ |
|
106 | - function getNextValue($objsoc,$project) |
|
107 | - { |
|
100 | + * Return next value |
|
101 | + * |
|
102 | + * @param Societe $objsoc Object third party |
|
103 | + * @param Project $project Object project |
|
104 | + * @return string Value if OK, 0 if KO |
|
105 | + */ |
|
106 | + function getNextValue($objsoc,$project) |
|
107 | + { |
|
108 | 108 | global $db,$conf; |
109 | 109 | |
110 | 110 | // D'abord on recupere la valeur max |
@@ -137,19 +137,19 @@ discard block |
||
137 | 137 | |
138 | 138 | dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num); |
139 | 139 | return $this->prefix.$yymm."-".$num; |
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * Return next reference not yet used as a reference |
|
145 | - * |
|
146 | - * @param Societe $objsoc Object third party |
|
147 | - * @param Project $project Object project |
|
148 | - * @return string Next not used reference |
|
149 | - */ |
|
150 | - function project_get_num($objsoc=0,$project='') |
|
151 | - { |
|
152 | - return $this->getNextValue($objsoc,$project); |
|
153 | - } |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * Return next reference not yet used as a reference |
|
145 | + * |
|
146 | + * @param Societe $objsoc Object third party |
|
147 | + * @param Project $project Object project |
|
148 | + * @return string Next not used reference |
|
149 | + */ |
|
150 | + function project_get_num($objsoc=0,$project='') |
|
151 | + { |
|
152 | + return $this->getNextValue($objsoc,$project); |
|
153 | + } |
|
154 | 154 | } |
155 | 155 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief File with class to manage the numbering module Simple for project references |
24 | 24 | */ |
25 | 25 | |
26 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/modules_project.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class mod_project_simple extends ModeleNumRefProjects |
33 | 33 | { |
34 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
35 | - var $prefix='PJ'; |
|
36 | - var $error=''; |
|
34 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
35 | + var $prefix = 'PJ'; |
|
36 | + var $error = ''; |
|
37 | 37 | var $nom = "Simple"; |
38 | 38 | var $name = "Simple"; |
39 | 39 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | function info() |
47 | 47 | { |
48 | 48 | global $langs; |
49 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
49 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
@@ -68,29 +68,29 @@ discard block |
||
68 | 68 | */ |
69 | 69 | function canBeActivated() |
70 | 70 | { |
71 | - global $conf,$langs,$db; |
|
71 | + global $conf, $langs, $db; |
|
72 | 72 | |
73 | - $coyymm=''; $max=''; |
|
73 | + $coyymm = ''; $max = ''; |
|
74 | 74 | |
75 | - $posindice=8; |
|
75 | + $posindice = 8; |
|
76 | 76 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
77 | - $sql.= " FROM ".MAIN_DB_PREFIX."projet"; |
|
78 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
79 | - $sql.= " AND entity = ".$conf->entity; |
|
80 | - $resql=$db->query($sql); |
|
77 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet"; |
|
78 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
79 | + $sql .= " AND entity = ".$conf->entity; |
|
80 | + $resql = $db->query($sql); |
|
81 | 81 | if ($resql) |
82 | 82 | { |
83 | 83 | $row = $db->fetch_row($resql); |
84 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
84 | + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
85 | 85 | } |
86 | - if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
86 | + if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) |
|
87 | 87 | { |
88 | 88 | return true; |
89 | 89 | } |
90 | 90 | else |
91 | 91 | { |
92 | 92 | $langs->load("errors"); |
93 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
93 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
94 | 94 | return false; |
95 | 95 | } |
96 | 96 | } |
@@ -103,23 +103,23 @@ discard block |
||
103 | 103 | * @param Project $project Object project |
104 | 104 | * @return string Value if OK, 0 if KO |
105 | 105 | */ |
106 | - function getNextValue($objsoc,$project) |
|
106 | + function getNextValue($objsoc, $project) |
|
107 | 107 | { |
108 | - global $db,$conf; |
|
108 | + global $db, $conf; |
|
109 | 109 | |
110 | 110 | // D'abord on recupere la valeur max |
111 | - $posindice=8; |
|
111 | + $posindice = 8; |
|
112 | 112 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
113 | - $sql.= " FROM ".MAIN_DB_PREFIX."projet"; |
|
114 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
115 | - $sql.= " AND entity = ".$conf->entity; |
|
113 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet"; |
|
114 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
115 | + $sql .= " AND entity = ".$conf->entity; |
|
116 | 116 | |
117 | - $resql=$db->query($sql); |
|
117 | + $resql = $db->query($sql); |
|
118 | 118 | if ($resql) |
119 | 119 | { |
120 | 120 | $obj = $db->fetch_object($resql); |
121 | 121 | if ($obj) $max = intval($obj->max); |
122 | - else $max=0; |
|
122 | + else $max = 0; |
|
123 | 123 | } |
124 | 124 | else |
125 | 125 | { |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | return -1; |
128 | 128 | } |
129 | 129 | |
130 | - $date=empty($project->date_c)?dol_now():$project->date_c; |
|
130 | + $date = empty($project->date_c) ?dol_now() : $project->date_c; |
|
131 | 131 | |
132 | 132 | //$yymm = strftime("%y%m",time()); |
133 | - $yymm = strftime("%y%m",$date); |
|
133 | + $yymm = strftime("%y%m", $date); |
|
134 | 134 | |
135 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
136 | - else $num = sprintf("%04s",$max+1); |
|
135 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
136 | + else $num = sprintf("%04s", $max + 1); |
|
137 | 137 | |
138 | 138 | dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num); |
139 | 139 | return $this->prefix.$yymm."-".$num; |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | * @param Project $project Object project |
148 | 148 | * @return string Next not used reference |
149 | 149 | */ |
150 | - function project_get_num($objsoc=0,$project='') |
|
150 | + function project_get_num($objsoc = 0, $project = '') |
|
151 | 151 | { |
152 | - return $this->getNextValue($objsoc,$project); |
|
152 | + return $this->getNextValue($objsoc, $project); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 |
@@ -130,7 +130,7 @@ |
||
130 | 130 | /** |
131 | 131 | * Return next reference not yet used as a reference |
132 | 132 | * |
133 | - * @param Societe $objsoc Object third party |
|
133 | + * @param integer $objsoc Object third party |
|
134 | 134 | * @param Project $project Object project |
135 | 135 | * @return string Next not used reference |
136 | 136 | */ |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | var $name = 'Universal'; |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Renvoi la description du modele de numerotation |
|
41 | - * |
|
42 | - * @return string Texte descripif |
|
43 | - */ |
|
39 | + /** |
|
40 | + * Renvoi la description du modele de numerotation |
|
41 | + * |
|
42 | + * @return string Texte descripif |
|
43 | + */ |
|
44 | 44 | function info() |
45 | - { |
|
46 | - global $conf,$langs; |
|
45 | + { |
|
46 | + global $conf,$langs; |
|
47 | 47 | |
48 | 48 | $langs->load("projects"); |
49 | 49 | $langs->load("admin"); |
@@ -75,20 +75,20 @@ discard block |
||
75 | 75 | $texte.= '</form>'; |
76 | 76 | |
77 | 77 | return $texte; |
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Renvoi un exemple de numerotation |
|
82 | - * |
|
83 | - * @return string Example |
|
84 | - */ |
|
85 | - function getExample() |
|
86 | - { |
|
87 | - global $conf,$langs,$mysoc; |
|
88 | - |
|
89 | - $old_code_client=$mysoc->code_client; |
|
90 | - $mysoc->code_client='CCCCCCCCCC'; |
|
91 | - $numExample = $this->getNextValue($mysoc,''); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Renvoi un exemple de numerotation |
|
82 | + * |
|
83 | + * @return string Example |
|
84 | + */ |
|
85 | + function getExample() |
|
86 | + { |
|
87 | + global $conf,$langs,$mysoc; |
|
88 | + |
|
89 | + $old_code_client=$mysoc->code_client; |
|
90 | + $mysoc->code_client='CCCCCCCCCC'; |
|
91 | + $numExample = $this->getNextValue($mysoc,''); |
|
92 | 92 | $mysoc->code_client=$old_code_client; |
93 | 93 | |
94 | 94 | if (! $numExample) |
@@ -96,17 +96,17 @@ discard block |
||
96 | 96 | $numExample = $langs->trans('NotConfigured'); |
97 | 97 | } |
98 | 98 | return $numExample; |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | /** |
102 | - * Return next value |
|
103 | - * |
|
104 | - * @param Societe $objsoc Object third party |
|
105 | - * @param Project $project Object project |
|
106 | - * @return string Value if OK, 0 if KO |
|
107 | - */ |
|
108 | - function getNextValue($objsoc,$project) |
|
109 | - { |
|
102 | + * Return next value |
|
103 | + * |
|
104 | + * @param Societe $objsoc Object third party |
|
105 | + * @param Project $project Object project |
|
106 | + * @return string Value if OK, 0 if KO |
|
107 | + */ |
|
108 | + function getNextValue($objsoc,$project) |
|
109 | + { |
|
110 | 110 | global $db,$conf; |
111 | 111 | |
112 | 112 | require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
@@ -127,16 +127,16 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | |
130 | - /** |
|
131 | - * Return next reference not yet used as a reference |
|
132 | - * |
|
133 | - * @param Societe $objsoc Object third party |
|
134 | - * @param Project $project Object project |
|
135 | - * @return string Next not used reference |
|
136 | - */ |
|
137 | - function project_get_num($objsoc=0,$project='') |
|
138 | - { |
|
139 | - return $this->getNextValue($objsoc,$project); |
|
140 | - } |
|
130 | + /** |
|
131 | + * Return next reference not yet used as a reference |
|
132 | + * |
|
133 | + * @param Societe $objsoc Object third party |
|
134 | + * @param Project $project Object project |
|
135 | + * @return string Next not used reference |
|
136 | + */ |
|
137 | + function project_get_num($objsoc=0,$project='') |
|
138 | + { |
|
139 | + return $this->getNextValue($objsoc,$project); |
|
140 | + } |
|
141 | 141 | } |
142 | 142 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/modules_project.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class mod_project_universal extends ModeleNumRefProjects |
32 | 32 | { |
33 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
33 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
34 | 34 | var $error = ''; |
35 | 35 | var $nom = 'Universal'; |
36 | 36 | var $name = 'Universal'; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | function info() |
45 | 45 | { |
46 | - global $conf,$langs; |
|
46 | + global $conf, $langs; |
|
47 | 47 | |
48 | 48 | $langs->load("projects"); |
49 | 49 | $langs->load("admin"); |
@@ -51,28 +51,28 @@ discard block |
||
51 | 51 | $form = new Form($this->db); |
52 | 52 | |
53 | 53 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
54 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
55 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
56 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
57 | - $texte.= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">'; |
|
58 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
59 | - |
|
60 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Project"),$langs->transnoentities("Project")); |
|
61 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
62 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
63 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Project"),$langs->transnoentities("Project")); |
|
64 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
54 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
55 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
56 | + $texte .= '<input type="hidden" name="action" value="updateMask">'; |
|
57 | + $texte .= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">'; |
|
58 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
59 | + |
|
60 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project")); |
|
61 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
62 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
63 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project")); |
|
64 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
65 | 65 | |
66 | 66 | // Parametrage du prefix |
67 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
68 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>'; |
|
67 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
68 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
69 | 69 | |
70 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
70 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
71 | 71 | |
72 | - $texte.= '</tr>'; |
|
72 | + $texte .= '</tr>'; |
|
73 | 73 | |
74 | - $texte.= '</table>'; |
|
75 | - $texte.= '</form>'; |
|
74 | + $texte .= '</table>'; |
|
75 | + $texte .= '</form>'; |
|
76 | 76 | |
77 | 77 | return $texte; |
78 | 78 | } |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function getExample() |
86 | 86 | { |
87 | - global $conf,$langs,$mysoc; |
|
87 | + global $conf, $langs, $mysoc; |
|
88 | 88 | |
89 | - $old_code_client=$mysoc->code_client; |
|
90 | - $mysoc->code_client='CCCCCCCCCC'; |
|
91 | - $numExample = $this->getNextValue($mysoc,''); |
|
92 | - $mysoc->code_client=$old_code_client; |
|
89 | + $old_code_client = $mysoc->code_client; |
|
90 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
91 | + $numExample = $this->getNextValue($mysoc, ''); |
|
92 | + $mysoc->code_client = $old_code_client; |
|
93 | 93 | |
94 | - if (! $numExample) |
|
94 | + if (!$numExample) |
|
95 | 95 | { |
96 | 96 | $numExample = $langs->trans('NotConfigured'); |
97 | 97 | } |
@@ -105,23 +105,23 @@ discard block |
||
105 | 105 | * @param Project $project Object project |
106 | 106 | * @return string Value if OK, 0 if KO |
107 | 107 | */ |
108 | - function getNextValue($objsoc,$project) |
|
108 | + function getNextValue($objsoc, $project) |
|
109 | 109 | { |
110 | - global $db,$conf; |
|
110 | + global $db, $conf; |
|
111 | 111 | |
112 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
112 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
113 | 113 | |
114 | 114 | // On defini critere recherche compteur |
115 | - $mask=$conf->global->PROJECT_UNIVERSAL_MASK; |
|
115 | + $mask = $conf->global->PROJECT_UNIVERSAL_MASK; |
|
116 | 116 | |
117 | - if (! $mask) |
|
117 | + if (!$mask) |
|
118 | 118 | { |
119 | - $this->error='NotConfigured'; |
|
119 | + $this->error = 'NotConfigured'; |
|
120 | 120 | return 0; |
121 | 121 | } |
122 | 122 | |
123 | - $date=empty($project->date_c)?dol_now():$project->date_c; |
|
124 | - $numFinal=get_next_value($db,$mask,'projet','ref','',$objsoc->code_client,$date); |
|
123 | + $date = empty($project->date_c) ?dol_now() : $project->date_c; |
|
124 | + $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', $objsoc->code_client, $date); |
|
125 | 125 | |
126 | 126 | return $numFinal; |
127 | 127 | } |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | * @param Project $project Object project |
135 | 135 | * @return string Next not used reference |
136 | 136 | */ |
137 | - function project_get_num($objsoc=0,$project='') |
|
137 | + function project_get_num($objsoc = 0, $project = '') |
|
138 | 138 | { |
139 | - return $this->getNextValue($objsoc,$project); |
|
139 | + return $this->getNextValue($objsoc, $project); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * Return an example of result returned by getNextValue |
115 | 115 | * |
116 | 116 | * @param Translate $langs Object langs |
117 | - * @param societe $objsoc Object thirdparty |
|
117 | + * @param integer $objsoc Object thirdparty |
|
118 | 118 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
119 | 119 | * @return string Return string example |
120 | 120 | */ |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | /** |
176 | 176 | * Return next value |
177 | 177 | * |
178 | - * @param Societe $objsoc Object third party |
|
178 | + * @param integer $objsoc Object third party |
|
179 | 179 | * @param int $type Client ou fournisseur (0:customer, 1:supplier) |
180 | 180 | * @return string Value if OK, '' if module not configured, <0 if KO |
181 | 181 | */ |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | */ |
35 | 35 | class mod_codeclient_elephant extends ModeleThirdPartyCode |
36 | 36 | { |
37 | - var $nom='Elephant'; // Nom du modele |
|
38 | - var $name='Elephant'; // Nom du modele |
|
39 | - var $code_modifiable; // Code modifiable |
|
40 | - var $code_modifiable_invalide; // Code modifiable si il est invalide |
|
41 | - var $code_modifiable_null; // Code modifiables si il est null |
|
42 | - var $code_null; // Code facultatif |
|
43 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
44 | - var $code_auto; // Numerotation automatique |
|
37 | + var $nom = 'Elephant'; // Nom du modele |
|
38 | + var $name = 'Elephant'; // Nom du modele |
|
39 | + var $code_modifiable; // Code modifiable |
|
40 | + var $code_modifiable_invalide; // Code modifiable si il est invalide |
|
41 | + var $code_modifiable_null; // Code modifiables si il est null |
|
42 | + var $code_null; // Code facultatif |
|
43 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
44 | + var $code_auto; // Numerotation automatique |
|
45 | 45 | |
46 | 46 | var $searchcode; // String de recherche |
47 | 47 | var $numbitcounter; // Nombre de chiffres du compteur |
@@ -74,37 +74,37 @@ discard block |
||
74 | 74 | |
75 | 75 | $langs->load("companies"); |
76 | 76 | |
77 | - $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
77 | + $disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
78 | 78 | |
79 | 79 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
80 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
81 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
82 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
83 | - $texte.= '<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">'; |
|
84 | - $texte.= '<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">'; |
|
85 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
86 | - |
|
87 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ThirdParty"),$langs->transnoentities("ThirdParty")); |
|
80 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
81 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
82 | + $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
83 | + $texte .= '<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">'; |
|
84 | + $texte .= '<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">'; |
|
85 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
86 | + |
|
87 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("ThirdParty"), $langs->transnoentities("ThirdParty")); |
|
88 | 88 | //$tooltip.=$langs->trans("GenericMaskCodes2"); Not required for third party numbering |
89 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
90 | - $tooltip.=$langs->trans("GenericMaskCodes4b"); |
|
91 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
89 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
90 | + $tooltip .= $langs->trans("GenericMaskCodes4b"); |
|
91 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
92 | 92 | |
93 | 93 | // Parametrage du prefix customers |
94 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):</td>'; |
|
95 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
94 | + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):</td>'; |
|
95 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'"'.$disabled.'>', $tooltip, 1, 1).'</td>'; |
|
96 | 96 | |
97 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
97 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
98 | 98 | |
99 | - $texte.= '</tr>'; |
|
99 | + $texte .= '</tr>'; |
|
100 | 100 | |
101 | 101 | // Parametrage du prefix suppliers |
102 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):</td>'; |
|
103 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
104 | - $texte.= '</tr>'; |
|
102 | + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):</td>'; |
|
103 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'"'.$disabled.'>', $tooltip, 1, 1).'</td>'; |
|
104 | + $texte .= '</tr>'; |
|
105 | 105 | |
106 | - $texte.= '</table>'; |
|
107 | - $texte.= '</form>'; |
|
106 | + $texte .= '</table>'; |
|
107 | + $texte .= '</form>'; |
|
108 | 108 | |
109 | 109 | return $texte; |
110 | 110 | } |
@@ -118,52 +118,52 @@ discard block |
||
118 | 118 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
119 | 119 | * @return string Return string example |
120 | 120 | */ |
121 | - function getExample($langs,$objsoc=0,$type=-1) |
|
121 | + function getExample($langs, $objsoc = 0, $type = -1) |
|
122 | 122 | { |
123 | 123 | if ($type == 0 || $type == -1) |
124 | 124 | { |
125 | - $examplecust = $this->getNextValue($objsoc,0); |
|
126 | - if (! $examplecust) |
|
125 | + $examplecust = $this->getNextValue($objsoc, 0); |
|
126 | + if (!$examplecust) |
|
127 | 127 | { |
128 | 128 | $examplecust = $langs->trans('NotConfigured'); |
129 | 129 | } |
130 | - if($examplecust=="ErrorBadMask") |
|
130 | + if ($examplecust == "ErrorBadMask") |
|
131 | 131 | { |
132 | 132 | $langs->load("errors"); |
133 | - $examplecust=$langs->trans($examplecust); |
|
133 | + $examplecust = $langs->trans($examplecust); |
|
134 | 134 | } |
135 | - if($examplecust=="ErrorCantUseRazIfNoYearInMask") |
|
135 | + if ($examplecust == "ErrorCantUseRazIfNoYearInMask") |
|
136 | 136 | { |
137 | 137 | $langs->load("errors"); |
138 | - $examplecust=$langs->trans($examplecust); |
|
138 | + $examplecust = $langs->trans($examplecust); |
|
139 | 139 | } |
140 | - if($examplecust=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask") |
|
140 | + if ($examplecust == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") |
|
141 | 141 | { |
142 | 142 | $langs->load("errors"); |
143 | - $examplecust=$langs->trans($examplecust); |
|
143 | + $examplecust = $langs->trans($examplecust); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | if ($type == 1 || $type == -1) |
147 | 147 | { |
148 | - $examplesup = $this->getNextValue($objsoc,1); |
|
149 | - if (! $examplesup) |
|
148 | + $examplesup = $this->getNextValue($objsoc, 1); |
|
149 | + if (!$examplesup) |
|
150 | 150 | { |
151 | 151 | $examplesup = $langs->trans('NotConfigured'); |
152 | 152 | } |
153 | - if($examplesup=="ErrorBadMask") |
|
153 | + if ($examplesup == "ErrorBadMask") |
|
154 | 154 | { |
155 | 155 | $langs->load("errors"); |
156 | - $examplesup=$langs->trans($examplesup); |
|
156 | + $examplesup = $langs->trans($examplesup); |
|
157 | 157 | } |
158 | - if($examplesup=="ErrorCantUseRazIfNoYearInMask") |
|
158 | + if ($examplesup == "ErrorCantUseRazIfNoYearInMask") |
|
159 | 159 | { |
160 | 160 | $langs->load("errors"); |
161 | - $examplesup=$langs->trans($examplesup); |
|
161 | + $examplesup = $langs->trans($examplesup); |
|
162 | 162 | } |
163 | - if($examplesup=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask") |
|
163 | + if ($examplesup == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") |
|
164 | 164 | { |
165 | 165 | $langs->load("errors"); |
166 | - $examplesup=$langs->trans($examplesup); |
|
166 | + $examplesup = $langs->trans($examplesup); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
@@ -179,23 +179,23 @@ discard block |
||
179 | 179 | * @param int $type Client ou fournisseur (0:customer, 1:supplier) |
180 | 180 | * @return string Value if OK, '' if module not configured, <0 if KO |
181 | 181 | */ |
182 | - function getNextValue($objsoc=0,$type=-1) |
|
182 | + function getNextValue($objsoc = 0, $type = -1) |
|
183 | 183 | { |
184 | - global $db,$conf; |
|
184 | + global $db, $conf; |
|
185 | 185 | |
186 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
186 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
187 | 187 | |
188 | 188 | // Get Mask value |
189 | 189 | $mask = ''; |
190 | - if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
191 | - if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
192 | - if (! $mask) |
|
190 | + if ($type == 0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
191 | + if ($type == 1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
192 | + if (!$mask) |
|
193 | 193 | { |
194 | - $this->error='NotConfigured'; |
|
194 | + $this->error = 'NotConfigured'; |
|
195 | 195 | return ''; |
196 | 196 | } |
197 | 197 | |
198 | - $field='';$where=''; |
|
198 | + $field = ''; $where = ''; |
|
199 | 199 | if ($type == 0) |
200 | 200 | { |
201 | 201 | $field = 'code_client'; |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | } |
209 | 209 | else return -1; |
210 | 210 | |
211 | - $now=dol_now(); |
|
211 | + $now = dol_now(); |
|
212 | 212 | |
213 | - $numFinal=get_next_value($db,$mask,'societe',$field,$where,'',$now); |
|
213 | + $numFinal = get_next_value($db, $mask, 'societe', $field, $where, '', $now); |
|
214 | 214 | |
215 | 215 | return $numFinal; |
216 | 216 | } |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | global $conf; |
227 | 227 | |
228 | 228 | $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
229 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
229 | + if (preg_match('/\{pre\}/i', $mask)) return 1; |
|
230 | 230 | |
231 | 231 | $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
232 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
232 | + if (preg_match('/\{pre\}/i', $mask)) return 1; |
|
233 | 233 | |
234 | 234 | return 0; |
235 | 235 | } |
@@ -252,32 +252,32 @@ discard block |
||
252 | 252 | { |
253 | 253 | global $conf; |
254 | 254 | |
255 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
255 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
256 | 256 | |
257 | - $result=0; |
|
257 | + $result = 0; |
|
258 | 258 | $code = strtoupper(trim($code)); |
259 | 259 | |
260 | 260 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
261 | 261 | { |
262 | - $result=0; |
|
262 | + $result = 0; |
|
263 | 263 | } |
264 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
264 | + else if (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) |
|
265 | 265 | { |
266 | - $result=-2; |
|
266 | + $result = -2; |
|
267 | 267 | } |
268 | 268 | else |
269 | 269 | { |
270 | 270 | // Get Mask value |
271 | 271 | $mask = ''; |
272 | - if ($type==0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
273 | - if ($type==1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
274 | - if (! $mask) |
|
272 | + if ($type == 0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
273 | + if ($type == 1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
274 | + if (!$mask) |
|
275 | 275 | { |
276 | - $this->error='NotConfigured'; |
|
276 | + $this->error = 'NotConfigured'; |
|
277 | 277 | return ''; |
278 | 278 | } |
279 | 279 | |
280 | - $result=check_value($mask,$code); |
|
280 | + $result = check_value($mask, $code); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | dol_syslog("mod_codeclient_elephant::verif type=".$type." result=".$result); |
@@ -296,10 +296,10 @@ discard block |
||
296 | 296 | function verif_dispo($db, $code, $soc) |
297 | 297 | { |
298 | 298 | $sql = "SELECT code_client FROM ".MAIN_DB_PREFIX."societe"; |
299 | - $sql.= " WHERE code_client = '".$code."'"; |
|
300 | - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
299 | + $sql .= " WHERE code_client = '".$code."'"; |
|
300 | + if ($soc->id > 0) $sql .= " AND rowid <> ".$soc->id; |
|
301 | 301 | |
302 | - $resql=$db->query($sql); |
|
302 | + $resql = $db->query($sql); |
|
303 | 303 | if ($resql) |
304 | 304 | { |
305 | 305 | if ($db->num_rows($resql) == 0) |
@@ -167,8 +167,12 @@ discard block |
||
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - if ($type == 0) return $examplecust; |
|
171 | - if ($type == 1) return $examplesup; |
|
170 | + if ($type == 0) { |
|
171 | + return $examplecust; |
|
172 | + } |
|
173 | + if ($type == 1) { |
|
174 | + return $examplesup; |
|
175 | + } |
|
172 | 176 | return $examplecust.'<br>'.$examplesup; |
173 | 177 | } |
174 | 178 | |
@@ -187,8 +191,12 @@ discard block |
||
187 | 191 | |
188 | 192 | // Get Mask value |
189 | 193 | $mask = ''; |
190 | - if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
191 | - if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
194 | + if ($type==0) { |
|
195 | + $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
196 | + } |
|
197 | + if ($type==1) { |
|
198 | + $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
199 | + } |
|
192 | 200 | if (! $mask) |
193 | 201 | { |
194 | 202 | $this->error='NotConfigured'; |
@@ -200,13 +208,13 @@ discard block |
||
200 | 208 | { |
201 | 209 | $field = 'code_client'; |
202 | 210 | //$where = ' AND client in (1,2)'; |
203 | - } |
|
204 | - else if ($type == 1) |
|
211 | + } else if ($type == 1) |
|
205 | 212 | { |
206 | 213 | $field = 'code_fournisseur'; |
207 | 214 | //$where = ' AND fournisseur = 1'; |
215 | + } else { |
|
216 | + return -1; |
|
208 | 217 | } |
209 | - else return -1; |
|
210 | 218 | |
211 | 219 | $now=dol_now(); |
212 | 220 | |
@@ -226,10 +234,14 @@ discard block |
||
226 | 234 | global $conf; |
227 | 235 | |
228 | 236 | $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
229 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
237 | + if (preg_match('/\{pre\}/i',$mask)) { |
|
238 | + return 1; |
|
239 | + } |
|
230 | 240 | |
231 | 241 | $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
232 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
242 | + if (preg_match('/\{pre\}/i',$mask)) { |
|
243 | + return 1; |
|
244 | + } |
|
233 | 245 | |
234 | 246 | return 0; |
235 | 247 | } |
@@ -260,17 +272,19 @@ discard block |
||
260 | 272 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
261 | 273 | { |
262 | 274 | $result=0; |
263 | - } |
|
264 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
275 | + } else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
265 | 276 | { |
266 | 277 | $result=-2; |
267 | - } |
|
268 | - else |
|
278 | + } else |
|
269 | 279 | { |
270 | 280 | // Get Mask value |
271 | 281 | $mask = ''; |
272 | - if ($type==0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
273 | - if ($type==1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
282 | + if ($type==0) { |
|
283 | + $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
284 | + } |
|
285 | + if ($type==1) { |
|
286 | + $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
287 | + } |
|
274 | 288 | if (! $mask) |
275 | 289 | { |
276 | 290 | $this->error='NotConfigured'; |
@@ -297,7 +311,9 @@ discard block |
||
297 | 311 | { |
298 | 312 | $sql = "SELECT code_client FROM ".MAIN_DB_PREFIX."societe"; |
299 | 313 | $sql.= " WHERE code_client = '".$code."'"; |
300 | - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
314 | + if ($soc->id > 0) { |
|
315 | + $sql.= " AND rowid <> ".$soc->id; |
|
316 | + } |
|
301 | 317 | |
302 | 318 | $resql=$db->query($sql); |
303 | 319 | if ($resql) |
@@ -305,13 +321,11 @@ discard block |
||
305 | 321 | if ($db->num_rows($resql) == 0) |
306 | 322 | { |
307 | 323 | return 0; |
308 | - } |
|
309 | - else |
|
324 | + } else |
|
310 | 325 | { |
311 | 326 | return -1; |
312 | 327 | } |
313 | - } |
|
314 | - else |
|
328 | + } else |
|
315 | 329 | { |
316 | 330 | return -2; |
317 | 331 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * Return an example of result returned by getNextValue |
79 | 79 | * |
80 | 80 | * @param Translate $langs Object langs |
81 | - * @param societe $objsoc Object thirdparty |
|
81 | + * @param integer $objsoc Object thirdparty |
|
82 | 82 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
83 | 83 | * @return string Return string example |
84 | 84 | */ |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | /** |
92 | 92 | * Return next value |
93 | 93 | * |
94 | - * @param Societe $objsoc Object third party |
|
94 | + * @param integer $objsoc Object third party |
|
95 | 95 | * @param int $type Client ou fournisseur (1:client, 2:fournisseur) |
96 | 96 | * @return string Value if OK, '' if module not configured, <0 if KO |
97 | 97 | */ |
@@ -120,7 +120,7 @@ |
||
120 | 120 | |
121 | 121 | // D'abord on recupere la valeur max (reponse immediate car champ indexe) |
122 | 122 | $posindice=8; |
123 | - $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
123 | + $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
124 | 124 | $sql.= " FROM ".MAIN_DB_PREFIX."societe"; |
125 | 125 | $sql.= " WHERE ".$field." LIKE '".$prefix."____-%'"; |
126 | 126 | $sql.= " AND entity IN (".getEntity('societe').")"; |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class mod_codeclient_monkey extends ModeleThirdPartyCode |
34 | 34 | { |
35 | - var $nom='Monkey'; // Nom du modele |
|
36 | - var $name='Monkey'; // Nom du modele |
|
37 | - var $code_modifiable; // Code modifiable |
|
38 | - var $code_modifiable_invalide; // Code modifiable si il est invalide |
|
39 | - var $code_modifiable_null; // Code modifiables si il est null |
|
40 | - var $code_null; // Code facultatif |
|
41 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
42 | - var $code_auto; // Numerotation automatique |
|
43 | - |
|
44 | - var $prefixcustomer='CU'; |
|
45 | - var $prefixsupplier='SU'; |
|
35 | + var $nom = 'Monkey'; // Nom du modele |
|
36 | + var $name = 'Monkey'; // Nom du modele |
|
37 | + var $code_modifiable; // Code modifiable |
|
38 | + var $code_modifiable_invalide; // Code modifiable si il est invalide |
|
39 | + var $code_modifiable_null; // Code modifiables si il est null |
|
40 | + var $code_null; // Code facultatif |
|
41 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
42 | + var $code_auto; // Numerotation automatique |
|
43 | + |
|
44 | + var $prefixcustomer = 'CU'; |
|
45 | + var $prefixsupplier = 'SU'; |
|
46 | 46 | var $prefixIsRequired; // Le champ prefix du tiers doit etre renseigne quand on utilise {pre} |
47 | 47 | |
48 | 48 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | function info($langs) |
72 | 72 | { |
73 | - return $langs->trans("MonkeyNumRefModelDesc",$this->prefixcustomer,$this->prefixsupplier); |
|
73 | + return $langs->trans("MonkeyNumRefModelDesc", $this->prefixcustomer, $this->prefixsupplier); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
83 | 83 | * @return string Return string example |
84 | 84 | */ |
85 | - function getExample($langs,$objsoc=0,$type=-1) |
|
85 | + function getExample($langs, $objsoc = 0, $type = -1) |
|
86 | 86 | { |
87 | 87 | return $this->prefixcustomer.'0901-0001<br>'.$this->prefixsupplier.'0901-0001'; |
88 | 88 | } |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | * @param int $type Client ou fournisseur (1:client, 2:fournisseur) |
96 | 96 | * @return string Value if OK, '' if module not configured, <0 if KO |
97 | 97 | */ |
98 | - function getNextValue($objsoc=0,$type=-1) |
|
98 | + function getNextValue($objsoc = 0, $type = -1) |
|
99 | 99 | { |
100 | 100 | global $db, $conf, $mc; |
101 | 101 | |
102 | - $return='000001'; |
|
102 | + $return = '000001'; |
|
103 | 103 | |
104 | - $field='';$where=''; |
|
104 | + $field = ''; $where = ''; |
|
105 | 105 | if ($type == 0) |
106 | 106 | { |
107 | 107 | $field = 'code_client'; |
@@ -115,24 +115,24 @@ discard block |
||
115 | 115 | else return -1; |
116 | 116 | |
117 | 117 | |
118 | - if ($type == 0) $prefix=$this->prefixcustomer; |
|
119 | - if ($type == 1) $prefix=$this->prefixsupplier; |
|
118 | + if ($type == 0) $prefix = $this->prefixcustomer; |
|
119 | + if ($type == 1) $prefix = $this->prefixsupplier; |
|
120 | 120 | |
121 | 121 | // D'abord on recupere la valeur max (reponse immediate car champ indexe) |
122 | - $posindice=8; |
|
123 | - $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
124 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe"; |
|
125 | - $sql.= " WHERE ".$field." LIKE '".$prefix."____-%'"; |
|
126 | - $sql.= " AND entity IN (".getEntity('societe').")"; |
|
122 | + $posindice = 8; |
|
123 | + $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
124 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe"; |
|
125 | + $sql .= " WHERE ".$field." LIKE '".$prefix."____-%'"; |
|
126 | + $sql .= " AND entity IN (".getEntity('societe').")"; |
|
127 | 127 | |
128 | 128 | dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
129 | 129 | |
130 | - $resql=$db->query($sql); |
|
130 | + $resql = $db->query($sql); |
|
131 | 131 | if ($resql) |
132 | 132 | { |
133 | 133 | $obj = $db->fetch_object($resql); |
134 | 134 | if ($obj) $max = intval($obj->max); |
135 | - else $max=0; |
|
135 | + else $max = 0; |
|
136 | 136 | } |
137 | 137 | else |
138 | 138 | { |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | $date = dol_now(); |
143 | - $yymm = strftime("%y%m",$date); |
|
143 | + $yymm = strftime("%y%m", $date); |
|
144 | 144 | |
145 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
146 | - else $num = sprintf("%04s",$max+1); |
|
145 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
146 | + else $num = sprintf("%04s", $max + 1); |
|
147 | 147 | |
148 | 148 | dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
149 | 149 | return $prefix.$yymm."-".$num; |
@@ -167,16 +167,16 @@ discard block |
||
167 | 167 | { |
168 | 168 | global $conf; |
169 | 169 | |
170 | - $result=0; |
|
170 | + $result = 0; |
|
171 | 171 | $code = strtoupper(trim($code)); |
172 | 172 | |
173 | 173 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
174 | 174 | { |
175 | - $result=0; |
|
175 | + $result = 0; |
|
176 | 176 | } |
177 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
177 | + else if (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) |
|
178 | 178 | { |
179 | - $result=-2; |
|
179 | + $result = -2; |
|
180 | 180 | } |
181 | 181 | else |
182 | 182 | { |
@@ -185,22 +185,22 @@ discard block |
||
185 | 185 | $is_dispo = $this->verif_dispo($db, $code, $soc); |
186 | 186 | if ($is_dispo <> 0) |
187 | 187 | { |
188 | - $result=-3; |
|
188 | + $result = -3; |
|
189 | 189 | } |
190 | 190 | else |
191 | 191 | { |
192 | - $result=0; |
|
192 | + $result = 0; |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | else |
196 | 196 | { |
197 | 197 | if (dol_strlen($code) == 0) |
198 | 198 | { |
199 | - $result=-2; |
|
199 | + $result = -2; |
|
200 | 200 | } |
201 | 201 | else |
202 | 202 | { |
203 | - $result=-1; |
|
203 | + $result = -1; |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | } |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | global $conf, $mc; |
224 | 224 | |
225 | 225 | $sql = "SELECT code_client FROM ".MAIN_DB_PREFIX."societe"; |
226 | - $sql.= " WHERE code_client = '".$code."'"; |
|
227 | - $sql.= " AND entity IN (".getEntity('societe').")"; |
|
228 | - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
226 | + $sql .= " WHERE code_client = '".$code."'"; |
|
227 | + $sql .= " AND entity IN (".getEntity('societe').")"; |
|
228 | + if ($soc->id > 0) $sql .= " AND rowid <> ".$soc->id; |
|
229 | 229 | |
230 | 230 | dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG); |
231 | - $resql=$db->query($sql); |
|
231 | + $resql = $db->query($sql); |
|
232 | 232 | if ($resql) |
233 | 233 | { |
234 | 234 | if ($db->num_rows($resql) == 0) |
@@ -106,17 +106,21 @@ discard block |
||
106 | 106 | { |
107 | 107 | $field = 'code_client'; |
108 | 108 | //$where = ' AND client in (1,2)'; |
109 | - } |
|
110 | - else if ($type == 1) |
|
109 | + } else if ($type == 1) |
|
111 | 110 | { |
112 | 111 | $field = 'code_fournisseur'; |
113 | 112 | //$where = ' AND fournisseur = 1'; |
113 | + } else { |
|
114 | + return -1; |
|
114 | 115 | } |
115 | - else return -1; |
|
116 | 116 | |
117 | 117 | |
118 | - if ($type == 0) $prefix=$this->prefixcustomer; |
|
119 | - if ($type == 1) $prefix=$this->prefixsupplier; |
|
118 | + if ($type == 0) { |
|
119 | + $prefix=$this->prefixcustomer; |
|
120 | + } |
|
121 | + if ($type == 1) { |
|
122 | + $prefix=$this->prefixsupplier; |
|
123 | + } |
|
120 | 124 | |
121 | 125 | // D'abord on recupere la valeur max (reponse immediate car champ indexe) |
122 | 126 | $posindice=8; |
@@ -131,10 +135,12 @@ discard block |
||
131 | 135 | if ($resql) |
132 | 136 | { |
133 | 137 | $obj = $db->fetch_object($resql); |
134 | - if ($obj) $max = intval($obj->max); |
|
135 | - else $max=0; |
|
136 | - } |
|
137 | - else |
|
138 | + if ($obj) { |
|
139 | + $max = intval($obj->max); |
|
140 | + } else { |
|
141 | + $max=0; |
|
142 | + } |
|
143 | + } else |
|
138 | 144 | { |
139 | 145 | return -1; |
140 | 146 | } |
@@ -142,8 +148,13 @@ discard block |
||
142 | 148 | $date = dol_now(); |
143 | 149 | $yymm = strftime("%y%m",$date); |
144 | 150 | |
145 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
146 | - else $num = sprintf("%04s",$max+1); |
|
151 | + if ($max >= (pow(10, 4) - 1)) { |
|
152 | + $num=$max+1; |
|
153 | + } |
|
154 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
155 | + else { |
|
156 | + $num = sprintf("%04s",$max+1); |
|
157 | + } |
|
147 | 158 | |
148 | 159 | dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
149 | 160 | return $prefix.$yymm."-".$num; |
@@ -173,12 +184,10 @@ discard block |
||
173 | 184 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
174 | 185 | { |
175 | 186 | $result=0; |
176 | - } |
|
177 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
187 | + } else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
178 | 188 | { |
179 | 189 | $result=-2; |
180 | - } |
|
181 | - else |
|
190 | + } else |
|
182 | 191 | { |
183 | 192 | if ($this->verif_syntax($code) >= 0) |
184 | 193 | { |
@@ -186,19 +195,16 @@ discard block |
||
186 | 195 | if ($is_dispo <> 0) |
187 | 196 | { |
188 | 197 | $result=-3; |
189 | - } |
|
190 | - else |
|
198 | + } else |
|
191 | 199 | { |
192 | 200 | $result=0; |
193 | 201 | } |
194 | - } |
|
195 | - else |
|
202 | + } else |
|
196 | 203 | { |
197 | 204 | if (dol_strlen($code) == 0) |
198 | 205 | { |
199 | 206 | $result=-2; |
200 | - } |
|
201 | - else |
|
207 | + } else |
|
202 | 208 | { |
203 | 209 | $result=-1; |
204 | 210 | } |
@@ -225,7 +231,9 @@ discard block |
||
225 | 231 | $sql = "SELECT code_client FROM ".MAIN_DB_PREFIX."societe"; |
226 | 232 | $sql.= " WHERE code_client = '".$code."'"; |
227 | 233 | $sql.= " AND entity IN (".getEntity('societe').")"; |
228 | - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
234 | + if ($soc->id > 0) { |
|
235 | + $sql.= " AND rowid <> ".$soc->id; |
|
236 | + } |
|
229 | 237 | |
230 | 238 | dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG); |
231 | 239 | $resql=$db->query($sql); |
@@ -234,13 +242,11 @@ discard block |
||
234 | 242 | if ($db->num_rows($resql) == 0) |
235 | 243 | { |
236 | 244 | return 0; |
237 | - } |
|
238 | - else |
|
245 | + } else |
|
239 | 246 | { |
240 | 247 | return -1; |
241 | 248 | } |
242 | - } |
|
243 | - else |
|
249 | + } else |
|
244 | 250 | { |
245 | 251 | return -2; |
246 | 252 | } |
@@ -261,8 +267,7 @@ discard block |
||
261 | 267 | if (dol_strlen($code) < 11) |
262 | 268 | { |
263 | 269 | $res = -1; |
264 | - } |
|
265 | - else |
|
270 | + } else |
|
266 | 271 | { |
267 | 272 | $res = 0; |
268 | 273 | } |
@@ -87,7 +87,7 @@ |
||
87 | 87 | * Return an example of result returned by getNextValue |
88 | 88 | * |
89 | 89 | * @param Translate $langs Object langs |
90 | - * @param societe $objsoc Object thirdparty |
|
90 | + * @param integer $objsoc Object thirdparty |
|
91 | 91 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
92 | 92 | * @return string Return string example |
93 | 93 | */ |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | */ |
45 | 45 | function __construct() |
46 | 46 | { |
47 | - global $conf; |
|
47 | + global $conf; |
|
48 | 48 | if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; |
49 | - if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; |
|
49 | + if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; |
|
50 | 50 | $this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; |
51 | - $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; |
|
51 | + $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | */ |
61 | 61 | function info($langs) |
62 | 62 | { |
63 | - global $conf; |
|
64 | - global $form; |
|
63 | + global $conf; |
|
64 | + global $form; |
|
65 | 65 | |
66 | 66 | $langs->load("companies"); |
67 | 67 | |
68 | - $tooltip=''; |
|
68 | + $tooltip=''; |
|
69 | 69 | $texte = '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
70 | 70 | $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
71 | 71 | $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | $texte.= '<tr><td>'.$langs->trans("ModuleCompanyCode".$this->name,$s1,$s2)."<br>\n"; |
78 | 78 | $texte.= '</td>'; |
79 | 79 | $texte.= '<td align="left"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
80 | - $texte.= '</tr></table>'; |
|
81 | - $texte.= '</form>'; |
|
80 | + $texte.= '</tr></table>'; |
|
81 | + $texte.= '</form>'; |
|
82 | 82 | |
83 | 83 | return $texte; |
84 | 84 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | function getExample($langs,$objsoc=0,$type=-1) |
95 | 95 | { |
96 | - return $this->prefixsupplieraccountancycode.'SUPPCODE'."<br>\n".$this->prefixcustomeraccountancycode.'CUSTCODE'; |
|
96 | + return $this->prefixsupplieraccountancycode.'SUPPCODE'."<br>\n".$this->prefixcustomeraccountancycode.'CUSTCODE'; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class mod_codecompta_aquarium extends ModeleAccountancyCode |
33 | 33 | { |
34 | - var $nom='Aquarium'; |
|
35 | - var $name='Aquarium'; |
|
36 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
34 | + var $nom = 'Aquarium'; |
|
35 | + var $name = 'Aquarium'; |
|
36 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | 37 | |
38 | 38 | var $prefixcustomeraccountancycode; |
39 | 39 | var $prefixsupplieraccountancycode; |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | function __construct() |
46 | 46 | { |
47 | 47 | global $conf; |
48 | - if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; |
|
49 | - if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; |
|
50 | - $this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; |
|
51 | - $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; |
|
48 | + if (!isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER = '411'; |
|
49 | + if (!isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER = '401'; |
|
50 | + $this->prefixcustomeraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; |
|
51 | + $this->prefixsupplieraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -65,20 +65,20 @@ discard block |
||
65 | 65 | |
66 | 66 | $langs->load("companies"); |
67 | 67 | |
68 | - $tooltip=''; |
|
68 | + $tooltip = ''; |
|
69 | 69 | $texte = '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
70 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
71 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
72 | - $texte.= '<input type="hidden" name="param1" value="COMPANY_AQUARIUM_MASK_SUPPLIER">'; |
|
73 | - $texte.= '<input type="hidden" name="param2" value="COMPANY_AQUARIUM_MASK_CUSTOMER">'; |
|
74 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
75 | - $s1= $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER.'">',$tooltip,1,1); |
|
76 | - $s2= $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER.'">',$tooltip,1,1); |
|
77 | - $texte.= '<tr><td>'.$langs->trans("ModuleCompanyCode".$this->name,$s1,$s2)."<br>\n"; |
|
78 | - $texte.= '</td>'; |
|
79 | - $texte.= '<td align="left"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
80 | - $texte.= '</tr></table>'; |
|
81 | - $texte.= '</form>'; |
|
70 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
71 | + $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
72 | + $texte .= '<input type="hidden" name="param1" value="COMPANY_AQUARIUM_MASK_SUPPLIER">'; |
|
73 | + $texte .= '<input type="hidden" name="param2" value="COMPANY_AQUARIUM_MASK_CUSTOMER">'; |
|
74 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
75 | + $s1 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER.'">', $tooltip, 1, 1); |
|
76 | + $s2 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER.'">', $tooltip, 1, 1); |
|
77 | + $texte .= '<tr><td>'.$langs->trans("ModuleCompanyCode".$this->name, $s1, $s2)."<br>\n"; |
|
78 | + $texte .= '</td>'; |
|
79 | + $texte .= '<td align="left"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
80 | + $texte .= '</tr></table>'; |
|
81 | + $texte .= '</form>'; |
|
82 | 82 | |
83 | 83 | return $texte; |
84 | 84 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
92 | 92 | * @return string Return string example |
93 | 93 | */ |
94 | - function getExample($langs,$objsoc=0,$type=-1) |
|
94 | + function getExample($langs, $objsoc = 0, $type = -1) |
|
95 | 95 | { |
96 | 96 | return $this->prefixsupplieraccountancycode.'SUPPCODE'."<br>\n".$this->prefixcustomeraccountancycode.'CUSTCODE'; |
97 | 97 | } |
@@ -105,36 +105,36 @@ discard block |
||
105 | 105 | * @param string $type 'customer' or 'supplier' |
106 | 106 | * @return int >=0 if OK, <0 if KO |
107 | 107 | */ |
108 | - function get_code($db, $societe, $type='') |
|
108 | + function get_code($db, $societe, $type = '') |
|
109 | 109 | { |
110 | 110 | $i = 0; |
111 | 111 | $this->db = $db; |
112 | 112 | |
113 | - dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(! empty($societe->name)?$societe->name:'')); |
|
113 | + dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(!empty($societe->name) ? $societe->name : '')); |
|
114 | 114 | |
115 | 115 | // Regle gestion compte compta |
116 | - $codetouse=''; |
|
116 | + $codetouse = ''; |
|
117 | 117 | if ($type == 'customer') |
118 | 118 | { |
119 | 119 | $codetouse = $this->prefixcustomeraccountancycode; |
120 | - $codetouse.= (! empty($societe->code_client)?$societe->code_client:'CUSTCODE'); |
|
120 | + $codetouse .= (!empty($societe->code_client) ? $societe->code_client : 'CUSTCODE'); |
|
121 | 121 | } |
122 | 122 | else if ($type == 'supplier') |
123 | 123 | { |
124 | 124 | $codetouse = $this->prefixsupplieraccountancycode; |
125 | - $codetouse.= (! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE'); |
|
125 | + $codetouse .= (!empty($societe->code_fournisseur) ? $societe->code_fournisseur : 'SUPPCODE'); |
|
126 | 126 | } |
127 | - $codetouse=strtoupper(preg_replace('/([^a-z0-9])/i','',$codetouse)); |
|
127 | + $codetouse = strtoupper(preg_replace('/([^a-z0-9])/i', '', $codetouse)); |
|
128 | 128 | |
129 | 129 | $is_dispo = $this->verif($db, $codetouse, $societe, $type); |
130 | - if (! $is_dispo) |
|
130 | + if (!$is_dispo) |
|
131 | 131 | { |
132 | - $this->code=$codetouse; |
|
132 | + $this->code = $codetouse; |
|
133 | 133 | } |
134 | 134 | else |
135 | 135 | { |
136 | 136 | // Pour retour |
137 | - $this->code=$codetouse; |
|
137 | + $this->code = $codetouse; |
|
138 | 138 | } |
139 | 139 | dol_syslog("mod_codecompta_aquarium::get_code found code=".$this->code); |
140 | 140 | return $is_dispo; |
@@ -153,33 +153,33 @@ discard block |
||
153 | 153 | function verif($db, $code, $societe, $type) |
154 | 154 | { |
155 | 155 | $sql = "SELECT "; |
156 | - if ($type == 'customer') $sql.= "code_compta"; |
|
157 | - else if ($type == 'supplier') $sql.= "code_compta_fournisseur"; |
|
158 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe"; |
|
159 | - $sql.= " WHERE "; |
|
160 | - if ($type == 'customer') $sql.= "code_compta"; |
|
161 | - else if ($type == 'supplier') $sql.= "code_compta_fournisseur"; |
|
162 | - $sql.= " = '".$db->escape($code)."'"; |
|
163 | - if (! empty($societe->id)) $sql.= " AND rowid <> ".$societe->id; |
|
164 | - |
|
165 | - $resql=$db->query($sql); |
|
156 | + if ($type == 'customer') $sql .= "code_compta"; |
|
157 | + else if ($type == 'supplier') $sql .= "code_compta_fournisseur"; |
|
158 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe"; |
|
159 | + $sql .= " WHERE "; |
|
160 | + if ($type == 'customer') $sql .= "code_compta"; |
|
161 | + else if ($type == 'supplier') $sql .= "code_compta_fournisseur"; |
|
162 | + $sql .= " = '".$db->escape($code)."'"; |
|
163 | + if (!empty($societe->id)) $sql .= " AND rowid <> ".$societe->id; |
|
164 | + |
|
165 | + $resql = $db->query($sql); |
|
166 | 166 | if ($resql) |
167 | 167 | { |
168 | 168 | if ($db->num_rows($resql) == 0) |
169 | 169 | { |
170 | 170 | dol_syslog("mod_codecompta_aquarium::verif code '".$code."' available"); |
171 | - return 1; // Dispo |
|
171 | + return 1; // Dispo |
|
172 | 172 | } |
173 | 173 | else |
174 | 174 | { |
175 | 175 | dol_syslog("mod_codecompta_aquarium::verif code '".$code."' not available"); |
176 | - return 0; // Non dispo |
|
176 | + return 0; // Non dispo |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | else |
180 | 180 | { |
181 | - $this->error=$db->error()." sql=".$sql; |
|
182 | - return -1; // Erreur |
|
181 | + $this->error = $db->error()." sql=".$sql; |
|
182 | + return -1; // Erreur |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
@@ -45,8 +45,12 @@ discard block |
||
45 | 45 | function __construct() |
46 | 46 | { |
47 | 47 | global $conf; |
48 | - if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; |
|
49 | - if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; |
|
48 | + if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') { |
|
49 | + $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; |
|
50 | + } |
|
51 | + if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') { |
|
52 | + $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; |
|
53 | + } |
|
50 | 54 | $this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; |
51 | 55 | $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; |
52 | 56 | } |
@@ -118,8 +122,7 @@ discard block |
||
118 | 122 | { |
119 | 123 | $codetouse = $this->prefixcustomeraccountancycode; |
120 | 124 | $codetouse.= (! empty($societe->code_client)?$societe->code_client:'CUSTCODE'); |
121 | - } |
|
122 | - else if ($type == 'supplier') |
|
125 | + } else if ($type == 'supplier') |
|
123 | 126 | { |
124 | 127 | $codetouse = $this->prefixsupplieraccountancycode; |
125 | 128 | $codetouse.= (! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE'); |
@@ -130,8 +133,7 @@ discard block |
||
130 | 133 | if (! $is_dispo) |
131 | 134 | { |
132 | 135 | $this->code=$codetouse; |
133 | - } |
|
134 | - else |
|
136 | + } else |
|
135 | 137 | { |
136 | 138 | // Pour retour |
137 | 139 | $this->code=$codetouse; |
@@ -153,14 +155,22 @@ discard block |
||
153 | 155 | function verif($db, $code, $societe, $type) |
154 | 156 | { |
155 | 157 | $sql = "SELECT "; |
156 | - if ($type == 'customer') $sql.= "code_compta"; |
|
157 | - else if ($type == 'supplier') $sql.= "code_compta_fournisseur"; |
|
158 | + if ($type == 'customer') { |
|
159 | + $sql.= "code_compta"; |
|
160 | + } else if ($type == 'supplier') { |
|
161 | + $sql.= "code_compta_fournisseur"; |
|
162 | + } |
|
158 | 163 | $sql.= " FROM ".MAIN_DB_PREFIX."societe"; |
159 | 164 | $sql.= " WHERE "; |
160 | - if ($type == 'customer') $sql.= "code_compta"; |
|
161 | - else if ($type == 'supplier') $sql.= "code_compta_fournisseur"; |
|
165 | + if ($type == 'customer') { |
|
166 | + $sql.= "code_compta"; |
|
167 | + } else if ($type == 'supplier') { |
|
168 | + $sql.= "code_compta_fournisseur"; |
|
169 | + } |
|
162 | 170 | $sql.= " = '".$db->escape($code)."'"; |
163 | - if (! empty($societe->id)) $sql.= " AND rowid <> ".$societe->id; |
|
171 | + if (! empty($societe->id)) { |
|
172 | + $sql.= " AND rowid <> ".$societe->id; |
|
173 | + } |
|
164 | 174 | |
165 | 175 | $resql=$db->query($sql); |
166 | 176 | if ($resql) |
@@ -169,14 +179,12 @@ discard block |
||
169 | 179 | { |
170 | 180 | dol_syslog("mod_codecompta_aquarium::verif code '".$code."' available"); |
171 | 181 | return 1; // Dispo |
172 | - } |
|
173 | - else |
|
182 | + } else |
|
174 | 183 | { |
175 | 184 | dol_syslog("mod_codecompta_aquarium::verif code '".$code."' not available"); |
176 | 185 | return 0; // Non dispo |
177 | 186 | } |
178 | - } |
|
179 | - else |
|
187 | + } else |
|
180 | 188 | { |
181 | 189 | $this->error=$db->error()." sql=".$sql; |
182 | 190 | return -1; // Erreur |