diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 7593c814b31..11acc1914a1 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -203,7 +203,7 @@ $var=true; */ $max=5; -$sql = "SELECT a.rowid, a.statut, a.nom as lastname, a.prenom as firstname,"; +$sql = "SELECT a.rowid, a.statut, a.nom as lastname, a.prenom as firstname, a.societe as company, a.fk_soc,"; $sql.= " a.tms as datem, datefin as date_end_subscription,"; $sql.= " ta.rowid as typeid, ta.libelle, ta.cotisation"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; @@ -232,11 +232,18 @@ if ($resql) $staticmember->id=$obj->rowid; $staticmember->lastname=$obj->lastname; $staticmember->firstname=$obj->firstname; + if (! empty($obj->fk_soc)) { + $staticmember->socid = $obj->fk_soc; + $staticmember->fetch_thirdparty(); + $staticmember->name=$staticmember->thirdparty->name; + } else { + $staticmember->name=$obj->company; + } $staticmember->ref=$staticmember->getFullName($langs); $statictype->id=$obj->typeid; $statictype->libelle=$obj->libelle; - print ''.$staticmember->getNomUrl(1,24).''; - print ''.$statictype->getNomUrl(1,16).''; + print ''.$staticmember->getNomUrl(1,32).''; + print ''.$statictype->getNomUrl(1,32).''; print ''.dol_print_date($db->jdate($obj->datem),'dayhour').''; print ''.$staticmember->LibStatut($obj->statut,($obj->cotisation=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).''; print ''; @@ -256,7 +263,7 @@ else */ $max=5; -$sql = "SELECT a.rowid, a.statut, a.nom as lastname, a.prenom as firstname,"; +$sql = "SELECT a.rowid, a.statut, a.nom as lastname, a.prenom as firstname, a.societe as company, a.fk_soc,"; $sql.= " datefin as date_end_subscription,"; $sql.= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.cotisation"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."cotisation as c"; @@ -287,9 +294,16 @@ if ($resql) $staticmember->id=$obj->rowid; $staticmember->lastname=$obj->lastname; $staticmember->firstname=$obj->firstname; + if (! empty($obj->fk_soc)) { + $staticmember->socid = $obj->fk_soc; + $staticmember->fetch_thirdparty(); + $staticmember->name=$staticmember->thirdparty->name; + } else { + $staticmember->name=$obj->company; + } $staticmember->ref=$staticmember->getFullName($langs); print ''.$subscriptionstatic->getNomUrl(1).''; - print ''.$staticmember->getNomUrl(1,24,'subscription').''; + print ''.$staticmember->getNomUrl(1,32,'subscription').''; print ''.get_date_range($db->jdate($obj->date_start),$db->jdate($obj->date_end)).''; print ''.price($obj->cotisation).''; //print ''.$staticmember->LibStatut($obj->statut,($obj->cotisation=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).''; @@ -320,7 +334,7 @@ foreach ($AdherentType as $key => $adhtype) { $var=!$var; print ""; - print ''.img_object($langs->trans("ShowType"),"group").' '.$adhtype->getNomUrl(0,dol_size(16)).''; + print ''.$adhtype->getNomUrl(1, dol_size(32)).''; print ''.(isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0?$MemberToValidate[$key]:'').' '.$staticmember->LibStatut(-1,$adhtype->cotisation,0,3).''; print ''.(isset($MembersValidated[$key]) && ($MembersValidated[$key]-$MemberUpToDate[$key] > 0) ? $MembersValidated[$key]-$MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,0,3).''; print ''.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,$now,3).''; diff --git a/htdocs/adherents/liste.php b/htdocs/adherents/liste.php index ca87562153a..4752a36a65a 100644 --- a/htdocs/adherents/liste.php +++ b/htdocs/adherents/liste.php @@ -84,7 +84,7 @@ llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adhé $now=dol_now(); -$sql = "SELECT d.rowid, d.login, d.nom as lastname, d.prenom as firstname, d.societe, "; +$sql = "SELECT d.rowid, d.login, d.nom as lastname, d.prenom as firstname, d.societe as company, d.fk_soc,"; $sql.= " d.datefin,"; $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; $sql.= " t.libelle as type, t.cotisation"; @@ -238,7 +238,7 @@ if ($resql) print ''; $listetype=$membertypestatic->liste_array(); - print $form->selectarray("type", $listetype, $type, 1, 0, 0, '', 0, 12); + print $form->selectarray("type", $listetype, $type, 1, 0, 0, '', 0, 32); print ''; print ' '; @@ -268,6 +268,14 @@ if ($resql) $memberstatic->lastname=$objp->lastname; $memberstatic->firstname=$objp->firstname; + if (! empty($objp->fk_soc)) { + $memberstatic->socid = $objp->fk_soc; + $memberstatic->fetch_thirdparty(); + $companyname=$memberstatic->thirdparty->name; + } else { + $companyname=$objp->company; + } + $var=!$var; print ""; @@ -277,14 +285,11 @@ if ($resql) print "\n"; // Lastname - if ($objp->societe != '') - { - print "rowid\">".dol_trunc($memberstatic->getFullName($langs))." / ".dol_trunc($objp->societe,12)."\n"; - } - else - { - print "rowid\">".dol_trunc($memberstatic->getFullName($langs))."\n"; - } + print "rowid\">"; + print ((! empty($objp->lastname) || ! empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : ''); + print (((! empty($objp->lastname) || ! empty($objp->firstname)) && ! empty($companyname)) ? ' / ' : ''); + print (! empty($companyname) ? dol_trunc($companyname, 32) : ''); + print "\n"; // Login print "".$objp->login."\n"; @@ -293,7 +298,7 @@ if ($resql) $membertypestatic->id=$objp->type_id; $membertypestatic->libelle=$objp->type; print ''; - print $membertypestatic->getNomUrl(1,12); + print $membertypestatic->getNomUrl(1,32); print ''; // Moral/Physique diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 56c1434feac..5dcc2332015 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -8,6 +8,7 @@ * Copyright (C) 2011 Remy Younes * Copyright (C) 2012 Marcos García * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2011-2012 Alexandre Spangaro * * 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 @@ -136,7 +137,7 @@ $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.t $tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.deductible, p.code as pays_code, p.libelle as pays, a.fk_pays as pays_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_pays as p WHERE a.fk_pays=p.rowid and p.active=1"; $tabsql[8] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_typent"; $tabsql[9] = "SELECT code_iso as code, label as libelle, unicode, active FROM ".MAIN_DB_PREFIX."c_currencies"; -$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, p.libelle as pays, p.code as pays_code, t.fk_pays as pays_id, t.recuperableonly, t.note, t.active, t.accountancy_code FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p WHERE t.fk_pays=p.rowid"; +$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, p.libelle as pays, p.code as pays_code, t.fk_pays as pays_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p WHERE t.fk_pays=p.rowid"; $tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; $tabsql[12]= "SELECT c.rowid as rowid, code, sortorder, c.libelle, c.libelle_facture, nbjour, fdm, decalage, active FROM ".MAIN_DB_PREFIX.'c_payment_term AS c'; $tabsql[13]= "SELECT id as rowid, code, c.libelle, type, active FROM ".MAIN_DB_PREFIX."c_paiement AS c"; @@ -188,7 +189,7 @@ $tabfield[6] = "code,libelle,type,position"; $tabfield[7] = "code,libelle,pays_id,pays,deductible"; $tabfield[8] = "code,libelle"; $tabfield[9] = "code,libelle,unicode"; -$tabfield[10]= "pays_id,pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code,note"; +$tabfield[10]= "pays_id,pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[11]= "element,source,code,libelle"; $tabfield[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage"; $tabfield[13]= "code,libelle,type"; @@ -214,7 +215,7 @@ $tabfieldvalue[6] = "code,libelle,type,position"; $tabfieldvalue[7] = "code,libelle,pays,deductible"; $tabfieldvalue[8] = "code,libelle"; $tabfieldvalue[9] = "code,libelle,unicode"; -$tabfieldvalue[10]= "pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code,note"; +$tabfieldvalue[10]= "pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldvalue[11]= "element,source,code,libelle"; $tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage"; $tabfieldvalue[13]= "code,libelle,type"; @@ -240,7 +241,7 @@ $tabfieldinsert[6] = "code,libelle,type,position"; $tabfieldinsert[7] = "code,libelle,fk_pays,deductible"; $tabfieldinsert[8] = "code,libelle"; $tabfieldinsert[9] = "code_iso,label,unicode"; -$tabfieldinsert[10]= "fk_pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code,note"; +$tabfieldinsert[10]= "fk_pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldinsert[11]= "element,source,code,libelle"; $tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage"; $tabfieldinsert[13]= "code,libelle,type"; @@ -344,45 +345,45 @@ $elementList = array(); $sourceList=array(); if ($id == 11) { - $langs->load("orders"); - $langs->load("contracts"); - $langs->load("projects"); - $langs->load("propal"); - $langs->load("bills"); - $langs->load("interventions"); - $elementList = array( - 'commande' => $langs->trans('Order'), - 'invoice_supplier' => $langs->trans('SupplierBill'), - 'order_supplier' => $langs->trans('SupplierOrder'), - 'contrat' => $langs->trans('Contract'), - 'project' => $langs->trans('Project'), - 'project_task' => $langs->trans('Task'), - 'propal' => $langs->trans('Proposal'), - 'facture' => $langs->trans('Bill'), - 'facture_fourn' => $langs->trans('SupplierBill'), - 'fichinter' => $langs->trans('InterventionCard') - ); - if (! empty($conf->global->MAIN_SUPPORT_CONTACT_TYPE_FOR_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty'); - $sourceList = array( - 'internal' => $langs->trans('Internal'), - 'external' => $langs->trans('External') - ); + $langs->load("orders"); + $langs->load("contracts"); + $langs->load("projects"); + $langs->load("propal"); + $langs->load("bills"); + $langs->load("interventions"); + $elementList = array( + 'commande' => $langs->trans('Order'), + 'invoice_supplier' => $langs->trans('SupplierBill'), + 'order_supplier' => $langs->trans('SupplierOrder'), + 'contrat' => $langs->trans('Contract'), + 'project' => $langs->trans('Project'), + 'project_task' => $langs->trans('Task'), + 'propal' => $langs->trans('Proposal'), + 'facture' => $langs->trans('Bill'), + 'facture_fourn' => $langs->trans('SupplierBill'), + 'fichinter' => $langs->trans('InterventionCard') + ); + if (! empty($conf->global->MAIN_SUPPORT_CONTACT_TYPE_FOR_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty'); + $sourceList = array( + 'internal' => $langs->trans('Internal'), + 'external' => $langs->trans('External') + ); } // Define localtax_typeList (used for dictionnary "c_tva") $localtax_typeList = array(); if (GETPOST("id") == 10) { - $localtax_typeList = array( - "0" => $langs->trans("No"), - "1" => $langs->trans("Yes").' ('.$langs->trans("Type")." 1)", //$langs->trans("%ageOnAllWithoutVAT"), - "2" => $langs->trans("Yes").' ('.$langs->trans("Type")." 2)", //$langs->trans("%ageOnAllBeforeVAT"), - "3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)", //$langs->trans("%ageOnProductsWithoutVAT"), - "4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)", //$langs->trans("%ageOnProductsBeforeVAT"), - "5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"), - "6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)", //$langs->trans("%ageOnServiceBeforeVAT"), - "7" => $langs->trans("Yes").' ('.$langs->trans("Type")." 7)" //$langs->trans("AmountOnOrder") // We will enable this later. For the moment, work only of invoice localtype - ); + $localtax_typeList = array( + "0" => $langs->trans("No"), + "1" => $langs->trans("Yes").' ('.$langs->trans("Type")." 1)", //$langs->trans("%ageOnAllWithoutVAT"), + "2" => $langs->trans("Yes").' ('.$langs->trans("Type")." 2)", //$langs->trans("%ageOnAllBeforeVAT"), + "3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)", //$langs->trans("%ageOnProductsWithoutVAT"), + "4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)", //$langs->trans("%ageOnProductsBeforeVAT"), + "5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"), + "6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)", //$langs->trans("%ageOnServiceBeforeVAT"), + "7" => $langs->trans("Yes").' ('.$langs->trans("Type")." 7)" //$langs->trans("AmountOnOrder") // We will enable this later. For the moment, work only of invoice localtype + ); } $msg=''; @@ -404,7 +405,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue; if ((! isset($_POST[$value]) || $_POST[$value]=='') // && (! in_array($listfield[$f], array('decalage','module','accountancy_code','localtax1','localtax2'))) // Fields that are not mandatory - && (! in_array($listfield[$f], array('decalage','module','accountancy_code'))) // Fields that are not mandatory + && (! in_array($listfield[$f], array('decalage','module','accountancy_code_sell','accountancy_code_buy'))) // Fields that are not mandatory ) { $ok=0; @@ -464,14 +465,14 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) // Add new entry $sql = "INSERT INTO ".$tabname[$id]." ("; // List of fields - if ($tabrowid[$id] && - ! in_array($tabrowid[$id],$listfieldinsert)) $sql.= $tabrowid[$id].","; + if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) + $sql.= $tabrowid[$id].","; $sql.= $tabfieldinsert[$id]; $sql.=",active)"; $sql.= " VALUES("; // List of values - if ($tabrowid[$id] && - ! in_array($tabrowid[$id],$listfieldinsert)) $sql.= $newid.","; + if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) + $sql.= $newid.","; $i=0; foreach ($listfieldinsert as $f => $value) { @@ -516,7 +517,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) // Modify entry $sql = "UPDATE ".$tabname[$id]." SET "; // Modifie valeur des champs - if ($tabrowid[$id] && !in_array($tabrowid[$id],$listfieldmodify)) + if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify)) { $sql.= $tabrowid[$id]."="; $sql.= "'".$db->escape($rowid)."', "; @@ -633,7 +634,7 @@ $linkback=''; if ($id) { $titre.=' - '.$langs->trans($tablib[$id]); - $linkback=''.$langs->trans("BackToDictionnaryList").''; + $linkback=''.$langs->trans("BackToDictionnaryList").''; } print_fiche_titre($titre,$linkback,'setup'); @@ -685,7 +686,7 @@ if ($id) $fieldlist=explode(',',$tabfield[$id]); - print '
'; + print ''; print ''; print ''; @@ -710,9 +711,9 @@ if ($id) if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } if ($fieldlist[$field]=='taux') { $valuetoshow=$langs->trans("Rate"); } if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$form->textwithtooltip($langs->trans("UseLocalTax")." 2",$langs->trans("LocalTaxDesc"),2,1,img_help(1,'')); $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $align="right"; } + if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2";} if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$form->textwithtooltip($langs->trans("UseLocalTax")." 3",$langs->trans("LocalTaxDesc"),2,1,img_help(1,'')); $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $align="right"; } + if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3";} if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } @@ -731,7 +732,8 @@ if ($id) if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); } if ($fieldlist[$field]=='unit') { $valuetoshow=$langs->trans("MeasuringUnit"); } if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') { $valuetoshow=''; } - if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); } + if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); } + if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); } if ($fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } if ($fieldlist[$field]=='account_number') { $valuetoshow=$langs->trans("Account"); } if ($fieldlist[$field]=='account_parent') { $valuetoshow=$langs->trans("Accountparent"); } @@ -776,13 +778,14 @@ if ($id) print ''; print ""; - if ($alabelisused) // Si un des champs est un libelle + if (! empty($alabelisused)) // Si un des champs est un libelle { print ''; } print ''; } + print ''; // List of available values in database dol_syslog("htdocs/admin/dict sql=".$sql, LOG_DEBUG); @@ -825,9 +828,9 @@ if ($id) if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } if ($fieldlist[$field]=='taux') { $valuetoshow=$langs->trans("Rate"); } if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$form->textwithtooltip($langs->trans("UseLocalTax")." 2",$langs->trans("LocalTaxDesc"),2,1,img_help(1,'')); $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $align="right"; $sortable=0; } + if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $sortable=0; } if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$form->textwithtooltip($langs->trans("UseLocalTax")." 3",$langs->trans("LocalTaxDesc"),2,1,img_help(1,'')); $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $align="right"; $sortable=0; } + if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $sortable=0; } if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } @@ -843,7 +846,8 @@ if ($id) if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); } if ($fieldlist[$field]=='unit') { $valuetoshow=$langs->trans("MeasuringUnit"); } if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') { $showfield=0; } - if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); } + if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; } + if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); $sortable=0; } if ($fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } if ($fieldlist[$field]=='account_number') { $valuetoshow=$langs->trans("Accounts"); } if ($fieldlist[$field]=='account_parent') { $valuetoshow=$langs->trans("Accountsparent"); } @@ -869,9 +873,8 @@ if ($id) print ''; if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) { - print ''; + print ''; print ''; - print ''; print ''; print ''; @@ -886,7 +889,7 @@ if ($id) print ' '; } else - { + { $tmpaction = 'view'; $parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $reshook=$hookmanager->executeHooks('viewDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks @@ -919,7 +922,7 @@ if ($id) else { $key=$langs->trans("Country".strtoupper($obj->pays_code)); - $valuetoshow=($key != "Country".strtoupper($obj->pays_code))?$obj->pays_code." - ".$key:$obj->pays; + $valuetoshow=($key != "Country".strtoupper($obj->pays_code)?$obj->pays_code." - ".$key:$obj->pays); } } else if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field]=='fdm' || $fieldlist[$field] == 'deductible') { @@ -932,55 +935,55 @@ if ($id) else if ($fieldlist[$field]=='libelle_facture') { $langs->load("bills"); $key=$langs->trans("PaymentCondition".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); $valuetoshow=nl2br($valuetoshow); } else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_pays') { $key=$langs->trans("Country".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); } else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_availability') { $langs->load("propal"); $key=$langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); } else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_actioncomm') { $key=$langs->trans("Action".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); } else if (! empty($obj->code_iso) && $fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_currencies') { $key=$langs->trans("Currency".strtoupper($obj->code_iso)); - $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso))?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->$fieldlist[$field]); } else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_typent') { $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); } else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_prospectlevel') { $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); } else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_civilite') { $key=$langs->trans("Civility".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); } else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_type_contact') { $key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); } else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_payment_term') { $langs->load("bills"); $key=$langs->trans("PaymentConditionShort".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); } else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_paiement') { $langs->load("bills"); $key=$langs->trans("PaymentType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); } else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_input_reason') { $key=$langs->trans("DemandReasonType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); } else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_input_method') { $langs->load("orders"); @@ -990,18 +993,18 @@ if ($id) else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_shipment_mode') { $langs->load("sendings"); $key=$langs->trans("SendingMethod".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); } else if ($fieldlist[$field] == 'libelle' && $tabname[$_GET['id']]==MAIN_DB_PREFIX.'c_paper_format') { $key = $langs->trans('PaperFormat'.strtoupper($obj->code)); - $valuetoshow = ($obj->code && ($key != 'PaperFormat'.strtoupper($obj->code))) ? $key : $obj->$fieldlist[$field]; + $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); } else if ($fieldlist[$field] == 'libelle' && $tabname[$_GET['id']] == MAIN_DB_PREFIX.'c_type_fees') { $langs->load('trips'); $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($obj->code && ($key != strtoupper($obj->code))) ? $key : $obj->$fieldlist[$field]; + $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); } else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') { $showfield=0; @@ -1013,7 +1016,7 @@ if ($id) else if (($fieldlist[$field] == 'unit') && ($tabname[$_GET['id']] == MAIN_DB_PREFIX.'c_paper_format')) { $key = $langs->trans('SizeUnit'.strtolower($obj->unit)); - $valuetoshow = ($obj->code && ($key != 'SizeUnit'.strtolower($obj->unit))) ? $key : $obj->$fieldlist[$field]; + $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->$fieldlist[$field]); } else if ($fieldlist[$field]=='localtax1_type') { @@ -1167,108 +1170,110 @@ $db->close(); */ function fieldList($fieldlist,$obj='',$tabname='') { - global $conf,$langs,$db; - global $form; - global $region_id; - global $elementList,$sourceList,$localtax_typeList; + global $conf,$langs,$db; + global $form; + global $region_id; + global $elementList,$sourceList,$localtax_typeList; - $formadmin = new FormAdmin($db); - $formcompany = new FormCompany($db); + $formadmin = new FormAdmin($db); + $formcompany = new FormCompany($db); - foreach ($fieldlist as $field => $value) - { - if ($fieldlist[$field] == 'pays') { - if (in_array('region_id',$fieldlist)) { print ''; continue; } // For region page, we do not show the country input - print ''; - } - elseif ($fieldlist[$field] == 'pays_id') { - $pays_id = (! empty($obj->$fieldlist[$field])) ? $obj->$fieldlist[$field] : 0; - print ''; - } - elseif ($fieldlist[$field] == 'region') { - print ''; - } - elseif ($fieldlist[$field] == 'region_id') { - $region_id = (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:0); - print ''; - } - elseif ($fieldlist[$field] == 'lang') { - print ''; - } - // Le type de l'element (pour les type de contact).' - elseif ($fieldlist[$field] == 'element') - { - print ''; - } - // La source de l'element (pour les type de contact).' - elseif ($fieldlist[$field] == 'source') - { - print ''; - } - elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm") - { - print ''; - } - elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm' || $fieldlist[$field] == 'deductible') { - print ''; - } - elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) { - $align="left"; - if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) $align="right"; // Fields aligned on right - print ''; - } - elseif ($fieldlist[$field] == 'libelle_facture') { - print ''; - } - elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i',$fieldlist[$field])) { - print ''; - } - elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldlist[$field])) { - print ''; - } - elseif ($fieldlist[$field]=='unit') { - print ''; - } - // Le type de taxe locale - elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type') - { - print ''; - } - else - { - print ''; - } - } + foreach ($fieldlist as $field => $value) + { + if ($fieldlist[$field] == 'pays') { + if (in_array('region_id',$fieldlist)) { print ''; continue; } // For region page, we do not show the country input + print ''; + } + elseif ($fieldlist[$field] == 'pays_id') { + $pays_id = (! empty($obj->$fieldlist[$field]) ? $obj->$fieldlist[$field] : 0); + print ''; + } + elseif ($fieldlist[$field] == 'region') { + print ''; + } + elseif ($fieldlist[$field] == 'region_id') { + $region_id = (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:0); + print ''; + } + elseif ($fieldlist[$field] == 'lang') { + print ''; + } + // Le type de l'element (pour les type de contact) + elseif ($fieldlist[$field] == 'element') + { + print ''; + } + // La source de l'element (pour les type de contact) + elseif ($fieldlist[$field] == 'source') + { + print ''; + } + elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm") + { + print ''; + } + elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm' || $fieldlist[$field] == 'deductible') { + print ''; + } + elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) { + $align="left"; + if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) $align="right"; // Fields aligned on right + print ''; + } + elseif ($fieldlist[$field] == 'libelle_facture') { + print ''; + } + elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i',$fieldlist[$field])) { + print ''; + } + elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldlist[$field])) { + print ''; + } + elseif ($fieldlist[$field]=='unit') { + print ''; + } + // Le type de taxe locale + elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type') + { + print ''; + } + else + { + print ''; + } + } } ?> \ No newline at end of file diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 18a38ca3d8f..84c160351bd 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -236,7 +236,7 @@ if ($action == 'edit') // Edit print ''; print ''; - if ($conf->global->MAIN_FEATURES_LEVEL > 1) + if ($conf->global->MAIN_FEATURES_LEVEL >= 1 || ! empty($conf->global->MAIN_BUGTRACK_ENABLELINK)) { // Show bugtrack link $var=!$var; @@ -390,7 +390,7 @@ else // Show print yn((isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0),1); print ''; - if ($conf->global->MAIN_FEATURES_LEVEL > 1) + if ($conf->global->MAIN_FEATURES_LEVEL >= 1 || ! empty($conf->global->MAIN_BUGTRACK_ENABLELINK)) { // Show bugtrack link $var=!$var; diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index b6defe01040..5aa17340f22 100755 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -3,6 +3,7 @@ * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2011-2012 Alexandre Spangaro * * 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 @@ -95,7 +96,7 @@ $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.libelle,"; $sql.= " fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,"; $sql.= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur,"; $sql.= " p.rowid as pid, p.ref as ref, p.accountancy_code_buy,"; -$sql.= " ct.accountancy_code"; +$sql.= " ct.accountancy_code_buy as account_tva"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det fd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '".$idpays."'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product"; @@ -109,8 +110,8 @@ if ($result) { $num = $db->num_rows($result); // les variables - $cptfour = (! empty($conf->global->COMPTA_ACCOUNT_SUPPLIER))?$conf->global->COMPTA_ACCOUNT_SUPPLIER:$langs->trans("CodeNotDef"); - $cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT))?$conf->global->COMPTA_VAT_ACCOUNT:$langs->trans("CodeNotDef"); + $cptfour = (! empty($conf->global->COMPTA_ACCOUNT_SUPPLIER)?$conf->global->COMPTA_ACCOUNT_SUPPLIER:$langs->trans("CodeNotDef")); + $cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT)?$conf->global->COMPTA_VAT_ACCOUNT:$langs->trans("CodeNotDef")); $tabfac = array(); $tabht = array(); @@ -123,14 +124,14 @@ if ($result) { $obj = $db->fetch_object($result); // contrôles - $compta_soc = (! empty($obj->code_compta_fournisseur))?$obj->code_compta_fournisseur:$cptfour; + $compta_soc = (! empty($obj->code_compta_fournisseur)?$obj->code_compta_fournisseur:$cptfour); $compta_prod = $obj->accountancy_code_buy; if (empty($compta_prod)) { - if($obj->product_type == 0) $compta_prod = (! empty($conf->global->COMPTA_PRODUCT_BUY_ACCOUNT))?$conf->global->COMPTA_PRODUCT_BUY_ACCOUNT:$langs->trans("CodeNotDef"); - else $compta_prod = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT))?$conf->global->COMPTA_SERVICE_BUY_ACCOUNT:$langs->trans("CodeNotDef"); + if($obj->product_type == 0) $compta_prod = (! empty($conf->global->COMPTA_PRODUCT_BUY_ACCOUNT)?$conf->global->COMPTA_PRODUCT_BUY_ACCOUNT:$langs->trans("CodeNotDef")); + else $compta_prod = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT)?$conf->global->COMPTA_SERVICE_BUY_ACCOUNT:$langs->trans("CodeNotDef")); } - $compta_tva = (! empty($obj->accountancy_code))?$obj->accountancy_code:$cpttva; + $compta_tva = (! empty($obj->account_tva)?$obj->account_tva:$cpttva); $tabfac[$obj->rowid]["date"] = $obj->datef; $tabfac[$obj->rowid]["ref"] = $obj->facnumber; diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index a702387e247..78d174d9565 100755 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -3,6 +3,7 @@ * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2011-2012 Alexandre Spangaro * * 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 @@ -97,7 +98,7 @@ $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.ref_client,"; $sql.= " fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,"; $sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.client,"; $sql.= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell,"; -$sql.= " ct.accountancy_code"; +$sql.= " ct.accountancy_code_sell as account_tva"; $sql.= " FROM ".MAIN_DB_PREFIX."facturedet fd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product"; $sql.= " JOIN ".MAIN_DB_PREFIX."facture f ON f.rowid = fd.fk_facture"; @@ -134,7 +135,7 @@ if ($result) else $compta_prod = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT)?$conf->global->COMPTA_SERVICE_SOLD_ACCOUNT:$langs->trans("CodeNotDef")); } $cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT)?$conf->global->COMPTA_VAT_ACCOUNT:$langs->trans("CodeNotDef")); - $compta_tva = (! empty($obj->accountancy_code)?$obj->accountancy_code:$cpttva); + $compta_tva = (! empty($obj->account_tva)?$obj->account_tva:$cpttva); //la ligne facture $tabfac[$obj->rowid]["date"] = $obj->datef; diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 9b3cc8b487a..e3fcd8db695 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2012 Laurent Destailleur * * 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 @@ -133,14 +133,15 @@ if ($socid > 0) $totalpaye = $fac->getSommePaiement(); $var=!$var; - print ""; + print ""; print "\n"; print '\n"; print ''; print '\n"; - $solde = $solde + $fac->total_ttc; + if (($fac->statut == 3 ) || ($fac->statut == 2 && ! $fact->close_code) ) $solde = $solde = $solde + $totalpaye; + else $solde = $solde + $fac->total_ttc; print ''; print '\n"; diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 67e44abebbb..a37fdc15735 100755 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -73,7 +73,8 @@ class box_members extends ModeleBoxes if ($user->rights->societe->lire) { - $sql = "SELECT a.rowid, a.nom as lastname, a.prenom as firstname, a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; + $sql = "SELECT a.rowid, a.nom as lastname, a.prenom as firstname, a.societe, a.fk_soc,"; + $sql.= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; $sql.= " t.cotisation"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " WHERE a.entity = ".$conf->entity; @@ -97,6 +98,14 @@ class box_members extends ModeleBoxes $memberstatic->lastname=$objp->lastname; $memberstatic->firstname=$objp->firstname; + if (! empty($objp->fk_soc)) { + $memberstatic->socid = $objp->fk_soc; + $memberstatic->fetch_thirdparty(); + $memberstatic->name=$memberstatic->thirdparty->name; + } else { + $memberstatic->name=$objp->company; + } + $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT."/adherents/fiche.php?rowid=".$objp->rowid); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 299df8afdf1..93017f18362 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3152,7 +3152,7 @@ class Form * @param int $h 1=Show also hours * @param int $m 1=Show also minutes * @param int $empty 0=Fields required, 1=Empty input is allowed - * @param string $form_name Form name. Used by popup dates. + * @param string $form_name Not used * @param int $d 1=Show days, month, years * @param int $addnowbutton Add a button "Now" * @param int $nooutput Do not output html string but return it diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index b021db48448..b0d2c997d05 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -601,7 +601,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false) } /** - * Fonction retournant le nombre de jour fieries samedis et dimanches entre 2 dates entrees en timestamp + * Fonction retournant le nombre de jour feries samedis et dimanches entre 2 dates entrees en timestamp * Called by function num_open_day * * @param timestamp $timestampStart Timestamp de debut @@ -733,11 +733,12 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR') /** * Fonction retournant le nombre de jour entre deux dates + * Example: 2012-01-01 2012-01-02 => 1 if lastday=0, 2 if lastday=1 * * @param timestamp $timestampStart Timestamp de debut * @param timestamp $timestampEnd Timestamp de fin - * @param int $lastday On prend en compte le dernier jour, 0: non, 1:oui - * @return int Nombre de jours + * @param int $lastday Last day is included, 0: non, 1:oui + * @return int Number of days */ function num_between_day($timestampStart, $timestampEnd, $lastday=0) { @@ -751,8 +752,9 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0) { $bit = 1; } - $nbjours = round(($timestampEnd - $timestampStart)/(60*60*24)-$bit); + $nbjours = (int) floor(($timestampEnd - $timestampStart)/(60*60*24)) + 1 - $bit; } + //print ($timestampEnd - $timestampStart) - $lastday; return $nbjours; } @@ -762,22 +764,29 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0) * @param timestamp $timestampStart Timestamp de debut * @param timestamp $timestampEnd Timestamp de fin * @param int $inhour 0: sort le nombre de jour , 1: sort le nombre d'heure (72 max) - * @param int $lastday On prend en compte le dernier jour, 0: non, 1:oui + * @param int $lastday We include last day, 0: non, 1:oui * @return int Nombre de jours ou d'heures */ function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0) { global $langs; + dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday); + //print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday; if ($timestampStart < $timestampEnd) { - $bit = 0; - if ($lastday == 1) $bit = 1; - $nbOpenDay = num_between_day($timestampStart, $timestampEnd, $bit) - num_public_holiday($timestampStart, $timestampEnd); + //print num_between_day($timestampStart, $timestampEnd, $lastday).' - '.num_public_holiday($timestampStart, $timestampEnd); + $nbOpenDay = num_between_day($timestampStart, $timestampEnd, $lastday) - num_public_holiday($timestampStart, $timestampEnd, $lastday); $nbOpenDay.= " ".$langs->trans("Days"); if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); return $nbOpenDay; } + elseif ($timestampStart == $timestampEnd) + { + $nbOpenDay=$lastday; + if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); + return $nbOpenDay=1; + } else { return $langs->trans("Error"); diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 85dec26ca95..90a2b1b3698 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -531,6 +531,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m // For debugging //include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); + //$mask='{yyyy}-{0000}'; + //$date=dol_mktime(12, 0, 0, 1, 1, 1900); //$date=dol_stringtotime('20121001'); // Extract value for mask counter, mask raz and mask offset @@ -810,20 +812,18 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $numFinal = $mask; // We replace special codes except refclient - // FIXME: $yearoffset is 0 by default, this code is useless - //if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year - //{ + if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year + { $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date)+$yearoffset, $numFinal); $numFinal = preg_replace('/\{yy\}/i', date("y",$date)+$yearoffset, $numFinal); $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),2,1)+$yearoffset, $numFinal); - //} - /* + } else // we want yyyy to be current year { $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date), $numFinal); $numFinal = preg_replace('/\{yy\}/i', date("y",$date), $numFinal); $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),2,1), $numFinal); - }*/ + } $numFinal = preg_replace('/\{mm\}/i', date("m",$date), $numFinal); $numFinal = preg_replace('/\{dd\}/i', date("d",$date), $numFinal); diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index b2cbb2f55a5..dd14889dfb5 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -132,6 +132,8 @@ function product_prepare_head($object, $user) } } + complete_head_from_modules($conf,$langs,$object,$head,$h,'product', 'remove'); + return $head; } diff --git a/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php b/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php index 3b63eb25c65..b6b74ba8253 100755 --- a/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php +++ b/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php @@ -102,47 +102,54 @@ class InterfacePaypalWorkflow if ($action == 'PAYPAL_PAYMENT_OK') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". source=".$object->source." ref=".$object->ref); - - if ($object->source == 'membersubscription') + + if (! empty($object->source)) { - //require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherents.class.php'; - - // TODO add subscription treatment + if ($object->source == 'membersubscription') + { + //require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherents.class.php'; + + // TODO add subscription treatment + } + else + { + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + + $soc = new Societe($this->db); + + // Parse element/subelement (ex: project_task) + $element = $path = $filename = $object->source; + if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs)) + { + $element = $path = $regs[1]; + $filename = $regs[2]; + } + // For compatibility + if ($element == 'order') { + $path = $filename = 'commande'; + } + if ($element == 'invoice') { + $path = 'compta/facture'; $filename = 'facture'; + } + + dol_include_once('/'.$path.'/class/'.$filename.'.class.php'); + + $classname = ucfirst($filename); + $obj = new $classname($this->db); + + $ret = $obj->fetch('',$object->ref); + if ($ret < 0) return -1; + + // Add payer id + $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid); + + // Add transaction id + $obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]); + } } else { - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - - $soc = new Societe($this->db); - - // Parse element/subelement (ex: project_task) - $element = $path = $filename = $object->source; - if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs)) - { - $element = $path = $regs[1]; - $filename = $regs[2]; - } - // For compatibility - if ($element == 'order') { - $path = $filename = 'commande'; - } - if ($element == 'invoice') { - $path = 'compta/facture'; $filename = 'facture'; - } - - dol_include_once('/'.$path.'/class/'.$filename.'.class.php'); - - $classname = ucfirst($filename); - $obj = new $classname($this->db); - - $ret = $obj->fetch('',$object->ref); - if ($ret < 0) return -1; - - // Add payer id - $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid); - - // Add transaction id - $obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]); + // TODO add free tag treatment } } diff --git a/htdocs/holiday/admin/holiday.php b/htdocs/holiday/admin/holiday.php index dbb8dc67d74..c7ecb17f1da 100644 --- a/htdocs/holiday/admin/holiday.php +++ b/htdocs/holiday/admin/holiday.php @@ -32,6 +32,8 @@ require_once DOL_DOCUMENT_ROOT. '/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT. '/user/class/usergroup.class.php'; $action=GETPOST('action'); +$optName=GETPOST('optName'); +$optValue=GETPOST('optValue'); $langs->load("admin"); $langs->load("holiday"); @@ -155,7 +157,6 @@ if ($action == "add") $message.= '
'.$langs->trans('AddCPforUsers').'
'; } - dol_htmloutput_mesg($message); @@ -163,45 +164,41 @@ if ($action == "add") } elseif ($action == 'create_event') { - $error = false; + $error = 0; - if (!empty($_POST['optName'])) + $optName = trim($optName); + $optValue = price2num($optValue,2); + + if (! $optName) { - $optName = trim($_POST['optName']); - } else { - $error = true; + $message='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Name")).'
'; + $error++; } - - if (!empty($_POST['optValue'])) + if (! $optValue > 0) { - $optValue = price2num($_POST['optValue'],2); - } else { - $error = true; + $message='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Value")).'
'; + $error++; } $cp->optName = $optName; $cp->optValue = $optValue; - if($error) - { - $message = 'ErrorCreateEventCP'; - } - else + if (! $error) { $result = $cp->createEventCP($user); - if($result > 0) { $message = 'OkCreateEventCP'; + $optName=''; + $optValue=''; } else { - $message = 'ErrorCreateEventCP'; + $message = '
'.$cp->error.'
'; } } dol_htmloutput_mesg($message); - } elseif($action == 'event' && isset($_POST['update_event'])) { @@ -210,10 +207,10 @@ elseif($action == 'event' && isset($_POST['update_event'])) $eventId = array_keys($_POST['update_event']); $eventId = $eventId[0]; - $eventName = $_POST['optName']; + $eventName = $optName; $eventName = $eventName[$eventId]; - $eventValue = $_POST['optValue']; + $eventValue = $optValue; $eventValue = $eventValue[$eventId]; if(!empty($eventName)) { @@ -242,7 +239,6 @@ elseif($action == 'event' && isset($_POST['update_event'])) } dol_htmloutput_mesg($message); - } elseif($action && isset($_POST['delete_event'])) { @@ -353,16 +349,14 @@ if($cp_events == 1) { print ''."\n"; print ''."\n"; - print '
'.$langs->trans('TitleUpdateEventCP').'
'."\n"; - print '
* '.$langs->trans("LabelUsedByDefault").'.
 
 '; - print $form->select_country((! empty($obj->pays_code)?$obj->pays_code:(! empty($obj->pays)?$obj->pays:'')),'pays'); - print ''; - $formcompany->select_region($region_id,'region'); - print ''; - print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,'lang'); - print ''; - print $form->selectarray('element', $elementList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); - print ''; - print $form->selectarray('source', $sourceList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); - print ''; - print 'user'; - print ''; - print $form->selectyesno($fieldlist[$field],(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''),1); - print ''; - print ''; - print ''; - print $form->selectarray('unit', array( - 'mm' => $langs->trans('SizeUnitmm'), - 'cm' => $langs->trans('SizeUnitcm'), - 'point' => $langs->trans('SizeUnitpoint'), - 'inch' => $langs->trans('SizeUnitinch') - ), (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''), 0, 0, 0); - print ''; - print $form->selectarray($fieldlist[$field], $localtax_typeList,$obj->$fieldlist[$field]); - print ''; - $size=''; - if ($fieldlist[$field]=='libelle') $size='size="32" '; - if ($fieldlist[$field]=='accountancy_code') $size='size="9" '; - print ''; - print ' '; + print $form->select_country((! empty($obj->pays_code)?$obj->pays_code:(! empty($obj->pays)?$obj->pays:'')),'pays'); + print ''; + $formcompany->select_region($region_id,'region'); + print ''; + print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,'lang'); + print ''; + print $form->selectarray('element', $elementList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print ''; + print $form->selectarray('source', $sourceList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print ''; + print 'user'; + print ''; + print $form->selectyesno($fieldlist[$field],(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''),1); + print ''; + print ''; + print ''; + $units = array( + 'mm' => $langs->trans('SizeUnitmm'), + 'cm' => $langs->trans('SizeUnitcm'), + 'point' => $langs->trans('SizeUnitpoint'), + 'inch' => $langs->trans('SizeUnitinch') + ); + print $form->selectarray('unit', $units, (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''), 0, 0, 0); + print ''; + print $form->selectarray($fieldlist[$field], $localtax_typeList,$obj->$fieldlist[$field]); + print ''; + $size=''; + if ($fieldlist[$field]=='libelle') $size='size="32" '; + if ($fieldlist[$field]=='accountancy_code_sell') $size='size="15" '; + if ($fieldlist[$field]=='accountancy_code_buy') $size='size="15" '; + print ''; + print ' 
".dol_print_date($fac->date)."'.img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref."'.$fac->getLibStatut(2,$totalpaye).''.price($fac->total_ttc)." '.price($solde)."
'."\n"; print ''."\n"; print ''."\n"; print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; print ''."\n"; @@ -373,7 +367,7 @@ if($cp_events == 1) { print ''."\n"; print ''."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; print ''."\n"; print ''; @@ -388,6 +382,7 @@ if($cp_events == 1) { } print ''."\n"; +print ''."\n"; print $langs->trans('TitleCreateEventCP'); @@ -398,16 +393,14 @@ print ''; print ''; print ''; -print ''; +print ''; print ''; -print ''."\n"; - print ''; -print ''."\n"; -print ''."\n"; -print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; print ''."\n"; print ''; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 3a476b109a5..83c1a38ed0a 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -109,8 +109,8 @@ class Holiday extends CommonObject } $sql.= " NOW(),"; $sql.= " '".addslashes($this->description)."',"; - $sql.= " '".$this->date_debut."',"; - $sql.= " '".$this->date_fin."',"; + $sql.= " '".$this->db->idate($this->date_debut)."',"; + $sql.= " '".$this->db->idate($this->date_fin)."',"; $sql.= " '1',"; if(is_numeric($this->fk_validator)) { $sql.= " '".$this->fk_validator."'"; @@ -196,17 +196,17 @@ class Holiday extends CommonObject $this->rowid = $obj->rowid; $this->fk_user = $obj->fk_user; - $this->date_create = $obj->date_create; + $this->date_create = $this->db->jdate($obj->date_create); $this->description = $obj->description; - $this->date_debut = $obj->date_debut; - $this->date_fin = $obj->date_fin; + $this->date_debut = $this->db->jdate($obj->date_debut); + $this->date_fin = $this->db->jdate($obj->date_fin); $this->statut = $obj->statut; $this->fk_validator = $obj->fk_validator; - $this->date_valid = $obj->date_valid; + $this->date_valid = $this->db->jdate($obj->date_valid); $this->fk_user_valid = $obj->fk_user_valid; - $this->date_refuse = $obj->date_refuse; + $this->date_refuse = $this->db->jdate($obj->date_refuse); $this->fk_user_refuse = $obj->fk_user_refuse; - $this->date_cancel = $obj->date_cancel; + $this->date_cancel = $this->db->jdate($obj->date_cancel); $this->fk_user_cancel = $obj->fk_user_cancel; $this->detail_refuse = $obj->detail_refuse; @@ -289,17 +289,17 @@ class Holiday extends CommonObject $tab_result[$i]['rowid'] = $obj->rowid; $tab_result[$i]['fk_user'] = $obj->fk_user; - $tab_result[$i]['date_create'] = $obj->date_create; + $tab_result[$i]['date_create'] = $this->db->jdate($obj->date_create); $tab_result[$i]['description'] = $obj->description; - $tab_result[$i]['date_debut'] = $obj->date_debut; - $tab_result[$i]['date_fin'] = $obj->date_fin; + $tab_result[$i]['date_debut'] = $this->db->jdate($obj->date_debut); + $tab_result[$i]['date_fin'] = $this->db->jdate($obj->date_fin); $tab_result[$i]['statut'] = $obj->statut; $tab_result[$i]['fk_validator'] = $obj->fk_validator; - $tab_result[$i]['date_valid'] = $obj->date_valid; + $tab_result[$i]['date_valid'] = $this->db->jdate($obj->date_valid); $tab_result[$i]['fk_user_valid'] = $obj->fk_user_valid; - $tab_result[$i]['date_refuse'] = $obj->date_refuse; + $tab_result[$i]['date_refuse'] = $this->db->jdate($obj->date_refuse); $tab_result[$i]['fk_user_refuse'] = $obj->fk_user_refuse; - $tab_result[$i]['date_cancel'] = $obj->date_cancel; + $tab_result[$i]['date_cancel'] = $this->db->jdate($obj->date_cancel); $tab_result[$i]['fk_user_cancel'] = $obj->fk_user_cancel; $tab_result[$i]['detail_refuse'] = $obj->detail_refuse; @@ -430,12 +430,12 @@ class Holiday extends CommonObject $sql.= " description= '".addslashes($this->description)."',"; if(!empty($this->date_debut)) { - $sql.= " date_debut = '".$this->date_debut."',"; + $sql.= " date_debut = '".$this->db->idate($this->date_debut)."',"; } else { $error++; } if(!empty($this->date_fin)) { - $sql.= " date_fin = '".$this->date_fin."',"; + $sql.= " date_fin = '".$this->db->idate($this->date_fin)."',"; } else { $error++; } @@ -450,7 +450,7 @@ class Holiday extends CommonObject $error++; } if(!empty($this->date_valid)) { - $sql.= " date_valid = '".$this->date_valid."',"; + $sql.= " date_valid = '".$this->db->idate($this->date_valid)."',"; } else { $sql.= " date_valid = NULL,"; } @@ -460,7 +460,7 @@ class Holiday extends CommonObject $sql.= " fk_user_valid = NULL,"; } if(!empty($this->date_refuse)) { - $sql.= " date_refuse = '".$this->date_refuse."',"; + $sql.= " date_refuse = '".$this->db->idate($this->date_refuse)."',"; } else { $sql.= " date_refuse = NULL,"; } @@ -470,7 +470,7 @@ class Holiday extends CommonObject $sql.= " fk_user_refuse = NULL,"; } if(!empty($this->date_cancel)) { - $sql.= " date_cancel = '".$this->date_cancel."',"; + $sql.= " date_cancel = '".$this->db->idate($this->date_cancel)."',"; } else { $sql.= " date_cancel = NULL,"; } @@ -1214,56 +1214,6 @@ class Holiday extends CommonObject } - /** - * Retourne le nombre de jours ouvrés entre deux dates - * Prise en compte des jours fériés en France - * - * @param date $date_start Start date - * @param date $date_stop Stop date - * @return int Nb of days - */ - - function getOpenDays($date_start, $date_stop) { - - // Tableau des jours feriés - $arr_bank_holidays = array(); - - // On boucle dans le cas où l'année de départ serait différente de l'année d'arrivée - $diff_year = date('Y', $date_stop) - date('Y', $date_start); - - for ($i = 0; $i <= $diff_year; $i++) { - $year = (int) date('Y', $date_start) + $i; - // Liste des jours feriés - $arr_bank_holidays[] = '1_1_'.$year; // Jour de l'an - $arr_bank_holidays[] = '1_5_'.$year; // Fete du travail - $arr_bank_holidays[] = '8_5_'.$year; // Victoire 1945 - $arr_bank_holidays[] = '14_7_'.$year; // Fete nationale - $arr_bank_holidays[] = '15_8_'.$year; // Assomption - $arr_bank_holidays[] = '1_11_'.$year; // Toussaint - $arr_bank_holidays[] = '11_11_'.$year; // Armistice 1918 - $arr_bank_holidays[] = '25_12_'.$year; // Noel - // Récupération de paques. Permet ensuite d'obtenir le jour de l'ascension et celui de la pentecote - $easter = easter_date($year); - $arr_bank_holidays[] = date('j_n_'.$year, $easter + 86400); // Paques - $arr_bank_holidays[] = date('j_n_'.$year, $easter + (86400*39)); // Ascension - $arr_bank_holidays[] = date('j_n_'.$year, $easter + (86400*50)); // Pentecote - } - - $nb_days_open = 0; - - while ($date_start <= $date_stop) { - // Si le jour suivant n'est ni un dimanche (0) ou un samedi (6), ni un jour férié, on incrémente les jours ouvrés - if (!in_array(date('w', $date_start), array(0, 6)) && !in_array(date('j_n_'.date('Y', $date_start), $date_start), $arr_bank_holidays)) { - $nb_days_open++; - } - - $date_start = mktime(date('H', $date_start), date('i', $date_start), date('s', $date_start), date('m', $date_start), date('d', $date_start) + 1, date('Y', $date_start)); - } - - // On retourne le nombre de jours ouvrés - return $nb_days_open; - } - /** * Liste les évènements de congés payés enregistré * diff --git a/htdocs/holiday/fiche.php b/htdocs/holiday/fiche.php index 11ba6d0eb3e..9bfaaf8b32f 100644 --- a/htdocs/holiday/fiche.php +++ b/htdocs/holiday/fiche.php @@ -28,11 +28,13 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; // Get parameters $myparam = GETPOST("myparam"); $action=GETPOST('action'); +$id=GETPOST('id'); // Protection if external user if ($user->societe_id > 0) accessforbidden(); @@ -46,7 +48,7 @@ $user_id = $user->id; ********************************************************************/ // Si création de la demande -if ($action == 'add') +if ($action == 'create') { // Si pas le droit de créer une demande @@ -92,14 +94,15 @@ if ($action == 'add') $verifCP = $cp->verifDateHolidayCP($userID,$date_debut,$date_fin); // On vérifie si il n'y a pas déjà des congés payés sur cette période - if(!$verifCP) + if (! $verifCP) { header('Location: fiche.php?action=request&error=alreadyCP'); exit; } // Si aucun jours ouvrés dans la demande - if($cp->getOpenDays($testDateDebut,$testDateFin) < 1) + $nbopenedday=num_open_day($testDateDebut,$testDateFin,0,1); + if($nbopenedday < 1) { header('Location: fiche.php?action=request&error=DureeHoliday'); exit; @@ -137,6 +140,8 @@ if ($action == 'add') if ($action == 'update') { + $date_debut = dol_mktime(0, 0, 0, $_POST['date_debut_month'], $_POST['date_debut_day'], $_POST['date_debut_year']); + $date_fin = dol_mktime(0, 0, 0, $_POST['date_fin_month'], $_POST['date_fin_day'], $_POST['date_fin_year']); // Si pas le droit de modifier une demande if(!$user->rights->holiday->write) @@ -151,12 +156,9 @@ if ($action == 'update') // Si en attente de validation if ($cp->statut == 1) { - // Si c'est le créateur ou qu'il a le droit de tout lire / modifier if ($user->id == $cp->fk_user || $user->rights->holiday->lire_tous) { - $date_debut = $_POST['date_debut_year'].'-'.str_pad($_POST['date_debut_month'],2,"0",STR_PAD_LEFT).'-'.str_pad($_POST['date_debut_day'],2,"0",STR_PAD_LEFT); - $date_fin = $_POST['date_fin_year'].'-'.str_pad($_POST['date_fin_month'],2,"0",STR_PAD_LEFT).'-'.str_pad($_POST['date_fin_day'],2,"0",STR_PAD_LEFT); $valideur = $_POST['valideur']; $description = trim($_POST['description']); @@ -172,8 +174,8 @@ if ($action == 'update') exit; } - $testDateDebut = strtotime($date_debut); - $testDateFin = strtotime($date_fin); + $testDateDebut = $date_debut; + $testDateFin = $date_fin; // Si date de début après la date de fin if ($testDateDebut > $testDateFin) { @@ -188,7 +190,9 @@ if ($action == 'update') } // Si pas de jours ouvrés dans la demande - if ($cp->getOpenDays($testDateDebut,$testDateFin) < 1) { + $nbopenedday=num_open_day($testDateDebut,$testDateFin,0,1); + if ($nbopenedday < 1) + { header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=DureeHoliday'); exit; } @@ -284,9 +288,10 @@ if ($action == 'confirm_send') $message.= "Veuillez trouver ci-dessous une demande de congés payés à valider.\n"; $delayForRequest = $cp->getConfCP('delayForRequest'); - $delayForRequest = $delayForRequest * (60*60*24); + //$delayForRequest = $delayForRequest * (60*60*24); - $nextMonth = date('Y-m-d', time()+$delayForRequest); + $now=dol_now(); + $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd'); // Si l'option pour avertir le valideur en cas de délai trop court if($cp->getConfCP('AlertValidatorDelay')) { @@ -299,7 +304,9 @@ if ($action == 'confirm_send') // Si l'option pour avertir le valideur en cas de solde inférieur à la demande if($cp->getConfCP('AlertValidatorSolde')) { - if($cp->getOpenDays(strtotime($cp->date_debut),strtotime($cp->date_fin)) > $cp->getCPforUser($cp->fk_user)) { + $nbopenedday=num_open_day($cp->date_debut,$cp->date_fin,0,1); + if ($nbopenedday > $cp->getCPforUser($cp->fk_user)) + { $message.= "\n"; $message.= "L'utilisateur ayant fait cette demande de congés payés n'a pas le solde requis.\n"; } @@ -331,10 +338,10 @@ if ($action == 'confirm_send') } } + // Si Validation de la demande if($action == 'confirm_valid') { - $cp = new Holiday($db); $cp->fetch($_GET['id']); @@ -344,7 +351,7 @@ if($action == 'confirm_valid') if($cp->statut == 2 && $userID == $cp->fk_validator) { - $cp->date_valid = date('Y-m-d H:i:s', time()); + $cp->date_valid = dol_now(); $cp->fk_user_valid = $user->id; $cp->statut = 3; @@ -354,7 +361,7 @@ if($action == 'confirm_valid') if($verif > 0) { // Retrait du nombre de jours prit - $nbJour = $cp->getOpenDays(strtotime($cp->date_debut),strtotime($cp->date_fin)); + $nbJour = $nbopenedday=num_open_day($cp->date_debut,$cp->date_fin,0,1); $soldeActuel = $cp->getCpforUser($cp->fk_user); $newSolde = $soldeActuel - ($nbJour*$cp->getConfCP('nbHolidayDeducted')); @@ -570,7 +577,7 @@ if ($action == 'confirm_cancel' && $_GET['confirm'] == 'yes') llxHeader(array(),$langs->trans('CPTitreMenu')); -if ($action == 'request') +if (empty($id) || $action == 'add' || $action == 'request') { // Si l'utilisateur n'a pas le droit de faire une demande if(!$user->rights->holiday->write) @@ -619,9 +626,9 @@ if ($action == 'request') $cp = new Holiday($db); $delayForRequest = $cp->getConfCP('delayForRequest'); - $delayForRequest = $delayForRequest * (60*60*24); + //$delayForRequest = $delayForRequest * (60*60*24); - $nextMonth = date('Y-m-d', time()+$delayForRequest); + $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd'); print '
'.$langs->trans('NameEventCP').''.$langs->trans('ValueOptionCP').''.$langs->trans('UpdateEventOptionCP').''.$langs->trans('DeleteEventOptionCP').''.$langs->trans('ValueOptionCP').'  
'.$langs->trans('Jours').'
'.$langs->trans('NameEventCP').''.$langs->trans('ValueOptionCP').''.$langs->trans('CreateEventCP').' 
'.$langs->trans('Jours').' '.$langs->trans('Jours').'