diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index c5fd9b80482..982f61f5067 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -206,7 +206,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOS $search_state=""; $search_type=''; $search_country=''; - $search_type_thirdparty=''; + $search_type_thirdparty=''; $day=''; $year=''; $month=''; @@ -229,7 +229,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } - + /* * View @@ -255,7 +255,7 @@ $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. -if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed'; +if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed'; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -462,7 +462,7 @@ if ($resql) 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge") ); - if ($user->rights->facture->supprimer) + if ($user->rights->facture->supprimer) { //if (! empty($conf->global->STOCK_CALCULATE_ON_BILL) || empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) @@ -479,6 +479,7 @@ if ($resql) $i = 0; print '
'."\n"; + if ($optioncss != '') print ''; print ''; print ''; @@ -492,8 +493,8 @@ if ($resql) if ($massaction == 'presend') { $langs->load("mails"); - - if (! GETPOST('cancel')) + + if (! GETPOST('cancel')) { $objecttmp=new Facture($db); $listofselectedid=array(); @@ -502,7 +503,7 @@ if ($resql) foreach($arrayofselected as $toselectid) { $result=$objecttmp->fetch($toselectid); - if ($result > 0) + if ($result > 0) { $listofselectedid[$toselectid]=$toselectid; $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; @@ -513,10 +514,10 @@ if ($resql) } print ''; - + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - + dol_fiche_head(null, '', ''); $topicmail="SendBillRef"; @@ -584,16 +585,16 @@ if ($resql) //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; print $formmail->get_form(); - + dol_fiche_end(); } - + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - + // If the user can view prospects other than his' $moreforfilter=''; if ($user->rights->societe->client->voir || $socid) @@ -683,14 +684,14 @@ if ($resql) // Filters lines print ''; // Ref - if (! empty($arrayfields['f.facnumber']['checked'])) + if (! empty($arrayfields['f.facnumber']['checked'])) { print ''; print ''; print ''; } // Ref customer - if (! empty($arrayfields['f.ref_client']['checked'])) + if (! empty($arrayfields['f.ref_client']['checked'])) { print ''; print ''; @@ -711,7 +712,7 @@ if ($resql) print ''; } // Date invoice - if (! empty($arrayfields['f.date']['checked'])) + if (! empty($arrayfields['f.date']['checked'])) { print ''; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; @@ -720,7 +721,7 @@ if ($resql) print ''; } // Date due - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) + if (! empty($arrayfields['f.date_lim_reglement']['checked'])) { print ''; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; @@ -730,7 +731,7 @@ if ($resql) print ''; } // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) + if (! empty($arrayfields['s.nom']['checked'])) { print ''; } @@ -760,7 +761,7 @@ if ($resql) print ''; } // Payment mode - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) + if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) { print ''; $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 0, 1, 10); @@ -875,19 +876,19 @@ if ($resql) $totaldeposits = $facturestatic->getSumDepositsUsed(); $totalpay = $paiement + $totalcreditnotes + $totaldeposits; $remaintopay = $obj->total_ttc - $totalpay; - + print ''; if (! empty($arrayfields['f.facnumber']['checked'])) { print ''; print ''; - + print ''; - + print ''; print ''; print '
'; print $facturestatic->getNomUrl(1,'',200,0,'',0,1); print $obj->increment; print ''; $filename=dol_sanitizeFileName($obj->facnumber); $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->facnumber); @@ -896,7 +897,7 @@ if ($resql) print '
'; - + print "\n"; if (! $i) $totalarray['nbfield']++; } @@ -1085,12 +1086,12 @@ if ($resql) // Status if (! empty($arrayfields['f.fk_statut']['checked'])) { - print ''; - print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type); - print ""; - if (! $i) $totalarray['nbfield']++; + print ''; + print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type); + print ""; + if (! $i) $totalarray['nbfield']++; } - + // Action column print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined @@ -1101,7 +1102,7 @@ if ($resql) } print '' ; if (! $i) $totalarray['nbfield']++; - + print "\n"; $i++; @@ -1128,21 +1129,21 @@ if ($resql) else print ''; } print ''; - + } } $db->free($resql); - + $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - + print "\n"; print ""; - + print "
\n"; - + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { /* @@ -1150,11 +1151,11 @@ if ($resql) */ $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; $urlsource.=str_replace('&','&',$param); - + $filedir=$diroutputmassaction; $genallowed=$user->rights->facture->lire; $delallowed=$user->rights->facture->lire; - + print $formfile->showdocuments('massfilesarea_invoices','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } else diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 78e2940942f..dd64b53ae66 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -3,8 +3,8 @@ * Copyright (C) 2012-2016 Laurent Destailleur * Copyright (C) 2012-2016 Regis Houssin * Copyright (C) 2013 Juanjo Menent - * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2014-2017 Ferran Marcet * * 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 @@ -41,7 +41,6 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; $myparam = GETPOST("myparam"); $action=GETPOST('action', 'alpha'); $id=GETPOST('id', 'int'); -$userid = GETPOST('userid')?GETPOST('userid'):$user->id; // Protection if external user if ($user->societe_id > 0) accessforbidden(); @@ -61,7 +60,8 @@ if ($action == 'create') $object = new Holiday($db); // If no right to create a request - if (($userid == $user->id && empty($user->rights->holiday->write)) || ($userid != $user->id && empty($user->rights->holiday->write_all))) + $fuserid = GETPOST('fuserid'); + if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all))) { $error++; setEventMessages($langs->trans('CantCreateCP'), null, 'errors'); @@ -86,7 +86,6 @@ if ($action == 'create') $valideur = GETPOST('valideur'); $description = trim(GETPOST('description')); - $userID = GETPOST('userID'); // If no type if ($type <= 0) @@ -576,27 +575,27 @@ if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes') { $object = new Holiday($db); $object->fetch($id); - + $oldstatus = $object->statut; $object->statut = 1; - + $result = $object->update($user); if ($result < 0) { $error = $langs->trans('ErrorBackToDraft'); } - + if (! $error) { $db->commit(); - + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { $db->rollback(); - } + } } // Si Validation de la demande @@ -722,7 +721,7 @@ llxHeader('', $langs->trans('CPTitreMenu')); if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create') { // Si l'utilisateur n'a pas le droit de faire une demande - if (($userid == $user->id && empty($user->rights->holiday->write)) || ($userid != $user->id && empty($user->rights->holiday->write_all))) + if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all))) { $errors[]=$langs->trans('CantCreateCP'); } @@ -802,7 +801,6 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create // Formulaire de demande print '
'."\n"; print ''."\n"; - print ''."\n"; dol_fiche_head(); @@ -833,10 +831,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; if (empty($user->rights->holiday->write_all)) { - print $form->select_dolusers($userid, 'useridbis', 0, '', 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - print ''; + print $form->select_dolusers($fuserid, 'useridbis', 0, '', 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + print ''; } - else print $form->select_dolusers(GETPOST('userid')?GETPOST('userid'):$user->id,'userid',0,'',0); + else print $form->select_dolusers(GETPOST('fuserid')?GETPOST('fuserid'):$user->id,'fuserid',0,'',0); print ''; print ''; @@ -1023,7 +1021,7 @@ else { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleSetToDraft"),$langs->trans("ConfirmSetToDraft"),"confirm_draft", '', 1, 1); } - + $head=holiday_prepare_head($object); @@ -1038,14 +1036,14 @@ else dol_fiche_head($head,'card',$langs->trans("CPTitreMenu"),0,'holiday'); $linkback=''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref'); - - + + print '
'; print '
'; print '
'; - + print ''; print ''; @@ -1147,9 +1145,9 @@ else print ''; print '
'; print '
'; - + print '
'; - + // Info workflow print '
'."\n"; print ''; @@ -1206,12 +1204,12 @@ else print ''; print ''; print ''; - + print '
'; - + dol_fiche_end(); - + if ($action == 'edit' && $object->statut == 1) { print '
'; @@ -1267,7 +1265,7 @@ else { print ''.$langs->trans("SetToDraft").''; } - + print '
'; } diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index 1d7ad10d938..8d3049bed51 100755 --- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql +++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql @@ -63,7 +63,7 @@ ALTER TABLE llx_bookmark ADD COLUMN entity integer DEFAULT 1 NOT NULL; ALTER TABLE llx_bookmark MODIFY COLUMN url varchar(255) NOT NULL; -ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT '2001-01-01 00:00:00'; +-- VMYSQL4.1 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT '2001-01-01 00:00:00'; -- Clean corrupted values for tms -- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; @@ -74,7 +74,7 @@ ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT '2001-01- -- VMYSQL4.3 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN date_fin DATETIME NULL DEFAULT NULL; -- VPGSQL8.2 ALTER TABLE llx_opensurvey_sondage ALTER COLUMN date_fin DROP NOT NULL; -ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP; +-- VMYSQL4.1 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP; ALTER TABLE llx_opensurvey_sondage ADD COLUMN entity integer DEFAULT 1 NOT NULL; @@ -204,9 +204,14 @@ CREATE TABLE llx_payment_salary ( fk_user_modif integer )ENGINE=innodb; + +DELETE FROM llx_product_batch where fk_product_stock NOT IN (SELECT rowid from llx_product_stock); + ALTER TABLE llx_product_batch ADD INDEX idx_fk_product_stock (fk_product_stock); ALTER TABLE llx_product_batch ADD CONSTRAINT fk_product_batch_fk_product_stock FOREIGN KEY (fk_product_stock) REFERENCES llx_product_stock (rowid); +DELETE FROM llx_expeditiondet_batch where fk_expeditiondet NOT IN (SELECT rowid from llx_expeditiondet); + ALTER TABLE llx_expeditiondet_batch ADD INDEX idx_fk_expeditiondet (fk_expeditiondet); ALTER TABLE llx_expeditiondet_batch ADD CONSTRAINT fk_expeditiondet_batch_fk_expeditiondet FOREIGN KEY (fk_expeditiondet) REFERENCES llx_expeditiondet(rowid); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 1c7b717f6d1..71128872cc9 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -144,7 +144,7 @@ if ($id > 0 || ! empty($ref)) elseif ($user->rights->facture->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; - $sql.= " f.facnumber, f.datef, f.paye, f.fk_statut as statut, f.rowid as facid,"; + $sql.= " f.facnumber, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,"; $sql.= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -236,23 +236,24 @@ if ($id > 0 || ! empty($ref)) $var=True; while ($i < min($num,$conf->liste_limit)) { - $objp = $db->fetch_object($result); + $objp = $db->fetch_object($result); + $invoicestatic->id=$objp->facid; + $invoicestatic->ref=$objp->facnumber; + $societestatic->fetch($objp->socid); + $paiement = $invoicestatic->getSommePaiement(); $var=!$var; print ''; print '\n"; - $societestatic->fetch($objp->socid); print ''; print "\n"; print '"; print '\n"; print '\n"; - print ''; + print ''; print "\n"; $i++;
'; - $invoicestatic->id=$objp->facid; - $invoicestatic->ref=$objp->facnumber; print $invoicestatic->getNomUrl(1); print "'.$societestatic->getNomUrl(1).'".$objp->code_client."'; print dol_print_date($db->jdate($objp->datef),'day')."'.$objp->qty."'.price($objp->total_ht)."'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).''.$invoicestatic->LibStatut($objp->paye,$objp->statut,5,$paiement,$objp->type).'