diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index d66c55d05a1..f1a3fafec57 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2011 Philippe Grand * * 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 @@ -165,7 +166,7 @@ if ($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes' $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs); } else { @@ -203,7 +204,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer) $object->modelpdf = $_POST['model']; $object->cond_reglement_id = $_POST['cond_reglement_id']; $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->availability_id = $_POST['availability_id']; + $object->availability_id = $_POST['availability_id']; $object->date_livraison = $datelivraison; $object->fk_delivery_address = $_POST['fk_address']; $object->contactid = $_POST['contactidp']; @@ -243,10 +244,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer) $lines = $srcobject->lines; if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); - $fk_parent_line=0; - $num=sizeof($lines); - - for ($i=0;$i<$num;$i++) + for ($i = 0 ; $i < sizeof($lines) ; $i++) { $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); @@ -260,11 +258,6 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer) if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; - // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { - $fk_parent_line = 0; - } - $result = $object->addline( $object_id, $desc, @@ -283,8 +276,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer) $dateend, $product_type, $lines[$i]->rang, - $lines[$i]->special_code, - $fk_parent_line + $lines[$i]->special_code ); if ($result < 0) @@ -292,21 +284,6 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer) $error++; break; } - - // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) { - $fk_parent_line = $result; - } - } - - // Hooks - if (! empty($object->hooks)) - { - foreach($object->hooks as $module) - { - $res = $module->createfrom($srcobject,$object_id,$object->element); - if ($res < 0) $error++; - } } } else @@ -452,6 +429,13 @@ if ($_POST['action'] == 'setmode' && $user->rights->commande->creer) if ($result < 0) dol_print_error($db,$object->error); } +if ($_POST['action'] == 'setavailability' && $user->rights->commande->creer) +{ + $object->fetch($comid); + $result=$object->availability($_POST['availability_id']); + if ($result < 0) dol_print_error($db,$object->error); +} + if ($_POST['action'] == 'setconditions' && $user->rights->commande->creer) { $object->fetch($comid); @@ -595,10 +579,7 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer) $pu_ttc, $date_start, $date_end, - $type, - -1, - '', - $_POST['fk_parent_line'] + $type ); if ($result > 0) @@ -613,7 +594,7 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs); unset($_POST['qty']); unset($_POST['type']); @@ -705,8 +686,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS $info_bits, $date_start, $date_end, - $type, - $_POST['fk_parent_line'] + $type ); if ($result >= 0) @@ -721,7 +701,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs); } else { @@ -755,7 +735,7 @@ if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' & $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs); } } @@ -794,7 +774,7 @@ if ($_GET['action'] == 'modif' && $user->rights->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs); } } @@ -819,7 +799,7 @@ if ($_GET['action'] == 'up' && $user->rights->commande->creer) $outputlangs->setDefaultLang($newlang); } - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs); Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$comid.'#'.$_GET['rowid']); exit; @@ -841,7 +821,7 @@ if ($_GET['action'] == 'down' && $user->rights->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs); Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$comid.'#'.$_GET['rowid']); exit; @@ -873,7 +853,7 @@ if ($_REQUEST['action'] == 'builddoc') // In get or post $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + $result=commande_pdf_create($db, $object, $object->modelpdf, $outputlangs); if ($result <= 0) { dol_print_error($db,$result); @@ -1149,7 +1129,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) $soc = $objectsrc->client; $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); + $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; @@ -1159,7 +1139,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) { $cond_reglement_id = $soc->cond_reglement_id; $mode_reglement_id = $soc->mode_reglement_id; - $availability_id = $soc->availability_id; + $availability_id = $soc->availability_id; $remise_percent = $soc->remise_percent; $remise_absolue = 0; $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; @@ -1246,6 +1226,11 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) // Mode de reglement print ''.$langs->trans('PaymentMode').''; $html->select_types_paiements($soc->mode_reglement,'mode_reglement_id'); + print ''; + + // delai de livraison + print ''.$langs->trans('AvailabilityPeriod').''; + $html->select_availability($soc->availability,'availability_id'); print ''; // Projet @@ -1301,7 +1286,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva $objectsrc->remise_absolue=$remise_absolue; $objectsrc->remise_percent=$remise_percent; - $objectsrc->update_price(1); + $objectsrc->update_price(); } print "\n"; @@ -1381,6 +1366,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) print ''; + $objectsrc->printOriginTitleList(); $objectsrc->printOriginLinesList($object); print '
'; @@ -1709,8 +1695,8 @@ else $html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none'); } print ''; - - // Availability + + // Availability print ''; print ''; @@ -1803,8 +1789,13 @@ else print '
'; print $langs->trans('AvailabilityPeriod'); @@ -1720,11 +1706,11 @@ else print ''; if ($_GET['action'] == 'editavailability') { - $html->form_Availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->Availability_id,'Availability_id'); + $html->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'availability_id'); } else { - $html->form_Availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->Availability_id,'none'); + $html->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'none'); } print '
'; - // Show object lines - if (! empty($object->lines)) $object->printObjectLines(1,$mysoc,$soc); + if (!empty($object->lines)) + { + $object->print_title_list(); + $object->printLinesList(1,$mysoc,$soc); + } + + $numlines=sizeof($object->lines); /* * Form to add new line @@ -1815,13 +1806,13 @@ else { $var=true; - $object->formAddFreeProduct(1,$mysoc,$soc); + $object->showAddFreeProductForm(1,$mysoc,$soc); // Add predefined products/services if ($conf->product->enabled || $conf->service->enabled) { $var=!$var; - $object->formAddPredefinedProduct(1,$mysoc,$soc); + $object->showAddPredefinedProductForm(1,$mysoc,$soc); } // Hook of thirdparty module @@ -1982,7 +1973,7 @@ else $genallowed=$user->rights->commande->creer; $delallowed=$user->rights->commande->supprimer; - $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$object->hooks); + $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); /* * Linked object block