Merge pull request #5604 from atm-florian/FIX_createpropalfromproject

FIX : create proposal from project
This commit is contained in:
Juanjo Menent 2016-08-11 20:43:44 +02:00 committed by GitHub
commit 3b509db141
3 changed files with 34 additions and 23 deletions

View File

@ -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();

View File

@ -140,7 +140,7 @@ if (empty($reshook))
} }
} }
} }
if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer) if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer)
{ {
$result = $object->setValid($user); $result = $object->setValid($user);
@ -733,14 +733,14 @@ if (empty($reshook))
/* /*
* Send mail * Send mail
*/ */
// Actions to send emails // Actions to send emails
$actiontypecode='AC_OTH_AUTO'; $actiontypecode='AC_OTH_AUTO';
$trigger_name='FICHINTER_SENTBYMAIL'; $trigger_name='FICHINTER_SENTBYMAIL';
$paramname='id'; $paramname='id';
$mode='emailfromintervention'; $mode='emailfromintervention';
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
if ($action == 'update_extras') if ($action == 'update_extras')
{ {
@ -955,7 +955,7 @@ if ($action == 'create')
else else
$numprojet=select_projects($societe->id,$_POST["projectid"],'projectid'); $numprojet=select_projects($societe->id,$_POST["projectid"],'projectid');
*/ */
$numprojet=$formproject->select_projects($soc->id,GETPOST('projectid','int'),'projectid'); $numprojet=$formproject->select_projects($soc->id,$projectid,'projectid');
if ($numprojet==0) if ($numprojet==0)
{ {
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>'; print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>';
@ -1027,6 +1027,8 @@ if ($action == 'create')
{ {
print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">'; print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">'; print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
} elseif ($origin == 'project' && !empty($projectid)) {
print '<input type="hidden" name="projectid" value="' . $projectid . '">';
} }
dol_fiche_end(); dol_fiche_end();
@ -1044,6 +1046,13 @@ if ($action == 'create')
dol_fiche_head(''); dol_fiche_head('');
print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">'; print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
if (is_object($objectsrc))
{
print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
} elseif ($origin == 'project' && !empty($projectid)) {
print '<input type="hidden" name="projectid" value="' . $projectid . '">';
}
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td class="fieldrequired">'.$langs->trans("ThirdParty").'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans("ThirdParty").'</td><td>';
print $form->select_company('','socid','','SelectThirdParty',1); print $form->select_company('','socid','','SelectThirdParty',1);
@ -1137,7 +1146,7 @@ else if ($id > 0 || ! empty($ref))
// Paiement incomplet. On demande si motif = escompte ou autre // Paiement incomplet. On demande si motif = escompte ou autre
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneIntervention'), $langs->trans('ConfirmCloneIntervention', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneIntervention'), $langs->trans('ConfirmCloneIntervention', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
} }
if (!$formconfirm) if (!$formconfirm)
{ {
$parameters=array('lineid'=>$lineid); $parameters=array('lineid'=>$lineid);
@ -1168,7 +1177,7 @@ else if ($id > 0 || ! empty($ref))
print '<td colspan="3">'.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'</td>'; print '<td colspan="3">'.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'</td>';
print '</tr>'; print '</tr>';
} }
if (! empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES)) if (! empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES))
{ {
// Date Start // Date Start
@ -1177,14 +1186,14 @@ else if ($id > 0 || ! empty($ref))
print $object->dateo ? dol_print_date($object->dateo, 'daytext') : '&nbsp;'; print $object->dateo ? dol_print_date($object->dateo, 'daytext') : '&nbsp;';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Date End // Date End
print '<tr><td>'.$langs->trans("Datee").'</td>'; print '<tr><td>'.$langs->trans("Datee").'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
print $object->datee ? dol_print_date($object->datee, 'daytext') : '&nbsp;'; print $object->datee ? dol_print_date($object->datee, 'daytext') : '&nbsp;';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Date Terminate/close // Date Terminate/close
print '<tr><td>'.$langs->trans("Datet").'</td>'; print '<tr><td>'.$langs->trans("Datet").'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
@ -1428,7 +1437,7 @@ else if ($id > 0 || ! empty($ref))
print '<td align="center" class="nowrap">'; print '<td align="center" class="nowrap">';
$form->select_date($db->jdate($objp->date_intervention),'di',1,1,0,"date_intervention"); $form->select_date($db->jdate($objp->date_intervention),'di',1,1,0,"date_intervention");
print '</td>'; print '</td>';
// Duration // Duration
print '<td align="right">'; print '<td align="right">';
if (empty($conf->global->FICHINTER_WITHOUT_DURATION)) { if (empty($conf->global->FICHINTER_WITHOUT_DURATION)) {
@ -1629,7 +1638,7 @@ else if ($id > 0 || ! empty($ref))
if ($user->rights->ficheinter->creer) { if ($user->rights->ficheinter->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;socid=' . $object->socid . '&amp;action=clone&amp;object=ficheinter">' . $langs->trans("ToClone") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;socid=' . $object->socid . '&amp;action=clone&amp;object=ficheinter">' . $langs->trans("ToClone") . '</a></div>';
} }
// Delete // Delete
if (($object->statut == 0 && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer) if (($object->statut == 0 && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer)
{ {
@ -1742,7 +1751,7 @@ else if ($id > 0 || ! empty($ref))
{ {
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'int'.$object->id); $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'int'.$object->id);
} }
$formmail->withfrom=1; $formmail->withfrom=1;
$liste=array(); $liste=array();
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$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,
@ -284,7 +284,7 @@ $listofreferent=array(
'table'=>'fichinter', 'table'=>'fichinter',
'datefieldname'=>'date_valid', 'datefieldname'=>'date_valid',
'disableamount'=>1, 'disableamount'=>1,
'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&projectid='.$id.'&socid='.$socid, 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid,
'lang'=>'interventions', 'lang'=>'interventions',
'buttonnew'=>'AddIntervention', 'buttonnew'=>'AddIntervention',
'testnew'=>$user->rights->ficheinter->creer, 'testnew'=>$user->rights->ficheinter->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%">';