@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | |
26 | 26 | // Test if batch mode |
27 | 27 | if (substr($sapi_type, 0, 3) == 'cgi') { |
28 | - echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
29 | - exit; |
|
28 | + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
29 | + exit; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | // Global variables |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | |
54 | 54 | if (empty($confirm)) |
55 | 55 | { |
56 | - print "Usage: $script_file confirm\n"; |
|
57 | - print "Return code: 0 if success, <>0 if error\n"; |
|
58 | - exit(-1); |
|
56 | + print "Usage: $script_file confirm\n"; |
|
57 | + print "Return code: 0 if success, <>0 if error\n"; |
|
58 | + exit(-1); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe where client in (1, 3)"; |
114 | 114 | $resql=$db->query($sql); |
115 | 115 | if ($resql) { |
116 | - $num_thirdparties = $db->num_rows($resql); |
|
117 | - $i = 0; |
|
118 | - while ($i < $num_thirdparties) { |
|
119 | - $i++; |
|
120 | - $row = $db->fetch_row($resql); |
|
121 | - $societesid[$i] = $row[0]; |
|
122 | - } |
|
116 | + $num_thirdparties = $db->num_rows($resql); |
|
117 | + $i = 0; |
|
118 | + while ($i < $num_thirdparties) { |
|
119 | + $i++; |
|
120 | + $row = $db->fetch_row($resql); |
|
121 | + $societesid[$i] = $row[0]; |
|
122 | + } |
|
123 | 123 | } |
124 | 124 | else { print "err"; } |
125 | 125 | |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; |
128 | 128 | $resql=$db->query($sql); |
129 | 129 | if ($resql) { |
130 | - $num = $db->num_rows($resql); |
|
131 | - $i = 0; |
|
132 | - while ($i < $num) { |
|
133 | - $i++; |
|
134 | - $row = $db->fetch_row($resql); |
|
135 | - $commandesid[$i] = $row[0]; |
|
136 | - } |
|
130 | + $num = $db->num_rows($resql); |
|
131 | + $i = 0; |
|
132 | + while ($i < $num) { |
|
133 | + $i++; |
|
134 | + $row = $db->fetch_row($resql); |
|
135 | + $commandesid[$i] = $row[0]; |
|
136 | + } |
|
137 | 137 | } |
138 | 138 | else { print "err"; } |
139 | 139 | |
@@ -142,14 +142,14 @@ discard block |
||
142 | 142 | $resql = $db->query($sql); |
143 | 143 | if ($resql) |
144 | 144 | { |
145 | - $num_prods = $db->num_rows($resql); |
|
146 | - $i = 0; |
|
147 | - while ($i < $num_prods) |
|
145 | + $num_prods = $db->num_rows($resql); |
|
146 | + $i = 0; |
|
147 | + while ($i < $num_prods) |
|
148 | 148 | { |
149 | - $i++; |
|
149 | + $i++; |
|
150 | 150 | |
151 | - $row = $db->fetch_row($resql); |
|
152 | - $prodids[$i] = $row[0]; |
|
151 | + $row = $db->fetch_row($resql); |
|
152 | + $prodids[$i] = $row[0]; |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | $db->begin(); |
184 | 184 | |
185 | 185 | $result=$object->create($fuser); |
186 | - if ($result >= 0) |
|
187 | - { |
|
186 | + if ($result >= 0) |
|
187 | + { |
|
188 | 188 | $nbp = mt_rand(2, 5); |
189 | 189 | $xnbp = 0; |
190 | 190 | while ($xnbp < $nbp) |
@@ -200,24 +200,24 @@ discard block |
||
200 | 200 | $xnbp++; |
201 | 201 | } |
202 | 202 | |
203 | - $result=$object->valid($fuser); |
|
204 | - if ($result > 0) |
|
205 | - { |
|
203 | + $result=$object->valid($fuser); |
|
204 | + if ($result > 0) |
|
205 | + { |
|
206 | 206 | $db->commit(); |
207 | 207 | print " OK with ref ".$object->ref."\n"; |
208 | - } |
|
209 | - else |
|
210 | - { |
|
208 | + } |
|
209 | + else |
|
210 | + { |
|
211 | 211 | print " KO\n"; |
212 | - $db->rollback(); |
|
213 | - dol_print_error($db,$object->error); |
|
214 | - } |
|
215 | - } |
|
216 | - else |
|
217 | - { |
|
212 | + $db->rollback(); |
|
213 | + dol_print_error($db,$object->error); |
|
214 | + } |
|
215 | + } |
|
216 | + else |
|
217 | + { |
|
218 | 218 | print " KO\n"; |
219 | - $db->rollback(); |
|
220 | - dol_print_error($db,$object->error); |
|
221 | - } |
|
219 | + $db->rollback(); |
|
220 | + dol_print_error($db,$object->error); |
|
221 | + } |
|
222 | 222 | } |
223 | 223 |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | 'DELETE FROM '.MAIN_DB_PREFIX.'supplier_proposaldet', |
82 | 82 | 'DELETE FROM '.MAIN_DB_PREFIX.'supplier_proposal', |
83 | 83 | ), |
84 | - 'supplier_order'=>array( |
|
84 | + 'supplier_order'=>array( |
|
85 | 85 | 'DELETE FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet', |
86 | 86 | 'DELETE FROM '.MAIN_DB_PREFIX.'commande_fournisseur', |
87 | 87 | ), |
88 | - 'supplier_invoice'=>array( |
|
88 | + 'supplier_invoice'=>array( |
|
89 | 89 | 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det', |
90 | 90 | 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn', |
91 | 91 | ), |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | 'DELETE FROM '.MAIN_DB_PREFIX.'product_price', |
117 | 117 | 'DELETE FROM '.MAIN_DB_PREFIX.'product_fournisseur_price', |
118 | 118 | 'DELETE FROM '.MAIN_DB_PREFIX.'product_batch', |
119 | - 'DELETE FROM '.MAIN_DB_PREFIX.'product_stock', |
|
119 | + 'DELETE FROM '.MAIN_DB_PREFIX.'product_stock', |
|
120 | 120 | 'DELETE FROM '.MAIN_DB_PREFIX.'product_lot', |
121 | - 'DELETE FROM '.MAIN_DB_PREFIX.'product', |
|
121 | + 'DELETE FROM '.MAIN_DB_PREFIX.'product', |
|
122 | 122 | ), |
123 | 123 | 'project'=>array( |
124 | 124 | 'DELETE FROM '.MAIN_DB_PREFIX.'projet_task_time', |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'DELETE FROM '.MAIN_DB_PREFIX.'categorie_societe', |
138 | 138 | 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except', |
139 | 139 | 'DELETE FROM '.MAIN_DB_PREFIX.'societe_rib', |
140 | - 'DELETE FROM '.MAIN_DB_PREFIX.'societe', |
|
140 | + 'DELETE FROM '.MAIN_DB_PREFIX.'societe', |
|
141 | 141 | ) |
142 | 142 | ); |
143 | 143 | |
@@ -172,18 +172,18 @@ discard block |
||
172 | 172 | // Replace database handler |
173 | 173 | if (! empty($argv[3])) |
174 | 174 | { |
175 | - $db->close(); |
|
176 | - unset($db); |
|
177 | - $db=getDoliDBInstance($argv[3], $argv[4], $argv[5], $argv[6], $argv[7], $argv[8]); |
|
178 | - $user=new User($db); |
|
175 | + $db->close(); |
|
176 | + unset($db); |
|
177 | + $db=getDoliDBInstance($argv[3], $argv[4], $argv[5], $argv[6], $argv[7], $argv[8]); |
|
178 | + $user=new User($db); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | //var_dump($user->db->database_name); |
182 | 182 | $ret=$user->fetch('','admin'); |
183 | 183 | if (! $ret > 0) |
184 | 184 | { |
185 | - print 'An admin user with login "admin" must exists to use this script.'."\n"; |
|
186 | - exit; |
|
185 | + print 'An admin user with login "admin" must exists to use this script.'."\n"; |
|
186 | + exit; |
|
187 | 187 | } |
188 | 188 | //$user->getrights(); |
189 | 189 |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | // Test si mode batch |
27 | 27 | $sapi_type = php_sapi_name(); |
28 | 28 | if (substr($sapi_type, 0, 3) == 'cgi') { |
29 | - echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n"; |
|
30 | - exit; |
|
29 | + echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n"; |
|
30 | + exit; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | // Recupere root dolibarr |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | $ret=$user->fetch('','admin'); |
99 | 99 | if (! $ret > 0) |
100 | 100 | { |
101 | - print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
102 | - exit; |
|
101 | + print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
102 | + exit; |
|
103 | 103 | } |
104 | 104 | $user->getrights(); |
105 | 105 | |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | $resql = $db->query($sql); |
110 | 110 | if ($resql) |
111 | 111 | { |
112 | - $num_thirdparties = $db->num_rows($resql); |
|
113 | - $i = 0; |
|
114 | - while ($i < $num_thirdparties) |
|
115 | - { |
|
116 | - $i++; |
|
117 | - $row = $db->fetch_row($resql); |
|
118 | - $socids[$i] = $row[0]; |
|
119 | - } |
|
112 | + $num_thirdparties = $db->num_rows($resql); |
|
113 | + $i = 0; |
|
114 | + while ($i < $num_thirdparties) |
|
115 | + { |
|
116 | + $i++; |
|
117 | + $row = $db->fetch_row($resql); |
|
118 | + $socids[$i] = $row[0]; |
|
119 | + } |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | $prodids = array(); |
@@ -124,65 +124,65 @@ discard block |
||
124 | 124 | $resql = $db->query($sql); |
125 | 125 | if ($resql) |
126 | 126 | { |
127 | - $num_prods = $db->num_rows($resql); |
|
128 | - $i = 0; |
|
129 | - while ($i < $num_prods) |
|
130 | - { |
|
131 | - $i++; |
|
132 | - $row = $db->fetch_row($resql); |
|
133 | - $prodids[$i] = $row[0]; |
|
134 | - } |
|
127 | + $num_prods = $db->num_rows($resql); |
|
128 | + $i = 0; |
|
129 | + while ($i < $num_prods) |
|
130 | + { |
|
131 | + $i++; |
|
132 | + $row = $db->fetch_row($resql); |
|
133 | + $prodids[$i] = $row[0]; |
|
134 | + } |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | $i=0; |
138 | 138 | $result=0; |
139 | 139 | while ($i < GEN_NUMBER_FACTURE && $result >= 0) |
140 | 140 | { |
141 | - $i++; |
|
142 | - $socid = mt_rand(1, $num_thirdparties); |
|
141 | + $i++; |
|
142 | + $socid = mt_rand(1, $num_thirdparties); |
|
143 | 143 | |
144 | - print "Invoice ".$i." for socid ".$socid; |
|
144 | + print "Invoice ".$i." for socid ".$socid; |
|
145 | 145 | |
146 | - $object = new Facture($db); |
|
147 | - $object->socid = $socids[$socid]; |
|
148 | - $object->date = $dates[mt_rand(1, count($dates)-1)]; |
|
149 | - $object->cond_reglement_id = 3; |
|
150 | - $object->mode_reglement_id = 3; |
|
146 | + $object = new Facture($db); |
|
147 | + $object->socid = $socids[$socid]; |
|
148 | + $object->date = $dates[mt_rand(1, count($dates)-1)]; |
|
149 | + $object->cond_reglement_id = 3; |
|
150 | + $object->mode_reglement_id = 3; |
|
151 | 151 | |
152 | 152 | $fuser = new User($db); |
153 | 153 | $fuser->fetch(mt_rand(1,2)); |
154 | 154 | $fuser->getRights(); |
155 | 155 | |
156 | - $result=$object->create($fuser); |
|
157 | - if ($result >= 0) |
|
158 | - { |
|
159 | - $nbp = mt_rand(2, 5); |
|
160 | - $xnbp = 0; |
|
161 | - while ($xnbp < $nbp) |
|
162 | - { |
|
163 | - $prodid = mt_rand(1, $num_prods); |
|
164 | - $product=new Product($db); |
|
165 | - $result=$product->fetch($prodids[$prodid]); |
|
166 | - $result=$object->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); |
|
167 | - if ($result < 0) |
|
156 | + $result=$object->create($fuser); |
|
157 | + if ($result >= 0) |
|
158 | + { |
|
159 | + $nbp = mt_rand(2, 5); |
|
160 | + $xnbp = 0; |
|
161 | + while ($xnbp < $nbp) |
|
162 | + { |
|
163 | + $prodid = mt_rand(1, $num_prods); |
|
164 | + $product=new Product($db); |
|
165 | + $result=$product->fetch($prodids[$prodid]); |
|
166 | + $result=$object->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); |
|
167 | + if ($result < 0) |
|
168 | 168 | { |
169 | 169 | dol_print_error($db,$propal->error); |
170 | 170 | } |
171 | 171 | $xnbp++; |
172 | - } |
|
172 | + } |
|
173 | 173 | |
174 | - $result=$object->validate($fuser); |
|
175 | - if ($result) |
|
176 | - { |
|
177 | - print " OK with ref ".$object->ref."\n";; |
|
178 | - } |
|
179 | - else |
|
180 | - { |
|
181 | - dol_print_error($db,$object->error); |
|
182 | - } |
|
183 | - } |
|
184 | - else |
|
185 | - { |
|
186 | - dol_print_error($db,$object->error); |
|
187 | - } |
|
174 | + $result=$object->validate($fuser); |
|
175 | + if ($result) |
|
176 | + { |
|
177 | + print " OK with ref ".$object->ref."\n";; |
|
178 | + } |
|
179 | + else |
|
180 | + { |
|
181 | + dol_print_error($db,$object->error); |
|
182 | + } |
|
183 | + } |
|
184 | + else |
|
185 | + { |
|
186 | + dol_print_error($db,$object->error); |
|
187 | + } |
|
188 | 188 | } |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | $ret=$user->fetch('','admin'); |
56 | 56 | if (! $ret > 0) |
57 | 57 | { |
58 | - print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
59 | - exit; |
|
58 | + print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
59 | + exit; |
|
60 | 60 | } |
61 | 61 | $user->getrights(); |
62 | 62 | |
@@ -64,21 +64,21 @@ discard block |
||
64 | 64 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array(); |
65 | 65 | $resql=$db->query($sql); |
66 | 66 | if ($resql) { |
67 | - $num = $db->num_rows($resql); $i = 0; |
|
68 | - while ($i < $num) { $row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++; } |
|
67 | + $num = $db->num_rows($resql); $i = 0; |
|
68 | + while ($i < $num) { $row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++; } |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array(); |
72 | 72 | $resql=$db->query($sql); |
73 | 73 | if ($resql) { |
74 | - $num = $db->num_rows($resql); $i = 0; |
|
74 | + $num = $db->num_rows($resql); $i = 0; |
|
75 | 75 | while ($i < $num) { $row = $db->fetch_row($resql); $societesid[$i] = $row[0]; $i++; } |
76 | 76 | } else { print "err"; } |
77 | 77 | |
78 | 78 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array(); |
79 | 79 | $resql=$db->query($sql); |
80 | 80 | if ($resql) { |
81 | - $num = $db->num_rows($resql); $i = 0; |
|
81 | + $num = $db->num_rows($resql); $i = 0; |
|
82 | 82 | while ($i < $num) { $row = $db->fetch_row($resql); $commandesid[$i] = $row[0]; $i++; } |
83 | 83 | } else { print "err"; } |
84 | 84 | |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | $soc->tva_assuj=1; |
99 | 99 | $soc->country_id=1; |
100 | 100 | $soc->country_code='FR'; |
101 | - // Un client sur 3 a une remise de 5% |
|
101 | + // Un client sur 3 a une remise de 5% |
|
102 | 102 | $user_remise=mt_rand(1,3); if ($user_remise==3) $soc->remise_percent=5; |
103 | - print "> client=".$soc->client.", fournisseur=".$soc->fournisseur.", remise=".$soc->remise_percent."\n"; |
|
103 | + print "> client=".$soc->client.", fournisseur=".$soc->fournisseur.", remise=".$soc->remise_percent."\n"; |
|
104 | 104 | $soc->note_private = 'Company created by the script generate-societe.php'; |
105 | 105 | $socid = $soc->create(); |
106 | 106 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | else |
126 | 126 | { |
127 | - print "Error: ".$soc->error."\n"; |
|
127 | + print "Error: ".$soc->error."\n"; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | $ret=$user->fetch('','admin'); |
82 | 82 | if (! $ret > 0) |
83 | 83 | { |
84 | - print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
85 | - exit; |
|
84 | + print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
85 | + exit; |
|
86 | 86 | } |
87 | 87 | $user->getrights(); |
88 | 88 | |
@@ -182,116 +182,116 @@ discard block |
||
182 | 182 | print " - Error in create result code = ".$ret." - ".$object->errorsToString(); |
183 | 183 | $errorrecord++; |
184 | 184 | } |
185 | - else |
|
186 | - { |
|
187 | - print " - Creation OK with name ".$object->name." - id = ".$ret; |
|
188 | - } |
|
185 | + else |
|
186 | + { |
|
187 | + print " - Creation OK with name ".$object->name." - id = ".$ret; |
|
188 | + } |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | if (! $errorrecord) |
192 | 192 | { |
193 | 193 | dol_syslog("Set price level"); |
194 | - $object->set_price_level($object->price_level, $user); |
|
194 | + $object->set_price_level($object->price_level, $user); |
|
195 | + } |
|
196 | + |
|
197 | + // Assign sales representative |
|
198 | + if (! $errorrecord && $fields[3]) |
|
199 | + { |
|
200 | + $salesrep=new User($db); |
|
201 | + |
|
202 | + $tmp=explode(' ',$fields[3],2); |
|
203 | + $salesrep->firstname = trim($tmp[0]); |
|
204 | + $salesrep->lastname = trim($tmp[1]); |
|
205 | + if ($salesrep->lastname) $salesrep->login = strtolower(substr($salesrep->firstname, 0, 1)) . strtolower(substr($salesrep->lastname, 0)); |
|
206 | + else $salesrep->login=strtolower($salesrep->firstname); |
|
207 | + $salesrep->login=preg_replace('/ /','',$salesrep->login); |
|
208 | + $salesrep->fetch(0,$salesrep->login); |
|
209 | + |
|
210 | + $result = $object->add_commercial($user, $salesrep->id); |
|
211 | + if ($result < 0) |
|
212 | + { |
|
213 | + print " - Error in create link with sale representative result code = ".$result." - ".$object->errorsToString(); |
|
214 | + $errorrecord++; |
|
215 | + } |
|
216 | + else |
|
217 | + { |
|
218 | + print " - create link sale representative OK"; |
|
219 | + } |
|
195 | 220 | } |
196 | 221 | |
197 | - // Assign sales representative |
|
198 | - if (! $errorrecord && $fields[3]) |
|
199 | - { |
|
200 | - $salesrep=new User($db); |
|
201 | - |
|
202 | - $tmp=explode(' ',$fields[3],2); |
|
203 | - $salesrep->firstname = trim($tmp[0]); |
|
204 | - $salesrep->lastname = trim($tmp[1]); |
|
205 | - if ($salesrep->lastname) $salesrep->login = strtolower(substr($salesrep->firstname, 0, 1)) . strtolower(substr($salesrep->lastname, 0)); |
|
206 | - else $salesrep->login=strtolower($salesrep->firstname); |
|
207 | - $salesrep->login=preg_replace('/ /','',$salesrep->login); |
|
208 | - $salesrep->fetch(0,$salesrep->login); |
|
209 | - |
|
210 | - $result = $object->add_commercial($user, $salesrep->id); |
|
211 | - if ($result < 0) |
|
212 | - { |
|
213 | - print " - Error in create link with sale representative result code = ".$result." - ".$object->errorsToString(); |
|
214 | - $errorrecord++; |
|
215 | - } |
|
216 | - else |
|
217 | - { |
|
218 | - print " - create link sale representative OK"; |
|
219 | - } |
|
220 | - } |
|
221 | - |
|
222 | - dol_syslog("Add invoice contacts"); |
|
223 | - // Insert an invoice contact if there is an invoice email != standard email |
|
224 | - if (! $errorrecord && $fields[27] && $fields[26] != $fields[27]) |
|
225 | - { |
|
226 | - $ret1=$ret2=0; |
|
227 | - |
|
228 | - $contact = new Contact($db); |
|
229 | - $contact->lastname = $object->name; |
|
230 | - $contact->address=$object->address; |
|
231 | - $contact->zip=$object->zip; |
|
232 | - $contact->town=$object->town; |
|
233 | - $contact->country_id=$object->country_id; |
|
234 | - $contact->email=$fields[27]; |
|
235 | - $contact->socid=$object->id; |
|
236 | - |
|
237 | - $ret1=$contact->create($user); |
|
238 | - if ($ret1 > 0) |
|
239 | - { |
|
240 | - //$ret2=$contact->add_contact($object->id, 'BILLING'); |
|
241 | - } |
|
242 | - if ($ret1 < 0 || $ret2 < 0) |
|
222 | + dol_syslog("Add invoice contacts"); |
|
223 | + // Insert an invoice contact if there is an invoice email != standard email |
|
224 | + if (! $errorrecord && $fields[27] && $fields[26] != $fields[27]) |
|
225 | + { |
|
226 | + $ret1=$ret2=0; |
|
227 | + |
|
228 | + $contact = new Contact($db); |
|
229 | + $contact->lastname = $object->name; |
|
230 | + $contact->address=$object->address; |
|
231 | + $contact->zip=$object->zip; |
|
232 | + $contact->town=$object->town; |
|
233 | + $contact->country_id=$object->country_id; |
|
234 | + $contact->email=$fields[27]; |
|
235 | + $contact->socid=$object->id; |
|
236 | + |
|
237 | + $ret1=$contact->create($user); |
|
238 | + if ($ret1 > 0) |
|
239 | + { |
|
240 | + //$ret2=$contact->add_contact($object->id, 'BILLING'); |
|
241 | + } |
|
242 | + if ($ret1 < 0 || $ret2 < 0) |
|
243 | 243 | { |
244 | 244 | print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString(); |
245 | 245 | $errorrecord++; |
246 | 246 | } |
247 | - else |
|
248 | - { |
|
249 | - print " - create contact OK"; |
|
250 | - } |
|
251 | - } |
|
252 | - |
|
253 | - dol_syslog("Add delivery contacts"); |
|
254 | - // Insert a delivery contact |
|
255 | - if (! $errorrecord && $fields[47]) |
|
256 | - { |
|
257 | - $ret1=$ret2=0; |
|
258 | - |
|
259 | - $contact2 = new Contact($db); |
|
260 | - $contact2->lastname = 'Service livraison - '.$fields[47]; |
|
261 | - $contact2->address = $fields[48]; |
|
262 | - $contact2->zip = $fields[50]; |
|
263 | - $contact2->town = $fields[51]; |
|
264 | - $contact2->country_id=dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid'); |
|
265 | - $contact2->note_public=$fields[54]; |
|
266 | - $contact2->socid=$object->id; |
|
267 | - |
|
268 | - // Extrafields |
|
269 | - $contact2->array_options['options_anazoneliv']=price2num($fields[53]); |
|
270 | - |
|
271 | - $ret1=$contact2->create($user); |
|
272 | - if ($ret1 > 0) |
|
273 | - { |
|
274 | - //$ret2=$contact2->add_contact($object->id, 'SHIPPING'); |
|
275 | - } |
|
276 | - if ($ret1 < 0 || $ret2 < 0) |
|
247 | + else |
|
248 | + { |
|
249 | + print " - create contact OK"; |
|
250 | + } |
|
251 | + } |
|
252 | + |
|
253 | + dol_syslog("Add delivery contacts"); |
|
254 | + // Insert a delivery contact |
|
255 | + if (! $errorrecord && $fields[47]) |
|
256 | + { |
|
257 | + $ret1=$ret2=0; |
|
258 | + |
|
259 | + $contact2 = new Contact($db); |
|
260 | + $contact2->lastname = 'Service livraison - '.$fields[47]; |
|
261 | + $contact2->address = $fields[48]; |
|
262 | + $contact2->zip = $fields[50]; |
|
263 | + $contact2->town = $fields[51]; |
|
264 | + $contact2->country_id=dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid'); |
|
265 | + $contact2->note_public=$fields[54]; |
|
266 | + $contact2->socid=$object->id; |
|
267 | + |
|
268 | + // Extrafields |
|
269 | + $contact2->array_options['options_anazoneliv']=price2num($fields[53]); |
|
270 | + |
|
271 | + $ret1=$contact2->create($user); |
|
272 | + if ($ret1 > 0) |
|
273 | + { |
|
274 | + //$ret2=$contact2->add_contact($object->id, 'SHIPPING'); |
|
275 | + } |
|
276 | + if ($ret1 < 0 || $ret2 < 0) |
|
277 | 277 | { |
278 | 278 | print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString(); |
279 | 279 | $errorrecord++; |
280 | 280 | } |
281 | - else |
|
282 | - { |
|
283 | - print " - create contact OK"; |
|
284 | - } |
|
285 | - } |
|
281 | + else |
|
282 | + { |
|
283 | + print " - create contact OK"; |
|
284 | + } |
|
285 | + } |
|
286 | 286 | |
287 | 287 | |
288 | - print "\n"; |
|
288 | + print "\n"; |
|
289 | 289 | |
290 | - if ($errorrecord) |
|
291 | - { |
|
292 | - fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n"); |
|
293 | - $error++; // $errorrecord will be reset |
|
294 | - } |
|
290 | + if ($errorrecord) |
|
291 | + { |
|
292 | + fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n"); |
|
293 | + $error++; // $errorrecord will be reset |
|
294 | + } |
|
295 | 295 | } |
296 | 296 | |
297 | 297 |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | $ret=$user->fetch('','admin'); |
82 | 82 | if (! $ret > 0) |
83 | 83 | { |
84 | - print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
85 | - exit; |
|
84 | + print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
85 | + exit; |
|
86 | 86 | } |
87 | 87 | $user->getrights(); |
88 | 88 | |
@@ -143,18 +143,18 @@ discard block |
||
143 | 143 | print " - Error in create result code = ".$ret." - ".$object->errorsToString(); |
144 | 144 | $errorrecord++; |
145 | 145 | } |
146 | - else |
|
147 | - { |
|
148 | - print " - Creation OK with login ".$object->login." - id = ".$ret; |
|
149 | - } |
|
150 | - |
|
151 | - print "\n"; |
|
152 | - |
|
153 | - if ($errorrecord) |
|
154 | - { |
|
155 | - fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n"); |
|
156 | - $error++; // $errorrecord will be reset |
|
157 | - } |
|
146 | + else |
|
147 | + { |
|
148 | + print " - Creation OK with login ".$object->login." - id = ".$ret; |
|
149 | + } |
|
150 | + |
|
151 | + print "\n"; |
|
152 | + |
|
153 | + if ($errorrecord) |
|
154 | + { |
|
155 | + fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n"); |
|
156 | + $error++; // $errorrecord will be reset |
|
157 | + } |
|
158 | 158 | } |
159 | 159 | |
160 | 160 |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | $ret=$user->fetch('','admin'); |
82 | 82 | if (! $ret > 0) |
83 | 83 | { |
84 | - print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
85 | - exit; |
|
84 | + print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
85 | + exit; |
|
86 | 86 | } |
87 | 87 | $user->getrights(); |
88 | 88 | |
@@ -164,56 +164,56 @@ discard block |
||
164 | 164 | print " - Error in create result code = ".$ret." - ".$produit->errorsToString(); |
165 | 165 | $errorrecord++; |
166 | 166 | } |
167 | - else |
|
168 | - { |
|
169 | - print " - Creation OK with ref ".$produit->ref." - id = ".$ret; |
|
170 | - } |
|
167 | + else |
|
168 | + { |
|
169 | + print " - Creation OK with ref ".$produit->ref." - id = ".$ret; |
|
170 | + } |
|
171 | 171 | |
172 | - dol_syslog("Add prices"); |
|
172 | + dol_syslog("Add prices"); |
|
173 | 173 | |
174 | 174 | // If we use price level, insert price for each level |
175 | - if (! $errorrecord && 1) |
|
176 | - { |
|
177 | - $ret1=$produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array()); |
|
178 | - $ret2=$produit->updatePrice(price2num($fields[14]), 'HT', $user, $produit->tva_tx, $produit->price_min, 2, $produit->tva_npr, 0, 0, array()); |
|
179 | - if ($ret1 < 0 || $ret2 < 0) |
|
175 | + if (! $errorrecord && 1) |
|
176 | + { |
|
177 | + $ret1=$produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array()); |
|
178 | + $ret2=$produit->updatePrice(price2num($fields[14]), 'HT', $user, $produit->tva_tx, $produit->price_min, 2, $produit->tva_npr, 0, 0, array()); |
|
179 | + if ($ret1 < 0 || $ret2 < 0) |
|
180 | 180 | { |
181 | 181 | print " - Error in updatePrice result code = ".$ret1." ".$ret2." - ".$produit->errorsToString(); |
182 | 182 | $errorrecord++; |
183 | 183 | } |
184 | - else |
|
185 | - { |
|
186 | - print " - updatePrice OK"; |
|
187 | - } |
|
188 | - } |
|
184 | + else |
|
185 | + { |
|
186 | + print " - updatePrice OK"; |
|
187 | + } |
|
188 | + } |
|
189 | 189 | |
190 | - dol_syslog("Add multilangs"); |
|
190 | + dol_syslog("Add multilangs"); |
|
191 | 191 | |
192 | - // Add alternative languages |
|
193 | - if (! $errorrecord && 1) |
|
194 | - { |
|
195 | - $produit->multilangs['fr_FR']=array('label'=>$produit->label, 'description'=>$produit->description, 'note'=>$produit->note_private); |
|
196 | - $produit->multilangs['en_US']=array('label'=>$fields[3], 'description'=>$produit->description, 'note'=>$produit->note_private); |
|
192 | + // Add alternative languages |
|
193 | + if (! $errorrecord && 1) |
|
194 | + { |
|
195 | + $produit->multilangs['fr_FR']=array('label'=>$produit->label, 'description'=>$produit->description, 'note'=>$produit->note_private); |
|
196 | + $produit->multilangs['en_US']=array('label'=>$fields[3], 'description'=>$produit->description, 'note'=>$produit->note_private); |
|
197 | 197 | |
198 | - $ret=$produit->setMultiLangs($user); |
|
198 | + $ret=$produit->setMultiLangs($user); |
|
199 | 199 | if ($ret < 0) |
200 | 200 | { |
201 | 201 | print " - Error in setMultiLangs result code = ".$ret." - ".$produit->errorsToString(); |
202 | 202 | $errorrecord++; |
203 | 203 | } |
204 | - else |
|
205 | - { |
|
206 | - print " - setMultiLangs OK"; |
|
207 | - } |
|
208 | - } |
|
209 | - |
|
210 | - print "\n"; |
|
211 | - |
|
212 | - if ($errorrecord) |
|
213 | - { |
|
214 | - fwrite($fhandleerr, 'Error on record nb '.$i." - ".$produit->errorsToString()."\n"); |
|
215 | - $error++; // $errorrecord will be reset |
|
216 | - } |
|
204 | + else |
|
205 | + { |
|
206 | + print " - setMultiLangs OK"; |
|
207 | + } |
|
208 | + } |
|
209 | + |
|
210 | + print "\n"; |
|
211 | + |
|
212 | + if ($errorrecord) |
|
213 | + { |
|
214 | + fwrite($fhandleerr, 'Error on record nb '.$i." - ".$produit->errorsToString()."\n"); |
|
215 | + $error++; // $errorrecord will be reset |
|
216 | + } |
|
217 | 217 | } |
218 | 218 | |
219 | 219 |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | $ret=$user->fetch('','admin'); |
53 | 53 | if (! $ret > 0) |
54 | 54 | { |
55 | - print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
56 | - exit; |
|
55 | + print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
56 | + exit; |
|
57 | 57 | } |
58 | 58 | $user->getrights(); |
59 | 59 | |
@@ -61,21 +61,21 @@ discard block |
||
61 | 61 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array(); |
62 | 62 | $resql=$db->query($sql); |
63 | 63 | if ($resql) { |
64 | - $num = $db->num_rows($resql); $i = 0; |
|
65 | - while ($i < $num) { $row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++; } |
|
64 | + $num = $db->num_rows($resql); $i = 0; |
|
65 | + while ($i < $num) { $row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++; } |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array(); |
69 | 69 | $resql=$db->query($sql); |
70 | 70 | if ($resql) { |
71 | - $num = $db->num_rows($resql); $i = 0; |
|
71 | + $num = $db->num_rows($resql); $i = 0; |
|
72 | 72 | while ($i < $num) { $row = $db->fetch_row($resql); $societesid[$i] = $row[0]; $i++; } |
73 | 73 | } else { print "err"; } |
74 | 74 | |
75 | 75 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array(); |
76 | 76 | $resql=$db->query($sql); |
77 | 77 | if ($resql) { |
78 | - $num = $db->num_rows($resql); $i = 0; |
|
78 | + $num = $db->num_rows($resql); $i = 0; |
|
79 | 79 | while ($i < $num) { $row = $db->fetch_row($resql); $commandesid[$i] = $row[0]; $i++; } |
80 | 80 | } else { print "err"; } |
81 | 81 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $produit->tva_tx = "19.6"; |
95 | 95 | $ret=$produit->create($user); |
96 | 96 | if ($ret < 0) print "Error $ret - ".$produit->error."\n"; |
97 | - else print " OK with ref ".$produit->ref."\n"; |
|
97 | + else print " OK with ref ".$produit->ref."\n"; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 |