NEW Can create intervention from a proposal

This commit is contained in:
Laurent Destailleur 2017-10-17 10:44:18 +02:00
parent 082d59439f
commit eb1fdca157
7 changed files with 85 additions and 34 deletions

View File

@ -907,7 +907,7 @@ class ActionComm extends CommonObject
return $db->lasterror(); return $db->lasterror();
} }
} }
/** /**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate) * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
* *
@ -918,7 +918,7 @@ class ActionComm extends CommonObject
function load_board($user, $load_state_board=0) function load_board($user, $load_state_board=0)
{ {
global $conf, $langs; global $conf, $langs;
if(empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp"; if(empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp";
else { else {
$this->nb=array(); $this->nb=array();
@ -934,7 +934,7 @@ class ActionComm extends CommonObject
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id;
if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -956,7 +956,7 @@ class ActionComm extends CommonObject
if ($agenda_static->hasDelay()) $response->nbtodolate++; if ($agenda_static->hasDelay()) $response->nbtodolate++;
} else $this->nb["actionscomm"]=$obj->nb; } else $this->nb["actionscomm"]=$obj->nb;
} }
$this->db->free($resql); $this->db->free($resql);
if(empty($load_state_board)) return $response; if(empty($load_state_board)) return $response;
else return 1; else return 1;

View File

@ -2284,6 +2284,14 @@ if ($action == 'create')
} }
} }
// Create an intervention
if (! empty($conf->service->enabled) && ! empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) {
if ($user->rights->ficheinter->creer) {
$langs->load("interventions");
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/fichinter/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddIntervention") . '</a></div>';
}
}
// Create contract // Create contract
if ($conf->contrat->enabled && $object->statut == Propal::STATUS_SIGNED) { if ($conf->contrat->enabled && $object->statut == Propal::STATUS_SIGNED) {
$langs->load("contracts"); $langs->load("contracts");

View File

@ -1686,6 +1686,8 @@ if ($action == 'create' && $user->rights->commande->creer)
} }
print '<tr><td>' . $langs->trans($newclassname) . '</td><td>' . $objectsrc->getNomUrl(1) . '</td></tr>'; print '<tr><td>' . $langs->trans($newclassname) . '</td><td>' . $objectsrc->getNomUrl(1) . '</td></tr>';
// Amount
print '<tr><td>' . $langs->trans('TotalHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>'; print '<tr><td>' . $langs->trans('TotalHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>"; print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>";
if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE

View File

@ -3648,11 +3648,12 @@ abstract class CommonObject
* Return HTML table table of source object lines * Return HTML table table of source object lines
* TODO Move this and previous function into output html class file (htmlline.class.php). * TODO Move this and previous function into output html class file (htmlline.class.php).
* If lines are into a template, title must also be into a template * If lines are into a template, title must also be into a template
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * But for the moment we don't know if it's possible, so we keep the method available on overloaded objects.
* *
* @param string $restrictlist ''=All lines, 'services'=Restrict to services only
* @return void * @return void
*/ */
function printOriginLinesList() function printOriginLinesList($restrictlist='')
{ {
global $langs, $hookmanager, $conf; global $langs, $hookmanager, $conf;
@ -3674,8 +3675,6 @@ abstract class CommonObject
foreach ($this->lines as $line) foreach ($this->lines as $line)
{ {
if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
{ {
if (empty($line->fk_parent_line)) if (empty($line->fk_parent_line))
@ -3687,7 +3686,7 @@ abstract class CommonObject
} }
else else
{ {
$this->printOriginLine($line,$var); $this->printOriginLine($line, $var, $restrictlist);
} }
$i++; $i++;
@ -3700,11 +3699,12 @@ abstract class CommonObject
* If lines are into a template, title must also be into a template * If lines are into a template, title must also be into a template
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
* *
* @param CommonObjectLine $line Line * @param CommonObjectLine $line Line
* @param string $var Var * @param string $var Var
* @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not)
* @return void * @return void
*/ */
function printOriginLine($line,$var) function printOriginLine($line, $var, $restrictlist='')
{ {
global $langs, $conf; global $langs, $conf;
@ -3806,6 +3806,10 @@ abstract class CommonObject
if($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $line->getLabelOfUnit('long'); if($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $line->getLabelOfUnit('long');
$this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : '&nbsp;'; $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : '&nbsp;';
// Is the line strike or not
$this->tpl['strike']=0;
if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) $this->tpl['strike']=1;
// Output template part (modules that overwrite templates must declare this into descriptor) // Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer // Use global variables + $dateSelector + $seller and $buyer
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));

View File

@ -4742,6 +4742,7 @@ class Form
{ {
$shour = dol_print_date($set_time, "%H"); $shour = dol_print_date($set_time, "%H");
$smin = dol_print_date($set_time, "%M"); $smin = dol_print_date($set_time, "%M");
$ssec = dol_print_date($set_time, "%S");
} }
} }
else else
@ -4752,6 +4753,7 @@ class Form
$sday = ''; $sday = '';
$shour = !isset($conf->global->MAIN_DEFAULT_DATE_HOUR) ? '' : $conf->global->MAIN_DEFAULT_DATE_HOUR; $shour = !isset($conf->global->MAIN_DEFAULT_DATE_HOUR) ? '' : $conf->global->MAIN_DEFAULT_DATE_HOUR;
$smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? '' : $conf->global->MAIN_DEFAULT_DATE_MIN; $smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? '' : $conf->global->MAIN_DEFAULT_DATE_MIN;
$ssec = !isset($conf->global->MAIN_DEFAULT_DATE_SEC) ? '' : $conf->global->MAIN_DEFAULT_DATE_SEC;
} }
// You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery' // You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery'
@ -4932,6 +4934,8 @@ class Form
$retstring.='<option value="'.$min.'"'.(($min == $smin)?' selected':'').'>'.$min.(empty($conf->dol_optimize_smallscreen)?'':'').'</option>'; $retstring.='<option value="'.$min.'"'.(($min == $smin)?' selected':'').'>'.$min.(empty($conf->dol_optimize_smallscreen)?'':'').'</option>';
} }
$retstring.='</select>'; $retstring.='</select>';
$retstring.='<input type="hidden" name="'.$prefix.'sec" value="'.$ssec.'">';
} }
// Add a "Now" link // Add a "Now" link

View File

@ -19,8 +19,8 @@
?> ?>
<!-- BEGIN PHP TEMPLATE originproductline.tpl.php --> <!-- BEGIN PHP TEMPLATE originproductline.tpl.php -->
<?php <?php
print '<tr'.$bc[$var].'>'; print '<tr class="oddeven'.(empty($this->tpl['strike'])?'':' strikefordisabled').'">';
print '<td>'.$this->tpl['label'].'</td>'; print '<td>'.$this->tpl['label'].'</td>';
print '<td>'.$this->tpl['description'].'</td>'; print '<td>'.$this->tpl['description'].'</td>';
print '<td align="right">'.$this->tpl['vat_rate'].'</td>'; print '<td align="right">'.$this->tpl['vat_rate'].'</td>';
@ -29,7 +29,7 @@ if (!empty($conf->multicurrency->enabled))
print '<td align="right">'.$this->tpl['multicurrency_price'].'</td>'; print '<td align="right">'.$this->tpl['multicurrency_price'].'</td>';
print '<td align="right">'.$this->tpl['qty'].'</td>'; print '<td align="right">'.$this->tpl['qty'].'</td>';
if($conf->global->PRODUCT_USE_UNITS) if($conf->global->PRODUCT_USE_UNITS)
print '<td align="left">'.$langs->trans($this->tpl['unit']).'</td>'; print '<td align="left">'.$langs->trans($this->tpl['unit']).'</td>';
print '<td align="right">'.$this->tpl['remise_percent'].'</td>'; print '<td align="right">'.$this->tpl['remise_percent'].'</td>';

View File

@ -60,6 +60,7 @@ $ref = GETPOST('ref','alpha');
$socid = GETPOST('socid','int'); $socid = GETPOST('socid','int');
$contratid = GETPOST('contratid','int'); $contratid = GETPOST('contratid','int');
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$cancel = GETPOST('cancel','alpha');
$confirm = GETPOST('confirm','alpha'); $confirm = GETPOST('confirm','alpha');
$mesg = GETPOST('msg','alpha'); $mesg = GETPOST('msg','alpha');
$origin=GETPOST('origin','alpha'); $origin=GETPOST('origin','alpha');
@ -105,6 +106,16 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
if ($cancel)
{
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
$action='';
}
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
@ -201,11 +212,11 @@ if (empty($reshook))
else if ($action == 'add' && $user->rights->ficheinter->creer) else if ($action == 'add' && $user->rights->ficheinter->creer)
{ {
$object->socid = $socid; $object->socid = $socid;
$object->duration = GETPOST('duration','int'); $object->duration = GETPOST('duration','int');
$object->fk_project = GETPOST('projectid','int'); $object->fk_project = GETPOST('projectid','int');
$object->fk_contrat = GETPOST('contratid','int'); $object->fk_contrat = GETPOST('contratid','int');
$object->author = $user->id; $object->author = $user->id;
$object->description = GETPOST('description'); $object->description = GETPOST('description','none');
$object->ref = $ref; $object->ref = $ref;
$object->modelpdf = GETPOST('model','alpha'); $object->modelpdf = GETPOST('model','alpha');
$object->note_private = GETPOST('note_private','none'); $object->note_private = GETPOST('note_private','none');
@ -276,7 +287,7 @@ if (empty($reshook))
$fk_parent_line=0; $fk_parent_line=0;
$num=count($lines); $num=count($lines);
for ($i=0;$i<$num;$i++) for ($i=0; $i<$num; $i++)
{ {
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:Product::TYPE_PRODUCT); $product_type=($lines[$i]->product_type?$lines[$i]->product_type:Product::TYPE_PRODUCT);
@ -829,7 +840,7 @@ if ($action == 'create')
$soc=new Societe($db); $soc=new Societe($db);
print load_fiche_titre($langs->trans("AddIntervention")); print load_fiche_titre($langs->trans("AddIntervention"), '', 'title_commercial');
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
@ -1008,6 +1019,30 @@ if ($action == 'create')
$newclassname=$classname; $newclassname=$classname;
if ($newclassname=='Propal') $newclassname='CommercialProposal'; if ($newclassname=='Propal') $newclassname='CommercialProposal';
print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>'; print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>';
// Amount
/* Hide amount because we only copy services so amount may differ than source
print '<tr><td>' . $langs->trans('TotalHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>";
if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE
{
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax1) . "</td></tr>";
}
if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF
{
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax2) . "</td></tr>";
}
print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td>' . price($objectsrc->total_ttc) . "</td></tr>";
if (!empty($conf->multicurrency->enabled))
{
print '<tr><td>' . $langs->trans('MulticurrencyTotalHT') . '</td><td>' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('MulticurrencyTotalVAT') . '</td><td>' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
print '<tr><td>' . $langs->trans('MulticurrencyTotalTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
}
*/
} }
print '</table>'; print '</table>';
@ -1029,6 +1064,18 @@ if ($action == 'create')
print '</div>'; print '</div>';
print '</form>'; print '</form>';
// Show origin lines
if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) {
$title = $langs->trans('Services');
print load_fiche_titre($title);
print '<table class="noborder" width="100%">';
$objectsrc->printOriginLinesList(empty($conf->global->FICHINTER_PRINT_PRODUCTS)?'services':''); // Show only service, except if option FICHINTER_PRINT_PRODUCTS is on
print '</table>';
}
} }
else else
{ {
@ -1604,22 +1651,8 @@ else if ($id > 0 || ! empty($ref))
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a></div>';
} }
// Event agenda
if (! empty($conf->global->FICHINTER_ADDLINK_TO_EVENT))
{
if (! empty($conf->agenda->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
{
$langs->load("agenda");
if ($object->statut < Fichinter::STATUS_BILLED)
{
if ($user->rights->agenda->myactions->create) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'&amp;backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddEvent").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddEvent").'</a></div>';
}
}
}
// Proposal // Proposal
if (! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT) if ($conf->service->enabled && ! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
{ {
$langs->load("propal"); $langs->load("propal");
if ($object->statut < Fichinter::STATUS_BILLED) if ($object->statut < Fichinter::STATUS_BILLED)