From f7eaf35d30accf34855a5fe693ca301c802296a9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Jun 2015 11:55:39 +0200 Subject: [PATCH] NEW When creating order, proposal or invoice from thirdparty card, the project is asked during creation. A link to create project if it does not exists is also available. NEW Uniformize form creation of proposal to add public and private notes during creation like done for order and invoice. --- htdocs/comm/propal.php | 77 ++++++--- htdocs/commande/card.php | 35 ++-- htdocs/compta/facture.php | 228 +++++++++++++------------- htdocs/projet/card.php | 23 ++- htdocs/projet/class/project.class.php | 4 +- htdocs/theme/eldy/style.css.php | 4 + 6 files changed, 216 insertions(+), 155 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 47accf6b9a0..ce22d192f81 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -41,6 +41,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/modules/propale/modules_propale.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; @@ -305,7 +306,8 @@ if (empty($reshook)) $object->fk_project = GETPOST('projectid'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated - $object->note = GETPOST('note'); + $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public'); $object->statut = Propal::STATUS_DRAFT; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); @@ -331,7 +333,8 @@ if (empty($reshook)) $object->fk_project = GETPOST('projectid'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated - $object->note = GETPOST('note'); + $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public'); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); @@ -1256,6 +1259,7 @@ $formother = new FormOther($db); $formfile = new FormFile($db); $formpropal = new FormPropal($db); $companystatic = new Societe($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $now = dol_now(); @@ -1340,7 +1344,7 @@ if ($action == 'create') print ''; // Reference - print ''; + print ''; // Ref customer print ''; - // Model - print ''; - print ''; - print '"; + // Project + if (! empty($conf->projet->enabled) && $socid > 0) + { + $projectid = GETPOST('projectid')?GETPOST('projectid'):0; + if ($origin == 'project') $projectid = ($originid ? $originid : 0); + + $langs->load("projects"); + print ''; + print ''; + print ''; + } // Incoterms if (!empty($conf->incoterm->enabled)) @@ -1462,25 +1473,41 @@ if ($action == 'create') print ''; } - // Project - if (! empty($conf->projet->enabled) && $socid > 0) + // Template to use by default + print ''; + print ''; + print '"; + + // Public note + print ''; + print ''; + print ''; - print ''; + print ''; - print ''; + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + // print ' + print ''; } // Other attributes diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 5a4b434286c..fcd96f8c898 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1214,6 +1214,7 @@ llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients| $form = new Form($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } /** * ******************************************************************* @@ -1320,7 +1321,7 @@ if ($action == 'create' && $user->rights->commande->creer) print '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('RefCustomer') . ''; @@ -1444,13 +1448,20 @@ if ($action == 'create') } print '
' . $langs->trans("DefaultModel") . ''; - $liste = ModelePDFPropales::liste_modeles($db); - print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF)); - print "
' . $langs->trans("Project") . ''; + $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); + print '   id).'">' . $langs->trans("AddProject") . ''; + print '
' . $langs->trans("DefaultModel") . ''; + $liste = ModelePDFPropales::liste_modeles($db); + print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF)); + print "
' . $langs->trans('NotePublic') . ''; + $note_public = ''; + if (is_object($objectsrc)) // Take value from source object { - $formproject = new FormProjets($db); - - $projectid = 0; - if ($origin == 'project') - $projectid = ($originid ? $originid : 0); + $note_public = $objectsrc->note_public; + } + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + // Private note + if (empty($user->societe_id)) + { print '
' . $langs->trans("Project") . ''; - - $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); - if ($numprojet == 0) { - $langs->load("projects"); - print '   ' . $langs->trans("AddProject") . ''; + print '' . $langs->trans('NotePrivate') . ''; + $note_private = ''; + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) // Take value from source object + { + $note_private = $objectsrc->note_private; } - print '
'; // Reference - print ''; + print ''; // Reference client print ''; + print ''; + print '   id).'">' . $langs->trans("AddProject") . ''; + print ''; + print ''; } // Incoterms @@ -1458,29 +1461,30 @@ if ($action == 'create' && $user->rights->commande->creer) print $form->selectarray('model', $liste, $conf->global->COMMANDE_ADDON_PDF); print ""; - // Note publique + // Note public print ''; print ''; print ''; - // Note privee + // Note private if (empty($user->societe_id)) { print ''; print ''; print ''; } - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + { // TODO for compatibility if ($origin == 'contrat') { // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva @@ -1514,8 +1518,11 @@ if ($action == 'create' && $user->rights->commande->creer) } print '"; - } else { - if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) { + } + else + { + if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) + { /* * Services/produits predefinis */ diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 410377c5683..379d2d2ee5d 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1854,6 +1854,8 @@ $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); $bankaccountstatic = new Account($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } + $now = dol_now(); llxHeader('', $langs->trans('Bill'), 'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes'); @@ -2080,22 +2082,21 @@ if ($action == 'create') } print ''; if ($socid > 0) @@ -2293,12 +2292,15 @@ if ($action == 'create') print ''; // Project - if (! empty($conf->projet->enabled) && $socid > 0) { - $formproject = new FormProjets($db); + if (! empty($conf->projet->enabled) && $socid > 0) + { + $projectid = GETPOST('projectid')?GETPOST('projectid'):0; + if ($origin == 'project') $projectid = ($originid ? $originid : 0); $langs->load('projects'); print ''; } @@ -2320,7 +2322,7 @@ if ($action == 'create') print $object->showOptionals($extrafields, 'edit'); } - // Modele PDF + // Template to use by default print ''; print ''; @@ -2418,7 +2420,9 @@ if ($action == 'create') print '"; } print '"; - } else { + } + else + { // Show deprecated optional form to add product line here if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) { print ''; - print ''; - print ''; - print ''; - print ''; + if ($object->situation_cycle_ref && $object->statut == 0) { + print ''; + print ''; + print ''; + print ''; + print ''; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; - } - print ''; - print ''; - print ''; - if ($inputalsopricewithtax) print ''; - print ''; - print ''; - print ''; - if (! empty($conf->margin->enabled) && empty($user->societe_id)) - { - print ''; - if ((! empty($conf->global->DISPLAY_MARGIN_RATES) || ! empty($conf->global->DISPLAY_MARK_RATES)) && $user->rights->margins->liretous) { - print ''; + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; } - } - print ''; - print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print ''; + if ($inputalsopricewithtax) print ''; + print ''; + print ''; + print ''; + if (! empty($conf->margin->enabled) && empty($user->societe_id)) + { + print ''; + if ((! empty($conf->global->DISPLAY_MARGIN_RATES) || ! empty($conf->global->DISPLAY_MARK_RATES)) && $user->rights->margins->liretous) { + print ''; + } + } + print ''; + print ''; + print ''; + print ''; + print "\n"; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } } // Show object lines diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index b7ea6bd798b..791f01d5932 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -39,6 +39,7 @@ $ref=GETPOST('ref','alpha'); $action=GETPOST('action','alpha'); $backtopage=GETPOST('backtopage','alpha'); $cancel=GETPOST('cancel','alpha'); +$status=GETPOST('status','int'); if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $action != "update" && ! $_POST["cancel"])) accessforbidden(); @@ -139,6 +140,7 @@ if (empty($reshook)) $object->datec=dol_now(); $object->date_start=$date_start; $object->date_end=$date_end; + $object->statuts = $status; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -167,8 +169,16 @@ if (empty($reshook)) { $db->commit(); - header("Location:card.php?id=".$object->id); - exit; + if ($backtopage) + { + header("Location: ".$backtopage.'&projectid='.$object->id); + exit; + } + else + { + header("Location:card.php?id=".$object->id); + exit; + } } else { @@ -444,6 +454,15 @@ if ($action == 'create' && $user->rights->projet->creer) else print $text; print ''; + // Status + if ($status != '') + { + print ''; + } + // Public print '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('RefCustomer') . ''; @@ -1422,14 +1423,16 @@ if ($action == 'create' && $user->rights->commande->creer) // Project if (! empty($conf->projet->enabled) && $socid > 0) { - $formproject = new FormProjets($db); + $projectid = GETPOST('projectid')?GETPOST('projectid'):0; + if ($origin == 'project') $projectid = ($originid ? $originid : 0); - print '
' . $langs->trans('Project') . ''; + $langs->load("projects"); + print '
' . $langs->trans("Project") . ''; $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); - if ($numprojet == 0) { - print '   ' . $langs->trans("AddProject") . ''; - } - print '
' . $langs->trans('NotePublic') . ''; - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); // print ''; print '
' . $langs->trans('NotePrivate') . ''; - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); // print ''; print '
' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . "
' . $langs->trans('Type') . ''; - print '' . "\n"; + + print '
' . "\n"; // Standard invoice - print '
' . "\n"; + print ''; if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid)))) { // Deposit - print '' . "\n"; + + print ''; } if ($socid > 0) { if (! empty($conf->global->INVOICE_USE_SITUATION)) { - // First situation invoice - print '' . "\n"; + // First situation invoice + print '
'; + $tmp=' '; + $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceFirstSituationAsk"), $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); + print $desc; + print '
'; - // Next situation invoice - $opt = $form->load_situation_invoices(GETPOST('originid'), $socid); - print '' . "\n"; + // Next situation invoice + $opt = $form->load_situation_invoices(GETPOST('originid'), $socid); + print '
'; + $tmp='' . $langs->trans('NoSituations') . '') || (GETPOST('origin') && GETPOST('origin') != 'facture')) $tmp.=' disabled'; + $tmp.= '> '; + $text = $tmp.$langs->trans("InvoiceSituationAsk") . ' '; + $text .= ''; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceSituationDesc"), 1, 'help', '', 0, 3); + print $desc; + print '
'; } // Replacement - print '' . "\n"; + print ''; } else { - print '' . "\n"; + print ''; } if (empty($origin)) @@ -2191,12 +2192,10 @@ if ($action == 'create') if ($socid > 0) { // Credit note - print '' . "\n"; + print ''; } else { - print '' . "\n"; + print '' . "\n"; } } - print '
'; - print ''; - print ''; - $desc = $form->textwithpicto($langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1); + print '
'; + $tmp=' '; + $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3); print $desc; - print '
'; - print ''; - print ''; + print '
'; + $tmp=' '; print ''; - $desc = $form->textwithpicto($langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1); - print ''; - if (($origin == 'propal') || ($origin == 'commande')) { + + $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); + print '
' . $desc . '
'; + if (($origin == 'propal') || ($origin == 'commande')) + { print '
'; + print $desc; + print ''; $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1); @@ -2113,44 +2118,41 @@ if ($action == 'create') print '' . $langs->trans('Value') . ':'; } print '
'; - print '
'; - print ''; - print ''; - $desc = $form->textwithpicto($langs->trans("InvoiceFirstSituationAsk"), $langs->transnoentities("InvoiceFirstSituationDesc"), 1); - print $desc; - print '
'; - print '' . $langs->trans('NoSituations') . '' || (GETPOST('origin') && GETPOST('origin') != 'facture')) print 'disabled'; - print '>'; - print ''; - $text = $langs->trans("InvoiceSituationAsk") . ' '; - $text .= ''; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceSituationDesc"), 1); - print $desc; - print '
'; - print ''; - print ''; + print '
'; + $tmp=' jQuery(document).ready(function() { jQuery("#fac_replacement").change(function() { @@ -2158,7 +2160,7 @@ if ($action == 'create') }); }); '; - $text = $langs->trans("InvoiceReplacementAsk") . ' '; + $text = $tmp.$langs->trans("InvoiceReplacementAsk") . ' '; $text .= ''; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1); + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); print $desc; - print '
'; - print ''; - print ''; - $text = $langs->trans("InvoiceReplacement") . ' '; + print '
'; + $tmp=' '; + $text = $tmp.$langs->trans("InvoiceReplacement") . ' '; $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1); + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); print $desc; - print '
'; - print ''; - print ''; + print '
'; + $tmp=' jQuery(document).ready(function() { @@ -2212,7 +2211,7 @@ if ($action == 'create') }); }); '; - $text = $langs->transnoentities("InvoiceAvoirAsk") . ' '; + $text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' '; // $text.=''; $text .= ''; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1); + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; @@ -2233,22 +2232,22 @@ if ($action == 'create') print '
    0 ? 'checked':'').' /> "; print '
'; - print '
'; - print ''; - print ''; - $text = $langs->trans("InvoiceAvoir") . ' '; + print '
'; + $tmp=' '; + $text = $tmp.$langs->trans("InvoiceAvoir") . ' '; $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1); + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; - print '
'; + print ''; + print '
' . $langs->trans('Project') . ''; - $formproject->select_projects($soc->id, $projectid, 'projectid', 0); + $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); + print '   id).'">' . $langs->trans("AddProject") . ''; print '
' . $langs->trans('Model') . ''; include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; @@ -2337,7 +2339,7 @@ if ($action == 'create') { $note_public = $objectsrc->note_public; } - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); // Private note @@ -2351,7 +2353,7 @@ if ($action == 'create') { $note_private = $objectsrc->note_private; } - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); // print ' print '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . "
' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . "
'; @@ -3486,50 +3490,50 @@ if ($action == 'create') // Show global modifiers if (! empty($conf->global->INVOICE_US_SITUATION)) { - if ($object->situation_cycle_ref && $object->statut == 0) { - print '
 ' . $langs->trans('ModifyAllLines') . '     ' . $langs->trans('Progress') . '       
' . $langs->trans('ModifyAllLines') . '     ' . $langs->trans('Progress') . '      
  
     %
     %
'.$langs->trans("Status").''; + print ''; + print $object->LibStatut($status, 4); + print '
'.$langs->trans("Visibility").''; $array=array(0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject")); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8d3e9f39a08..ff005dd088f 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -125,12 +125,12 @@ class Project extends CommonObject $sql.= ", '" . $this->db->escape($this->description) . "'"; $sql.= ", " . ($this->socid > 0 ? $this->socid : "null"); $sql.= ", " . $user->id; - $sql.= ", 0"; + $sql.= ", ".(is_numeric($this->statuts) ? $this->statuts : '0'); $sql.= ", " . ($this->public ? 1 : 0); $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", " . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); $sql.= ", " . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); - $sql.= ", " . ($this->budget_amount != ''?price2num($this->budget_amount):'null'); + $sql.= ", " . ($this->budget_amount != '' ? price2num($this->budget_amount) : 'null'); $sql.= ", ".$conf->entity; $sql.= ")"; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 2a63e558801..93bd5a09d9a 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -448,6 +448,10 @@ textarea.centpercent { #formuserfile_link { margin-left: 1px; } +.listofinvoicetype { + height: 28px; + vertical-align: middle; +} /* Style to move picto into left of button */ /*