41 include_once
'inc.php';
42 if (!file_exists($conffile))
44 print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").';
46 require_once $conffile;
47 require_once $dolibarr_main_document_root.
'/compta/facture/class/facture.class.php';
48 require_once $dolibarr_main_document_root.
'/comm/propal/class/propal.class.php';
49 require_once $dolibarr_main_document_root.
'/contrat/class/contrat.class.php';
50 require_once $dolibarr_main_document_root.
'/commande/class/commande.class.php';
51 require_once $dolibarr_main_document_root.
'/fourn/class/fournisseur.commande.class.php';
52 require_once $dolibarr_main_document_root.
'/core/lib/price.lib.php';
53 require_once $dolibarr_main_document_root.
'/core/class/menubase.class.php';
54 require_once $dolibarr_main_document_root.
'/core/lib/files.lib.php';
65 $err = error_reporting();
67 if (!empty($conf->global->MAIN_OVERRIDE_TIME_LIMIT))
68 @set_time_limit((
int) $conf->global->MAIN_OVERRIDE_TIME_LIMIT);
69 else @set_time_limit(600);
70 error_reporting($err);
72 $setuplang =
GETPOST(
"selectlang",
'aZ09', 3) ?
GETPOST(
"selectlang",
'aZ09', 3) :
'auto';
73 $langs->setDefaultLang($setuplang);
74 $versionfrom =
GETPOST(
"versionfrom",
'alpha', 3) ?
GETPOST(
"versionfrom",
'alpha', 3) : (empty($argv[1]) ?
'' : $argv[1]);
75 $versionto =
GETPOST(
"versionto",
'alpha', 3) ?
GETPOST(
"versionto",
'alpha', 3) : (empty($argv[2]) ?
'' : $argv[2]);
76 $enablemodules =
GETPOST(
"enablemodules",
'alpha', 3) ?
GETPOST(
"enablemodules",
'alpha', 3) : (empty($argv[3]) ?
'' : $argv[3]);
78 $langs->loadLangs(array(
"admin",
"install",
"bills",
"suppliers"));
80 if ($dolibarr_main_db_type ==
'mysqli') $choix = 1;
81 if ($dolibarr_main_db_type ==
'pgsql') $choix = 2;
82 if ($dolibarr_main_db_type ==
'mssql') $choix = 3;
85 dolibarr_install_syslog(
"--- upgrade2: entering upgrade2.php page ".$versionfrom.
" ".$versionto.
" ".$enablemodules);
94 if ((!$versionfrom || preg_match(
'/version/', $versionfrom)) && (!$versionto || preg_match(
'/version/', $versionto)))
96 print 'Error: Parameter versionfrom or versionto missing or having a bad format.'.
"\n";
97 print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'.
"\n";
99 $sapi_type = php_sapi_name();
100 $script_file = basename(__FILE__);
102 if (substr($sapi_type, 0, 3) ==
'cli')
104 print 'Syntax from command line: '.$script_file.
" x.y.z a.b.c [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE...]\n";
109 pHeader(
'',
'step5',
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'upgrade',
'versionfrom='.$versionfrom.
'&versionto='.$versionto);
112 if (!
GETPOST(
'action',
'aZ09') || preg_match(
'/upgrade/i',
GETPOST(
'action',
'aZ09')))
114 print '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> '.$langs->trans(
'DataMigration').
'</h3>';
116 print '<table cellspacing="0" cellpadding="1" border="0" width="100%">';
119 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass))
121 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
122 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass))
124 $dolibarr_main_db_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
125 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_pass);
126 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
127 }
else $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
131 $conf->db->type = $dolibarr_main_db_type;
132 $conf->db->host = $dolibarr_main_db_host;
133 $conf->db->port = $dolibarr_main_db_port;
134 $conf->db->name = $dolibarr_main_db_name;
135 $conf->db->user = $dolibarr_main_db_user;
136 $conf->db->pass = $dolibarr_main_db_pass;
138 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
141 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
143 $hookmanager->initHooks(array(
'upgrade'));
147 print '<tr><td colspan="4">'.$langs->trans(
"ErrorFailedToConnectToDatabase", $conf->db->name).
'</td><td class="right">'.$langs->trans(
'Error').
'</td></tr>';
148 dolibarr_install_syslog(
'upgrade2: failed to connect to database :'.$conf->db->name.
' on '.$conf->db->host.
' for user '.$conf->db->user, LOG_ERR);
154 if ($db->database_selected)
162 if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0;
163 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
164 if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey =
'';
165 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
170 $conf->setValues($db);
172 if (defined(
'SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
173 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
188 $dolibarrlastupgradeversionarray = preg_split(
'/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL :
''));
194 $versiontoarray = explode(
'.', $versionto);
195 $versionranarray = explode(
'.', DOL_VERSION);
199 $sql =
'ALTER TABLE '.MAIN_DB_PREFIX.
'user ADD COLUMN birth date';
201 $sql =
'ALTER TABLE '.MAIN_DB_PREFIX.
'user ADD COLUMN dateemployment date';
203 $sql =
'ALTER TABLE '.MAIN_DB_PREFIX.
'user ADD COLUMN dateemploymentend date';
205 $sql =
'ALTER TABLE '.MAIN_DB_PREFIX.
'user ADD COLUMN default_range integer';
207 $sql =
'ALTER TABLE '.MAIN_DB_PREFIX.
'user ADD COLUMN default_c_exp_tax_cat integer';
209 $sql =
'ALTER TABLE '.MAIN_DB_PREFIX.
'extrafields ADD COLUMN langs varchar(24)';
211 $sql =
'ALTER TABLE '.MAIN_DB_PREFIX.
'extrafields ADD COLUMN fieldcomputed text';
213 $sql =
'ALTER TABLE '.MAIN_DB_PREFIX.
'extrafields ADD COLUMN fielddefault varchar(255)';
215 $sql =
'ALTER TABLE '.MAIN_DB_PREFIX.
"extrafields ADD COLUMN enabled varchar(255) DEFAULT '1'";
217 $sql =
'ALTER TABLE '.MAIN_DB_PREFIX.
'extrafields ADD COLUMN help text';
219 $sql =
'ALTER TABLE '.MAIN_DB_PREFIX.
'user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL';
223 $afterversionarray = explode(
'.',
'2.0.0');
224 $beforeversionarray = explode(
'.',
'2.7.9');
286 $afterversionarray = explode(
'.',
'2.7.9');
287 $beforeversionarray = explode(
'.',
'2.8.9');
313 $afterversionarray = explode(
'.',
'2.8.9');
314 $beforeversionarray = explode(
'.',
'2.9.9');
327 $afterversionarray = explode(
'.',
'2.9.9');
328 $beforeversionarray = explode(
'.',
'3.0.9');
335 $afterversionarray = explode(
'.',
'3.0.9');
336 $beforeversionarray = explode(
'.',
'3.1.9');
345 $afterversionarray = explode(
'.',
'3.1.9');
346 $beforeversionarray = explode(
'.',
'3.2.9');
357 $afterversionarray = explode(
'.',
'3.2.9');
358 $beforeversionarray = explode(
'.',
'3.3.9');
368 $afterversionarray = explode(
'.',
'3.6.9');
369 $beforeversionarray = explode(
'.',
'3.7.9');
376 $afterversionarray = explode(
'.',
'3.7.9');
377 $beforeversionarray = explode(
'.',
'3.8.9');
384 $afterversionarray = explode(
'.',
'3.9.9');
385 $beforeversionarray = explode(
'.',
'4.0.9');
392 $afterversionarray = explode(
'.',
'4.0.9');
393 $beforeversionarray = explode(
'.',
'5.0.9');
404 $afterversionarray = explode(
'.',
'5.0.9');
405 $beforeversionarray = explode(
'.',
'6.0.9');
408 if (!empty($conf->multicompany->enabled))
410 global $multicompany_transverse_mode;
413 if (empty($multicompany_transverse_mode))
425 $afterversionarray = explode(
'.',
'6.0.9');
426 $beforeversionarray = explode(
'.',
'7.0.9');
436 $afterversionarray = explode(
'.',
'7.0.9');
437 $beforeversionarray = explode(
'.',
'8.0.9');
444 $afterversionarray = explode(
'.',
'8.0.9');
445 $beforeversionarray = explode(
'.',
'9.0.9');
452 $afterversionarray = explode(
'.',
'10.0.9');
453 $beforeversionarray = explode(
'.',
'11.0.9');
466 $listofmodule = array(
467 'MAIN_MODULE_ACCOUNTING'=>
'newboxdefonly',
468 'MAIN_MODULE_AGENDA'=>
'newboxdefonly',
469 'MAIN_MODULE_BARCODE'=>
'newboxdefonly',
470 'MAIN_MODULE_CRON'=>
'newboxdefonly',
471 'MAIN_MODULE_COMMANDE'=>
'newboxdefonly',
472 'MAIN_MODULE_DEPLACEMENT'=>
'newboxdefonly',
473 'MAIN_MODULE_DON'=>
'newboxdefonly',
474 'MAIN_MODULE_ECM'=>
'newboxdefonly',
475 'MAIN_MODULE_EXTERNALSITE'=>
'newboxdefonly',
476 'MAIN_MODULE_EXPENSEREPORT'=>
'newboxdefonly',
477 'MAIN_MODULE_FACTURE'=>
'newboxdefonly',
478 'MAIN_MODULE_FOURNISSEUR'=>
'newboxdefonly',
479 'MAIN_MODULE_HOLIDAY'=>
'newboxdefonly',
480 'MAIN_MODULE_OPENSURVEY'=>
'newboxdefonly',
481 'MAIN_MODULE_PAYBOX'=>
'newboxdefonly',
482 'MAIN_MODULE_PRINTING'=>
'newboxdefonly',
483 'MAIN_MODULE_PRODUIT'=>
'newboxdefonly',
484 'MAIN_MODULE_RESOURCE'=>
'newboxdefonly',
485 'MAIN_MODULE_SALARIES'=>
'newboxdefonly',
486 'MAIN_MODULE_SYSLOG'=>
'newboxdefonly',
487 'MAIN_MODULE_SOCIETE'=>
'newboxdefonly',
488 'MAIN_MODULE_SERVICE'=>
'newboxdefonly',
489 'MAIN_MODULE_TICKET'=>
'newboxdefonly',
490 'MAIN_MODULE_TAKEPOS'=>
'newboxdefonly',
491 'MAIN_MODULE_USER'=>
'newboxdefonly',
492 'MAIN_MODULE_VARIANTS'=>
'newboxdefonly',
493 'MAIN_MODULE_WEBSITE'=>
'newboxdefonly',
503 if (!$error && $enablemodules)
506 $listofmodules = array();
507 $enablemodules = preg_replace(
'/enablemodules=/',
'', $enablemodules);
508 $tmplistofmodules = explode(
',', $enablemodules);
509 foreach ($tmplistofmodules as $value)
511 $listofmodules[$value] =
'forceactivate';
515 if ($resultreloadmodules < 0) {
524 $parameters = array(
'versionfrom'=>$versionfrom,
'versionto='.$versionto);
525 $object =
new stdClass();
527 $reshook = $hookmanager->executeHooks(
'doUpgrade2', $parameters, $object, $action);
528 if ($hookmanager->resNbOfHooks > 0)
532 print '<tr><td colspan="4">';
533 print '<b>'.$langs->trans(
'UpgradeExternalModule').
'</b>: ';
534 print $hookmanager->error;
535 print "<!-- (".$reshook.
") -->";
538 print '<tr><td colspan="4">';
539 print '<b>'.$langs->trans(
'UpgradeExternalModule').
'</b>: <span class="ok">OK</span>';
540 print "<!-- (".$reshook.
") -->";
545 if (!empty($conf->modules_parts[
'hooks']))
547 print '<tr><td colspan="4">';
548 print '<b>'.$langs->trans(
'UpgradeExternalModule').
'</b>: '.$langs->trans(
"None");
557 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"const SET VALUE = 'torefresh' WHERE name = 'MAIN_FIRST_PING_OK_ID'";
568 $srcroot = DOL_DOCUMENT_ROOT.
'/install/medias';
569 $destroot = DOL_DATA_ROOT.
'/medias';
581 print '<div><br>'.$langs->trans(
"MigrationFinished").
'</div>';
583 print '<div class="error">'.$langs->trans(
'ErrorWrongParameters').
'</div>';
588 if ($error && isset($argv[1])) $ret = 1;
592 pFooter($error ? 2 : 0, $setuplang);
594 if ($db->connected) $db->close();
597 if ($ret) exit($ret);
611 print '<tr><td colspan="4">';
614 print '<b>'.$langs->trans(
'MigrationPaymentsUpdate').
"</b><br>\n";
616 $result = $db->DDLDescTable(MAIN_DB_PREFIX.
"paiement",
"fk_facture");
617 $obj = $db->fetch_object($result);
620 $sql =
"SELECT p.rowid, p.fk_facture, p.amount";
621 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement as p";
622 $sql .=
" WHERE p.fk_facture > 0";
624 $resql = $db->query($sql);
631 $num = $db->num_rows(
$resql);
635 $obj = $db->fetch_object(
$resql);
636 $row[$i][0] = $obj->rowid;
637 $row[$i][1] = $obj->fk_facture;
638 $row[$i][2] = $obj->amount;
647 print $langs->trans(
'MigrationPaymentsNumberToUpdate', $num).
"<br>\n";
652 for ($i = 0; $i < $num; $i++)
654 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"paiement_facture (fk_facture, fk_paiement, amount)";
655 $sql .=
" VALUES (".$row[$i][1].
",".$row[$i][0].
",".$row[$i][2].
")";
657 $res += $db->query($sql);
659 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"paiement SET fk_facture = 0 WHERE rowid = ".$row[$i][0];
661 $res += $db->query($sql);
663 print $langs->trans(
'MigrationProcessPaymentUpdate', $row[$i][0]).
"<br>\n";
667 if ($res == (2 * count($row)))
670 print $langs->trans(
'MigrationSuccessfullUpdate').
"<br>";
673 print $langs->trans(
'MigrationUpdateFailed').
'<br>';
676 print $langs->trans(
'MigrationPaymentsNothingToUpdate').
"<br>\n";
679 print $langs->trans(
'MigrationPaymentsNothingToUpdate').
"<br>\n";
697 print '<tr><td colspan="4">';
700 print '<b>'.$langs->trans(
'MigrationPaymentsUpdate').
"</b><br>\n";
702 $result = $db->DDLDescTable(MAIN_DB_PREFIX.
"paiement",
"fk_facture");
703 $obj = $db->fetch_object($result);
707 $sql =
"SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,";
708 $sql .=
" bu2.url_id as socid";
709 $sql .=
" FROM (".MAIN_DB_PREFIX.
"paiement as p, ".MAIN_DB_PREFIX.
"bank_url as bu, ".MAIN_DB_PREFIX.
"bank as b)";
710 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement_facture as pf ON pf.fk_paiement = p.rowid";
711 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')";
712 $sql .=
" WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid";
713 $sql .=
" AND b.rappro = 1";
714 $sql .=
" AND (p.fk_facture = 0 OR p.fk_facture IS NULL)";
716 $resql = $db->query($sql);
723 $num = $db->num_rows(
$resql);
727 $obj = $db->fetch_object(
$resql);
728 if ($obj->pamount == $obj->bamount && $obj->socid)
730 $row[$j][
'paymentid'] = $obj->rowid;
731 $row[$j][
'pamount'] = $obj->pamount;
732 $row[$j][
'fk_bank'] = $obj->fk_bank;
733 $row[$j][
'bamount'] = $obj->bamount;
734 $row[$j][
'socid'] = $obj->socid;
735 $row[$j][
'datec'] = $obj->datec;
746 print $langs->trans(
'OrphelinsPaymentsDetectedByMethod', 1).
': '.count($row).
"<br>\n";
751 for ($i = 0; $i < $num; $i++)
753 if ($conf->global->MAIN_FEATURES_LEVEL == 2)
print '* '.$row[$i][
'datec'].
' paymentid='.$row[$i][
'paymentid'].
' pamount='.$row[$i][
'pamount'].
' fk_bank='.$row[$i][
'fk_bank'].
' bamount='.$row[$i][
'bamount'].
' socid='.$row[$i][
'socid'].
'<br>';
756 $sql =
" SELECT distinct f.rowid from ".MAIN_DB_PREFIX.
"facture as f";
757 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement_facture as pf ON f.rowid = pf.fk_facture";
758 $sql .=
" WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i][
'socid'].
" AND total_ttc = ".$row[$i][
'pamount'];
759 $sql .=
" AND pf.fk_facture IS NULL";
760 $sql .=
" ORDER BY f.fk_statut";
762 $resql = $db->query($sql);
765 $num = $db->num_rows(
$resql);
769 $obj = $db->fetch_object(
$resql);
770 $facid = $obj->rowid;
772 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"paiement_facture (fk_facture, fk_paiement, amount)";
773 $sql .=
" VALUES (".$facid.
",".$row[$i][
'paymentid'].
",".$row[$i][
'pamount'].
")";
775 $res += $db->query($sql);
777 print $langs->trans(
'MigrationProcessPaymentUpdate',
'facid='.$facid.
'-paymentid='.$row[$i][
'paymentid'].
'-amount='.$row[$i][
'pamount']).
"<br>\n";
786 print $langs->trans(
'MigrationSuccessfullUpdate').
"<br>";
788 print $langs->trans(
'MigrationPaymentsNothingUpdatable').
"<br>\n";
793 print $langs->trans(
'MigrationPaymentsNothingUpdatable').
"<br>\n";
796 print $langs->trans(
'MigrationPaymentsNothingUpdatable').
"<br>\n";
814 print '<tr><td colspan="4">';
817 print '<b>'.$langs->trans(
'MigrationPaymentsUpdate').
"</b><br>\n";
819 $result = $db->DDLDescTable(MAIN_DB_PREFIX.
"paiement",
"fk_facture");
820 $obj = $db->fetch_object($result);
824 $sql =
"SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,";
825 $sql .=
" bu2.url_id as socid";
826 $sql .=
" FROM (".MAIN_DB_PREFIX.
"paiement as p, ".MAIN_DB_PREFIX.
"bank_url as bu, ".MAIN_DB_PREFIX.
"bank as b)";
827 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement_facture as pf ON pf.fk_paiement = p.rowid";
828 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')";
829 $sql .=
" WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid";
830 $sql .=
" AND (p.fk_facture = 0 OR p.fk_facture IS NULL)";
832 $resql = $db->query($sql);
839 $num = $db->num_rows(
$resql);
843 $obj = $db->fetch_object(
$resql);
844 if ($obj->pamount == $obj->bamount && $obj->socid)
846 $row[$j][
'paymentid'] = $obj->rowid;
847 $row[$j][
'pamount'] = $obj->pamount;
848 $row[$j][
'fk_bank'] = $obj->fk_bank;
849 $row[$j][
'bamount'] = $obj->bamount;
850 $row[$j][
'socid'] = $obj->socid;
851 $row[$j][
'datec'] = $obj->datec;
865 print $langs->trans(
'OrphelinsPaymentsDetectedByMethod', 2).
': '.count($row).
"<br>\n";
869 for ($i = 0; $i < $num; $i++)
871 if ($conf->global->MAIN_FEATURES_LEVEL == 2)
print '* '.$row[$i][
'datec'].
' paymentid='.$row[$i][
'paymentid'].
' '.$row[$i][
'pamount'].
' fk_bank='.$row[$i][
'fk_bank'].
' '.$row[$i][
'bamount'].
' socid='.$row[$i][
'socid'].
'<br>';
874 $sql =
" SELECT distinct f.rowid from ".MAIN_DB_PREFIX.
"facture as f";
875 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement_facture as pf ON f.rowid = pf.fk_facture";
876 $sql .=
" WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i][
'socid'].
" AND total_ttc = ".$row[$i][
'pamount'];
877 $sql .=
" AND pf.fk_facture IS NULL";
878 $sql .=
" ORDER BY f.fk_statut";
880 $resql = $db->query($sql);
883 $num = $db->num_rows(
$resql);
887 $obj = $db->fetch_object(
$resql);
888 $facid = $obj->rowid;
890 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"paiement_facture (fk_facture, fk_paiement, amount)";
891 $sql .=
" VALUES (".$facid.
",".$row[$i][
'paymentid'].
",".$row[$i][
'pamount'].
")";
892 $res += $db->query($sql);
894 print $langs->trans(
'MigrationProcessPaymentUpdate',
'facid='.$facid.
'-paymentid='.$row[$i][
'paymentid'].
'-amount='.$row[$i][
'pamount']).
"<br>\n";
904 print $langs->trans(
'MigrationSuccessfullUpdate').
"<br>";
906 print $langs->trans(
'MigrationPaymentsNothingUpdatable').
"<br>\n";
911 print $langs->trans(
'MigrationPaymentsNothingUpdatable').
"<br>\n";
917 $sql =
"ALTER TABLE ".MAIN_DB_PREFIX.
"paiement DROP COLUMN fk_facture";
928 print $langs->trans(
'MigrationPaymentsNothingUpdatable').
"<br>\n";
945 print '<tr><td colspan="4">';
950 print '<b>'.$langs->trans(
'MigrationContractsUpdate').
"</b><br>\n";
952 $sql =
"SELECT c.rowid as cref, c.date_contrat, c.statut, c.fk_product, c.fk_facture, c.fk_user_author,";
953 $sql .=
" p.ref, p.label, p.description, p.price, p.tva_tx, p.duration, cd.rowid";
954 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c";
955 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p";
956 $sql .=
" ON c.fk_product = p.rowid";
957 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"contratdet as cd";
958 $sql .=
" ON c.rowid=cd.fk_contrat";
959 $sql .=
" WHERE cd.rowid IS NULL AND p.rowid IS NOT NULL";
960 $resql = $db->query($sql);
967 $num = $db->num_rows(
$resql);
971 print $langs->trans(
'MigrationContractsNumberToUpdate', $num).
"<br>\n";
976 $obj = $db->fetch_object(
$resql);
978 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"contratdet (";
979 $sql .=
"fk_contrat, fk_product, statut, label, description,";
980 $sql .=
"date_ouverture_prevue, date_ouverture, date_fin_validite, tva_tx, qty,";
981 $sql .=
"subprice, price_ht, fk_user_author, fk_user_ouverture)";
983 $sql .= $obj->cref.
", ".($obj->fk_product ? $obj->fk_product : 0).
", ";
985 $sql .=
"'".$db->escape($obj->label).
"', null, ";
986 $sql .= ($obj->date_contrat ?
"'".$db->escape($obj->date_contrat).
"'" :
"null").
", ";
989 $sql .=
"'".$db->escape($obj->tva_tx).
"' , 1, ";
990 $sql .=
"'".$db->escape($obj->price).
"', '".$db->escape($obj->price).
"', ".$obj->fk_user_author.
",";
994 if ($db->query($sql))
996 print $langs->trans(
'MigrationContractsLineCreation', $obj->cref).
"<br>\n";
1009 print $langs->trans(
'MigrationSuccessfullUpdate').
"<br>";
1012 print $langs->trans(
'MigrationUpdateFailed').
'<br>';
1015 print $langs->trans(
'MigrationContractsNothingToUpdate').
"<br>\n";
1018 print $langs->trans(
'MigrationContractsFieldDontExist').
"<br>\n";
1035 print '<tr><td colspan="4">';
1040 print '<b>'.$langs->trans(
'MigrationBankTransfertsUpdate').
"</b><br>\n";
1042 $sql =
"SELECT ba.rowid as barowid, bb.rowid as bbrowid";
1043 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as bb, ".MAIN_DB_PREFIX.
"bank as ba";
1044 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_url as bu ON bu.fk_bank = ba.rowid";
1045 $sql .=
" WHERE ba.amount = -bb.amount AND ba.fk_account <> bb.fk_account";
1046 $sql .=
" AND ba.datev = bb.datev AND ba.datec = bb.datec";
1047 $sql .=
" AND bu.fk_bank IS NULL";
1048 $resql = $db->query($sql);
1055 $num = $db->num_rows(
$resql);
1059 print $langs->trans(
'MigrationBankTransfertsToUpdate', $num).
"<br>\n";
1064 $obj = $db->fetch_object(
$resql);
1066 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_url (";
1067 $sql .=
"fk_bank, url_id, url, label, type";
1069 $sql .=
" VALUES (";
1070 $sql .= $obj->barowid.
",".$obj->bbrowid.
", '/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'";
1076 if (!$db->query($sql))
1089 print $langs->trans(
'MigrationSuccessfullUpdate').
"<br>";
1092 print $langs->trans(
'MigrationUpdateFailed').
'<br>';
1095 print $langs->trans(
'MigrationBankTransfertsNothingToUpdate').
"<br>\n";
1114 print '<tr><td colspan="4">';
1117 print '<b>'.$langs->trans(
'MigrationContractsEmptyDatesUpdate').
"</b><br>\n";
1119 $sql =
"update ".MAIN_DB_PREFIX.
"contrat set date_contrat=tms where date_contrat is null";
1121 $resql = $db->query($sql);
1123 if ($db->affected_rows(
$resql) > 0)
1124 print $langs->trans(
'MigrationContractsEmptyDatesUpdateSuccess').
"<br>\n";
1125 else print $langs->trans(
'MigrationContractsEmptyDatesNothingToUpdate').
"<br>\n";
1127 $sql =
"update ".MAIN_DB_PREFIX.
"contrat set datec=tms where datec is null";
1129 $resql = $db->query($sql);
1131 if ($db->affected_rows(
$resql) > 0)
1132 print $langs->trans(
'MigrationContractsEmptyCreationDatesUpdateSuccess').
"<br>\n";
1133 else print $langs->trans(
'MigrationContractsEmptyCreationDatesNothingToUpdate').
"<br>\n";
1148 print '<tr><td colspan="4">';
1153 print '<b>'.$langs->trans(
'MigrationContractsInvalidDatesUpdate').
"</b><br>\n";
1155 $sql =
"SELECT c.rowid as cref, c.datec, c.date_contrat, MIN(cd.date_ouverture) as datemin";
1156 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c,";
1157 $sql .=
" ".MAIN_DB_PREFIX.
"contratdet as cd";
1158 $sql .=
" WHERE c.rowid=cd.fk_contrat AND cd.date_ouverture IS NOT NULL";
1159 $sql .=
" GROUP BY c.rowid, c.date_contrat";
1160 $resql = $db->query($sql);
1167 $num = $db->num_rows(
$resql);
1171 $nbcontratsmodifie = 0;
1176 $obj = $db->fetch_object(
$resql);
1177 if ($obj->date_contrat > $obj->datemin)
1179 $datemin = $db->jdate($obj->datemin);
1181 print $langs->trans(
'MigrationContractsInvalidDateFix', $obj->cref, $obj->date_contrat, $obj->datemin).
"<br>\n";
1182 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"contrat";
1183 $sql .=
" SET date_contrat='".$db->idate($datemin).
"'";
1184 $sql .=
" WHERE rowid=".$obj->cref;
1185 $resql2 = $db->query($sql);
1188 $nbcontratsmodifie++;
1195 if ($nbcontratsmodifie)
1196 print $langs->trans(
'MigrationContractsInvalidDatesNumber', $nbcontratsmodifie).
"<br>\n";
1197 else print $langs->trans(
'MigrationContractsInvalidDatesNothingToUpdate').
"<br>\n";
1216 print '<tr><td colspan="4">';
1219 print '<b>'.$langs->trans(
'MigrationContractsIncoherentCreationDateUpdate').
"</b><br>\n";
1221 $sql =
"update ".MAIN_DB_PREFIX.
"contrat set datec=date_contrat where datec is null or datec > date_contrat";
1223 $resql = $db->query($sql);
1225 if ($db->affected_rows(
$resql) > 0)
1226 print $langs->trans(
'MigrationContractsIncoherentCreationDateUpdateSuccess').
"<br>\n";
1227 else print $langs->trans(
'MigrationContractsIncoherentCreationDateNothingToUpdate').
"<br>\n";
1242 print '<tr><td colspan="4">';
1245 print '<b>'.$langs->trans(
'MigrationReopeningContracts').
"</b><br>\n";
1247 $sql =
"SELECT c.rowid as cref FROM ".MAIN_DB_PREFIX.
"contrat as c, ".MAIN_DB_PREFIX.
"contratdet as cd";
1248 $sql .=
" WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat";
1250 $resql = $db->query($sql);
1252 if ($db->affected_rows(
$resql) > 0) {
1255 $num = $db->num_rows(
$resql);
1259 $nbcontratsmodifie = 0;
1264 $obj = $db->fetch_object(
$resql);
1266 print $langs->trans(
'MigrationReopenThisContract', $obj->cref).
"<br>\n";
1267 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"contrat";
1268 $sql .=
" SET statut=1";
1269 $sql .=
" WHERE rowid=".$obj->cref;
1270 $resql2 = $db->query($sql);
1273 $nbcontratsmodifie++;
1280 if ($nbcontratsmodifie)
1281 print $langs->trans(
'MigrationReopenedContractsNumber', $nbcontratsmodifie).
"<br>\n";
1282 else print $langs->trans(
'MigrationReopeningContractsNothingToUpdate').
"<br>\n";
1284 }
else print $langs->trans(
'MigrationReopeningContractsNothingToUpdate').
"<br>\n";
1301 print '<tr><td colspan="4">';
1303 print '<b>'.$langs->trans(
'SuppliersInvoices').
"</b><br>\n";
1306 $result = $db->DDLDescTable(MAIN_DB_PREFIX.
"paiementfourn",
"fk_facture_fourn");
1307 $obj = $db->fetch_object($result);
1313 $select_sql =
'SELECT rowid, fk_facture_fourn, amount';
1314 $select_sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn';
1315 $select_sql .=
' WHERE fk_facture_fourn IS NOT NULL';
1318 $select_resql = $db->query($select_sql);
1321 $select_num = $db->num_rows($select_resql);
1326 while (($i < $select_num) && (!$error))
1329 $select_obj = $db->fetch_object($select_resql);
1332 $check_sql =
'SELECT fk_paiementfourn, fk_facturefourn';
1333 $check_sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn';
1334 $check_sql .=
' WHERE fk_paiementfourn = '.$select_obj->rowid.
' AND fk_facturefourn = '.$select_obj->fk_facture_fourn;
1335 $check_resql = $db->query($check_sql);
1338 $check_num = $db->num_rows($check_resql);
1339 if ($check_num == 0)
1345 print '<tr><td colspan="4" class="nowrap"><b>'.$langs->trans(
'SuppliersInvoices').
'</b></td></tr>';
1346 print '<tr><td>fk_paiementfourn</td><td>fk_facturefourn</td><td>'.$langs->trans(
'Amount').
'</td><td> </td></tr>';
1349 print '<tr class="oddeven">';
1350 print '<td>'.$select_obj->rowid.
'</td><td>'.$select_obj->fk_facture_fourn.
'</td><td>'.$select_obj->amount.
'</td>';
1352 $insert_sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn SET ';
1353 $insert_sql .=
' fk_paiementfourn = \''.$select_obj->rowid.
'\',
';
1354 $insert_sql .= ' fk_facturefourn = \
''.$select_obj->fk_facture_fourn.
'\',
';
1355 $insert_sql .= ' amount = \
''.$select_obj->amount.
'\'';
1356 $insert_resql = $db->query($insert_sql);
1361 print '<td><span class="ok">'.$langs->trans(
"OK").
'</span></td>';
1363 print '<td><span class="error">Error on insert</span></td>';
1381 print '<tr><td>'.$langs->trans(
"AlreadyDone").
'</td></tr>';
1385 $sql =
"ALTER TABLE ".MAIN_DB_PREFIX.
"paiementfourn DROP COLUMN fk_facture_fourn";
1388 print '<tr><td>'.$langs->trans(
"Error").
'</td></tr>';
1392 print '<tr><td>'.$langs->trans(
"AlreadyDone").
'</td></tr>';
1409 $tmpmysoc->setMysoc($conf);
1413 print '<tr><td colspan="4">';
1416 print '<b>'.$langs->trans(
'MigrationInvoice').
"</b><br>\n";
1419 $sql =
"SELECT fd.rowid, fd.qty, fd.subprice, fd.remise_percent, fd.tva_tx as vatrate, fd.total_ttc, fd.info_bits,";
1420 $sql .=
" f.rowid as facid, f.remise_percent as remise_percent_global, f.total_ttc as total_ttc_f";
1421 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as fd, ".MAIN_DB_PREFIX.
"facture as f";
1422 $sql .=
" WHERE fd.fk_facture = f.rowid";
1423 $sql .=
" AND (((fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL) or f.total_ttc IS NULL)";
1427 $resql = $db->query($sql);
1430 $num = $db->num_rows(
$resql);
1436 $obj = $db->fetch_object(
$resql);
1438 $rowid = $obj->rowid;
1440 $pu = $obj->subprice;
1441 $vatrate = $obj->vatrate;
1442 $remise_percent = $obj->remise_percent;
1443 $remise_percent_global = $obj->remise_percent_global;
1444 $total_ttc_f = $obj->total_ttc_f;
1445 $info_bits = $obj->info_bits;
1449 $facligne->fetch($rowid);
1451 $result =
calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global,
'HT', $info_bits, $facligne->product_type, $tmpmysoc);
1452 $total_ht = $result[0];
1453 $total_tva = $result[1];
1454 $total_ttc = $result[2];
1456 $facligne->total_ht = $total_ht;
1457 $facligne->total_tva = $total_tva;
1458 $facligne->total_ttc = $total_ttc;
1460 dolibarr_install_syslog(
"upgrade2: line ".$rowid.
": facid=".$obj->facid.
" pu=".$pu.
" qty=".$qty.
" vatrate=".$vatrate.
" remise_percent=".$remise_percent.
" remise_global=".$remise_percent_global.
" -> ".$total_ht.
", ".$total_tva.
", ".$total_ttc);
1462 $facligne->update_total();
1469 $facture->id = $obj->facid;
1471 if ($facture->fetch($facture->id) >= 0)
1473 if ($facture->update_price() > 0)
1477 print "Error id=".$facture->id;
1490 print $langs->trans(
"AlreadyDone");
1496 print "Error #1 ".$db->error();
1518 $tmpmysoc->setMysoc($conf);
1522 print '<tr><td colspan="4">';
1525 print '<b>'.$langs->trans(
'MigrationProposal').
"</b><br>\n";
1528 $sql =
"SELECT pd.rowid, pd.qty, pd.subprice, pd.remise_percent, pd.tva_tx as vatrate, pd.info_bits,";
1529 $sql .=
" p.rowid as propalid, p.remise_percent as remise_percent_global";
1530 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propaldet as pd, ".MAIN_DB_PREFIX.
"propal as p";
1531 $sql .=
" WHERE pd.fk_propal = p.rowid";
1532 $sql .=
" AND ((pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL)";
1535 $resql = $db->query($sql);
1538 $num = $db->num_rows(
$resql);
1544 $obj = $db->fetch_object(
$resql);
1546 $rowid = $obj->rowid;
1548 $pu = $obj->subprice;
1549 $vatrate = $obj->vatrate;
1550 $remise_percent = $obj->remise_percent;
1551 $remise_percent_global = $obj->remise_percent_global;
1552 $info_bits = $obj->info_bits;
1556 $propalligne->fetch($rowid);
1558 $result =
calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global,
'HT', $info_bits, $propalligne->product_type, $tmpmysoc);
1559 $total_ht = $result[0];
1560 $total_tva = $result[1];
1561 $total_ttc = $result[2];
1563 $propalligne->total_ht = $total_ht;
1564 $propalligne->total_tva = $total_tva;
1565 $propalligne->total_ttc = $total_ttc;
1567 dolibarr_install_syslog(
"upgrade2: Line ".$rowid.
": propalid=".$obj->rowid.
" pu=".$pu.
" qty=".$qty.
" vatrate=".$vatrate.
" remise_percent=".$remise_percent.
" remise_global=".$remise_percent_global.
" -> ".$total_ht.
", ".$total_tva.
", ".$total_ttc);
1569 $propalligne->update_total();
1594 print $langs->trans(
"AlreadyDone");
1601 print "Error #1 ".$db->error();
1624 $tmpmysoc->setMysoc($conf);
1625 if (empty($tmpmysoc->country_id)) $tmpmysoc->country_id = 0;
1627 print '<tr><td colspan="4">';
1630 print '<b>'.$langs->trans(
'MigrationContract').
"</b><br>\n";
1633 $sql =
"SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,";
1634 $sql .=
" c.rowid as contratid";
1635 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contratdet as cd, ".MAIN_DB_PREFIX.
"contrat as c";
1636 $sql .=
" WHERE cd.fk_contrat = c.rowid";
1637 $sql .=
" AND ((cd.total_ttc = 0 AND cd.remise_percent != 100 AND cd.subprice > 0) or cd.total_ttc IS NULL)";
1640 $resql = $db->query($sql);
1643 $num = $db->num_rows(
$resql);
1649 $obj = $db->fetch_object(
$resql);
1651 $rowid = $obj->rowid;
1653 $pu = $obj->subprice;
1654 $vatrate = $obj->vatrate;
1655 $remise_percent = $obj->remise_percent;
1656 $info_bits = $obj->info_bits;
1661 $contratligne->fetch($rowid);
1663 $result =
calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, 0,
'HT', $info_bits, $contratligne->product_type, $tmpmysoc);
1664 $total_ht = $result[0];
1665 $total_tva = $result[1];
1666 $total_ttc = $result[2];
1668 $contratligne->total_ht = $total_ht;
1669 $contratligne->total_tva = $total_tva;
1670 $contratligne->total_ttc = $total_ttc;
1672 dolibarr_install_syslog(
"upgrade2: Line ".$rowid.
": contratdetid=".$obj->rowid.
" pu=".$pu.
" qty=".$qty.
" vatrate=".$vatrate.
" remise_percent=".$remise_percent.
" -> ".$total_ht.
", ".$total_tva.
" , ".$total_ttc);
1674 $contratligne->update_total();
1679 print $langs->trans(
"AlreadyDone");
1686 print "Error #1 ".$db->error();
1709 $tmpmysoc->setMysoc($conf);
1711 print '<tr><td colspan="4">';
1714 print '<b>'.$langs->trans(
'MigrationOrder').
"</b><br>\n";
1717 $sql =
"SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,";
1718 $sql .=
" c.rowid as commandeid, c.remise_percent as remise_percent_global";
1719 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd, ".MAIN_DB_PREFIX.
"commande as c";
1720 $sql .=
" WHERE cd.fk_commande = c.rowid";
1721 $sql .=
" AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)";
1724 $resql = $db->query($sql);
1727 $num = $db->num_rows(
$resql);
1733 $obj = $db->fetch_object(
$resql);
1735 $rowid = $obj->rowid;
1737 $pu = $obj->subprice;
1738 $vatrate = $obj->vatrate;
1739 $remise_percent = $obj->remise_percent;
1740 $remise_percent_global = $obj->remise_percent_global;
1741 $info_bits = $obj->info_bits;
1745 $commandeligne->fetch($rowid);
1747 $result =
calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global,
'HT', $info_bits, $commandeligne->product_type, $tmpmysoc);
1748 $total_ht = $result[0];
1749 $total_tva = $result[1];
1750 $total_ttc = $result[2];
1752 $commandeligne->total_ht = $total_ht;
1753 $commandeligne->total_tva = $total_tva;
1754 $commandeligne->total_ttc = $total_ttc;
1756 dolibarr_install_syslog(
"upgrade2: Line ".$rowid.
" : commandeid=".$obj->rowid.
" pu=".$pu.
" qty=".$qty.
" vatrate=".$vatrate.
" remise_percent=".$remise_percent.
" remise_global=".$remise_percent_global.
" -> ".$total_ht.
", ".$total_tva.
", ".$total_ttc);
1758 $commandeligne->update_total();
1782 print $langs->trans(
"AlreadyDone");
1799 print "Error #1 ".$db->error();
1822 $tmpmysoc->setMysoc($conf);
1824 print '<tr><td colspan="4">';
1827 print '<b>'.$langs->trans(
'MigrationSupplierOrder').
"</b><br>\n";
1830 $sql =
"SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,";
1831 $sql .=
" c.rowid as commandeid, c.remise_percent as remise_percent_global";
1832 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd, ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
1833 $sql .=
" WHERE cd.fk_commande = c.rowid";
1834 $sql .=
" AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)";
1837 $resql = $db->query($sql);
1840 $num = $db->num_rows(
$resql);
1846 $obj = $db->fetch_object(
$resql);
1848 $rowid = $obj->rowid;
1850 $pu = $obj->subprice;
1851 $vatrate = $obj->vatrate;
1852 $remise_percent = $obj->remise_percent;
1853 $remise_percent_global = $obj->remise_percent_global;
1854 $info_bits = $obj->info_bits;
1858 $commandeligne->fetch($rowid);
1860 $result =
calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global,
'HT', $info_bits, $commandeligne->product_type, $tmpsoc);
1861 $total_ht = $result[0];
1862 $total_tva = $result[1];
1863 $total_ttc = $result[2];
1865 $commandeligne->total_ht = $total_ht;
1866 $commandeligne->total_tva = $total_tva;
1867 $commandeligne->total_ttc = $total_ttc;
1869 dolibarr_install_syslog(
"upgrade2: Line ".$rowid.
": commandeid=".$obj->rowid.
" pu=".$pu.
" qty=".$qty.
" vatrate=".$vatrate.
" remise_percent=".$remise_percent.
" remise_global=".$remise_percent_global.
" -> ".$total_ht.
", ".$total_tva.
", ".$total_ttc);
1871 $commandeligne->update_total();
1895 print $langs->trans(
"AlreadyDone");
1912 print "Error #1 ".$db->error();
1937 if (!empty($conf->facture->enabled))
1939 include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
1941 if (count($modellist) == 0)
1944 $sql =
" insert into ".MAIN_DB_PREFIX.
"document_model(nom,type) values('crabe','invoice')";
1945 $resql = $db->query($sql);
1950 if (!empty($conf->commande->enabled))
1952 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
1954 if (count($modellist) == 0)
1957 $sql =
" insert into ".MAIN_DB_PREFIX.
"document_model(nom,type) values('einstein','order')";
1958 $resql = $db->query($sql);
1963 if (!empty($conf->expedition->enabled))
1965 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
1966 $modellist = ModelePDFExpedition::liste_modeles($db);
1967 if (count($modellist) == 0)
1970 $sql =
" insert into ".MAIN_DB_PREFIX.
"document_model(nom,type) values('rouget','shipping')";
1971 $resql = $db->query($sql);
1992 print '<tr><td colspan="4">';
1995 print '<b>'.$langs->trans(
'MigrationShipmentOrderMatching').
"</b><br>\n";
1997 $result = $db->DDLDescTable(MAIN_DB_PREFIX.
"expedition",
"fk_commande");
1998 $obj = $db->fetch_object($result);
2005 $sql =
"SELECT e.rowid, e.fk_commande FROM ".MAIN_DB_PREFIX.
"expedition as e";
2006 $resql = $db->query($sql);
2010 $num = $db->num_rows(
$resql);
2016 $obj = $db->fetch_object(
$resql);
2018 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"co_exp (fk_expedition,fk_commande)";
2019 $sql .=
" VALUES (".$obj->rowid.
",".$obj->fk_commande.
")";
2020 $resql2 = $db->query($sql);
2035 $sql =
"ALTER TABLE ".MAIN_DB_PREFIX.
"expedition DROP COLUMN fk_commande";
2036 print $langs->trans(
'FieldRenamed').
"<br>\n";
2046 print $langs->trans(
'AlreadyDone').
"<br>\n";
2063 print '<tr><td colspan="4">';
2066 print '<b>'.$langs->trans(
'MigrationDeliveryOrderMatching').
"</b><br>\n";
2068 $result = $db->DDLDescTable(MAIN_DB_PREFIX.
"livraison",
"fk_commande");
2069 $obj = $db->fetch_object($result);
2076 $sql =
"SELECT l.rowid, l.fk_commande,";
2077 $sql .=
" c.ref_client, c.date_livraison as delivery_date";
2078 $sql .=
" FROM ".MAIN_DB_PREFIX.
"livraison as l, ".MAIN_DB_PREFIX.
"commande as c";
2079 $sql .=
" WHERE c.rowid = l.fk_commande";
2080 $resql = $db->query($sql);
2084 $num = $db->num_rows(
$resql);
2090 $obj = $db->fetch_object(
$resql);
2092 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"co_liv (fk_livraison,fk_commande)";
2093 $sql .=
" VALUES (".$obj->rowid.
",".$obj->fk_commande.
")";
2094 $resql2 = $db->query($sql);
2098 $delivery_date = $db->jdate($obj->delivery_date);
2100 $sqlu =
"UPDATE ".MAIN_DB_PREFIX.
"livraison SET";
2101 $sqlu .=
" ref_client='".$db->escape($obj->ref_client).
"'";
2102 $sqlu .=
", date_livraison='".$db->idate($delivery_date).
"'";
2103 $sqlu .=
" WHERE rowid = ".$obj->rowid;
2104 $resql3 = $db->query($sqlu);
2122 $sql =
"ALTER TABLE ".MAIN_DB_PREFIX.
"livraison DROP COLUMN fk_commande";
2123 print $langs->trans(
'FieldRenamed').
"<br>\n";
2133 print $langs->trans(
'AlreadyDone').
"<br>\n";
2150 print '<tr><td colspan="4">';
2153 print '<b>'.$langs->trans(
'MigrationDeliveryDetail').
"</b><br>\n";
2157 $result = $db->DDLDescTable(MAIN_DB_PREFIX.
"livraisondet",
"fk_commande_ligne");
2158 $obj = $db->fetch_object($result);
2165 $sql =
"SELECT cd.rowid, cd.fk_product, cd.description, cd.subprice, cd.total_ht";
2166 $sql .=
", ld.fk_livraison";
2167 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd, ".MAIN_DB_PREFIX.
"livraisondet as ld";
2168 $sql .=
" WHERE ld.fk_commande_ligne = cd.rowid";
2169 $resql = $db->query($sql);
2173 $num = $db->num_rows(
$resql);
2179 $obj = $db->fetch_object(
$resql);
2181 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"livraisondet SET";
2182 $sql .=
" fk_product=".$obj->fk_product;
2183 $sql .=
",description='".$db->escape($obj->description).
"'";
2184 $sql .=
",subprice='".$db->escape($obj->subprice).
"'";
2185 $sql .=
",total_ht='".$db->escape($obj->total_ht).
"'";
2186 $sql .=
" WHERE fk_commande_ligne = ".$obj->rowid;
2187 $resql2 = $db->query($sql);
2191 $sql =
"SELECT total_ht";
2192 $sql .=
" FROM ".MAIN_DB_PREFIX.
"livraison";
2193 $sql .=
" WHERE rowid = ".$obj->fk_livraison;
2194 $resql3 = $db->query($sql);
2198 $obju = $db->fetch_object($resql3);
2199 $total_ht = $obju->total_ht + $obj->total_ht;
2201 $sqlu =
"UPDATE ".MAIN_DB_PREFIX.
"livraison SET";
2202 $sqlu .=
" total_ht='".$db->escape($total_ht).
"'";
2203 $sqlu .=
" WHERE rowid=".$obj->fk_livraison;
2204 $resql4 = $db->query($sqlu);
2226 $sql =
"ALTER TABLE ".MAIN_DB_PREFIX.
"livraisondet CHANGE fk_commande_ligne fk_origin_line integer";
2227 print $langs->trans(
'FieldRenamed').
"<br>\n";
2237 $result = $db->DDLDescTable(MAIN_DB_PREFIX.
"livraisondet",
"fk_origin_line");
2238 $obj = $db->fetch_object($result);
2241 $sql =
"ALTER TABLE ".MAIN_DB_PREFIX.
"livraisondet ADD COLUMN fk_origin_line integer after fk_livraison";
2244 print $langs->trans(
'AlreadyDone').
"<br>\n";
2261 print '<tr><td colspan="4">';
2264 print '<b>'.$langs->trans(
'MigrationStockDetail').
"</b><br>\n";
2270 $sql =
"SELECT SUM(reel) as total, fk_product";
2271 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps";
2272 $sql .=
" GROUP BY fk_product";
2273 $resql = $db->query($sql);
2277 $num = $db->num_rows(
$resql);
2283 $obj = $db->fetch_object(
$resql);
2285 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product SET";
2286 $sql .=
" stock = '".$db->escape($obj->total).
"'";
2287 $sql .=
" WHERE rowid=".$obj->fk_product;
2289 $resql2 = $db->query($sql);
2328 print '<tr><td colspan="4">';
2331 print '<b>'.$langs->trans(
'MigrationMenusDetail').
"</b><br>\n";
2335 if ($db->DDLInfoTable(MAIN_DB_PREFIX.
"menu_constraint"))
2339 $sql =
"SELECT m.rowid, mc.action";
2340 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu_constraint as mc, ".MAIN_DB_PREFIX.
"menu_const as md, ".MAIN_DB_PREFIX.
"menu as m";
2341 $sql .=
" WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid";
2342 $sql .=
" AND m.enabled = '1'";
2343 $resql = $db->query($sql);
2347 $num = $db->num_rows(
$resql);
2352 $obj = $db->fetch_object(
$resql);
2354 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu SET";
2355 $sql .=
" enabled = '".$db->escape($obj->action).
"'";
2356 $sql .=
" WHERE rowid=".$obj->rowid;
2357 $sql .=
" AND enabled = '1'";
2359 $resql2 = $db->query($sql);
2382 print $langs->trans(
'AlreadyDone').
"<br>\n";
2401 print '<tr><td colspan="4">';
2404 print '<b>'.$langs->trans(
'MigrationDeliveryAddress').
"</b><br>\n";
2408 if ($db->DDLInfoTable(MAIN_DB_PREFIX.
"co_exp"))
2412 $sql =
"SELECT c.fk_adresse_livraison, ce.fk_expedition";
2413 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c";
2414 $sql .=
", ".MAIN_DB_PREFIX.
"co_exp as ce";
2415 $sql .=
" WHERE c.rowid = ce.fk_commande";
2416 $sql .=
" AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0";
2418 $resql = $db->query($sql);
2422 $num = $db->num_rows(
$resql);
2428 $obj = $db->fetch_object(
$resql);
2430 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"expedition SET";
2431 $sql .=
" fk_adresse_livraison = '".$db->escape($obj->fk_adresse_livraison).
"'";
2432 $sql .=
" WHERE rowid=".$obj->fk_expedition;
2434 $resql2 = $db->query($sql);
2444 print $langs->trans(
'AlreadyDone').
"<br>\n";
2458 print $langs->trans(
'AlreadyDone').
"<br>\n";
2477 if (($db->type ==
'mysql' || $db->type ==
'mysqli'))
2481 dolibarr_install_syslog(
"upgrade2::migrate_restore_missing_links Version of database too old to make this migrate action");
2485 print '<tr><td colspan="4">';
2488 print '<b>'.$langs->trans(
'MigrationFixData').
"</b> (1)<br>\n";
2494 $table1 =
'facturedet'; $field1 =
'fk_remise_except';
2495 $table2 =
'societe_remise_except'; $field2 =
'fk_facture_line';
2499 $sql =
"SELECT t1.rowid, t1.".$field1.
" as field";
2500 $sql .=
" FROM ".MAIN_DB_PREFIX.$table1.
" as t1";
2501 $sql .=
" WHERE t1.".$field1.
" IS NOT NULL AND t1.".$field1.
" NOT IN";
2502 $sql .=
" (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2.
" as t2";
2503 $sql .=
" WHERE t1.rowid = t2.".$field2.
")";
2506 $resql = $db->query($sql);
2510 $num = $db->num_rows(
$resql);
2516 $obj = $db->fetch_object(
$resql);
2518 print 'Line '.$obj->rowid.
' in '.$table1.
' is linked to record '.$obj->field.
' in '.$table2.
' that has no link to '.$table1.
'. We fix this.<br>';
2519 $sql =
"UPDATE ".MAIN_DB_PREFIX.$table2.
" SET";
2520 $sql .=
" ".$field2.
" = '".$db->escape($obj->rowid).
"'";
2521 $sql .=
" WHERE rowid=".$obj->field;
2523 $resql2 = $db->query($sql);
2532 }
else print $langs->trans(
'AlreadyDone').
"<br>\n";
2548 print '<tr><td colspan="4">';
2551 print '<b>'.$langs->trans(
'MigrationFixData').
"</b> (2)<br>\n";
2554 $table2 =
'facturedet'; $field2 =
'fk_remise_except';
2555 $table1 =
'societe_remise_except'; $field1 =
'fk_facture_line';
2559 $sql =
"SELECT t1.rowid, t1.".$field1.
" as field";
2560 $sql .=
" FROM ".MAIN_DB_PREFIX.$table1.
" as t1";
2561 $sql .=
" WHERE t1.".$field1.
" IS NOT NULL AND t1.".$field1.
" NOT IN";
2562 $sql .=
" (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2.
" as t2";
2563 $sql .=
" WHERE t1.rowid = t2.".$field2.
")";
2566 $resql = $db->query($sql);
2570 $num = $db->num_rows(
$resql);
2576 $obj = $db->fetch_object(
$resql);
2578 print 'Line '.$obj->rowid.
' in '.$table1.
' is linked to record '.$obj->field.
' in '.$table2.
' that has no link to '.$table1.
'. We fix this.<br>';
2579 $sql =
"UPDATE ".MAIN_DB_PREFIX.$table2.
" SET";
2580 $sql .=
" ".$field2.
" = '".$db->escape($obj->rowid).
"'";
2581 $sql .=
" WHERE rowid=".$obj->field;
2583 $resql2 = $db->query($sql);
2593 print $langs->trans(
'AlreadyDone').
"<br>\n";
2622 print '<tr><td colspan="4">';
2625 print '<b>'.$langs->trans(
'MigrationProjectUserResp').
"</b><br>\n";
2627 $result = $db->DDLDescTable(MAIN_DB_PREFIX.
"projet",
"fk_user_resp");
2628 $obj = $db->fetch_object($result);
2635 $sql =
"SELECT rowid, fk_user_resp FROM ".MAIN_DB_PREFIX.
"projet";
2636 $resql = $db->query($sql);
2640 $num = $db->num_rows(
$resql);
2646 $obj = $db->fetch_object(
$resql);
2648 $sql2 =
"INSERT INTO ".MAIN_DB_PREFIX.
"element_contact (";
2649 $sql2 .=
"datecreate";
2650 $sql2 .=
", statut";
2651 $sql2 .=
", element_id";
2652 $sql2 .=
", fk_c_type_contact";
2653 $sql2 .=
", fk_socpeople";
2654 $sql2 .=
") VALUES (";
2655 $sql2 .=
"'".$db->idate(
dol_now()).
"'";
2657 $sql2 .=
", ".$obj->rowid;
2659 $sql2 .=
", ".$obj->fk_user_resp;
2662 if ($obj->fk_user_resp > 0)
2664 $resql2 = $db->query($sql2);
2679 $sqlDrop =
"ALTER TABLE ".MAIN_DB_PREFIX.
"projet DROP COLUMN fk_user_resp";
2680 if ($db->query($sqlDrop))
2694 print $langs->trans(
'AlreadyDone').
"<br>\n";
2711 print '<tr><td colspan="4">';
2714 print '<b>'.$langs->trans(
'MigrationProjectTaskActors').
"</b><br>\n";
2716 if ($db->DDLInfoTable(MAIN_DB_PREFIX.
"projet_task_actors"))
2722 $sql =
"SELECT fk_projet_task as fk_project_task, fk_user FROM ".MAIN_DB_PREFIX.
"projet_task_actors";
2723 $resql = $db->query($sql);
2727 $num = $db->num_rows(
$resql);
2733 $obj = $db->fetch_object(
$resql);
2735 $sql2 =
"INSERT INTO ".MAIN_DB_PREFIX.
"element_contact (";
2736 $sql2 .=
"datecreate";
2737 $sql2 .=
", statut";
2738 $sql2 .=
", element_id";
2739 $sql2 .=
", fk_c_type_contact";
2740 $sql2 .=
", fk_socpeople";
2741 $sql2 .=
") VALUES (";
2742 $sql2 .=
"'".$db->idate(
dol_now()).
"'";
2744 $sql2 .=
", ".$obj->fk_project_task;
2746 $sql2 .=
", ".$obj->fk_user;
2749 $resql2 = $db->query($sql2);
2763 $sqlDrop =
"DROP TABLE ".MAIN_DB_PREFIX.
"projet_task_actors";
2764 if ($db->query($sqlDrop))
2778 print $langs->trans(
'AlreadyDone').
"<br>\n";
2798 print '<tr><td colspan="4">';
2801 print '<b>'.$langs->trans(
'MigrationRelationshipTables', MAIN_DB_PREFIX.$table).
"</b><br>\n";
2805 if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table))
2811 $sqlSelect =
"SELECT ".$fk_source.
", ".$fk_target;
2812 $sqlSelect .=
" FROM ".MAIN_DB_PREFIX.$table;
2814 $resql = $db->query($sqlSelect);
2818 $num = $db->num_rows(
$resql);
2824 $obj = $db->fetch_object(
$resql);
2826 $sqlInsert =
"INSERT INTO ".MAIN_DB_PREFIX.
"element_element (";
2827 $sqlInsert .=
"fk_source";
2828 $sqlInsert .=
", sourcetype";
2829 $sqlInsert .=
", fk_target";
2830 $sqlInsert .=
", targettype";
2831 $sqlInsert .=
") VALUES (";
2832 $sqlInsert .= $obj->$fk_source;
2833 $sqlInsert .=
", '".$db->escape($sourcetype).
"'";
2834 $sqlInsert .=
", ".$obj->$fk_target;
2835 $sqlInsert .=
", '".$db->escape($targettype).
"'";
2838 $result = $db->query($sqlInsert);
2848 print $langs->trans(
'AlreadyDone').
"<br>\n";
2853 $sqlDrop =
"DROP TABLE ".MAIN_DB_PREFIX.$table;
2854 if ($db->query($sqlDrop))
2868 print $langs->trans(
'AlreadyDone').
"<br>\n";
2886 print '<tr><td colspan="4">';
2889 print '<b>'.$langs->trans(
'MigrationProjectTaskTime').
"</b><br>\n";
2895 $sql =
"SELECT rowid, fk_task, task_duration";
2896 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task_time";
2897 $resql = $db->query($sql);
2901 $num = $db->num_rows(
$resql);
2905 $totaltime = array();
2910 $obj = $db->fetch_object(
$resql);
2912 if ($obj->task_duration > 0)
2916 list($hour, $min) = explode(
'.', $obj->task_duration);
2917 $hour = $hour * 60 * 60;
2918 $min = ($min / 100) * 60 * 60;
2919 $newtime = $hour + $min;
2921 $sql2 =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task_time SET";
2922 $sql2 .=
" task_duration = ".$newtime;
2923 $sql2 .=
" WHERE rowid = ".$obj->rowid;
2925 $resql2 = $db->query($sql2);
2933 if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime;
2934 else $totaltime[$obj->fk_task] = $newtime;
2936 if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration;
2937 else $totaltime[$obj->fk_task] = $obj->task_duration;
2947 foreach ($totaltime as $taskid => $total_duration)
2949 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET";
2950 $sql .=
" duration_effective = ".$total_duration;
2951 $sql .=
" WHERE rowid = ".$taskid;
2953 $resql = $db->query($sql);
2961 print $langs->trans(
'AlreadyDone').
"<br>\n";
2967 print $langs->trans(
'AlreadyDone').
"<br>\n";
2993 print '<tr><td colspan="4">';
2996 print '<b>'.$langs->trans(
'MigrationCustomerOrderShipping').
"</b><br>\n";
3000 $result1 = $db->DDLDescTable(MAIN_DB_PREFIX.
"expedition",
"ref_customer");
3001 $result2 = $db->DDLDescTable(MAIN_DB_PREFIX.
"expedition",
"date_delivery");
3002 $obj1 = $db->fetch_object($result1);
3003 $obj2 = $db->fetch_object($result2);
3004 if (!$obj1 && !$obj2)
3010 $sqlAdd1 =
"ALTER TABLE ".MAIN_DB_PREFIX.
"expedition ADD COLUMN ref_customer varchar(30) AFTER entity";
3011 $sqlAdd2 =
"ALTER TABLE ".MAIN_DB_PREFIX.
"expedition ADD COLUMN date_delivery date DEFAULT NULL AFTER date_expedition";
3013 if ($db->query($sqlAdd1) && $db->query($sqlAdd2))
3015 $sqlSelect =
"SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison as delivery_date";
3016 $sqlSelect .=
" FROM ".MAIN_DB_PREFIX.
"expedition as e";
3017 $sqlSelect .=
", ".MAIN_DB_PREFIX.
"element_element as el";
3018 $sqlSelect .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande as c ON c.rowid = el.fk_source AND el.sourcetype = 'commande'";
3019 $sqlSelect .=
" WHERE e.rowid = el.fk_target";
3020 $sqlSelect .=
" AND el.targettype = 'shipping'";
3022 $resql = $db->query($sqlSelect);
3026 $num = $db->num_rows(
$resql);
3032 $obj = $db->fetch_object(
$resql);
3034 $sqlUpdate =
"UPDATE ".MAIN_DB_PREFIX.
"expedition SET";
3035 $sqlUpdate .=
" ref_customer = '".$db->escape($obj->ref_client).
"'";
3036 $sqlUpdate .=
", date_delivery = '".$db->escape($obj->delivery_date ? $obj->delivery_date :
'null').
"'";
3037 $sqlUpdate .=
" WHERE rowid = ".$obj->shipping_id;
3039 $result = $db->query($sqlUpdate);
3049 print $langs->trans(
'AlreadyDone').
"<br>\n";
3068 print $langs->trans(
'AlreadyDone').
"<br>\n";
3084 print '<tr><td colspan="4">';
3087 print '<b>'.$langs->trans(
'MigrationShippingDelivery').
"</b><br>\n";
3091 $result = $db->DDLDescTable(MAIN_DB_PREFIX.
"livraison",
"fk_expedition");
3092 $obj = $db->fetch_object($result);
3099 $sqlSelect =
"SELECT rowid, fk_expedition";
3100 $sqlSelect .=
" FROM ".MAIN_DB_PREFIX.
"livraison";
3101 $sqlSelect .=
" WHERE fk_expedition is not null";
3103 $resql = $db->query($sqlSelect);
3107 $num = $db->num_rows(
$resql);
3113 $obj = $db->fetch_object(
$resql);
3115 $sqlInsert =
"INSERT INTO ".MAIN_DB_PREFIX.
"element_element (";
3116 $sqlInsert .=
"fk_source";
3117 $sqlInsert .=
", sourcetype";
3118 $sqlInsert .=
", fk_target";
3119 $sqlInsert .=
", targettype";
3120 $sqlInsert .=
") VALUES (";
3121 $sqlInsert .= $obj->fk_expedition;
3122 $sqlInsert .=
", 'shipping'";
3123 $sqlInsert .=
", ".$obj->rowid;
3124 $sqlInsert .=
", 'delivery'";
3127 $result = $db->query($sqlInsert);
3130 $sqlUpdate =
"UPDATE ".MAIN_DB_PREFIX.
"livraison SET fk_expedition = NULL";
3131 $sqlUpdate .=
" WHERE rowid = ".$obj->rowid;
3133 $result = $db->query($sqlUpdate);
3147 print $langs->trans(
'AlreadyDone').
"<br>\n";
3152 $sqlDelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"element_element WHERE sourcetype = 'commande' AND targettype = 'delivery'";
3153 $db->query($sqlDelete);
3158 $sqlDrop =
"ALTER TABLE ".MAIN_DB_PREFIX.
"livraison DROP COLUMN fk_expedition";
3159 $db->query($sqlDrop);
3169 print $langs->trans(
'AlreadyDone').
"<br>\n";
3186 print '<tr><td colspan="4">';
3189 print '<b>'.$langs->trans(
'MigrationShippingDelivery2').
"</b><br>\n";
3197 $sqlSelect =
"SELECT l.rowid as delivery_id, e.ref_customer, e.date_delivery";
3198 $sqlSelect .=
" FROM ".MAIN_DB_PREFIX.
"livraison as l,";
3199 $sqlSelect .=
" ".MAIN_DB_PREFIX.
"element_element as el,";
3200 $sqlSelect .=
" ".MAIN_DB_PREFIX.
"expedition as e";
3201 $sqlSelect .=
" WHERE l.rowid = el.fk_target";
3202 $sqlSelect .=
" AND el.targettype = 'delivery'";
3203 $sqlSelect .=
" AND e.rowid = el.fk_source AND el.sourcetype = 'shipping'";
3204 $sqlSelect .=
" AND (e.ref_customer IS NOT NULL OR e.date_delivery IS NOT NULL)";
3206 $sqlSelect .=
" AND (l.ref_customer IS NULL".($db->type !=
'pgsql' ?
" or l.ref_customer = ''" :
"").
")";
3207 $sqlSelect .=
" AND (l.date_delivery IS NULL".($db->type !=
'pgsql' ?
" or l.date_delivery = ''" :
"").
")";
3209 $resql = $db->query($sqlSelect);
3213 $num = $db->num_rows(
$resql);
3219 $obj = $db->fetch_object(
$resql);
3221 $sqlUpdate =
"UPDATE ".MAIN_DB_PREFIX.
"livraison SET";
3222 $sqlUpdate .=
" ref_customer = '".$db->escape($obj->ref_customer).
"',";
3223 $sqlUpdate .=
" date_delivery = ".($obj->date_delivery ?
"'".$db->escape($obj->date_delivery).
"'" :
'null');
3224 $sqlUpdate .=
" WHERE rowid = ".$obj->delivery_id;
3226 $result = $db->query($sqlUpdate);
3236 print $langs->trans(
'AlreadyDone').
"<br>\n";
3264 print '<tr><td colspan="4">';
3267 print '<b>'.$langs->trans(
'MigrationActioncommElement').
"</b><br>\n";
3270 'propal' =>
'propalrowid',
3271 'order' =>
'fk_commande',
3272 'invoice' =>
'fk_facture',
3273 'contract' =>
'fk_contract',
3274 'order_supplier' =>
'fk_supplier_order',
3275 'invoice_supplier' =>
'fk_supplier_invoice'
3278 foreach ($elements as $type => $field)
3280 $result = $db->DDLDescTable(MAIN_DB_PREFIX.
"actioncomm", $field);
3281 $obj = $db->fetch_object($result);
3288 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"actioncomm SET ";
3289 $sql .=
"fk_element = ".$field.
", elementtype = '".$db->escape($type).
"'";
3290 $sql .=
" WHERE ".$field.
" IS NOT NULL";
3291 $sql .=
" AND fk_element IS NULL";
3292 $sql .=
" AND elementtype IS NULL";
3294 $resql = $db->query($sql);
3309 print $langs->trans(
'AlreadyDone').
"<br>\n";
3326 print '<tr><td colspan="4">';
3329 print '<b>'.$langs->trans(
'MigrationPaymentMode').
"</b><br>\n";
3332 'old_id' => array(5, 8, 9, 10, 11),
3333 'new_id' => array(50, 51, 52, 53, 54),
3334 'code' => array(
'VAD',
'TRA',
'LCR',
'FAC',
'PRO'),
3335 'tables' => array(
'commande_fournisseur',
'commande',
'facture_rec',
'facture',
'propal')
3339 foreach ($elements[
'old_id'] as $key => $old_id)
3345 $sqlSelect =
"SELECT id";
3346 $sqlSelect .=
" FROM ".MAIN_DB_PREFIX.
"c_paiement";
3347 $sqlSelect .=
" WHERE id = ".$old_id;
3348 $sqlSelect .=
" AND code = '".$db->escape($elements[
'code'][$key]).
"'";
3350 $resql = $db->query($sqlSelect);
3353 $num = $db->num_rows(
$resql);
3360 $sqla =
"UPDATE ".MAIN_DB_PREFIX.
"paiement SET ";
3361 $sqla .=
"fk_paiement = ".$elements[
'new_id'][$key];
3362 $sqla .=
" WHERE fk_paiement = ".$old_id;
3363 $sqla .=
" AND fk_paiement IN (SELECT id FROM ".MAIN_DB_PREFIX.
"c_paiement WHERE id = ".$old_id.
" AND code = '".$db->escape($elements[
'code'][$key]).
"')";
3364 $resqla = $db->query($sqla);
3366 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"c_paiement SET ";
3367 $sql .=
"id = ".$elements[
'new_id'][$key];
3368 $sql .=
" WHERE id = ".$old_id;
3369 $sql .=
" AND code = '".$db->escape($elements[
'code'][$key]).
"'";
3370 $resql = $db->query($sql);
3374 foreach ($elements[
'tables'] as $table)
3376 $sql =
"UPDATE ".MAIN_DB_PREFIX.$table.
" SET ";
3377 $sql .=
"fk_mode_reglement = ".$elements[
'new_id'][$key];
3378 $sql .=
" WHERE fk_mode_reglement = ".$old_id;
3380 $resql = $db->query($sql);
3404 if ($count == 0)
print $langs->trans(
'AlreadyDone').
"<br>\n";
3421 $result = $db->DDLDescTable(MAIN_DB_PREFIX.
"categorie_association");
3424 $obj = $db->fetch_object($result);
3429 $sql =
"SELECT fk_categorie_mere, fk_categorie_fille";
3430 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_association";
3432 $resql = $db->query($sql);
3435 $num = $db->num_rows(
$resql);
3436 while ($obj = $db->fetch_object(
$resql))
3438 if (!isset($filles[$obj->fk_categorie_fille]))
3440 if ($obj->fk_categorie_mere != $obj->fk_categorie_fille)
3442 $filles[$obj->fk_categorie_fille] = 1;
3443 $couples[$obj->fk_categorie_mere.
'_'.$obj->fk_categorie_fille] = array(
'mere'=>$obj->fk_categorie_mere,
'fille'=>$obj->fk_categorie_fille);
3451 if (count($couples) > 0 && $num > count($couples))
3458 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_association";
3460 $resqld = $db->query($sql);
3464 foreach ($couples as $key => $val)
3466 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie_association(fk_categorie_mere,fk_categorie_fille)";
3467 $sql .=
" VALUES(".$val[
'mere'].
", ".$val[
'fille'].
")";
3469 $resqli = $db->query($sql);
3470 if (!$resqli) $error++;
3476 print '<tr><td>'.$langs->trans(
"MigrationCategorieAssociation").
'</td>';
3477 print '<td class="right">'.$langs->trans(
"RemoveDuplicates").
' '.$langs->trans(
"Success").
' ('.$num.
'=>'.count($couples).
')</td></tr>';
3480 print '<tr><td>'.$langs->trans(
"MigrationCategorieAssociation").
'</td>';
3481 print '<td class="right">'.$langs->trans(
"RemoveDuplicates").
' '.$langs->trans(
"Failed").
'</td></tr>';
3486 print '<tr><td>'.$langs->trans(
"Error").
'</td>';
3487 print '<td class="right"><div class="error">'.$db->lasterror().
'</div></td></tr>';
3504 print '<tr><td colspan="4">';
3507 print '<b>'.$langs->trans(
'MigrationCategorieAssociation').
"</b><br>\n";
3511 if ($db->DDLInfoTable(MAIN_DB_PREFIX.
"categorie_association"))
3517 $sqlSelect =
"SELECT fk_categorie_mere, fk_categorie_fille";
3518 $sqlSelect .=
" FROM ".MAIN_DB_PREFIX.
"categorie_association";
3520 $resql = $db->query($sqlSelect);
3524 $num = $db->num_rows(
$resql);
3530 $obj = $db->fetch_object(
$resql);
3532 $sqlUpdate =
"UPDATE ".MAIN_DB_PREFIX.
"categorie SET ";
3533 $sqlUpdate .=
"fk_parent = ".$obj->fk_categorie_mere;
3534 $sqlUpdate .=
" WHERE rowid = ".$obj->fk_categorie_fille;
3536 $result = $db->query($sqlUpdate);
3546 print $langs->trans(
'AlreadyDone').
"<br>\n";
3573 print $langs->trans(
'AlreadyDone').
"<br>\n";
3589 print '<tr><td colspan="4">';
3592 print '<b>'.$langs->trans(
'MigrationEvents').
"</b><br>\n";
3600 $sqlSelect =
"SELECT a.id, a.fk_user_action";
3601 $sqlSelect .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
3602 $sqlSelect .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'user' AND ar.fk_element = a.fk_user_action";
3603 $sqlSelect .=
" WHERE fk_user_action > 0 AND fk_user_action NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX.
"actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'user')";
3604 $sqlSelect .=
" ORDER BY a.id";
3607 $resql = $db->query($sqlSelect);
3611 $num = $db->num_rows(
$resql);
3617 $obj = $db->fetch_object(
$resql);
3619 $sqlUpdate =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element) ";
3620 $sqlUpdate .=
"VALUES(".$obj->id.
", 'user', ".$obj->fk_user_action.
")";
3622 $result = $db->query($sqlUpdate);
3632 print $langs->trans(
'AlreadyDone').
"<br>\n";
3660 print '<tr><td colspan="4">';
3663 print '<b>'.$langs->trans(
'MigrationEventsContact').
"</b><br>\n";
3671 $sqlSelect =
"SELECT a.id, a.fk_contact";
3672 $sqlSelect .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
3673 $sqlSelect .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople' AND ar.fk_element = a.fk_contact";
3674 $sqlSelect .=
" WHERE fk_contact > 0 AND fk_contact NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX.
"actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople')";
3675 $sqlSelect .=
" ORDER BY a.id";
3678 $resql = $db->query($sqlSelect);
3682 $num = $db->num_rows(
$resql);
3688 $obj = $db->fetch_object(
$resql);
3690 $sqlUpdate =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element) ";
3691 $sqlUpdate .=
"VALUES(".$obj->id.
", 'socpeople', ".$obj->fk_contact.
")";
3693 $result = $db->query($sqlUpdate);
3703 print $langs->trans(
'AlreadyDone').
"<br>\n";
3734 require_once DOL_DOCUMENT_ROOT.
'/blockedlog/class/blockedlog.class.php';
3736 print '<tr><td colspan="4">';
3739 print '<b>'.$langs->trans(
'MigrationResetBlockedLog').
"</b><br>\n";
3747 $sqlSelect =
"SELECT DISTINCT entity";
3748 $sqlSelect .=
" FROM ".MAIN_DB_PREFIX.
"blockedlog";
3752 $resql = $db->query($sqlSelect);
3756 $num = $db->num_rows(
$resql);
3762 $obj = $db->fetch_object(
$resql);
3764 print 'Process entity '.$obj->entity;
3766 $sqlSearch =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"blockedlog WHERE action = 'MODULE_SET' and entity = ".$obj->entity;
3767 $resqlSearch = $db->query($sqlSearch);
3770 $objSearch = $db->fetch_object($resqlSearch);
3772 if ($objSearch && $objSearch->nb == 0)
3774 print ' - Record for entity must be reset...';
3776 $sqlUpdate =
"DELETE FROM ".MAIN_DB_PREFIX.
"blockedlog";
3777 $sqlUpdate .=
" WHERE entity = ".$obj->entity;
3778 $resqlUpdate = $db->query($sqlUpdate);
3785 $object =
new stdClass();
3787 $object->element =
'module';
3788 $object->ref =
'systemevent';
3789 $object->entity = $obj->entity;
3793 $b->setObjectData($object,
'MODULE_SET', 0);
3795 $res = $b->create($user);
3801 print ' - '.$langs->trans(
'AlreadyInV7').
'<br>';
3810 print $langs->trans(
'NothingToDo').
"<br>\n";
3838 print '<tr><td colspan="4">';
3841 print '<b>'.$langs->trans(
'MigrationRemiseEntity').
"</b><br>\n";
3849 $sqlSelect =
"SELECT sr.rowid, s.entity";
3850 $sqlSelect .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise as sr, ".MAIN_DB_PREFIX.
"societe as s";
3851 $sqlSelect .=
" WHERE sr.fk_soc = s.rowid and sr.entity != s.entity";
3855 $resql = $db->query($sqlSelect);
3859 $num = $db->num_rows(
$resql);
3865 $obj = $db->fetch_object(
$resql);
3867 $sqlUpdate =
"UPDATE ".MAIN_DB_PREFIX.
"societe_remise SET";
3868 $sqlUpdate .=
" entity = ".$obj->entity;
3869 $sqlUpdate .=
" WHERE rowid = ".$obj->rowid;
3871 $result = $db->query($sqlUpdate);
3882 print $langs->trans(
'AlreadyDone').
"<br>\n";
3909 print '<tr><td colspan="4">';
3912 print '<b>'.$langs->trans(
'MigrationRemiseExceptEntity').
"</b><br>\n";
3920 $sqlSelect =
"SELECT sr.rowid, sr.fk_soc, sr.fk_facture_source, sr.fk_facture, sr.fk_facture_line";
3921 $sqlSelect .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as sr";
3924 $resql = $db->query($sqlSelect);
3928 $num = $db->num_rows(
$resql);
3934 $obj = $db->fetch_object(
$resql);
3936 if (!empty($obj->fk_facture_source) || !empty($obj->fk_facture))
3938 $fk_facture = (!empty($obj->fk_facture_source) ? $obj->fk_facture_source : $obj->fk_facture);
3940 $sqlSelect2 =
"SELECT f.entity";
3941 $sqlSelect2 .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
3942 $sqlSelect2 .=
" WHERE f.rowid = ".$fk_facture;
3943 } elseif (!empty($obj->fk_facture_line))
3945 $sqlSelect2 =
"SELECT f.entity";
3946 $sqlSelect2 .=
" FROM ".MAIN_DB_PREFIX.
"facture as f, ".MAIN_DB_PREFIX.
"facturedet as fd";
3947 $sqlSelect2 .=
" WHERE fd.rowid = ".$obj->fk_facture_line;
3948 $sqlSelect2 .=
" AND fd.fk_facture = f.rowid";
3950 $sqlSelect2 =
"SELECT s.entity";
3951 $sqlSelect2 .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
3952 $sqlSelect2 .=
" WHERE s.rowid = ".$obj->fk_soc;
3955 $resql2 = $db->query($sqlSelect2);
3958 if ($db->num_rows($resql2) > 0)
3960 $obj2 = $db->fetch_object($resql2);
3962 $sqlUpdate =
"UPDATE ".MAIN_DB_PREFIX.
"societe_remise_except SET";
3963 $sqlUpdate .=
" entity = ".$obj2->entity;
3964 $sqlUpdate .=
" WHERE rowid = ".$obj->rowid;
3966 $result = $db->query($sqlUpdate);
3982 print $langs->trans(
'AlreadyDone').
"<br>\n";
4010 print '<tr><td colspan="4">';
4012 print '<b>'.$langs->trans(
'MigrationUserRightsEntity').
"</b><br>\n";
4020 $sqlSelect =
"SELECT u.rowid, u.entity";
4021 $sqlSelect .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
4022 $sqlSelect .=
" WHERE u.entity > 1";
4025 $resql = $db->query($sqlSelect);
4029 $num = $db->num_rows(
$resql);
4035 $obj = $db->fetch_object(
$resql);
4037 $sqlUpdate =
"UPDATE ".MAIN_DB_PREFIX.
"user_rights SET";
4038 $sqlUpdate .=
" entity = ".$obj->entity;
4039 $sqlUpdate .=
" WHERE fk_user = ".$obj->rowid;
4041 $result = $db->query($sqlUpdate);
4052 print $langs->trans(
'AlreadyDone').
"<br>\n";
4080 print '<tr><td colspan="4">';
4082 print '<b>'.$langs->trans(
'MigrationUserGroupRightsEntity').
"</b><br>\n";
4090 $sqlSelect =
"SELECT u.rowid, u.entity";
4091 $sqlSelect .=
" FROM ".MAIN_DB_PREFIX.
"usergroup as u";
4092 $sqlSelect .=
" WHERE u.entity > 1";
4095 $resql = $db->query($sqlSelect);
4099 $num = $db->num_rows(
$resql);
4105 $obj = $db->fetch_object(
$resql);
4107 $sqlUpdate =
"UPDATE ".MAIN_DB_PREFIX.
"usergroup_rights SET";
4108 $sqlUpdate .=
" entity = ".$obj->entity;
4109 $sqlUpdate .=
" WHERE fk_usergroup = ".$obj->rowid;
4111 $result = $db->query($sqlUpdate);
4122 print $langs->trans(
'AlreadyDone').
"<br>\n";
4154 if (is_dir(DOL_DATA_ROOT.$oldname) && !file_exists(DOL_DATA_ROOT.$newname))
4156 dolibarr_install_syslog(
"upgrade2::migrate_rename_directories move ".DOL_DATA_ROOT.$oldname.
' into '.DOL_DATA_ROOT.$newname);
4157 @rename(DOL_DATA_ROOT.$oldname, DOL_DATA_ROOT.$newname);
4177 $filetodeletearray = array(
4178 '/core/triggers/interface_demo.class.php',
4179 '/core/menus/barre_left/default.php',
4180 '/core/menus/barre_top/default.php',
4181 '/core/modules/modComptabiliteExpert.class.php',
4182 '/core/modules/modCommercial.class.php',
4183 '/core/modules/modProduit.class.php',
4184 '/core/modules/modSkype.class.php',
4185 '/phenix/inc/triggers/interface_modPhenix_Phenixsynchro.class.php',
4186 '/webcalendar/inc/triggers/interface_modWebcalendar_webcalsynchro.class.php',
4187 '/core/triggers/interface_modWebcalendar_Webcalsynchro.class.php',
4188 '/core/triggers/interface_modCommande_Ecotax.class.php',
4189 '/core/triggers/interface_modCommande_fraisport.class.php',
4190 '/core/triggers/interface_modPropale_PropalWorkflow.class.php',
4191 '/core/menus/smartphone/iphone.lib.php',
4192 '/core/menus/smartphone/iphone_backoffice.php',
4193 '/core/menus/smartphone/iphone_frontoffice.php',
4194 '/core/menus/standard/auguria_backoffice.php',
4195 '/core/menus/standard/auguria_frontoffice.php',
4196 '/core/menus/standard/eldy_backoffice.php',
4197 '/core/menus/standard/eldy_frontoffice.php',
4198 '/core/modules/mailings/contacts2.modules.php',
4199 '/core/modules/mailings/contacts3.modules.php',
4200 '/core/modules/mailings/contacts4.modules.php',
4201 '/core/modules/mailings/framboise.modules.php',
4202 '/core/modules/mailings/dolibarr_services_expired.modules.php',
4203 '/core/modules/mailings/peche.modules.php',
4204 '/core/modules/mailings/poire.modules.php',
4205 '/core/modules/mailings/kiwi.modules.php',
4206 '/core/modules/facture/pdf_crabe.modules.php',
4207 '/core/modules/facture/pdf_oursin.modules.php',
4208 '/core/modules/export/export_excel.modules.php',
4209 '/core/modules/export/export_excel2007new.modules.php',
4211 '/api/class/api_generic.class.php',
4212 '/categories/class/api_category.class.php',
4213 '/categories/class/api_deprecated_category.class.php',
4214 '/compta/facture/class/api_invoice.class.php',
4215 '/commande/class/api_commande.class.php',
4216 '/user/class/api_user.class.php',
4217 '/product/class/api_product.class.php',
4218 '/societe/class/api_contact.class.php',
4219 '/societe/class/api_thirdparty.class.php',
4220 '/support/online.php',
4221 '/takepos/class/actions_takepos.class.php',
4223 '/install/mysql/tables/llx_c_ticketsup_category.key.sql',
4224 '/install/mysql/tables/llx_c_ticketsup_category.sql',
4225 '/install/mysql/tables/llx_c_ticketsup_severity.key.sql',
4226 '/install/mysql/tables/llx_c_ticketsup_severity.sql',
4227 '/install/mysql/tables/llx_c_ticketsup_type.key.sql',
4228 '/install/mysql/tables/llx_c_ticketsup_type.sql'
4231 foreach ($filetodeletearray as $filetodelete) {
4234 if (file_exists(DOL_DOCUMENT_ROOT.$filetodelete)) {
4235 $result =
dol_delete_file(DOL_DOCUMENT_ROOT.$filetodelete, 0, 0, 0, null,
true,
false);
4237 $langs->load(
"errors");
4238 print '<div class="error">'.$langs->trans(
"Error").
': '.$langs->trans(
"ErrorFailToDeleteFile", DOL_DOCUMENT_ROOT.$filetodelete);
4239 print ' '.$langs->trans(
"RemoveItManuallyAndPressF5ToContinue").
'</div>';
4263 $filetodeletearray = array(
4264 DOL_DOCUMENT_ROOT.
'/core/modules/facture/terre',
4265 DOL_DOCUMENT_ROOT.
'/core/modules/facture/mercure',
4268 foreach ($filetodeletearray as $filetodelete) {
4270 if (file_exists($filetodelete)) {
4274 $langs->load(
"errors");
4275 print '<div class="error">'.$langs->trans(
"Error").
': '.$langs->trans(
"ErrorFailToDeleteDir", $filetodelete);
4276 print ' '.$langs->trans(
"RemoveItManuallyAndPressF5ToContinue").
'</div>';
4297 if (count($listofmodule) == 0)
return;
4299 dolibarr_install_syslog(
"upgrade2::migrate_reload_modules force=".$force.
", listofmodule=".join(
',', array_keys($listofmodule)));
4301 foreach ($listofmodule as $moduletoreload => $reloadmode) {
4302 if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && !$force))
continue;
4306 if ($moduletoreload ==
'MAIN_MODULE_AGENDA') {
4308 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modAgenda.class.php';
4311 $mod->remove(
'noboxes');
4312 $mod->init($reloadmode);
4314 } elseif ($moduletoreload ==
'MAIN_MODULE_API') {
4316 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modApi.class.php';
4320 $mod->init($reloadmode);
4322 } elseif ($moduletoreload ==
'MAIN_MODULE_BARCODE') {
4324 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modBarcode.class.php';
4327 $mod->remove(
'noboxes');
4328 $mod->init($reloadmode);
4330 } elseif ($moduletoreload ==
'MAIN_MODULE_CRON') {
4332 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modCron.class.php';
4335 $mod->remove(
'noboxes');
4336 $mod->init($reloadmode);
4338 } elseif ($moduletoreload ==
'MAIN_MODULE_EXTERNALSITE') {
4340 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modExternalSite.class.php';
4343 $mod->remove(
'noboxes');
4344 $mod->init($reloadmode);
4346 } elseif ($moduletoreload ==
'MAIN_MODULE_SOCIETE') {
4348 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modSociete.class.php';
4351 $mod->remove(
'noboxes');
4352 $mod->init($reloadmode);
4354 } elseif ($moduletoreload ==
'MAIN_MODULE_PRODUIT') {
4356 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modProduct.class.php';
4360 $mod->init($reloadmode);
4362 } elseif ($moduletoreload ==
'MAIN_MODULE_SERVICE') {
4364 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modService.class.php';
4368 $mod->init($reloadmode);
4370 } elseif ($moduletoreload ==
'MAIN_MODULE_COMMANDE') {
4372 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modCommande.class.php';
4376 $mod->init($reloadmode);
4378 } elseif ($moduletoreload ==
'MAIN_MODULE_FACTURE') {
4380 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modFacture.class.php';
4384 $mod->init($reloadmode);
4386 } elseif ($moduletoreload ==
'MAIN_MODULE_FOURNISSEUR') {
4388 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modFournisseur.class.php';
4392 $mod->init($reloadmode);
4394 } elseif ($moduletoreload ==
'MAIN_MODULE_HOLIDAY') {
4396 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modHoliday.class.php';
4399 $mod->remove(
'noboxes');
4400 $mod->init($reloadmode);
4402 } elseif ($moduletoreload ==
'MAIN_MODULE_DEPLACEMENT') {
4404 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modDeplacement.class.php';
4408 $mod->init($reloadmode);
4410 } elseif ($moduletoreload ==
'MAIN_MODULE_EXPENSEREPORT') {
4412 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modExpenseReport.class.php';
4416 $mod->init($reloadmode);
4418 } elseif ($moduletoreload ==
'MAIN_MODULE_DON') {
4420 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modDon.class.php';
4424 $mod->init($reloadmode);
4426 } elseif ($moduletoreload ==
'MAIN_MODULE_ECM') {
4428 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modECM.class.php';
4431 $mod->remove(
'noboxes');
4432 $mod->init($reloadmode);
4434 } elseif ($moduletoreload ==
'MAIN_MODULE_PAYBOX') {
4436 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modPaybox.class.php';
4438 $mod =
new modPaybox($db);
4439 $mod->remove(
'noboxes');
4440 $mod->init($reloadmode);
4442 } elseif ($moduletoreload ==
'MAIN_MODULE_SUPPLIERPROPOSAL') {
4444 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modSupplierProposal.class.php';
4447 $mod->remove(
'noboxes');
4448 $mod->init($reloadmode);
4450 } elseif ($moduletoreload ==
'MAIN_MODULE_OPENSURVEY') {
4452 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modOpenSurvey.class.php';
4455 $mod->remove(
'noboxes');
4456 $mod->init($reloadmode);
4458 } elseif ($moduletoreload ==
'MAIN_MODULE_PRODUCTBATCH') {
4460 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modProductBatch.class.php';
4463 $mod->remove(
'noboxes');
4464 $mod->init($reloadmode);
4466 } elseif ($moduletoreload ==
'MAIN_MODULE_TAKEPOS') {
4468 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/modTakePos.class.php';
4471 $mod->remove(
'noboxes');
4472 $mod->init($reloadmode);
4476 $tmp = preg_match(
'/MAIN_MODULE_([a-zA-Z0-9]+)/', $moduletoreload, $reg);
4477 if (!empty($reg[1]))
4479 if (strtoupper($moduletoreload) == $moduletoreload)
4481 $moduletoreloadshort = ucfirst(strtolower($reg[1]));
4484 $moduletoreloadshort = $reg[1];
4486 dolibarr_install_syslog(
"upgrade2::migrate_reload_modules Reactivate module ".$moduletoreloadshort.
" with mode ".$reloadmode);
4487 $res = @include_once DOL_DOCUMENT_ROOT.
'/core/modules/mod'.$moduletoreloadshort.
'.class.php';
4489 $classname =
'mod'.$moduletoreloadshort;
4490 $mod =
new $classname($db);
4492 $mod->init($reloadmode);
4494 dolibarr_install_syslog(
'Failed to include '.DOL_DOCUMENT_ROOT.
'/core/modules/mod'.$moduletoreloadshort.
'.class.php');
4496 $res = @
dol_include_once(strtolower($moduletoreloadshort).
'/core/modules/mod'.$moduletoreloadshort.
'.class.php');
4498 $classname =
'mod'.$moduletoreloadshort;
4499 $mod =
new $classname($db);
4501 $mod->init($reloadmode);
4503 dolibarr_install_syslog(
'Failed to include '.strtolower($moduletoreloadshort).
'/core/modules/mod'.$moduletoreloadshort.
'.class.php', LOG_ERR);
4504 print "Error, can't find module with name ".$moduletoreload.
"\n";
4510 print "Error, can't find module with name ".$moduletoreload.
"\n";
4515 if (!empty($mod) && is_object($mod))
4517 print '<tr><td colspan="4">';
4518 print '<b>'.$langs->trans(
'Upgrade').
'</b>: ';
4519 print $langs->trans(
'MigrationReloadModule').
' '.$mod->getName();
4520 print "<!-- (".$reloadmode.
") -->";
4545 $listofmenuhandler = array();
4546 if ($conf->global->MAIN_MENU_STANDARD ==
'auguria_menu' || $conf->global->MAIN_MENU_SMARTPHONE ==
'auguria_menu'
4547 || $conf->global->MAIN_MENUFRONT_STANDARD ==
'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE ==
'auguria_menu')
4549 $listofmenuhandler[
'auguria'] = 1;
4552 foreach ($listofmenuhandler as $key => $val)
4554 print '<tr><td colspan="4">';
4558 print '<b>'.$langs->trans(
'Upgrade').
'</b>: '.$langs->trans(
'MenuHandler').
" ".$key.
"<br>\n";
4561 $dir = DOL_DOCUMENT_ROOT.
"/core/menus/";
4562 $file =
'init_menu_'.$key.
'.sql';
4563 if (file_exists($dir.$file))
4565 $result =
run_sql($dir.$file, 1,
'', 1, $key);
4579 global $conf, $db, $langs, $user;
4581 print '<tr><td colspan="4">';
4583 print '<b>'.$langs->trans(
'MigrationUserPhotoPath').
"</b><br>\n";
4585 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
4586 $fuser =
new User($db);
4588 if (!is_object($user)) $user = $fuser;
4590 $sql =
"SELECT rowid as uid from ".MAIN_DB_PREFIX.
"user";
4591 $resql = $db->query($sql);
4594 while ($obj = $db->fetch_object(
$resql))
4596 $fuser->fetch($obj->uid);
4598 $entity = (empty($fuser->entity) ? 1 : $fuser->entity);
4600 $dir = DOL_DATA_ROOT.
'/'.$entity.
'/users';
4602 $dir = $conf->user->multidir_output[$entity];
4608 $origin = $dir.
'/'.
get_exdir($fuser->id, 2, 0, 1, $fuser,
'user');
4609 $destin = $dir.
'/'.$fuser->id;
4618 $handle = opendir($origin_osencoded);
4619 if (is_resource($handle))
4621 while (($file = readdir($handle)) !==
false)
4623 if ($file ==
'.' || $file ==
'..')
continue;
4627 $thumbs = opendir($origin_osencoded.
'/'.$file);
4628 if (is_resource($thumbs))
4631 while (($thumb = readdir($thumbs)) !==
false)
4635 if ($thumb ==
'.' || $thumb ==
'..')
continue;
4639 dol_copy($origin.
'/'.$file.
'/'.$thumb, $destin.
'/'.$file.
'/'.$thumb, 0, 0);
4651 dol_copy($origin.
'/'.$file, $destin.
'/'.$file, 0, 0);
4688 print '<tr><td colspan="4">';
4689 $sql =
'SELECT rowid, socialnetworks';
4690 $sql .=
', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.
'user WHERE';
4691 $sql .=
" skype IS NOT NULL OR skype <> ''";
4692 $sql .=
" OR twitter IS NOT NULL OR twitter <> ''";
4693 $sql .=
" OR facebook IS NOT NULL OR facebook <> ''";
4694 $sql .=
" OR linkedin IS NOT NULL OR linkedin <> ''";
4695 $sql .=
" OR instagram IS NOT NULL OR instagram <> ''";
4696 $sql .=
" OR snapchat IS NOT NULL OR snapchat <> ''";
4697 $sql .=
" OR googleplus IS NOT NULL OR googleplus <> ''";
4698 $sql .=
" OR youtube IS NOT NULL OR youtube <> ''";
4699 $sql .=
" OR whatsapp IS NOT NULL OR whatsapp <> ''";
4701 $resql = $db->query($sql);
4703 while ($obj = $db->fetch_object(
$resql)) {
4704 $arraysocialnetworks = array();
4705 if (!empty($obj->skype)) {
4706 $arraysocialnetworks[
'skype'] = $obj->skype;
4708 if (!empty($obj->twitter)) {
4709 $arraysocialnetworks[
'twitter'] = $obj->twitter;
4711 if (!empty($obj->facebook)) {
4712 $arraysocialnetworks[
'facebook'] = $obj->facebook;
4714 if (!empty($obj->linkedin)) {
4715 $arraysocialnetworks[
'linkedin'] = $obj->linkedin;
4717 if (!empty($obj->instagram)) {
4718 $arraysocialnetworks[
'instagram'] = $obj->instagram;
4720 if (!empty($obj->snapchat)) {
4721 $arraysocialnetworks[
'snapchat'] = $obj->snapchat;
4723 if (!empty($obj->googleplus)) {
4724 $arraysocialnetworks[
'googleplus'] = $obj->googleplus;
4726 if (!empty($obj->youtube)) {
4727 $arraysocialnetworks[
'youtube'] = $obj->youtube;
4729 if (!empty($obj->whatsapp)) {
4730 $arraysocialnetworks[
'whatsapp'] = $obj->whatsapp;
4732 if ($obj->socialnetworks ==
'' || is_null($obj->socialnetworks)) {
4733 $obj->socialnetworks =
'[]';
4735 $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks,
true));
4736 $sqlupd =
'UPDATE '.MAIN_DB_PREFIX.
"user SET socialnetworks='".$db->escape(json_encode($socialnetworks,
true)).
"'";
4737 $sqlupd .=
', skype=null';
4738 $sqlupd .=
', twitter=null';
4739 $sqlupd .=
', facebook=null';
4740 $sqlupd .=
', linkedin=null';
4741 $sqlupd .=
', instagram=null';
4742 $sqlupd .=
', snapchat=null';
4743 $sqlupd .=
', googleplus=null';
4744 $sqlupd .=
', youtube=null';
4745 $sqlupd .=
', whatsapp=null';
4746 $sqlupd .=
' WHERE rowid='.$obj->rowid;
4748 $resqlupd = $db->query($sqlupd);
4763 print '<b>'.$langs->trans(
'MigrationFieldsSocialNetworks',
'Users').
"</b><br>\n";
4776 print '<tr><td colspan="4">';
4779 print '<tr><td colspan="4">';
4780 $sql =
'SELECT rowid, socialnetworks';
4781 $sql .=
', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.
'adherent WHERE ';
4782 $sql .=
" skype IS NOT NULL OR skype <> ''";
4783 $sql .=
" OR twitter IS NOT NULL OR twitter <> ''";
4784 $sql .=
" OR facebook IS NOT NULL OR facebook <> ''";
4785 $sql .=
" OR linkedin IS NOT NULL OR linkedin <> ''";
4786 $sql .=
" OR instagram IS NOT NULL OR instagram <> ''";
4787 $sql .=
" OR snapchat IS NOT NULL OR snapchat <> ''";
4788 $sql .=
" OR googleplus IS NOT NULL OR googleplus <> ''";
4789 $sql .=
" OR youtube IS NOT NULL OR youtube <> ''";
4790 $sql .=
" OR whatsapp IS NOT NULL OR whatsapp <> ''";
4792 $resql = $db->query($sql);
4794 while ($obj = $db->fetch_object(
$resql)) {
4795 $arraysocialnetworks = array();
4796 if (!empty($obj->skype)) {
4797 $arraysocialnetworks[
'skype'] = $obj->skype;
4799 if (!empty($obj->twitter)) {
4800 $arraysocialnetworks[
'twitter'] = $obj->twitter;
4802 if (!empty($obj->facebook)) {
4803 $arraysocialnetworks[
'facebook'] = $obj->facebook;
4805 if (!empty($obj->linkedin)) {
4806 $arraysocialnetworks[
'linkedin'] = $obj->linkedin;
4808 if (!empty($obj->instagram)) {
4809 $arraysocialnetworks[
'instagram'] = $obj->instagram;
4811 if (!empty($obj->snapchat)) {
4812 $arraysocialnetworks[
'snapchat'] = $obj->snapchat;
4814 if (!empty($obj->googleplus)) {
4815 $arraysocialnetworks[
'googleplus'] = $obj->googleplus;
4817 if (!empty($obj->youtube)) {
4818 $arraysocialnetworks[
'youtube'] = $obj->youtube;
4820 if (!empty($obj->whatsapp)) {
4821 $arraysocialnetworks[
'whatsapp'] = $obj->whatsapp;
4823 if ($obj->socialnetworks ==
'' || is_null($obj->socialnetworks)) {
4824 $obj->socialnetworks =
'[]';
4826 $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks,
true));
4827 $sqlupd =
'UPDATE '.MAIN_DB_PREFIX.
"adherent SET socialnetworks='".$db->escape(json_encode($socialnetworks,
true)).
"'";
4828 $sqlupd .=
', skype=null';
4829 $sqlupd .=
', twitter=null';
4830 $sqlupd .=
', facebook=null';
4831 $sqlupd .=
', linkedin=null';
4832 $sqlupd .=
', instagram=null';
4833 $sqlupd .=
', snapchat=null';
4834 $sqlupd .=
', googleplus=null';
4835 $sqlupd .=
', youtube=null';
4836 $sqlupd .=
', whatsapp=null';
4837 $sqlupd .=
' WHERE rowid='.$obj->rowid;
4839 $resqlupd = $db->query($sqlupd);
4854 print '<b>'.$langs->trans(
'MigrationFieldsSocialNetworks',
'Members').
"</b><br>\n";
4869 print '<tr><td colspan="4">';
4870 $sql =
'SELECT rowid, socialnetworks';
4871 $sql .=
', jabberid, skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.
'socpeople WHERE ';
4872 $sql .=
" jabberid IS NOT NULL OR jabberid <> ''";
4873 $sql .=
" OR skype IS NOT NULL OR skype <> ''";
4874 $sql .=
" OR twitter IS NOT NULL OR twitter <> ''";
4875 $sql .=
" OR facebook IS NOT NULL OR facebook <> ''";
4876 $sql .=
" OR linkedin IS NOT NULL OR linkedin <> ''";
4877 $sql .=
" OR instagram IS NOT NULL OR instagram <> ''";
4878 $sql .=
" OR snapchat IS NOT NULL OR snapchat <> ''";
4879 $sql .=
" OR googleplus IS NOT NULL OR googleplus <> ''";
4880 $sql .=
" OR youtube IS NOT NULL OR youtube <> ''";
4881 $sql .=
" OR whatsapp IS NOT NULL OR whatsapp <> ''";
4883 $resql = $db->query($sql);
4885 while ($obj = $db->fetch_object(
$resql)) {
4886 $arraysocialnetworks = array();
4887 if (!empty($obj->jabberid)) {
4888 $arraysocialnetworks[
'jabber'] = $obj->jabberid;
4890 if (!empty($obj->skype)) {
4891 $arraysocialnetworks[
'skype'] = $obj->skype;
4893 if (!empty($obj->twitter)) {
4894 $arraysocialnetworks[
'twitter'] = $obj->twitter;
4896 if (!empty($obj->facebook)) {
4897 $arraysocialnetworks[
'facebook'] = $obj->facebook;
4899 if (!empty($obj->linkedin)) {
4900 $arraysocialnetworks[
'linkedin'] = $obj->linkedin;
4902 if (!empty($obj->instagram)) {
4903 $arraysocialnetworks[
'instagram'] = $obj->instagram;
4905 if (!empty($obj->snapchat)) {
4906 $arraysocialnetworks[
'snapchat'] = $obj->snapchat;
4908 if (!empty($obj->googleplus)) {
4909 $arraysocialnetworks[
'googleplus'] = $obj->googleplus;
4911 if (!empty($obj->youtube)) {
4912 $arraysocialnetworks[
'youtube'] = $obj->youtube;
4914 if (!empty($obj->whatsapp)) {
4915 $arraysocialnetworks[
'whatsapp'] = $obj->whatsapp;
4917 if ($obj->socialnetworks ==
'' || is_null($obj->socialnetworks)) {
4918 $obj->socialnetworks =
'[]';
4920 $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks,
true));
4921 $sqlupd =
'UPDATE '.MAIN_DB_PREFIX.
"socpeople SET socialnetworks='".$db->escape(json_encode($socialnetworks,
true)).
"'";
4922 $sqlupd .=
', jabberid=null';
4923 $sqlupd .=
', skype=null';
4924 $sqlupd .=
', twitter=null';
4925 $sqlupd .=
', facebook=null';
4926 $sqlupd .=
', linkedin=null';
4927 $sqlupd .=
', instagram=null';
4928 $sqlupd .=
', snapchat=null';
4929 $sqlupd .=
', googleplus=null';
4930 $sqlupd .=
', youtube=null';
4931 $sqlupd .=
', whatsapp=null';
4932 $sqlupd .=
' WHERE rowid='.$obj->rowid;
4934 $resqlupd = $db->query($sqlupd);
4949 print '<b>'.$langs->trans(
'MigrationFieldsSocialNetworks',
'Contacts').
"</b><br>\n";
4964 print '<tr><td colspan="4">';
4965 $sql =
'SELECT rowid, socialnetworks';
4966 $sql .=
', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.
'societe WHERE ';
4967 $sql .=
" skype IS NOT NULL OR skype <> ''";
4968 $sql .=
" OR twitter IS NOT NULL OR twitter <> ''";
4969 $sql .=
" OR facebook IS NOT NULL OR facebook <> ''";
4970 $sql .=
" OR linkedin IS NOT NULL OR linkedin <> ''";
4971 $sql .=
" OR instagram IS NOT NULL OR instagram <> ''";
4972 $sql .=
" OR snapchat IS NOT NULL OR snapchat <> ''";
4973 $sql .=
" OR googleplus IS NOT NULL OR googleplus <> ''";
4974 $sql .=
" OR youtube IS NOT NULL OR youtube <> ''";
4975 $sql .=
" OR whatsapp IS NOT NULL OR whatsapp <> ''";
4977 $resql = $db->query($sql);
4979 while ($obj = $db->fetch_object(
$resql)) {
4980 $arraysocialnetworks = array();
4981 if (!empty($obj->skype)) {
4982 $arraysocialnetworks[
'skype'] = $obj->skype;
4984 if (!empty($obj->twitter)) {
4985 $arraysocialnetworks[
'twitter'] = $obj->twitter;
4987 if (!empty($obj->facebook)) {
4988 $arraysocialnetworks[
'facebook'] = $obj->facebook;
4990 if (!empty($obj->linkedin)) {
4991 $arraysocialnetworks[
'linkedin'] = $obj->linkedin;
4993 if (!empty($obj->instagram)) {
4994 $arraysocialnetworks[
'instagram'] = $obj->instagram;
4996 if (!empty($obj->snapchat)) {
4997 $arraysocialnetworks[
'snapchat'] = $obj->snapchat;
4999 if (!empty($obj->googleplus)) {
5000 $arraysocialnetworks[
'googleplus'] = $obj->googleplus;
5002 if (!empty($obj->youtube)) {
5003 $arraysocialnetworks[
'youtube'] = $obj->youtube;
5005 if (!empty($obj->whatsapp)) {
5006 $arraysocialnetworks[
'whatsapp'] = $obj->whatsapp;
5008 if ($obj->socialnetworks ==
'' || is_null($obj->socialnetworks)) {
5009 $obj->socialnetworks =
'[]';
5011 $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks,
true));
5012 $sqlupd =
'UPDATE '.MAIN_DB_PREFIX.
"societe SET socialnetworks='".$db->escape(json_encode($socialnetworks,
true)).
"'";
5013 $sqlupd .=
', skype=null';
5014 $sqlupd .=
', twitter=null';
5015 $sqlupd .=
', facebook=null';
5016 $sqlupd .=
', linkedin=null';
5017 $sqlupd .=
', instagram=null';
5018 $sqlupd .=
', snapchat=null';
5019 $sqlupd .=
', googleplus=null';
5020 $sqlupd .=
', youtube=null';
5021 $sqlupd .=
', whatsapp=null';
5022 $sqlupd .=
' WHERE rowid='.$obj->rowid;
5024 $resqlupd = $db->query($sqlupd);
5039 print '<b>'.$langs->trans(
'MigrationFieldsSocialNetworks',
'Thirdparties').
"</b><br>\n";
migrate_user_photospath()
Migrate file from old path to new one for users.
migrate_commande_livraison($db, $langs, $conf)
Correspondance des livraisons et des commandes clients dans la table llx_co_liv.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement=null, $excludesubdir=0)
Copy a dir to another dir.
pHeader($subtitle, $next, $action= 'set', $param= '', $forcejqueryurl= '', $csstable= 'main-inside')
Show HTML header of install pages.
migrate_rename_directories($db, $langs, $conf, $oldname, $newname)
Migration directory.
migrate_project_task_actors($db, $langs, $conf)
Migration de la table llx_projet_task_actors vers llx_element_contact.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
migrate_contracts_det($db, $langs, $conf)
Mise a jour des contrats (gestion du contrat + detail de contrat)
migrate_delete_old_files($db, $langs, $conf)
Delete deprecated files.
migrate_commande_deliveryaddress($db, $langs, $conf)
Migration du champ fk_adresse_livraison dans expedition 2.6 -> 2.7.
Description and activation class for module ECM.
dol_decode($chain, $key= '1')
Decode a base 64 encoded + specific delta change.
migrate_price_propal($db, $langs, $conf)
Update total of proposal lines.
migrate_price_contrat($db, $langs, $conf)
Update total of contract lines.
migrate_reload_menu($db, $langs, $conf)
Reload menu if dynamic menus, if modified by version.
migrate_contracts_date3($db, $langs, $conf)
Mise a jour des dates de creation de contrat.
migrate_shipping_delivery2($db, $langs, $conf)
We try to complete field ref_customer and date_delivery that are empty into llx_livraison.
migrate_contacts_socialnetworks()
Migrate contacts fields facebook and co to socialnetworks.
migrate_actioncomm_element($db, $langs, $conf)
Migrate link stored into fk_xxxx into fk_element and elementtype.
migrate_event_assignement($db, $langs, $conf)
Migrate event assignement to owner.
migrate_links_transfert($db, $langs, $conf)
Function to migrate links into llx_bank_url.
dol_now($mode= 'auto')
Return date for now.
migrate_paiements_orphelins_2($db, $langs, $conf)
Corrige paiement orphelins (liens paumes suite a bugs) Pour verifier s'il reste des orphelins: select...
calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller= '', $localtaxes_array= '', $progress=100, $multicurrency_tx=1, $pu_devise=0, $multicurrency_code= '')
Calculate totals (net, vat, ...) of a line.
Class to manage Dolibarr users.
migrate_paiementfourn_facturefourn($db, $langs, $conf)
Factures fournisseurs.
Description and activation class for module ExpenseReport.
migrate_project_user_resp($db, $langs, $conf)
Migration du champ fk_user_resp de llx_projet vers llx_element_contact.
migrate_reset_blocked_log($db, $langs, $conf)
Migrate to reset the blocked log for V7+ algorithm.
migrate_categorie_association($db, $langs, $conf)
Migrate categorie association.
dol_is_dir($folder)
Test if filename is a directory.
Class to manage lines of contracts.
Description and activation class for module holiday.
migrate_usergroup_rights_entity($db, $langs, $conf)
Migrate to add entity value into llx_usergroup_rights.
migrate_clean_association($db, $langs, $conf)
Delete duplicates in table categorie_association.
migrate_menus($db, $langs, $conf)
Migration of menus (use only 1 table instead of 3) 2.6 -> 2.7.
migrate_contracts_date1($db, $langs, $conf)
Mise a jour des date de contrats non renseignees.
migrate_delete_old_dir($db, $langs, $conf)
Remove deprecated directories.
Class to describe a Cron module.
Class to manage order lines.
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
migrate_customerorder_shipping($db, $langs, $conf)
Migrate order ref_customer and date_delivery fields to llx_expedition.
migrate_price_commande($db, $langs, $conf)
Update total of sales order lines.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to describe and enable/disable module Agenda.
migrate_contracts_open($db, $langs, $conf)
Reouverture des contrats qui ont au moins une ligne non fermee.
Class to describe Barcode.
Description and activation class for module Api.
migrate_users_socialnetworks()
Migrate users fields facebook and co to socialnetworks.
Description and activation class for module opensurvey.
migrate_paiements_orphelins_1($db, $langs, $conf)
Corrige paiement orphelins (liens paumes suite a bugs) Pour verifier s'il reste des orphelins: select...
Class to manage Blocked Log.
Class to describe and enable module Service.
Description and activation class for module Fournisseur.
migrate_stocks($db, $langs, $conf)
Migration du champ stock dans produits.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
Class to describe and enable module TakePos.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories) ...
migrate_restore_missing_links($db, $langs, $conf)
Migration du champ fk_remise_except dans llx_facturedet doit correspondre a lien dans llx_societe_rem...
migrate_event_assignement_contact($db, $langs, $conf)
Migrate event assignement to owner.
Class to manage commercial proposal lines.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
migrate_shipping_delivery($db, $langs, $conf)
Migrate link stored into fk_expedition into llx_element_element.
Class to describe and enable module Donation.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
run_sql($sqlfile, $silent=1, $entity= '', $usesavepoint=1, $handler= '', $okerror= 'default', $linelengthlimit=32768, $nocommentremoval=0, $offsetforchartofaccount=0)
Launch a sql file.
migrate_price_commande_fournisseur($db, $langs, $conf)
Update total of purchase order lines.
Class to describe and enable module SupplierProposal.
migrate_paiements($db, $langs, $conf)
Reporte liens vers une facture de paiements sur table de jointure (lien n-n paiements factures) ...
Description and activation class for module productdluo.
dol_is_file($pathoffile)
Return if path is a file.
Class descriptor of Product module.
pFooter($nonext=0, $setuplang= '', $jscheckfunction= '', $withpleasewait=0)
Print HTML footer of install pages.
migrate_commande_expedition($db, $langs, $conf)
Correspondance des expeditions et des commandes clients dans la table llx_co_exp. ...
Class to describe and enable module Societe.
migrate_price_facture($db, $langs, $conf)
Update total of invoice lines.
print
Draft customers invoices.
migrate_reload_modules($db, $langs, $conf, $listofmodule=array(), $force=0)
Disable/Reenable features modules.
migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $sourcetype, $fk_target, $targettype)
Migration des tables de relation.
migrate_detail_livraison($db, $langs, $conf)
Migration des details commandes dans les details livraisons.
migrate_remise_except_entity($db, $langs, $conf)
Migrate to add entity value into llx_societe_remise_except.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
migrate_remise_entity($db, $langs, $conf)
Migrate to add entity value into llx_societe_remise.
migrate_contracts_date2($db, $langs, $conf)
Update contracts with date min real if service date is lower.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Description and activation class for module ExternalSite.
migrate_modeles($db, $langs, $conf)
Mise a jour des modeles selectionnes.
Class to manage invoices.
migrate_thirdparties_socialnetworks()
Migrate thirdparties fields facebook and co to socialnetworks.
migrate_user_rights_entity($db, $langs, $conf)
Migrate to add entity value into llx_user_rights.
Class to describe module customer orders.
migrate_mode_reglement($db, $langs, $conf)
Migrate link stored into fk_mode_reglement.
migrate_members_socialnetworks()
Migrate members fields facebook and co to socialnetworks.
Class to describe and enable module Deplacement.
Class to describe module customer invoices.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage invoice lines.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
migrate_project_task_time($db, $langs, $conf)
Migrate duration in seconds.
Class to manage line orders.