FIX : create proposal from project

This commit is contained in:
florian HENRY 2016-08-10 11:34:10 +02:00
parent 8c63d68083
commit d38ff5c246
2 changed files with 29 additions and 27 deletions

View File

@ -279,7 +279,7 @@ if (empty($reshook))
if ($socid < 1) { if ($socid < 1) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), null, 'errors');
$action = 'create'; $action = 'create';
$error ++; $error ++;
} }
@ -345,7 +345,7 @@ if (empty($reshook))
$object->origin = GETPOST('origin'); $object->origin = GETPOST('origin');
$object->origin_id = GETPOST('originid'); $object->origin_id = GETPOST('originid');
// Multicurrency // Multicurrency
if (!empty($conf->multicurrency->enabled)) if (!empty($conf->multicurrency->enabled))
{ {
@ -718,7 +718,7 @@ if (empty($reshook))
$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
if (empty($tva_tx)) $tva_npr=0; if (empty($tva_tx)) $tva_npr=0;
$pu_ht = $prod->price; $pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc; $pu_ttc = $prod->price_ttc;
$price_min = $prod->price_min; $price_min = $prod->price_min;
@ -932,7 +932,7 @@ if (empty($reshook))
// Add buying price // Add buying price
$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); $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_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')); $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 // Actions to build doc
$upload_dir = $conf->propal->dir_output; $upload_dir = $conf->propal->dir_output;
$permissioncreate=$user->rights->propal->creer; $permissioncreate=$user->rights->propal->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
} }
@ -1266,6 +1266,8 @@ if ($action == 'create')
if ($origin != 'project' && $originid) { if ($origin != 'project' && $originid) {
print '<input type="hidden" name="origin" value="' . $origin . '">'; print '<input type="hidden" name="origin" value="' . $origin . '">';
print '<input type="hidden" name="originid" value="' . $originid . '">'; print '<input type="hidden" name="originid" value="' . $originid . '">';
} elseif ($origin == 'project' && !empty($projectid)) {
print '<input type="hidden" name="projectid" value="' . $projectid . '">';
} }
dol_fiche_head(); dol_fiche_head();
@ -1432,11 +1434,11 @@ if ($action == 'create')
print '<tr>'; print '<tr>';
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>'; print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
print '<td colspan="3" class="maxwidthonsmartphone">'; print '<td colspan="3" class="maxwidthonsmartphone">';
$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 $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
print '</td></tr>'; print '</td></tr>';
} }
// Public note // Public note
print '<tr>'; print '<tr>';
print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>'; print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
@ -1934,7 +1936,7 @@ if ($action == 'create')
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none');
} }
print '</td></tr>'; print '</td></tr>';
// Multicurrency rate // Multicurrency rate
print '<tr>'; print '<tr>';
print '<td width="25%">'; print '<td width="25%">';
@ -2053,7 +2055,7 @@ if ($action == 'create')
print '<td class="nowrap" colspan="2">' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>'; print '<td class="nowrap" colspan="2">' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
// Margin Infos // Margin Infos
if (! empty($conf->margin->enabled)) if (! empty($conf->margin->enabled))
{ {
$rowspan=4; $rowspan=4;
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) $rowspan++; if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) $rowspan++;
@ -2087,25 +2089,25 @@ if ($action == 'create')
print '<tr><td height="10">' . $langs->trans('AmountTTC') . '</td>'; print '<tr><td height="10">' . $langs->trans('AmountTTC') . '</td>';
print '<td class="nowrap" colspan="2">' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>'; print '<td class="nowrap" colspan="2">' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>'; print '</tr>';
if (!empty($conf->multicurrency->enabled)) if (!empty($conf->multicurrency->enabled))
{ {
// Multicurrency Amount HT // Multicurrency Amount HT
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>'; print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>'; print '</tr>';
// Multicurrency Amount VAT // Multicurrency Amount VAT
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>'; print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>'; print '</tr>';
// Multicurrency Amount TTC // Multicurrency Amount TTC
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>'; print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>'; print '</tr>';
} }
// Statut // Statut
print '<tr><td height="10">' . $langs->trans('Status') . '</td><td align="left" colspan="2">' . $object->getLibStatut(4) . '</td></tr>'; print '<tr><td height="10">' . $langs->trans('Status') . '</td><td align="left" colspan="2">' . $object->getLibStatut(4) . '</td></tr>';
@ -2397,7 +2399,7 @@ if ($action == 'create')
{ {
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'pro'.$object->id); $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'pro'.$object->id);
} }
$formmail->withfrom = 1; $formmail->withfrom = 1;
$liste = array(); $liste = array();
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value)

View File

@ -165,7 +165,7 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
$code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code');
if ($code) print $langs->trans("OppStatus".$code); if ($code) print $langs->trans("OppStatus".$code);
print '</td></tr>'; print '</td></tr>';
// Opportunity Amount // Opportunity Amount
print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>'; print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>';
if (strcmp($object->opp_amount,'')) print price($object->opp_amount,'',$langs,0,0,0,$conf->currency); if (strcmp($object->opp_amount,'')) print price($object->opp_amount,'',$langs,0,0,0,$conf->currency);
@ -193,7 +193,7 @@ $listofreferent=array(
'class'=>'Propal', 'class'=>'Propal',
'table'=>'propal', 'table'=>'propal',
'datefieldname'=>'datep', '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', 'lang'=>'propal',
'buttonnew'=>'AddProp', 'buttonnew'=>'AddProp',
'testnew'=>$user->rights->propal->creer, 'testnew'=>$user->rights->propal->creer,
@ -356,19 +356,19 @@ if ($action=="addelement")
$tablename = GETPOST("tablename"); $tablename = GETPOST("tablename");
$elementselectid = GETPOST("elementselect"); $elementselectid = GETPOST("elementselect");
$result=$object->update_element($tablename, $elementselectid); $result=$object->update_element($tablename, $elementselectid);
if ($result<0) if ($result<0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
elseif ($action == "unlink") elseif ($action == "unlink")
{ {
$tablename = GETPOST("tablename"); $tablename = GETPOST("tablename");
$elementselectid = GETPOST("elementselect"); $elementselectid = GETPOST("elementselect");
$result = $object->remove_element($tablename, $elementselectid); $result = $object->remove_element($tablename, $elementselectid);
if ($result < 0) if ($result < 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
@ -399,7 +399,7 @@ if (! $showdatefilter)
print '</tr></table>'; print '</tr></table>';
print '</form>'; print '</form>';
print '</div>'; print '</div>';
$showdatefilter++; $showdatefilter++;
} }
@ -569,14 +569,14 @@ foreach ($listofreferent as $key => $value)
$urlnew=$value['urlnew']; $urlnew=$value['urlnew'];
$buttonnew=$value['buttonnew']; $buttonnew=$value['buttonnew'];
$testnew=$value['testnew']; $testnew=$value['testnew'];
if ($qualified) if ($qualified)
{ {
// If we want the project task array to have details of users // If we want the project task array to have details of users
//if ($key == 'project_task') $key = 'project_task_time'; //if ($key == 'project_task') $key = 'project_task_time';
if ($langtoload) $langs->load($langtoload); if ($langtoload) $langs->load($langtoload);
$element = new $classname($db); $element = new $classname($db);
$addform=''; $addform='';
@ -584,7 +584,7 @@ foreach ($listofreferent as $key => $value)
$idtofilterthirdparty=0; $idtofilterthirdparty=0;
if (! in_array($tablename, array('facture_fourn', 'commande_fournisseur'))) $idtofilterthirdparty=$object->thirdparty->id; 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'); $selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300');
if (! $selectList || ($selectList<0)) if (! $selectList || ($selectList<0))
@ -615,7 +615,7 @@ foreach ($listofreferent as $key => $value)
else $addform.='<a class="buttonxxx buttonRefused" disabled="disabled" href="#">'.($buttonnew?$langs->trans($buttonnew):$langs->trans("Create")).'</a>'; else $addform.='<a class="buttonxxx buttonRefused" disabled="disabled" href="#">'.($buttonnew?$langs->trans($buttonnew):$langs->trans("Create")).'</a>';
$addform.='<div>'; $addform.='<div>';
} }
print load_fiche_titre($langs->trans($title), $addform, ''); print load_fiche_titre($langs->trans($title), $addform, '');
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';