diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 2bdfc30a440..4d26149de64 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -230,7 +230,7 @@ class Contrat extends CommonObject * @return void */ function cloture($user) - { + { $this->db->begin(); // Load lines @@ -280,7 +280,7 @@ class Contrat extends CommonObject function validate($user) { global $langs, $conf; - + $error=0; $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 1"; @@ -352,7 +352,8 @@ class Contrat extends CommonObject $this->note_private = $result["note_private"]; $this->note_public = $result["note_public"]; - $this->fk_projet = $result["fk_projet"]; + $this->fk_projet = $result["fk_projet"]; // deprecated + $this->fk_project = $result["fk_projet"]; $this->socid = $result["fk_soc"]; $this->fk_soc = $result["fk_soc"]; @@ -441,7 +442,7 @@ class Contrat extends CommonObject $line->statut = $objp->statut; $line->remise_percent = $objp->remise_percent; $line->price_ht = $objp->price_ht; - $line->price = $objp->price; // For backward compatibility + $line->price = $objp->price_ht; // For backward compatibility $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; $line->total_localtax1 = $objp->total_localtax1; @@ -620,7 +621,7 @@ class Contrat extends CommonObject if (! $paramsok) return -1; $this->db->begin(); - + $now=dol_now(); // Insert contract @@ -702,7 +703,7 @@ class Contrat extends CommonObject function delete($user) { global $conf, $langs; - + $error=0; $this->db->begin(); @@ -790,7 +791,7 @@ class Contrat extends CommonObject $error++; } } - + if (! $error) { // Appel des triggers @@ -802,7 +803,7 @@ class Contrat extends CommonObject } // Fin appel triggers } - + if (! $error) { // We remove directory diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 97dbbaa2c9c..2c09a9b94c3 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -1,9 +1,9 @@ - * Copyright (C) 2004-2009 Laurent Destailleur - * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005 Regis Houssin - * Copyright (C) 2005 Simon TOSSER +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005 Simon TOSSER * * 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 @@ -76,7 +76,7 @@ $modulepart='contract'; /* * Action envoie fichier */ -if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) { if (dol_mkdir($upload_dir) >= 0) { @@ -135,7 +135,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $form = new Form($db); -llxHeader("","",$langs->trans("CardProduct".$product->type)); +llxHeader(); if ($object->id) @@ -183,7 +183,7 @@ if ($object->id) // Affiche formulaire upload $formfile=new FormFile($db); - $formfile->form_attach_new_file(DOL_URL_ROOT.'/contrat/document.php?id='.$object->id,'',0,0,$user->rights->contrat->creer,50,$object); + $formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id,'',0,0,$user->rights->contrat->creer,50,$object); // List of document @@ -196,7 +196,7 @@ else print $langs->trans("UnkownError"); } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index e675bb3e33e..b1c828b7a3e 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -31,10 +31,12 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/price.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'); require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/modules/contract/modules_contract.php"); -if ($conf->produit->enabled || $conf->service->enabled) require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); -if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); -if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); -if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/core/lib/project.lib.php"); +if (! empty($conf->produit->enabled) || ! empty($conf->service->enabled)) require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); +if (! empty($conf->propal->enabled)) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); +if ($conf->projet->enabled) { + require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); + require_once(DOL_DOCUMENT_ROOT."/core/lib/project.lib.php"); +} $langs->load("contracts"); $langs->load("orders"); @@ -48,11 +50,13 @@ $socid = GETPOST('socid','int'); $id = GETPOST('id','int'); $ref=GETPOST('ref','alpha'); +$datecontrat=''; + // Security check if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'contrat',$id); -$usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; +$usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0); $object = new Contrat($db); @@ -64,7 +68,7 @@ $object = new Contrat($db); if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer) { $object->fetch($id); - $result = $object->active_line($user, $_GET["ligne"], $_GET["date"], $_GET["dateend"], $_GET["comment"]); + $result = $object->active_line($user, GETPOST('ligne'), GETPOST('date'), GETPOST('dateend'), GETPOST('comment')); if ($result > 0) { @@ -79,7 +83,7 @@ if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat-> else if ($action == 'confirm_closeline' && $confirm == 'yes' && $user->rights->contrat->activer) { $object->fetch($id); - $result = $object->close_line($user, $_GET["ligne"], $_GET["dateend"], urldecode($_GET["comment"])); + $result = $object->close_line($user, GETPOST('ligne'), GETPOST('dateend'), urldecode(GETPOST('comment'))); if ($result > 0) { @@ -92,32 +96,32 @@ else if ($action == 'confirm_closeline' && $confirm == 'yes' && $user->rights->c } // Si ajout champ produit predefini -if ($_POST["mode"]=='predefined') +if (GETPOST('mode')=='predefined') { $date_start=''; $date_end=''; - if ($_POST["date_startmonth"] && $_POST["date_startday"] && $_POST["date_startyear"]) + if (GETPOST('date_startmonth') && GETPOST('date_startday') && GETPOST('date_startyear')) { - $date_start=dol_mktime($_POST["date_starthour"], $_POST["date_startmin"], 0, $_POST["date_startmonth"], $_POST["date_startday"], $_POST["date_startyear"]); + $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); } - if ($_POST["date_endmonth"] && $_POST["date_endday"] && $_POST["date_endyear"]) + if (GETPOST('date_endmonth') && GETPOST('date_endday') && GETPOST('date_endyear')) { - $date_end=dol_mktime($_POST["date_endhour"], $_POST["date_endmin"], 0, $_POST["date_endmonth"], $_POST["date_endday"], $_POST["date_endyear"]); + $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); } } // Si ajout champ produit libre -if ($_POST["mode"]=='libre') +if (GETPOST('mode')=='libre') { $date_start_sl=''; $date_end_sl=''; - if ($_POST["date_start_slmonth"] && $_POST["date_start_slday"] && $_POST["date_start_slyear"]) + if (GETPOST('date_start_slmonth') && GETPOST('date_start_slday') && GETPOST('date_start_slyear')) { - $date_start_sl=dol_mktime($_POST["date_start_slhour"], $_POST["date_start_slmin"], 0, $_POST["date_start_slmonth"], $_POST["date_start_slday"], $_POST["date_start_slyear"]); + $date_start_sl=dol_mktime(GETPOST('date_start_slhour'), GETPOST('date_start_slmin'), 0, GETPOST('date_start_slmonth'), GETPOST('date_start_slday'), GETPOST('date_start_slyear')); } - if ($_POST["date_end_slmonth"] && $_POST["date_end_slday"] && $_POST["date_end_slyear"]) + if (GETPOST('date_end_slmonth') && GETPOST('date_end_slday') && GETPOST('date_end_slyear')) { - $date_end_sl=dol_mktime($_POST["date_end_slhour"], $_POST["date_end_slmin"], 0, $_POST["date_end_slmonth"], $_POST["date_end_slday"], $_POST["date_end_slyear"]); + $date_end_sl=dol_mktime(GETPOST('date_end_slhour'), GETPOST('date_end_slmin'), 0, GETPOST('date_end_slmonth'), GETPOST('date_end_slday'), GETPOST('date_end_slyear')); } } @@ -127,25 +131,25 @@ $date_start_update=''; $date_end_update=''; $date_start_real_update=''; $date_end_real_update=''; -if ($_POST["date_start_updatemonth"] && $_POST["date_start_updateday"] && $_POST["date_start_updateyear"]) +if (GETPOST('date_start_updatemonth') && GETPOST('date_start_updateday') && GETPOST('date_start_updateyear')) { - $date_start_update=dol_mktime($_POST["date_start_updatehour"], $_POST["date_start_updatemin"], 0, $_POST["date_start_updatemonth"], $_POST["date_start_updateday"], $_POST["date_start_updateyear"]); + $date_start_update=dol_mktime(GETPOST('date_start_updatehour'), GETPOST('date_start_updatemin'), 0, GETPOST('date_start_updatemonth'), GETPOST('date_start_updateday'), GETPOST('date_start_updateyear')); } -if ($_POST["date_end_updatemonth"] && $_POST["date_end_updateday"] && $_POST["date_end_updateyear"]) +if (GETPOST('date_end_updatemonth') && GETPOST('date_end_updateday') && GETPOST('date_end_updateyear')) { - $date_end_update=dol_mktime($_POST["date_end_updatehour"], $_POST["date_end_updatemin"], 0, $_POST["date_end_updatemonth"], $_POST["date_end_updateday"], $_POST["date_end_updateyear"]); + $date_end_update=dol_mktime(GETPOST('date_end_updatehour'), GETPOST('date_end_updatemin'), 0, GETPOST('date_end_updatemonth'), GETPOST('date_end_updateday'), GETPOST('date_end_updateyear')); } -if ($_POST["date_start_real_updatemonth"] && $_POST["date_start_real_updateday"] && $_POST["date_start_real_updateyear"]) +if (GETPOST('date_start_real_updatemonth') && GETPOST('date_start_real_updateday') && GETPOST('date_start_real_updateyear')) { - $date_start_real_update=dol_mktime($_POST["date_start_real_updatehour"], $_POST["date_start_real_updatemin"], 0, $_POST["date_start_real_updatemonth"], $_POST["date_start_real_updateday"], $_POST["date_start_real_updateyear"]); + $date_start_real_update=dol_mktime(GETPOST('date_start_real_updatehour'), GETPOST('date_start_real_updatemin'), 0, GETPOST('date_start_real_updatemonth'), GETPOST('date_start_real_updateday'), GETPOST('date_start_real_updateyear')); } -if ($_POST["date_end_real_updatemonth"] && $_POST["date_end_real_updateday"] && $_POST["date_end_real_updateyear"]) +if (GETPOST('date_end_real_updatemonth') && GETPOST('date_end_real_updateday') && GETPOST('date_end_real_updateyear')) { - $date_end_real_update=dol_mktime($_POST["date_end_real_updatehour"], $_POST["date_end_real_updatemin"], 0, $_POST["date_end_real_updatemonth"], $_POST["date_end_real_updateday"], $_POST["date_end_real_updateyear"]); + $date_end_real_update=dol_mktime(GETPOST('date_end_real_updatehour'), GETPOST('date_end_real_updatemin'), 0, GETPOST('date_end_real_updatemonth'), GETPOST('date_end_real_updateday'), GETPOST('date_end_real_updateyear')); } -if ($_POST["remonth"] && $_POST["reday"] && $_POST["reyear"]) +if (GETPOST('remonth') && GETPOST('reday') && GETPOST('reyear')) { - $datecontrat = dol_mktime($_POST["rehour"], $_POST["remin"], 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datecontrat = dol_mktime(GETPOST('rehour'), GETPOST('remin'), 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); } if ($action == 'add' && $user->rights->contrat->creer) @@ -153,13 +157,13 @@ if ($action == 'add' && $user->rights->contrat->creer) $object->socid = $socid; $object->date_contrat = $datecontrat; - $object->commercial_suivi_id = $_POST["commercial_suivi_id"]; - $object->commercial_signature_id = $_POST["commercial_signature_id"]; + $object->commercial_suivi_id = GETPOST('commercial_suivi_id','int'); + $object->commercial_signature_id = GETPOST('commercial_signature_id','int'); - $object->note = trim($_POST["note"]); - $object->fk_project = trim($_POST["projectid"]); - $object->remise_percent = trim($_POST["remise_percent"]); - $object->ref = trim($_POST["ref"]); + $object->note = GETPOST('note','alpha'); + $object->fk_project = GETPOST('projectid','int'); + $object->remise_percent = GETPOST('remise_percent','alpha'); + $object->ref = GETPOST('ref','alpha'); // Check if (empty($datecontrat)) @@ -187,12 +191,12 @@ if ($action == 'add' && $user->rights->contrat->creer) else if ($action == 'classin' && $user->rights->contrat->creer) { $object->fetch($id); - $object->setProject($_POST["projectid"]); + $object->setProject(GETPOST('projectid')); } else if ($action == 'addline' && $user->rights->contrat->creer) { - if ($_POST["pqty"] && (($_POST["pu"] != '' && $_POST["desc"]) || $_POST["idprod"])) + if (GETPOST('pqty') && ((GETPOST('pu') != '' && GETPOST('desc')) || GETPOST('idprod'))) { $ret=$object->fetch($id); if ($ret < 0) @@ -205,27 +209,27 @@ else if ($action == 'addline' && $user->rights->contrat->creer) $date_start=''; $date_end=''; // Si ajout champ produit libre - if ($_POST['mode'] == 'libre') + if (GETPOST('mode') == 'libre') { - if ($_POST["date_start_slmonth"] && $_POST["date_start_slday"] && $_POST["date_start_slyear"]) + if (GETPOST('date_start_slmonth') && GETPOST('date_start_slday') && GETPOST('date_start_slyear')) { - $date_start=dol_mktime($_POST["date_start_slhour"], $_POST["date_start_slmin"], 0, $_POST["date_start_slmonth"], $_POST["date_start_slday"], $_POST["date_start_slyear"]); + $date_start=dol_mktime(GETPOST('date_start_slhour'), GETPOST('date_start_slmin'), 0, GETPOST('date_start_slmonth'), GETPOST('date_start_slday'), GETPOST('date_start_slyear')); } - if ($_POST["date_end_slmonth"] && $_POST["date_end_slday"] && $_POST["date_end_slyear"]) + if (GETPOST('date_end_slmonth') && GETPOST('date_end_slday') && GETPOST('date_end_slyear')) { - $date_end=dol_mktime($_POST["date_end_slhour"], $_POST["date_end_slmin"], 0, $_POST["date_end_slmonth"], $_POST["date_end_slday"], $_POST["date_end_slyear"]); + $date_end=dol_mktime(GETPOST('date_end_slhour'), GETPOST('date_end_slmin'), 0, GETPOST('date_end_slmonth'), GETPOST('date_end_slday'), GETPOST('date_end_slyear')); } } // Si ajout champ produit predefini - if ($_POST['mode'] == 'predefined') + if (GETPOST('mode') == 'predefined') { - if ($_POST["date_startmonth"] && $_POST["date_startday"] && $_POST["date_startyear"]) + if (GETPOST('date_startmonth') && GETPOST('date_startday') && GETPOST('date_startyear')) { - $date_start=dol_mktime($_POST["date_starthour"], $_POST["date_startmin"], 0, $_POST["date_startmonth"], $_POST["date_startday"], $_POST["date_startyear"]); + $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); } - if ($_POST["date_endmonth"] && $_POST["date_endday"] && $_POST["date_endyear"]) + if (GETPOST('date_endmonth') && GETPOST('date_endday') && GETPOST('date_endyear')) { - $date_end=dol_mktime($_POST["date_endhour"], $_POST["date_endmin"], 0, $_POST["date_endmonth"], $_POST["date_endday"], $_POST["date_endyear"]); + $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); } } @@ -233,10 +237,10 @@ else if ($action == 'addline' && $user->rights->contrat->creer) // Ecrase $desc par celui du produit // Ecrase $txtva par celui du produit // Ecrase $base_price_type par celui du produit - if ($_POST['idprod']) + if (GETPOST('idprod')) { $prod = new Product($db); - $prod->fetch($_POST['idprod']); + $prod->fetch(GETPOST('idprod')); $tva_tx = get_default_tva($mysoc,$object->thirdparty,$prod->id); $tva_npr = get_default_npr($mysoc,$object->thirdparty,$prod->id); @@ -272,16 +276,16 @@ else if ($action == 'addline' && $user->rights->contrat->creer) } $desc = $prod->description; - $desc.= $prod->description && $_POST['desc'] ? "\n" : ""; - $desc.= $_POST['desc']; + $desc.= $prod->description && GETPOST('desc') ? "\n" : ""; + $desc.= GETPOST('desc'); } else { - $pu_ht=$_POST['pu']; + $pu_ht=GETPOST('pu'); $price_base_type = 'HT'; - $tva_tx=str_replace('*','',$_POST['tva_tx']); - $tva_npr=preg_match('/\*/',$_POST['tva_tx'])?1:0; - $desc=$_POST['desc']; + $tva_tx=str_replace('*','',GETPOST('tva_tx')); + $tva_npr=preg_match('/\*/',GETPOST('tva_tx'))?1:0; + $desc=GETPOST('desc'); } $localtax1_tx=get_localtax($tva_tx,1,$object->societe); @@ -290,7 +294,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer) $info_bits=0; if ($tva_npr) $info_bits |= 0x01; - if($price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min))) + if($price_min && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) { $object->error = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)); $result = -1 ; @@ -301,12 +305,12 @@ else if ($action == 'addline' && $user->rights->contrat->creer) $result = $object->addline( $desc, $pu_ht, - $_POST["pqty"], + GETPOST('pqty'), $tva_tx, $localtax1_tx, $localtax2_tx, - $_POST["idprod"], - $_POST["premise"], + GETPOST('idprod'), + GETPOST('premise'), $date_start, $date_end, $price_base_type, @@ -342,7 +346,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer) } } -else if ($action == 'updateligne' && $user->rights->contrat->creer && ! $_POST["cancel"]) +else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST('cancel')) { $ret=$object->fetch($id); if ($ret < 0) @@ -353,22 +357,22 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! $_POST[" $object->fetch_thirdparty(); $objectline = new ContratLigne($db); - if ($objectline->fetch($_POST["elrowid"])) + if ($objectline->fetch(GETPOST('elrowid'))) { $db->begin(); if ($date_start_real_update == '') $date_start_real_update=$objectline->date_ouverture; if ($date_end_real_update == '') $date_end_real_update=$objectline->date_cloture; - $localtax1_tx=get_localtax($_POST["eltva_tx"],1,$object->thirdparty); - $localtax2_tx=get_localtax($_POST["eltva_tx"],2,$object->thirdparty); + $localtax1_tx=get_localtax(GETPOST('eltva_tx'),1,$object->thirdparty); + $localtax2_tx=get_localtax(GETPOST('eltva_tx'),2,$object->thirdparty); - $objectline->description=$_POST["eldesc"]; - $objectline->price_ht=$_POST["elprice"]; - $objectline->subprice=$_POST["elprice"]; - $objectline->qty=$_POST["elqty"]; - $objectline->remise_percent=$_POST["elremise_percent"]; - $objectline->tva_tx=$_POST["eltva_tx"]; + $objectline->description=GETPOST('eldesc'); + $objectline->price_ht=GETPOST('elprice'); + $objectline->subprice=GETPOST('elprice'); + $objectline->qty=GETPOST('elqty'); + $objectline->remise_percent=GETPOST('elremise_percent'); + $objectline->tva_tx=GETPOST('eltva_tx'); $objectline->localtax1_tx=$localtax1_tx; $objectline->localtax2_tx=$localtax2_tx; $objectline->date_ouverture_prevue=$date_start_update; @@ -399,7 +403,7 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! $_POST[" else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer) { $object->fetch($id); - $result = $object->deleteline($_GET["lineid"],$user); + $result = $object->deleteline(GETPOST('lineid'),$user); if ($result >= 0) { @@ -443,11 +447,11 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->cont else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) { - if ($_POST['newcid'] > 0) + if (GETPOST('newcid') > 0) { $contractline = new ContratLigne($db); - $result=$contractline->fetch($_GET["lineid"]); - $contractline->fk_contrat = $_POST["newcid"]; + $result=$contractline->fetch(GETPOST('lineid')); + $contractline->fk_contrat = GETPOST('newcid'); $result=$contractline->update($user,1); if ($result >= 0) { @@ -486,7 +490,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $result = $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); } if ($result >= 0) @@ -525,7 +529,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) else if ($action == 'deletecontact' && $user->rights->contrat->creer) { $object->fetch($id); - $result = $object->delete_contact($_GET["lineid"]); + $result = $object->delete_contact(GETPOST('lineid')); if ($result >= 0) { @@ -557,7 +561,7 @@ $objectlignestatic=new ContratLigne($db); *********************************************************************/ if ($action == 'create') { - dol_fiche_head($head, $a, $langs->trans("AddContract"), 0, 'contract'); + dol_fiche_head('', '', $langs->trans("AddContract"), 0, 'contract'); dol_htmloutput_errors($mesg,''); @@ -565,7 +569,6 @@ if ($action == 'create') $soc->fetch($socid); $object->date_contrat = dol_now(); - if ($contratid) $result=$object->fetch($contratid); $numct = $object->getNextNumRef($soc); @@ -713,7 +716,7 @@ else /* * Contrat */ - if ($object->brouillon && $user->rights->contrat->creer) + if (! empty($object->brouillon) && $user->rights->contrat->creer) { print '
'; print ''; @@ -776,7 +779,7 @@ else print ""; - if ($object->brouillon == 1 && $user->rights->contrat->creer) + if (! empty($object->brouillon) && $user->rights->contrat->creer) { print '
'; } @@ -857,7 +860,7 @@ else $var=!$var; - if ($action != 'editline' || $_GET["rowid"] != $objp->rowid) + if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) { print ''; // Libelle @@ -956,7 +959,7 @@ else print '
'; print ''; print ''; - print ''; + print ''; // Ligne carac print ""; print ''; @@ -1016,16 +1019,16 @@ else /* * Confirmation to delete service line of contract */ - if ($action == 'deleteline' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline-1]->id == $_GET["rowid"]) + if ($action == 'deleteline' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline-1]->id == GETPOST('rowid')) { - $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".$_GET["rowid"],$langs->trans("DeleteContractLine"),$langs->trans("ConfirmDeleteContractLine"),"confirm_deleteline",'',0,1); + $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid'),$langs->trans("DeleteContractLine"),$langs->trans("ConfirmDeleteContractLine"),"confirm_deleteline",'',0,1); if ($ret == 'html') print '
'; } /* * Confirmation to move service toward another contract */ - if ($action == 'move' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline-1]->id == $_GET["rowid"]) + if ($action == 'move' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline-1]->id == GETPOST('rowid')) { $arraycontractid=array(); foreach($arrayothercontracts as $contractcursor) @@ -1038,31 +1041,31 @@ else 'text' => $langs->trans("ConfirmMoveToAnotherContractQuestion"), array('type' => 'select', 'name' => 'newcid', 'values' => $arraycontractid)); - $form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".$_GET["rowid"],$langs->trans("MoveToAnotherContract"),$langs->trans("ConfirmMoveToAnotherContract"),"confirm_move",$formquestion); + $form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid'),$langs->trans("MoveToAnotherContract"),$langs->trans("ConfirmMoveToAnotherContract"),"confirm_move",$formquestion); print '
'; } /* * Confirmation de la validation activation */ - if ($action == 'active' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline-1]->id == $_GET["ligne"]) + if ($action == 'active' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline-1]->id == GETPOST('ligne')) { - $dateactstart = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $dateactend = dol_mktime(12, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - $comment = $_POST["comment"]; - $form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".$_GET["ligne"]."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment),$langs->trans("ActivateService"),$langs->trans("ConfirmActivateService",dol_print_date($dateactstart,"%A %d %B %Y")),"confirm_active", '', 0, 1); + $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); + $comment = GETPOST('comment'); + $form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment),$langs->trans("ActivateService"),$langs->trans("ConfirmActivateService",dol_print_date($dateactstart,"%A %d %B %Y")),"confirm_active", '', 0, 1); print '
'; } /* * Confirmation de la validation fermeture */ - if ($action == 'closeline' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline-1]->id == $_GET["ligne"]) + if ($action == 'closeline' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline-1]->id == GETPOST('ligne')) { - $dateactstart = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $dateactend = dol_mktime(12, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - $comment = $_POST["comment"]; - $form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".$_GET["ligne"]."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment), $langs->trans("CloseService"), $langs->trans("ConfirmCloseService",dol_print_date($dateactend,"%A %d %B %Y")), "confirm_closeline", '', 0, 1); + $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); + $comment = GETPOST('comment'); + $form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment), $langs->trans("CloseService"), $langs->trans("ConfirmCloseService",dol_print_date($dateactend,"%A %d %B %Y")), "confirm_closeline", '', 0, 1); print '
'; } @@ -1120,12 +1123,12 @@ else print ''; } - if ($user->rights->contrat->activer && $action == 'activateline' && $object->lines[$cursorline-1]->id == $_GET["ligne"]) + if ($user->rights->contrat->activer && $action == 'activateline' && $object->lines[$cursorline-1]->id == GETPOST('ligne')) { /** * Activer la ligne de contrat */ - print ''; + print ''; print ''; print ''; @@ -1133,11 +1136,11 @@ else // Definie date debut et fin par defaut $dateactstart = $objp->date_debut; - if ($_POST["remonth"]) $dateactstart = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + if (GETPOST('remonth')) $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); elseif (! $dateactstart) $dateactstart = time(); $dateactend = $objp->date_fin; - if ($_POST["endmonth"]) $dateactend = dol_mktime(12, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + if (GETPOST('endmonth')) $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); elseif (! $dateactend) { if ($objp->fk_product > 0) @@ -1163,14 +1166,14 @@ else print ''; - print ''; + print ''; print '
'.$langs->trans("Comment").'
'.$langs->trans("Comment").'
'; print '
'; } - if ($user->rights->contrat->activer && $action == 'unactivateline' && $object->lines[$cursorline-1]->id == $_GET["ligne"]) + if ($user->rights->contrat->activer && $action == 'unactivateline' && $object->lines[$cursorline-1]->id == GETPOST('ligne')) { /** * Desactiver la ligne de contrat @@ -1182,11 +1185,11 @@ else // Definie date debut et fin par defaut $dateactstart = $objp->date_debut_reelle; - if ($_POST["remonth"]) $dateactstart = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + if (GETPOST('remonth')) $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); elseif (! $dateactstart) $dateactstart = time(); $dateactend = $objp->date_fin_reelle; - if ($_POST["endmonth"]) $dateactend = dol_mktime(12, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + if (GETPOST('endmonth')) $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); elseif (! $dateactend) { if ($objp->fk_product > 0) @@ -1214,7 +1217,7 @@ else print ''; print ''; - print ''.$langs->trans("Comment").''; + print ''.$langs->trans("Comment").''; print ''; print ''; diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 8f7a3f5f63e..e3247a9e7a7 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -30,17 +30,17 @@ require_once (DOL_DOCUMENT_ROOT."/product/class/product.class.php"); $langs->load("products"); $langs->load("companies"); -$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:(isset($_POST["sortfield"])?$_POST["sortfield"]:''); -$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:(isset($_POST["sortorder"])?$_POST["sortorder"]:''); -$page = isset($_GET["page"])?$_GET["page"]:(isset($_POST["page"])?$_POST["page"]:''); +$sortfield=GETPOST('sortfield','alpha'); +$sortorder=GETPOST('sortorder','alpha'); +$page=GETPOST('page','int'); -$statut=isset($_GET["statut"])?$_GET["statut"]:1; +$statut=GETPOST('statut')?GETPOST('statut'):1; // Security check $socid=0; $id = GETPOST('id','int'); -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'contrat',$id,''); +if (! empty($user->societe_id)) $socid=$user->societe_id; +$result = restrictedArea($user, 'contrat', $id); $staticcompany=new Societe($db); $staticcontrat=new Contrat($db); @@ -71,7 +71,7 @@ print ''; print ''; @@ -193,7 +193,7 @@ foreach($listofstatus as $status) if ($status==4 && $bool==false) $bool=true; else $bool=false; } -if ($conf->use_javascript_ajax) +if (! empty($conf->use_javascript_ajax)) { print ''; @@ -223,7 +223,7 @@ print "
'; // Search contract -if ($conf->contrat->enabled) +if (! empty($conf->contrat->enabled)) { $var=false; print '
'; @@ -181,8 +181,8 @@ $var=true; $listofstatus=array(0,4,4,5); $bool=false; foreach($listofstatus as $status) { - $dataseries[]=array('label'=>$staticcontratligne->LibStatut($status,1,($bool?1:0)),'data'=>($nb[$status.$bool]?(int) $nb[$status.$bool]:0)); - if (! $conf->use_javascript_ajax) + $dataseries[]=array('label'=>$staticcontratligne->LibStatut($status,1,($bool?1:0)),'data'=>(isset($nb[$status.$bool])?(int) $nb[$status.$bool]:0)); + if (empty($conf->use_javascript_ajax)) { $var=!$var; print '
'; $data=array('series'=>$dataseries); @@ -204,7 +204,7 @@ $var=true; $listofstatus=array(0,4,4,5); $bool=false; foreach($listofstatus as $status) { - if (! $conf->use_javascript_ajax) + if (empty($conf->use_javascript_ajax)) { $var=!$var; print '

"; /** * Draft contratcs */ -if ($conf->contrat->enabled && $user->rights->contrat->lire) +if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $sql = "SELECT c.rowid as ref, c.rowid,"; $sql.= " s.nom, s.rowid as socid"; diff --git a/htdocs/contrat/liste.php b/htdocs/contrat/liste.php index e72774e3dac..855cd269347 100644 --- a/htdocs/contrat/liste.php +++ b/htdocs/contrat/liste.php @@ -30,26 +30,26 @@ $langs->load("contracts"); $langs->load("products"); $langs->load("companies"); -$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; -$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; -$page = isset($_GET["page"])?$_GET["page"]:$_POST["page"]; +$sortfield=GETPOST('sortfield','alpha'); +$sortorder=GETPOST('sortorder','alpha'); +$page=GETPOST('page','int'); if ($page == -1) { $page = 0 ; } $limit = $conf->liste_limit; $offset = $limit * $page ; -$search_nom=isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"]; -$search_contract=isset($_GET["search_contract"])?$_GET["search_contract"]:$_POST["search_contract"]; -$sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"]; -$statut=isset($_GET["statut"])?$_GET["statut"]:1; -$socid=isset($_GET['socid'])?$_GET['socid']:$_POST['socid']; +$search_nom=GETPOST('search_nom'); +$search_contract=GETPOST('search_contract'); +$sall=GETPOST('sall'); +$statut=GETPOST('statut')?GETPOST('statut'):1; +$socid=GETPOST('socid'); if (! $sortfield) $sortfield="c.rowid"; if (! $sortorder) $sortorder="DESC"; // Security check -$contratid = isset($_GET["id"])?$_GET["id"]:''; +$id=GETPOST('id','int'); if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'contrat', $contratid,''); +$result = restrictedArea($user, 'contrat', $id); $staticcontrat=new Contrat($db); $staticcontratligne=new ContratLigne($db); @@ -64,11 +64,11 @@ $now=dol_now(); llxHeader(); $sql = 'SELECT'; -$sql.= ' sum('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,'; -$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= ".$db->idate($now).")",1,0).') as nb_running,'; -$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < ".$db->idate($now).")",1,0).') as nb_expired,'; -$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < ".$db->idate($now - $conf->contrat->services->expires->warning_delay).")",1,0).') as nb_late,'; -$sql.= ' sum('.$db->ifsql("cd.statut=5",1,0).') as nb_closed,'; +$sql.= ' SUM('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,'; +$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= ".$db->idate($now).")",1,0).') as nb_running,'; +$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < ".$db->idate($now).")",1,0).') as nb_expired,'; +$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < ".$db->idate($now - $conf->contrat->services->expires->warning_delay).")",1,0).') as nb_late,'; +$sql.= ' SUM('.$db->ifsql("cd.statut=5",1,0).') as nb_closed,'; $sql.= " c.rowid as cid, c.ref, c.datec, c.date_contrat, c.statut,"; $sql.= " s.nom, s.rowid as socid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -79,9 +79,9 @@ $sql.= " WHERE c.fk_soc = s.rowid "; $sql.= " AND c.entity = ".$conf->entity; if ($socid) $sql.= " AND s.rowid = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($search_nom) $sql.= " AND s.nom like '%".$db->escape($search_nom)."%'"; +if ($search_nom) $sql.= " AND s.nom LIKE '%".$db->escape($search_nom)."%'"; if ($search_contract) $sql.= " AND c.rowid = '".$db->escape($search_contract)."'"; -if ($sall) $sql.= " AND (s.nom like '%".$db->escape($sall)."%' OR cd.label like '%".$db->escape($sall)."%' OR cd.description like '%".$db->escape($sall)."%')"; +if ($sall) $sql.= " AND (s.nom LIKE '%".$db->escape($sall)."%' OR cd.label LIKE '%".$db->escape($sall)."%' OR cd.description LIKE '%".$db->escape($sall)."%')"; $sql.= " GROUP BY c.rowid, c.ref, c.datec, c.date_contrat, c.statut,"; $sql.= " s.nom, s.rowid"; $sql.= " ORDER BY $sortfield $sortorder"; @@ -93,7 +93,7 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num); + print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], '&search_contract='.$search_contract.'&search_nom='.$search_nom, $sortfield, $sortorder,'',$num); print ''; @@ -111,7 +111,7 @@ if ($resql) print ''; print "\n"; - print ''; + print ''; print ''; print ''; print '
'.$staticcontratligne->LibStatut(5,3).'
'; @@ -151,7 +151,6 @@ if ($resql) $db->free($resql); print "
"; - } else { @@ -159,7 +158,6 @@ else } -$db->close(); - llxFooter(); +$db->close(); ?> diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 433df3249d8..97ad5eae634 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * 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 @@ -47,13 +47,22 @@ $filter=GETPOST("filter"); $search_nom=GETPOST("search_nom"); $search_contract=GETPOST("search_contract"); $search_service=GETPOST("search_service"); -$statut=isset($_GET["statut"])?$_GET["statut"]:1; +$statut=GETPOST('statut')?GETPOST('statut'):1; $socid=GETPOST('socid','int'); +$op1month=GETPOST('op1month'); +$op1day=GETPOST('op1day'); +$op1year=GETPOST('op1year'); +$filter_op1=GETPOST('filter_op1'); +$op2month=GETPOST('op2month'); +$op2day=GETPOST('op2day'); +$op2year=GETPOST('op2year'); +$filter_op2=GETPOST('filter_op2'); + // Security check $contratid = GETPOST('id','int'); -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'contrat',$contratid,''); +if (! empty($user->societe_id)) $socid=$user->societe_id; +$result = restrictedArea($user, 'contrat',$contratid); $staticcontrat=new Contrat($db); @@ -92,14 +101,14 @@ if ($mode == "0") $sql.= " AND cd.statut = 0"; if ($mode == "4") $sql.= " AND cd.statut = 4"; if ($mode == "5") $sql.= " AND cd.statut = 5"; if ($filter == "expired") $sql.= " AND cd.date_fin_validite < '".$db->idate($now)."'"; -if ($search_nom) $sql.= " AND s.nom like '%".$db->escape($search_nom)."%'"; +if ($search_nom) $sql.= " AND s.nom LIKE '%".$db->escape($search_nom)."%'"; if ($search_contract) $sql.= " AND c.rowid = '".$db->escape($search_contract)."'"; -if ($search_service) $sql.= " AND (p.ref like '%".$db->escape($search_service)."%' OR p.description like '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; +if ($search_service) $sql.= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; if ($socid > 0) $sql.= " AND s.rowid = ".$socid; -$filter_date1=dol_mktime(0,0,0,$_REQUEST['op1month'],$_REQUEST['op1day'],$_REQUEST['op1year']); -$filter_date2=dol_mktime(0,0,0,$_REQUEST['op2month'],$_REQUEST['op2day'],$_REQUEST['op2year']); -if (! empty($_REQUEST['filter_op1']) && $_REQUEST['filter_op1'] != -1 && $filter_date1 != '') $sql.= " AND date_ouverture_prevue ".$_REQUEST['filter_op1']." ".$db->idate($filter_date1); -if (! empty($_REQUEST['filter_op2']) && $_REQUEST['filter_op2'] != -1 && $filter_date2 != '') $sql.= " AND date_fin_validite ".$_REQUEST['filter_op2']." ".$db->idate($filter_date2); +$filter_date1=dol_mktime(0,0,0,$op1month,$op1day,$op1year); +$filter_date2=dol_mktime(0,0,0,$op2month,$op2day,$op2year); +if (! empty($filter_op1) && $filter_op1 != -1 && $filter_date1 != '') $sql.= " AND date_ouverture_prevue ".$filter_op1." ".$db->idate($filter_date1); +if (! empty($filter_op2) && $filter_op2 != -1 && $filter_date2 != '') $sql.= " AND date_fin_validite ".$filter_op2." ".$db->idate($filter_date2); $sql .= $db->order($sortfield,$sortorder); $sql .= $db->plimit($limit + 1, $offset); @@ -117,10 +126,10 @@ if ($resql) if ($search_service) $param.='&search_service='.urlencode($search_service); if ($mode) $param.='&mode='.$mode; if ($filter) $param.='&filter='.$filter; - if (! empty($_REQUEST['filter_op1']) && $_REQUEST['filter_op1'] != -1) $param.='&filter_op1='.urlencode($_REQUEST['filter_op1']); - if (! empty($_REQUEST['filter_op2']) && $_REQUEST['filter_op2'] != -1) $param.='&filter_op2='.urlencode($_REQUEST['filter_op2']); - if ($filter_date1 != '') $param.='&op1day='.$_REQUEST['op1day'].'&op1month='.$_REQUEST['op1month'].'&op1year='.$_REQUEST['op1year']; - if ($filter_date2 != '') $param.='&op2day='.$_REQUEST['op2day'].'&op2month='.$_REQUEST['op2month'].'&op2year='.$_REQUEST['op2year']; + if (! empty($filter_op1) && $filter_op1 != -1) $param.='&filter_op1='.urlencode($filter_op1); + if (! empty($filter_op2) && $filter_op2 != -1) $param.='&filter_op2='.urlencode($filter_op2); + if ($filter_date1 != '') $param.='&op1day='.$op1day.'&op1month='.$op1month.'&op1year='.$op1year; + if ($filter_date2 != '') $param.='&op2day='.$op2day.'&op2month='.$op2month.'&op2year='.$op2year; $title=$langs->trans("ListOfServices"); if ($mode == "0") $title=$langs->trans("ListOfInactiveServices"); // Must use == "0" @@ -163,16 +172,16 @@ if ($resql) print ''; print ''; $arrayofoperators=array('<'=>'<','>'=>'>'); - print $form->selectarray('filter_op1',$arrayofoperators,$_REQUEST['filter_op1'],1); + print $form->selectarray('filter_op1',$arrayofoperators,$filter_op1,1); print ' '; - $filter_date1=dol_mktime(0,0,0,$_REQUEST['op1month'],$_REQUEST['op1day'],$_REQUEST['op1year']); + $filter_date1=dol_mktime(0,0,0,$op1month,$op1day,$op1year); print $form->select_date($filter_date1,'op1',0,0,1); print ''; print ''; $arrayofoperators=array('<'=>'<','>'=>'>'); - print $form->selectarray('filter_op2',$arrayofoperators,$_REQUEST['filter_op2'],1); + print $form->selectarray('filter_op2',$arrayofoperators,$filter_op2,1); print ' '; - $filter_date2=dol_mktime(0,0,0,$_REQUEST['op2month'],$_REQUEST['op2day'],$_REQUEST['op2year']); + $filter_date2=dol_mktime(0,0,0,$op2month,$op2day,$op2year); print $form->select_date($filter_date2,'op2',0,0,1); print ''; print ''; @@ -204,7 +213,7 @@ if ($resql) $productstatic->ref=$obj->pref; print $productstatic->getNomUrl(1,'',20); print $obj->label?' - '.dol_trunc($obj->label,16):''; - if ($obj->description && $conf->global->PRODUIT_DESC_IN_LIST) print '
'.dol_nl2br($obj->description); + if (! empty($obj->description) && ! empty($conf->global->PRODUIT_DESC_IN_LIST)) print '
'.dol_nl2br($obj->description); } else { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 35e158231e4..f72ba0a705d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -42,6 +42,8 @@ abstract class CommonObject public $nom; public $civility_id; + public $array_options=array(); + // No constructor as it is an abstract class diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index defd5886f6d..bbc54bb4471 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2760,11 +2760,11 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr if (! $found) { // If vat of product for the country not found or not defined, we return higher vat of country. - $sql.="SELECT taux as vat_rate"; - $sql.=" FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; - $sql.=" WHERE t.active=1 AND t.fk_pays = p.rowid AND p.code='".$thirdparty_seller->country_code."'"; - $sql.=" ORDER BY t.taux DESC, t.recuperableonly ASC"; - $sql.=$db->plimit(1); + $sql = "SELECT taux as vat_rate"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; + $sql.= " WHERE t.active=1 AND t.fk_pays = p.rowid AND p.code='".$thirdparty_seller->country_code."'"; + $sql.= " ORDER BY t.taux DESC, t.recuperableonly ASC"; + $sql.= $db->plimit(1); $resql=$db->query($sql); if ($resql) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 082e9e11228..10f30aba273 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -29,11 +29,11 @@ require_once(DOL_DOCUMENT_ROOT."/expedition/class/expedition.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/order.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/sendings.lib.php"); -if ($conf->product->enabled || $conf->service->enabled) require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); -if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); -if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); -if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"); -if ($conf->stock->enabled) require_once(DOL_DOCUMENT_ROOT."/product/stock/class/entrepot.class.php"); +if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); +if (! empty($conf->projet->enabled)) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); +if (! empty($conf->propal->enabled)) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); +if (! empty($conf->commande->enabled)) require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"); +if (! empty($conf->stock->enabled)) require_once(DOL_DOCUMENT_ROOT."/product/stock/class/entrepot.class.php"); $langs->load('orders'); $langs->load("companies"); @@ -48,7 +48,7 @@ $action=GETPOST('action','alpha'); // Security check $socid=0; -if ($user->societe_id) $socid=$user->societe_id; +if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'commande',$id); @@ -518,7 +518,7 @@ if ($id > 0 || ! empty($ref)) // Define a new tree with quantiies recalculated $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); //var_dump($prods_arbo); - if(count($prods_arbo) > 0) + if (count($prods_arbo) > 0) { foreach($prods_arbo as $key => $value) { @@ -529,11 +529,11 @@ if ($id > 0 || ! empty($ref)) { $img=img_warning($langs->trans("StockTooLow")); } - print "      -> - ".$value['fullpath']." - (".$value['nb'].") ".$value['nb_total']."   - ".$value['stock']." ".$img.""; - print $value[0]; + print '      -> '.$value['fullpath'].' ('.$value['nb'].')'; + print ' '.$value['nb_total'].''; + print ' '; + print ' '; + print ''.$value['stock'].' '.$img.''."\n"; print ''."\n"; } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ed3320135fc..89e2baef38a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -722,7 +722,7 @@ $bcdd=array(0=>'class="impair drag drop"',1=>'class="pair drag drop"'); $bcnd=array(0=>'class="impair nodrag nodrop"',1=>'class="pair nodrag nodrop"'); // Define messages variables -$mesg=''; $mesgs=array(); +$mesg=''; $mesgs=array(); $warning=''; $warnings=array(); $error=0; $errors=array(); if (isset($_SESSION['dol_message'])) { $mesgs[]=$_SESSION['dol_message']; diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 2e4802ddc9b..4e5036ebbfc 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2010 Laurent Destailleur +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2010 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin * * 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 @@ -164,8 +165,6 @@ class CompanyBankAccount extends Account $this->id = $obj->rowid; $this->socid = $obj->fk_soc; $this->bank = $obj->bank; - $this->courant = $obj->courant; - $this->clos = $obj->clos; $this->code_banque = $obj->code_banque; $this->code_guichet = $obj->code_guichet; $this->number = $obj->number; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index ca9ac156ad9..1b8e8a33604 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1696,7 +1696,7 @@ else { foreach($extrafields->attribute_label as $key=>$label) { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + $value=(GETPOST('options_'.$key)?GETPOST('options_'.$key):(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:'')); print ''.$label.''; print $extrafields->showOutputField($key,$value); print "\n";