From d38ff5c246410dea9841941e6bb55b25cd475848 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 10 Aug 2016 11:34:10 +0200 Subject: [PATCH] FIX : create proposal from project --- htdocs/comm/propal/card.php | 34 ++++++++++++++++++---------------- htdocs/projet/element.php | 22 +++++++++++----------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 25337446b5b..d3924e944a6 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -279,7 +279,7 @@ if (empty($reshook)) if ($socid < 1) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), null, 'errors'); - + $action = 'create'; $error ++; } @@ -345,7 +345,7 @@ if (empty($reshook)) $object->origin = GETPOST('origin'); $object->origin_id = GETPOST('originid'); - + // Multicurrency if (!empty($conf->multicurrency->enabled)) { @@ -718,7 +718,7 @@ if (empty($reshook)) $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); if (empty($tva_tx)) $tva_npr=0; - + $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; $price_min = $prod->price_min; @@ -932,7 +932,7 @@ if (empty($reshook)) // Add buying price $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value + $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); @@ -1167,12 +1167,12 @@ if (empty($reshook)) } } } - + // Actions to build doc $upload_dir = $conf->propal->dir_output; $permissioncreate=$user->rights->propal->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - + } @@ -1266,6 +1266,8 @@ if ($action == 'create') if ($origin != 'project' && $originid) { print ''; print ''; + } elseif ($origin == 'project' && !empty($projectid)) { + print ''; } dol_fiche_head(); @@ -1432,11 +1434,11 @@ if ($action == 'create') print ''; print ''.fieldLabel('Currency','multicurrency_code').''; print ''; - $currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)); + $currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)); print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0); print ''; } - + // Public note print ''; print '' . $langs->trans('NotePublic') . ''; @@ -1934,7 +1936,7 @@ if ($action == 'create') $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); } print ''; - + // Multicurrency rate print ''; print ''; @@ -2053,7 +2055,7 @@ if ($action == 'create') print '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . ''; // Margin Infos - if (! empty($conf->margin->enabled)) + if (! empty($conf->margin->enabled)) { $rowspan=4; if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) $rowspan++; @@ -2087,25 +2089,25 @@ if ($action == 'create') print '' . $langs->trans('AmountTTC') . ''; print '' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . ''; print ''; - + if (!empty($conf->multicurrency->enabled)) { // Multicurrency Amount HT print '' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . ''; print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; print ''; - + // Multicurrency Amount VAT print '' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . ''; print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; print ''; - + // Multicurrency Amount TTC print '' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . ''; print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; - print ''; + print ''; } - + // Statut print '' . $langs->trans('Status') . '' . $object->getLibStatut(4) . ''; @@ -2397,7 +2399,7 @@ if ($action == 'create') { include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'pro'.$object->id); - } + } $formmail->withfrom = 1; $liste = array(); foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 2f07756fb8d..017a03fd4bd 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -165,7 +165,7 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); if ($code) print $langs->trans("OppStatus".$code); print ''; - + // Opportunity Amount print ''.$langs->trans("OpportunityAmount").''; if (strcmp($object->opp_amount,'')) print price($object->opp_amount,'',$langs,0,0,0,$conf->currency); @@ -193,7 +193,7 @@ $listofreferent=array( 'class'=>'Propal', 'table'=>'propal', 'datefieldname'=>'datep', - 'urlnew'=>DOL_URL_ROOT.'/comm/propal/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/comm/propal/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, 'lang'=>'propal', 'buttonnew'=>'AddProp', 'testnew'=>$user->rights->propal->creer, @@ -356,19 +356,19 @@ if ($action=="addelement") $tablename = GETPOST("tablename"); $elementselectid = GETPOST("elementselect"); $result=$object->update_element($tablename, $elementselectid); - if ($result<0) + if ($result<0) { setEventMessages($object->error, $object->errors, 'errors'); } } -elseif ($action == "unlink") +elseif ($action == "unlink") { $tablename = GETPOST("tablename"); $elementselectid = GETPOST("elementselect"); $result = $object->remove_element($tablename, $elementselectid); - if ($result < 0) + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -399,7 +399,7 @@ if (! $showdatefilter) print ''; print ''; print ''; - + $showdatefilter++; } @@ -569,14 +569,14 @@ foreach ($listofreferent as $key => $value) $urlnew=$value['urlnew']; $buttonnew=$value['buttonnew']; $testnew=$value['testnew']; - + if ($qualified) { // If we want the project task array to have details of users //if ($key == 'project_task') $key = 'project_task_time'; - + if ($langtoload) $langs->load($langtoload); - + $element = new $classname($db); $addform=''; @@ -584,7 +584,7 @@ foreach ($listofreferent as $key => $value) $idtofilterthirdparty=0; if (! in_array($tablename, array('facture_fourn', 'commande_fournisseur'))) $idtofilterthirdparty=$object->thirdparty->id; - if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty > 0) + if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty > 0) { $selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300'); if (! $selectList || ($selectList<0)) @@ -615,7 +615,7 @@ foreach ($listofreferent as $key => $value) else $addform.=''.($buttonnew?$langs->trans($buttonnew):$langs->trans("Create")).''; $addform.='
'; } - + print load_fiche_titre($langs->trans($title), $addform, ''); print '';