diff --git a/dev/initdemo/updatedemo.php b/dev/initdemo/updatedemo.php index feabbe9ac6c0c2e93df88ab8a7bec375c4529b72..1d4a8f01f94695d5adee7eb6c70c8ad7247c33ed 100755 --- a/dev/initdemo/updatedemo.php +++ b/dev/initdemo/updatedemo.php @@ -1,6 +1,6 @@ #!/usr/bin/env php <?php -/* Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -62,100 +62,58 @@ if (empty($confirm)) $tmp=dol_getdate(dol_now()); +$tables=array( + 'propal'=>array(0=>'datep', 1=>'fin_validite', 2=>'date_valid', 3=>'date_cloture'), + 'commande'=>array(0=>'date_commande', 1=>'date_valid', 2=>'date_cloture'), + 'facture'=>array(0=>'datef', 1=>'date_valid', 2=>'date_lim_reglement'), + 'paiement'=>array(0=>'datep'), + 'bank'=>array(0=>'datev', 1=>'dateo', ) +); $year=2010; $currentyear=$tmp['year']; -while ($year < ($currentyear - 1)) // We want to keep 2 years of data +while ($year <= $currentyear) { $delta=($currentyear - $year); + $delta=-1; - print "Correct proposal for year ".$year." and move them to current year ".$currentyear."\n"; - $sql="select rowid from ".MAIN_DB_PREFIX."propal where datep between '".$year."-01-01' and '".$year."-12-31'"; - $resql = $db->query($sql); - if ($resql) + if ($delta) { - $num = $db->num_rows($resql); - $i=0; - while ($i < $num) + foreach($tables as $tablekey => $tableval) { - $obj=$db->fetch_object($resql); - if ($obj) + print "\nCorrect ".$tablekey." for year ".$year." and move them to current year ".$currentyear." "; + $sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." < DATE_ADD(NOW(), INTERVAL -1 YEAR)"; + //$sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." > NOW()"; + $resql = $db->query($sql); + if ($resql) { - print "."; - - $sql2="UPDATE ".MAIN_DB_PREFIX."propal set "; - $sql2.= "datep = DATE_ADD(datep, INTERVAL ".$delta." YEAR),"; - $sql2.= "fin_validite = DATE_ADD(fin_validite, INTERVAL ".$delta." YEAR),"; - $sql2.= "date_valid = DATE_ADD(date_valid, INTERVAL ".$delta." YEAR),"; - $sql2.= "date_cloture = DATE_ADD(date_cloture, INTERVAL ".$delta." YEAR)"; - $sql2.=" WHERE rowid = ".$obj->rowid; - //print $sql2."\n"; - - $resql2 = $db->query($sql2); - if (! $resql2) dol_print_error($db); - } - $i++; - } - } - else dol_print_error($db); - - print "Correct order for year ".$year." and move them to current year ".$currentyear."\n"; - $sql="select rowid from ".MAIN_DB_PREFIX."commande where date_commande between '".$year."-01-01' and '".$year."-12-31'"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i=0; - while ($i < $num) - { - $obj=$db->fetch_object($resql); - if ($obj) - { - print "."; - - $sql2="UPDATE ".MAIN_DB_PREFIX."commande set "; - $sql2.= "date_commande = DATE_ADD(date_commande, INTERVAL ".$delta." YEAR),"; - $sql2.= "date_valid = DATE_ADD(date_valid, INTERVAL ".$delta." YEAR),"; - $sql2.= "date_cloture = DATE_ADD(date_cloture, INTERVAL ".$delta." YEAR)"; - $sql2.=" WHERE rowid = ".$obj->rowid; - //print $sql2."\n"; - - $resql2 = $db->query($sql2); - if (! $resql2) dol_print_error($db); - } - $i++; - } - } - else dol_print_error($db); - - print "Correct invoice for year ".$year." and move them to current year ".$currentyear."\n"; - $sql="select rowid from ".MAIN_DB_PREFIX."facture where datef between '".$year."-01-01' and '".$year."-12-31'"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i=0; - while ($i < $num) - { - $obj=$db->fetch_object($resql); - if ($obj) - { - print "."; - - $sql2="UPDATE ".MAIN_DB_PREFIX."facture set "; - $sql2.= "datef = DATE_ADD(datef, INTERVAL ".$delta." YEAR),"; - $sql2.= "date_valid = DATE_ADD(date_valid, INTERVAL ".$delta." YEAR),"; - $sql2.= "date_lim_reglement = DATE_ADD(date_lim_reglement, INTERVAL ".$delta." YEAR)"; - $sql2.=" WHERE rowid = ".$obj->rowid; - //print $sql2."\n"; - - $resql2 = $db->query($sql2); - if (! $resql2) dol_print_error($db); + $num = $db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj=$db->fetch_object($resql); + if ($obj) + { + print "."; + $sql2="UPDATE ".MAIN_DB_PREFIX.$tablekey." set "; + $j=0; + foreach($tableval as $field) + { + if ($j) $sql2.=", "; + $sql2.= $field." = DATE_ADD(".$field.", INTERVAL ".$delta." YEAR)"; + $j++; + } + $sql2.=" WHERE rowid = ".$obj->rowid; + //print $sql2."\n"; + $resql2 = $db->query($sql2); + if (! $resql2) dol_print_error($db); + } + $i++; + } } - $i++; + else dol_print_error($db); } } - else dol_print_error($db); $year++; } diff --git a/htdocs/compta/bank/virement.php b/htdocs/compta/bank/virement.php index 146ed4759c406085c4dcdb3019d801f581142876..78950923b34db8561eeee6bc2490117071fb98bf 100644 --- a/htdocs/compta/bank/virement.php +++ b/htdocs/compta/bank/virement.php @@ -152,7 +152,7 @@ if($error) $amount = GETPOST('amount','int'); } -print load_fiche_titre($langs->trans("BankTransfer"), '', 'title_bank.png'); +print load_fiche_titre($langs->trans("MenuBankInternalTransfer"), '', 'title_bank.png'); print $langs->trans("TransferDesc"); print "<br><br>"; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 948c3a440f1e9fab5a92ddfe6292557a198b0b6a..f833ed144b1df7a7a0d55731c9d248c95f8ce698 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1062,7 +1062,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/compta/bank/search.php",$langs->trans("ListTransactions"),1,$user->rights->banque->lire); $newmenu->add("/compta/bank/budget.php",$langs->trans("ListTransactionsByCategory"),1,$user->rights->banque->lire); - $newmenu->add("/compta/bank/virement.php",$langs->trans("BankTransfers"),1,$user->rights->banque->transfer); + $newmenu->add("/compta/bank/virement.php",$langs->trans("MenuBankInternalTransfer"),1,$user->rights->banque->transfer); } if (! empty($conf->categorie->enabled)) { diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index b868967b10b44c2c3e69fae8b4055c313d181f6f..819664dfdc4f31aaae1d6d408c6024d91c258475 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -94,7 +94,8 @@ WithdrawalPayment=Withdrawal payment SocialContributionPayment=Social/fiscal tax payment BankTransfer=Bank transfer BankTransfers=Bank transfers -TransferDesc=Transfer from one account to another one, Dolibarr will write two records (a debit in source account and a credit in target account, of the same amount. The same label and date will be used for this transaction) +MenuBankInternalTransfer=Internal transfer +TransferDesc=Transfer from one account to another one, Dolibarr will write two records (a debit in source account and a credit in target account. The same amount (except sign), label and date will be used for this transaction) TransferFrom=From TransferTo=To TransferFromToDone=A transfer from <b>%s</b> to <b>%s</b> of <b>%s</b> %s has been recorded.