From dc14268ac6699d8ea0ee8ab2b6cdd6758914dcbf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Apr 2017 15:24:41 +0200 Subject: [PATCH] FIX complete hourly rate when not defined into table of time spent --- htdocs/install/repair.php | 76 ++++++++++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index cdaa0b22b7f..0338945df0f 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -76,6 +76,7 @@ print 'Option restore_thirdparties_logos is '.(GETPOST('restore_thirdparties_log print 'Option clean_linked_elements is '.(GETPOST('clean_linked_elements')?GETPOST('clean_linked_elements'):'0').'
'."\n"; print 'Option clean_orphelin_dir (1 or confirmed) is '.(GETPOST('clean_orphelin_dir')?GETPOST('clean_orphelin_dir'):'0').'
'."\n"; print 'Option clean_product_stock_batch (1 or confirmed) is '.(GETPOST('clean_product_stock_batch')?GETPOST('clean_product_stock_batch'):'0').'
'."\n"; +print 'Option set_empty_time_spent_amount (1 or confirmed) is '.(GETPOST('set_empty_time_spent_amount')?GETPOST('set_empty_time_spent_amount'):'0').'
'."\n"; print '
'; print ''; @@ -151,7 +152,7 @@ if ($ok) } // Show wait message -print ''; +print ''; flush(); @@ -190,7 +191,7 @@ if ($ok) // Loop on each file foreach($filelist as $file) { - print ''; $name = substr($file, 0, dol_strlen($file) - 4); @@ -210,7 +211,7 @@ if ($ok) 'socpeople'=>'socpeople', 'commande'=>'commande', 'facture'=>'facture', 'commande_fournisseur'=>'commande_fournisseur', 'actioncomm'=>'actioncomm', 'adherent_type'=>'adherent_type','user'=>'user','projet'=>'projet', 'projet_task'=>'projet_task'); - print ''; + print ''; foreach($listofmodulesextra as $tablename => $elementtype) { // Get list of fields @@ -324,7 +325,7 @@ if ($ok && GETPOST('restore_thirdparties_logos')) $ext=''; - print ''; + print ''; // propal => order print '\n"; @@ -435,7 +436,7 @@ if ($ok && GETPOST('clean_orphelin_dir')) if (empty($upload_dir)) continue; - print ''; + print ''; $filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','(\.meta|_preview\.png)$','^temp$','^payments$','^CVS$','^thumbs$'),'',SORT_DESC,1,true); @@ -546,7 +547,7 @@ if ($ok && GETPOST('clean_orphelin_dir')) // clean_linked_elements: Check and clean linked elements if ($ok && GETPOST('clean_product_stock_batch')) { - print ''; + print ''; $sql ="SELECT p.rowid, p.ref, p.tobatch, ps.rowid as psrowid, ps.fk_entrepot, ps.reel, SUM(pb.qty) as reelbatch"; $sql.=" FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product_batch as pb"; @@ -636,12 +637,69 @@ if ($ok && GETPOST('clean_product_stock_batch')) { dol_print_error($db); } - - } +// clean_linked_elements: Check and clean linked elements +if ($ok && GETPOST('set_empty_time_spent_amount')) +{ + print ''; + + $sql ="SELECT COUNT(ptt.rowid) as nb, u.rowid as user_id, u.login, u.thm as user_thm"; + $sql.=" FROM ".MAIN_DB_PREFIX."projet_task_time as ptt, ".MAIN_DB_PREFIX."user as u"; + $sql.=" WHERE ptt.fk_user = u.rowid"; + $sql.=" AND ptt.thm IS NULL and u.thm > 0"; + $sql.=" GROUP BY u.rowid, u.login, u.thm"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj=$db->fetch_object($resql); + print ''; + + if ($error) break; + + $i++; + } + } + else + { + print ''; + } + } + else + { + dol_print_error($db); + } + + +} + + print '
'.$langs->trans("PleaseBePatient").'
'.$langs->trans("PleaseBePatient").'

'; + print '
*** '; print $langs->trans("Script").''.$file.'

Check fields into extra table structure match table of definition. If not add column into table

*** Check fields into extra table structure match table of definition. If not add column into table

'; + print '

*** Restore thirdparties logo
'; //foreach($exts as $ext) //{ $sql="SELECT s.rowid, s.nom as name, s.logo FROM ".MAIN_DB_PREFIX."societe as s ORDER BY s.nom"; @@ -395,7 +396,7 @@ if ($ok && GETPOST('restore_thirdparties_logos')) // clean_linked_elements: Check and clean linked elements if ($ok && GETPOST('clean_linked_elements')) { - print '

Check table of linked elements and delete orphelins links

*** Check table of linked elements and delete orphelins links
'.checkLinkedElements('propal', 'commande')."

Clean orphelins files into files '.$upload_dir.'

*** Clean orphelins files into files '.$upload_dir.'

Clean table product_batch

*** Clean table product_batch

*** Set value of time spent without amount
'.$obj->login.'-'.$obj->user_id.' ('.$obj->nb.' lines to fix) -> '.$obj->user_thm; + + $db->begin(); + + $sql2 ="UPDATE ".MAIN_DB_PREFIX."projet_task_time"; + $sql2.=" SET thm = ".$obj->user_thm." WHERE thm IS NULL AND fk_user = ".$obj->user_id; + $resql2=$db->query($sql2); + if (! $resql2) + { + $error++; + dol_print_error($db); + } + + if (!$error) $db->commit(); + else $db->rollback(); + + print'
No time spent with empty line on users with a hourly rate defined
';