Qual: Fix architecture problem with canvas
This commit is contained in:
parent
daaffd5f14
commit
d72f417868
@ -53,8 +53,148 @@ class ActionsContactCardCommon
|
|||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigne les valeurs par defaut pour le canvas
|
* Load data control
|
||||||
|
*/
|
||||||
|
function doActions($id)
|
||||||
|
{
|
||||||
|
global $conf, $user, $langs;
|
||||||
|
|
||||||
|
// Creation utilisateur depuis contact
|
||||||
|
if (GETPOST("action") == 'confirm_create_user' && GETPOST("confirm") == 'yes')
|
||||||
|
{
|
||||||
|
// Recuperation contact actuel
|
||||||
|
$result = $this->object->fetch($id);
|
||||||
|
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
// Creation user
|
||||||
|
$nuser = new User($this->db);
|
||||||
|
$result=$nuser->create_from_contact($this->object,$_POST["login"]);
|
||||||
|
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$result2=$nuser->setPassword($user,$_POST["password"],0,1,1);
|
||||||
|
if ($result2)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->errors=$nuser->error;
|
||||||
|
|
||||||
|
$this->db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->errors=$this->object->errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creation contact
|
||||||
|
if ($_POST["action"] == 'add')
|
||||||
|
{
|
||||||
|
$this->assign_post();
|
||||||
|
|
||||||
|
if (! $_POST["name"])
|
||||||
|
{
|
||||||
|
array_push($this->errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
|
||||||
|
$_GET["action"] = $_POST["action"] = 'create';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_POST["name"])
|
||||||
|
{
|
||||||
|
$id = $this->object->create($user);
|
||||||
|
if ($id > 0)
|
||||||
|
{
|
||||||
|
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->errors=$this->object->errors;
|
||||||
|
$_GET["action"] = $_POST["action"] = 'create';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes')
|
||||||
|
{
|
||||||
|
$result=$this->object->fetch($id);
|
||||||
|
|
||||||
|
$this->object->old_name = $_POST["old_name"];
|
||||||
|
$this->object->old_firstname = $_POST["old_firstname"];
|
||||||
|
|
||||||
|
$result = $this->object->delete();
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
Header("Location: index.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->errors=$this->object->errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_POST["action"] == 'update' && ! $_POST["cancel"])
|
||||||
|
{
|
||||||
|
if (empty($_POST["name"]))
|
||||||
|
{
|
||||||
|
$this->error=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
|
||||||
|
$_GET["action"] = $_POST["action"] = 'edit';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($this->error))
|
||||||
|
{
|
||||||
|
$this->object->fetch($_POST["contactid"]);
|
||||||
|
|
||||||
|
$this->object->oldcopy=dol_clone($this->object);
|
||||||
|
|
||||||
|
$this->assign_post();
|
||||||
|
|
||||||
|
$result = $this->object->update($_POST["contactid"], $user);
|
||||||
|
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$this->object->old_name='';
|
||||||
|
$this->object->old_firstname='';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->errors=$this->object->errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the title of card
|
||||||
|
*/
|
||||||
|
function getTitle($action)
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
$out='';
|
||||||
|
|
||||||
|
if ($action == 'view' || $action == 'edit') $out.= $langs->trans("Contact");
|
||||||
|
if ($action == 'create') $out.= $langs->trans("AddContact");
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set content of ->tpl array, to use into template
|
||||||
* @param action Type of template
|
* @param action Type of template
|
||||||
*/
|
*/
|
||||||
function assign_values($action='')
|
function assign_values($action='')
|
||||||
@ -67,6 +207,10 @@ class ActionsContactCardCommon
|
|||||||
$this->tpl[$key] = $value;
|
$this->tpl[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->tpl['title']=$this->getTitle($action);
|
||||||
|
$this->tpl['error']=$this->error;
|
||||||
|
$this->tpl['errors']=$this->errors;
|
||||||
|
|
||||||
if ($action == 'create' || $action == 'edit')
|
if ($action == 'create' || $action == 'edit')
|
||||||
{
|
{
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax)
|
||||||
@ -293,129 +437,6 @@ class ActionsContactCardCommon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load data control
|
|
||||||
*/
|
|
||||||
function doActions($id)
|
|
||||||
{
|
|
||||||
global $conf, $user, $langs;
|
|
||||||
|
|
||||||
// Creation utilisateur depuis contact
|
|
||||||
if (GETPOST("action") == 'confirm_create_user' && GETPOST("confirm") == 'yes')
|
|
||||||
{
|
|
||||||
// Recuperation contact actuel
|
|
||||||
$result = $this->object->fetch($id);
|
|
||||||
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
|
||||||
$this->db->begin();
|
|
||||||
|
|
||||||
// Creation user
|
|
||||||
$nuser = new User($this->db);
|
|
||||||
$result=$nuser->create_from_contact($this->object,$_POST["login"]);
|
|
||||||
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
|
||||||
$result2=$nuser->setPassword($user,$_POST["password"],0,1,1);
|
|
||||||
if ($result2)
|
|
||||||
{
|
|
||||||
$this->db->commit();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->db->rollback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->errors=$nuser->error;
|
|
||||||
|
|
||||||
$this->db->rollback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->errors=$this->object->errors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creation contact
|
|
||||||
if ($_POST["action"] == 'add')
|
|
||||||
{
|
|
||||||
$this->assign_post();
|
|
||||||
|
|
||||||
if (! $_POST["name"])
|
|
||||||
{
|
|
||||||
array_push($this->errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
|
|
||||||
$_GET["action"] = $_POST["action"] = 'create';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_POST["name"])
|
|
||||||
{
|
|
||||||
$id = $this->object->create($user);
|
|
||||||
if ($id > 0)
|
|
||||||
{
|
|
||||||
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->errors=$this->object->errors;
|
|
||||||
$_GET["action"] = $_POST["action"] = 'create';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes')
|
|
||||||
{
|
|
||||||
$result=$this->object->fetch($id);
|
|
||||||
|
|
||||||
$this->object->old_name = $_POST["old_name"];
|
|
||||||
$this->object->old_firstname = $_POST["old_firstname"];
|
|
||||||
|
|
||||||
$result = $this->object->delete();
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
|
||||||
Header("Location: index.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->errors=$this->object->errors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_POST["action"] == 'update' && ! $_POST["cancel"])
|
|
||||||
{
|
|
||||||
if (empty($_POST["name"]))
|
|
||||||
{
|
|
||||||
$this->error=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
|
|
||||||
$_GET["action"] = $_POST["action"] = 'edit';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($this->error))
|
|
||||||
{
|
|
||||||
$this->object->fetch($_POST["contactid"]);
|
|
||||||
|
|
||||||
$this->object->oldcopy=dol_clone($this->object);
|
|
||||||
|
|
||||||
$this->assign_post();
|
|
||||||
|
|
||||||
$result = $this->object->update($_POST["contactid"], $user);
|
|
||||||
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
|
||||||
$this->object->old_name='';
|
|
||||||
$this->object->old_firstname='';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->errors=$this->object->errors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -44,19 +45,23 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
|
|||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute actions
|
||||||
|
* @param Id of object (may be empty for creation)
|
||||||
|
*/
|
||||||
|
function doActions($id)
|
||||||
|
{
|
||||||
|
$return = parent::doActions($id);
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the title of card
|
* Return the title of card
|
||||||
*/
|
*/
|
||||||
function getTitle($action)
|
function getTitle($action)
|
||||||
{
|
{
|
||||||
global $langs;
|
return parent::getTitle($action);
|
||||||
|
|
||||||
$out='';
|
|
||||||
|
|
||||||
if ($action == 'view' || $action == 'edit') $out.= $langs->trans("Contact");
|
|
||||||
if ($action == 'create') $out.= $langs->trans("AddContact");
|
|
||||||
|
|
||||||
return $out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,17 +83,6 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
|
|||||||
parent::assign_post();
|
parent::assign_post();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute actions
|
|
||||||
* @param Id of object (may be empty for creation)
|
|
||||||
*/
|
|
||||||
function doActions($id)
|
|
||||||
{
|
|
||||||
$return = parent::doActions($id);
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign custom values for canvas
|
* Assign custom values for canvas
|
||||||
* @param action Type of action
|
* @param action Type of action
|
||||||
@ -100,8 +94,15 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
|
|||||||
|
|
||||||
parent::assign_values($action);
|
parent::assign_values($action);
|
||||||
|
|
||||||
|
$this->tpl['title'] = $this->getTitle($action);
|
||||||
|
$this->tpl['error'] = $this->error;
|
||||||
|
$this->tpl['errors']= $this->errors;
|
||||||
|
|
||||||
if ($action == 'view')
|
if ($action == 'view')
|
||||||
{
|
{
|
||||||
|
// Card header
|
||||||
|
$this->tpl['showhead']=$this->showHead($action);
|
||||||
|
|
||||||
// Confirm delete contact
|
// Confirm delete contact
|
||||||
if ($user->rights->societe->contact->supprimer)
|
if ($user->rights->societe->contact->supprimer)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -21,7 +21,12 @@
|
|||||||
|
|
||||||
<!-- BEGIN PHP TEMPLATE -->
|
<!-- BEGIN PHP TEMPLATE -->
|
||||||
|
|
||||||
<?php echo $this->control->tpl['ajax_selectcountry']; ?>
|
<?php
|
||||||
|
print_fiche_titre($this->control->tpl['title']);
|
||||||
|
|
||||||
|
dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']);
|
||||||
|
|
||||||
|
echo $this->control->tpl['ajax_selectcountry']; ?>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,13 @@
|
|||||||
|
|
||||||
<!-- BEGIN PHP TEMPLATE -->
|
<!-- BEGIN PHP TEMPLATE -->
|
||||||
|
|
||||||
<?php echo $this->control->tpl['ajax_selectcountry']; ?>
|
<?php
|
||||||
|
print_fiche_titre($this->control->tpl['title']);
|
||||||
|
|
||||||
|
dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']);
|
||||||
|
|
||||||
|
echo $this->control->tpl['ajax_selectcountry'];
|
||||||
|
?>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,10 @@
|
|||||||
|
|
||||||
<!-- BEGIN PHP TEMPLATE -->
|
<!-- BEGIN PHP TEMPLATE -->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']);
|
||||||
|
?>
|
||||||
|
|
||||||
<?php if ($this->control->tpl['action_create_user']) echo $this->control->tpl['action_create_user']; ?>
|
<?php if ($this->control->tpl['action_create_user']) echo $this->control->tpl['action_create_user']; ?>
|
||||||
<?php if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?>
|
<?php if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?>
|
||||||
|
|
||||||
|
|||||||
@ -81,6 +81,16 @@ if (method_exists($objcanvas->control,'doActions'))
|
|||||||
// When used with CANVAS
|
// When used with CANVAS
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
$objcanvas->doActions($id);
|
$objcanvas->doActions($id);
|
||||||
|
if (empty($objcanvas->error) && (empty($objcanvas->errors) || sizeof($objcanvas->errors) == 0))
|
||||||
|
{
|
||||||
|
if ($action=='add') { $objcanvas->action='create'; $action='create'; }
|
||||||
|
if ($action=='update') { $objcanvas->action='view'; $action='view'; }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($action=='add') { $objcanvas->action='create'; $action='create'; }
|
||||||
|
if ($action=='update') { $objcanvas->action='edit'; $action='edit'; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -297,95 +307,28 @@ if (! empty($objcanvas->template_dir))
|
|||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create')
|
||||||
{
|
{
|
||||||
/*
|
$objcanvas->assign_post(); // Assign POST data
|
||||||
* Mode creation
|
$objcanvas->assign_values($action); // Set value for templates
|
||||||
*/
|
$objcanvas->display_canvas($action); // Show template
|
||||||
|
|
||||||
// Assign _POST data to objcanvas->object->xxx
|
|
||||||
$objcanvas->assign_post();
|
|
||||||
|
|
||||||
// Assign template values into objcanvas->control->tpl
|
|
||||||
$objcanvas->assign_values();
|
|
||||||
|
|
||||||
// Card header TODO This should be done into canvas_display
|
|
||||||
$title = $objcanvas->getTitle();
|
|
||||||
print_fiche_titre($title);
|
|
||||||
|
|
||||||
// Show errors TODO This should be done into assign_values()
|
|
||||||
// that should get string of dol_htmloutput_errors and
|
|
||||||
// assigne it into objcanvas->control->tpl like other strings to show
|
|
||||||
// by templates, then output of string should be done into display_canvas
|
|
||||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
|
||||||
|
|
||||||
// Display canvas
|
|
||||||
$objcanvas->display_canvas('create');
|
|
||||||
}
|
}
|
||||||
else if ($action == 'edit')
|
else if ($action == 'edit')
|
||||||
{
|
{
|
||||||
/*
|
$objcanvas->fetch($id); // Reload object
|
||||||
* Mode edition
|
$objcanvas->assign_post(); // Assign POST data
|
||||||
*/
|
$objcanvas->assign_values($action); // Set value for templates
|
||||||
|
$objcanvas->display_canvas($action); // Show template
|
||||||
// Fetch object
|
|
||||||
$result=$objcanvas->fetch($id);
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
|
||||||
// Card header
|
|
||||||
$objcanvas->showHead();
|
|
||||||
|
|
||||||
if ($_POST["name"])
|
|
||||||
{
|
|
||||||
// Assign _POST data
|
|
||||||
$objcanvas->assign_post();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign values
|
|
||||||
$objcanvas->assign_values();
|
|
||||||
|
|
||||||
// Display canvas
|
|
||||||
$objcanvas->display_canvas('edit');
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
$result=$objcanvas->fetch($id); // Reload object
|
||||||
}
|
$objcanvas->assign_values('view'); // Assign values
|
||||||
}
|
$objcanvas->display_canvas('view'); // Show template
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Mode view
|
|
||||||
*/
|
|
||||||
// Fetch object
|
|
||||||
$result=$objcanvas->fetch($id);
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
|
||||||
// Assign values
|
|
||||||
$objcanvas->assign_values();
|
|
||||||
|
|
||||||
// FIXME div of tab is shown by showHead but /div is closed by
|
|
||||||
// display_canvas. All output should be processed by template so
|
|
||||||
// showHead and dol_htmloutput_errors should be moved into
|
|
||||||
// display_canvas.
|
|
||||||
|
|
||||||
// Card header
|
|
||||||
$objcanvas->showHead();
|
|
||||||
|
|
||||||
// Show errors TODO This output string should be set by
|
|
||||||
// assign_values and output by template into display_canvas
|
|
||||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
|
||||||
|
|
||||||
// Display canvas
|
|
||||||
$objcanvas->display_canvas('view');
|
|
||||||
|
|
||||||
|
// TODO Move this also into template
|
||||||
print show_actions_todo($conf,$langs,$db,$objsoc,$objcanvas->control->object);
|
print show_actions_todo($conf,$langs,$db,$objsoc,$objcanvas->control->object);
|
||||||
|
|
||||||
print show_actions_done($conf,$langs,$db,$objsoc,$objcanvas->control->object);
|
print show_actions_done($conf,$langs,$db,$objsoc,$objcanvas->control->object);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -103,8 +103,7 @@ class Canvas
|
|||||||
/*print 'canvas='.$this->canvas.'<br>';
|
/*print 'canvas='.$this->canvas.'<br>';
|
||||||
print 'childmodule='.$childmodule.' targetmodule='.$targetmodule.'<br>';
|
print 'childmodule='.$childmodule.' targetmodule='.$targetmodule.'<br>';
|
||||||
print 'this->aliasmodule='.$this->aliasmodule.' this->targetmodule='.$this->targetmodule.'<br>';
|
print 'this->aliasmodule='.$this->aliasmodule.' this->targetmodule='.$this->targetmodule.'<br>';
|
||||||
print 'childmodule='.$conf->$childmodule->enabled.' targetmodule='.$conf->$targetmodule->enabled.'<br>';
|
print 'childmodule='.$conf->$childmodule->enabled.' targetmodule='.$conf->$targetmodule->enabled.'<br>';*/
|
||||||
*/
|
|
||||||
|
|
||||||
if (! $conf->$childmodule->enabled || ! $conf->$targetmodule->enabled) accessforbidden();
|
if (! $conf->$childmodule->enabled || ! $conf->$targetmodule->enabled) accessforbidden();
|
||||||
|
|
||||||
@ -132,7 +131,7 @@ class Canvas
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Include specific library
|
// Include specific library
|
||||||
// FIXME Specific libraries must be included by files that need them only, so by actions and/or dao files.
|
// TODO Specific libraries must be included by files that need them only, so by actions and/or dao files.
|
||||||
$libfile = dol_buildpath('/'.$this->aliasmodule.'/lib/'.$this->aliasmodule.'.lib.php');
|
$libfile = dol_buildpath('/'.$this->aliasmodule.'/lib/'.$this->aliasmodule.'.lib.php');
|
||||||
if (file_exists($libfile)) require_once($libfile);
|
if (file_exists($libfile)) require_once($libfile);
|
||||||
|
|
||||||
@ -142,6 +141,8 @@ class Canvas
|
|||||||
{
|
{
|
||||||
$this->template_dir='';
|
$this->template_dir='';
|
||||||
}
|
}
|
||||||
|
//print '/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/tpl/';
|
||||||
|
//print 'template_dir='.$this->template_dir.'<br>';
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -195,19 +196,8 @@ class Canvas
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the title of card
|
|
||||||
* // FIXME An output function is stored inside an action class. Must change this.
|
|
||||||
*/
|
|
||||||
function getTitle()
|
|
||||||
{
|
|
||||||
if (method_exists($this->control,'getTitle')) return $this->control->getTitle($this->action);
|
|
||||||
else return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the head of card (tabs)
|
* Return the head of card (tabs)
|
||||||
* // FIXME An output function is stored inside an action class. Must change this.
|
|
||||||
*/
|
*/
|
||||||
function showHead()
|
function showHead()
|
||||||
{
|
{
|
||||||
@ -217,7 +207,7 @@ class Canvas
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigne les valeurs POST dans l'objet
|
* Assigne les valeurs POST dans l'objet
|
||||||
* // FIXME This is useless. POST is already visible from everywhere.
|
* // TODO This should be useless. POST is already visible from everywhere.
|
||||||
*/
|
*/
|
||||||
function assign_post()
|
function assign_post()
|
||||||
{
|
{
|
||||||
@ -230,7 +220,7 @@ class Canvas
|
|||||||
*/
|
*/
|
||||||
function assign_values()
|
function assign_values()
|
||||||
{
|
{
|
||||||
$this->control->assign_values($this->action);
|
if (method_exists($this->control,'assign_values')) $this->control->assign_values($this->action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -53,344 +54,6 @@ class ActionsCardCommon
|
|||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Assigne les valeurs par defaut pour le canvas
|
|
||||||
* @param action Type of template
|
|
||||||
*/
|
|
||||||
function assign_values($action='')
|
|
||||||
{
|
|
||||||
global $conf, $langs, $user, $mysoc, $canvas;
|
|
||||||
global $form, $formadmin, $formcompany;
|
|
||||||
|
|
||||||
if ($_GET["type"]=='f') { $this->object->fournisseur=1; }
|
|
||||||
if ($_GET["type"]=='c') { $this->object->client=1; }
|
|
||||||
if ($_GET["type"]=='p') { $this->object->client=2; }
|
|
||||||
if ($_GET["type"]=='cp') { $this->object->client=3; }
|
|
||||||
if ($_REQUEST["private"]==1) { $this->object->particulier=1; }
|
|
||||||
|
|
||||||
foreach($this->object as $key => $value)
|
|
||||||
{
|
|
||||||
$this->tpl[$key] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'create')
|
|
||||||
{
|
|
||||||
if ($conf->use_javascript_ajax)
|
|
||||||
{
|
|
||||||
$this->tpl['ajax_selecttype'] = "\n".'<script type="text/javascript" language="javascript">
|
|
||||||
jQuery(document).ready(function () {
|
|
||||||
jQuery("#radiocompany").click(function() {
|
|
||||||
document.formsoc.action.value="create";
|
|
||||||
document.formsoc.canvas.value="default";
|
|
||||||
document.formsoc.private.value=0;
|
|
||||||
document.formsoc.submit();
|
|
||||||
});
|
|
||||||
jQuery("#radioprivate").click(function() {
|
|
||||||
document.formsoc.action.value="create";
|
|
||||||
document.formsoc.canvas.value="individual";
|
|
||||||
document.formsoc.private.value=1;
|
|
||||||
document.formsoc.submit();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>'."\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'create' || $action == 'edit')
|
|
||||||
{
|
|
||||||
if ($conf->use_javascript_ajax)
|
|
||||||
{
|
|
||||||
$this->tpl['ajax_selectcountry'] = "\n".'<script type="text/javascript" language="javascript">
|
|
||||||
jQuery(document).ready(function () {
|
|
||||||
jQuery("#selectpays_id").change(function() {
|
|
||||||
document.formsoc.action.value="'.$action.'";
|
|
||||||
document.formsoc.canvas.value="'.$canvas.'";
|
|
||||||
document.formsoc.submit();
|
|
||||||
});
|
|
||||||
})
|
|
||||||
</script>'."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load object modCodeClient
|
|
||||||
$module=$conf->global->SOCIETE_CODECLIENT_ADDON;
|
|
||||||
if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined"));
|
|
||||||
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
|
|
||||||
{
|
|
||||||
$module = substr($module, 0, dol_strlen($module)-4);
|
|
||||||
}
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php");
|
|
||||||
$modCodeClient = new $module;
|
|
||||||
$this->tpl['auto_customercode'] = $modCodeClient->code_auto;
|
|
||||||
// We verified if the tag prefix is used
|
|
||||||
if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
|
|
||||||
|
|
||||||
// TODO create a function
|
|
||||||
$this->tpl['select_customertype'] = '<select class="flat" name="client">';
|
|
||||||
$this->tpl['select_customertype'].= '<option value="2"'.($this->object->client==2?' selected="selected"':'').'>'.$langs->trans('Prospect').'</option>';
|
|
||||||
$this->tpl['select_customertype'].= '<option value="3"'.($this->object->client==3?' selected="selected"':'').'>'.$langs->trans('ProspectCustomer').'</option>';
|
|
||||||
$this->tpl['select_customertype'].= '<option value="1"'.($this->object->client==1?' selected="selected"':'').'>'.$langs->trans('Customer').'</option>';
|
|
||||||
$this->tpl['select_customertype'].= '<option value="0"'.($this->object->client==0?' selected="selected"':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
|
|
||||||
$this->tpl['select_customertype'].= '</select>';
|
|
||||||
|
|
||||||
// Customer
|
|
||||||
$this->tpl['customercode'] = $this->object->code_client;
|
|
||||||
if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) $this->tpl['customercode'] = $modCodeClient->getNextValue($this->object,0);
|
|
||||||
$this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable();
|
|
||||||
$s=$modCodeClient->getToolTip($langs,$this->object,0);
|
|
||||||
$this->tpl['help_customercode'] = $form->textwithpicto('',$s,1);
|
|
||||||
|
|
||||||
if ($conf->fournisseur->enabled)
|
|
||||||
{
|
|
||||||
$this->tpl['supplier_enabled'] = 1;
|
|
||||||
|
|
||||||
// Load object modCodeFournisseur
|
|
||||||
$module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
|
|
||||||
if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
|
|
||||||
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
|
|
||||||
{
|
|
||||||
$module = substr($module, 0, dol_strlen($module)-4);
|
|
||||||
}
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php");
|
|
||||||
$modCodeFournisseur = new $module;
|
|
||||||
$this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto;
|
|
||||||
// We verified if the tag prefix is used
|
|
||||||
if ($modCodeFournisseur->code_auto) $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
|
|
||||||
|
|
||||||
// Supplier
|
|
||||||
$this->tpl['yn_supplier'] = $form->selectyesno("fournisseur",$this->object->fournisseur,1);
|
|
||||||
$this->tpl['suppliercode'] = $this->object->code_fournisseur;
|
|
||||||
if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object,1);
|
|
||||||
$this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable();
|
|
||||||
$s=$modCodeFournisseur->getToolTip($langs,$this->object,1);
|
|
||||||
$this->tpl['help_suppliercode'] = $form->textwithpicto('',$s,1);
|
|
||||||
|
|
||||||
$this->object->LoadSupplierCateg();
|
|
||||||
$this->tpl['suppliercategory'] = $this->object->SupplierCategories;
|
|
||||||
$this->tpl['select_suppliercategory'] = $form->selectarray("fournisseur_categorie",$this->object->SupplierCategories,$_POST["fournisseur_categorie"],1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Zip
|
|
||||||
$this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip,'zipcode',array('town','selectpays_id','departement_id'),6);
|
|
||||||
|
|
||||||
// Town
|
|
||||||
$this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town,'town',array('zipcode','selectpays_id','departement_id'));
|
|
||||||
|
|
||||||
// Country
|
|
||||||
$this->tpl['select_country'] = $form->select_country($this->object->pays_id,'pays_id');
|
|
||||||
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
|
||||||
|
|
||||||
if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
|
||||||
|
|
||||||
// State
|
|
||||||
if ($this->object->pays_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->departement_id,$this->object->pays_code);
|
|
||||||
else $this->tpl['select_state'] = $countrynotdefined;
|
|
||||||
|
|
||||||
// Language
|
|
||||||
if ($conf->global->MAIN_MULTILANGS) $this->tpl['select_lang'] = $formadmin->select_language(($this->object->default_lang?$this->object->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1);
|
|
||||||
|
|
||||||
// VAT
|
|
||||||
$this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value',$this->tpl['tva_assuj'],1); // Assujeti par defaut en creation
|
|
||||||
|
|
||||||
// Select users
|
|
||||||
$this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id,'commercial_id',1);
|
|
||||||
|
|
||||||
// Local Tax
|
|
||||||
// TODO mettre dans une classe propre au pays
|
|
||||||
if($mysoc->pays_code=='ES')
|
|
||||||
{
|
|
||||||
$this->tpl['localtax'] = '';
|
|
||||||
|
|
||||||
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
|
|
||||||
{
|
|
||||||
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td>';
|
|
||||||
$this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',$this->object->localtax1_assuj,1);
|
|
||||||
$this->tpl['localtax'].= '</td><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td>';
|
|
||||||
$this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',$this->object->localtax1_assuj,1);
|
|
||||||
$this->tpl['localtax'].= '</td></tr>';
|
|
||||||
}
|
|
||||||
elseif($mysoc->localtax1_assuj=="1")
|
|
||||||
{
|
|
||||||
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
|
|
||||||
$this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',$this->object->localtax1_assuj,1);
|
|
||||||
$this->tpl['localtax'].= '</td><tr>';
|
|
||||||
}
|
|
||||||
elseif($mysoc->localtax2_assuj=="1")
|
|
||||||
{
|
|
||||||
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
|
|
||||||
$this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',$this->object->localtax1_assuj,1);
|
|
||||||
$this->tpl['localtax'].= '</td><tr>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'view')
|
|
||||||
{
|
|
||||||
$this->tpl['showrefnav'] = $form->showrefnav($this->object,'socid','',($user->societe_id?0:1),'rowid','nom');
|
|
||||||
|
|
||||||
$this->tpl['checkcustomercode'] = $this->object->check_codeclient();
|
|
||||||
$this->tpl['checksuppliercode'] = $this->object->check_codefournisseur();
|
|
||||||
$this->tpl['address'] = dol_nl2br($this->object->address);
|
|
||||||
|
|
||||||
$img=picto_from_langcode($this->object->pays_code);
|
|
||||||
if ($this->object->isInEEC()) $this->tpl['country'] = $form->textwithpicto(($img?$img.' ':'').$this->object->country,$langs->trans("CountryIsInEEC"),1,0);
|
|
||||||
$this->tpl['country'] = ($img?$img.' ':'').$this->object->country;
|
|
||||||
|
|
||||||
$this->tpl['phone'] = dol_print_phone($this->object->tel,$this->object->pays_code,0,$this->object->id,'AC_TEL');
|
|
||||||
$this->tpl['fax'] = dol_print_phone($this->object->fax,$this->object->pays_code,0,$this->object->id,'AC_FAX');
|
|
||||||
$this->tpl['email'] = dol_print_email($this->object->email,0,$this->object->id,'AC_EMAIL');
|
|
||||||
$this->tpl['url'] = dol_print_url($this->object->url);
|
|
||||||
|
|
||||||
$this->tpl['tva_assuj'] = yn($this->object->tva_assuj);
|
|
||||||
|
|
||||||
// Third party type
|
|
||||||
$arr = $formcompany->typent_array(1);
|
|
||||||
$this->tpl['typent'] = $arr[$this->object->typent_code];
|
|
||||||
|
|
||||||
if ($conf->global->MAIN_MULTILANGS)
|
|
||||||
{
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
|
||||||
//$s=picto_from_langcode($this->default_lang);
|
|
||||||
//print ($s?$s.' ':'');
|
|
||||||
$langs->load("languages");
|
|
||||||
$this->tpl['default_lang'] = ($this->default_lang?$langs->trans('Language_'.$this->object->default_lang):'');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->tpl['image_edit'] = img_edit();
|
|
||||||
|
|
||||||
$this->tpl['display_rib'] = $this->object->display_rib();
|
|
||||||
|
|
||||||
// Sales representatives
|
|
||||||
$this->tpl['sales_representatives'] = '';
|
|
||||||
$listsalesrepresentatives=$this->object->getSalesRepresentatives($user);
|
|
||||||
$nbofsalesrepresentative=sizeof($listsalesrepresentatives);
|
|
||||||
if ($nbofsalesrepresentative > 3) // We print only number
|
|
||||||
{
|
|
||||||
$this->tpl['sales_representatives'].= '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$this->object->id.'">';
|
|
||||||
$this->tpl['sales_representatives'].= $nbofsalesrepresentative;
|
|
||||||
$this->tpl['sales_representatives'].= '</a>';
|
|
||||||
}
|
|
||||||
else if ($nbofsalesrepresentative > 0)
|
|
||||||
{
|
|
||||||
$userstatic=new User($db);
|
|
||||||
$i=0;
|
|
||||||
foreach($listsalesrepresentatives as $val)
|
|
||||||
{
|
|
||||||
$userstatic->id=$val['id'];
|
|
||||||
$userstatic->nom=$val['name'];
|
|
||||||
$userstatic->prenom=$val['firstname'];
|
|
||||||
$this->tpl['sales_representatives'].= $userstatic->getNomUrl(1);
|
|
||||||
$i++;
|
|
||||||
if ($i < $nbofsalesrepresentative) $this->tpl['sales_representatives'].= ', ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else $this->tpl['sales_representatives'].= $langs->trans("NoSalesRepresentativeAffected");
|
|
||||||
|
|
||||||
// Linked member
|
|
||||||
if ($conf->adherent->enabled)
|
|
||||||
{
|
|
||||||
$langs->load("members");
|
|
||||||
$adh=new Adherent($this->db);
|
|
||||||
$result=$adh->fetch('','',$this->object->id);
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
|
||||||
$adh->ref=$adh->getFullName($langs);
|
|
||||||
$this->tpl['linked_member'] = $adh->getNomUrl(1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->tpl['linked_member'] = $langs->trans("UserNotLinkedToMember");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Local Tax
|
|
||||||
// TODO mettre dans une classe propre au pays
|
|
||||||
if($mysoc->pays_code=='ES')
|
|
||||||
{
|
|
||||||
$this->tpl['localtax'] = '';
|
|
||||||
|
|
||||||
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
|
|
||||||
{
|
|
||||||
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>';
|
|
||||||
$this->tpl['localtax'].= '<td>'.yn($this->object->localtax1_assuj).'</td>';
|
|
||||||
$this->tpl['localtax'].= '<td>'.$langs->trans("LocalTax2IsUsedES").'</td>';
|
|
||||||
$this->tpl['localtax'].= '<td>'.yn($this->object->localtax2_assuj).'</td></tr>';
|
|
||||||
}
|
|
||||||
elseif($mysoc->localtax1_assuj=="1")
|
|
||||||
{
|
|
||||||
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>';
|
|
||||||
$this->tpl['localtax'].= '<td colspan="3">'.yn($this->object->localtax1_assuj).'</td></tr>';
|
|
||||||
}
|
|
||||||
elseif($mysoc->localtax2_assuj=="1")
|
|
||||||
{
|
|
||||||
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td>';
|
|
||||||
$this->tpl['localtax'].= '<td colspan="3">'.yn($this->object->localtax2_assuj).'</td></tr>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Assigne les valeurs POST dans l'objet
|
|
||||||
*/
|
|
||||||
function assign_post()
|
|
||||||
{
|
|
||||||
global $langs, $mysoc;
|
|
||||||
|
|
||||||
$this->object->id = $_POST["socid"];
|
|
||||||
$this->object->nom = $_POST["nom"];
|
|
||||||
$this->object->prefix_comm = $_POST["prefix_comm"];
|
|
||||||
$this->object->client = $_POST["client"];
|
|
||||||
$this->object->code_client = $_POST["code_client"];
|
|
||||||
$this->object->fournisseur = $_POST["fournisseur"];
|
|
||||||
$this->object->code_fournisseur = $_POST["code_fournisseur"];
|
|
||||||
$this->object->adresse = $_POST["adresse"]; // TODO obsolete
|
|
||||||
$this->object->address = $_POST["adresse"];
|
|
||||||
$this->object->zip = $_POST["zipcode"];
|
|
||||||
$this->object->town = $_POST["town"];
|
|
||||||
$this->object->pays_id = $_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
|
|
||||||
$this->object->departement_id = $_POST["departement_id"];
|
|
||||||
$this->object->tel = $_POST["tel"];
|
|
||||||
$this->object->fax = $_POST["fax"];
|
|
||||||
$this->object->email = $_POST["email"];
|
|
||||||
$this->object->url = $_POST["url"];
|
|
||||||
$this->object->capital = $_POST["capital"];
|
|
||||||
$this->object->siren = $_POST["idprof1"];
|
|
||||||
$this->object->siret = $_POST["idprof2"];
|
|
||||||
$this->object->ape = $_POST["idprof3"];
|
|
||||||
$this->object->idprof4 = $_POST["idprof4"];
|
|
||||||
$this->object->typent_id = $_POST["typent_id"];
|
|
||||||
$this->object->effectif_id = $_POST["effectif_id"];
|
|
||||||
$this->object->gencod = $_POST["gencod"];
|
|
||||||
$this->object->forme_juridique_code = $_POST["forme_juridique_code"];
|
|
||||||
$this->object->default_lang = $_POST["default_lang"];
|
|
||||||
$this->object->commercial_id = $_POST["commercial_id"];
|
|
||||||
|
|
||||||
$this->object->tva_assuj = $_POST["assujtva_value"]?$_POST["assujtva_value"]:1;
|
|
||||||
$this->object->tva_intra = $_POST["tva_intra"];
|
|
||||||
|
|
||||||
//Local Taxes
|
|
||||||
$this->object->localtax1_assuj = $_POST["localtax1assuj_value"];
|
|
||||||
$this->object->localtax2_assuj = $_POST["localtax2assuj_value"];
|
|
||||||
|
|
||||||
// We set pays_id, and pays_code label of the chosen country
|
|
||||||
// TODO move in business class
|
|
||||||
if ($this->object->pays_id)
|
|
||||||
{
|
|
||||||
$sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_pays WHERE rowid = ".$this->object->pays_id;
|
|
||||||
$resql=$this->db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error($this->db);
|
|
||||||
}
|
|
||||||
$this->object->pays_code = $obj->code;
|
|
||||||
$this->object->pays = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load data control
|
* Load data control
|
||||||
@ -673,6 +336,379 @@ class ActionsCardCommon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the title of card
|
||||||
|
*/
|
||||||
|
function getTitle($action)
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
$out='';
|
||||||
|
|
||||||
|
if ($action == 'view') $out.= $langs->trans("Individual");
|
||||||
|
if ($action == 'edit') $out.= $langs->trans("EditIndividual");
|
||||||
|
if ($action == 'create') $out.= $langs->trans("NewIndividual");
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the head of card (tabs)
|
||||||
|
*/
|
||||||
|
function showHead($action)
|
||||||
|
{
|
||||||
|
$head = societe_prepare_head($this->object);
|
||||||
|
$title = $this->getTitle($action);
|
||||||
|
|
||||||
|
return dol_fiche_head($head, 'card', $title, 0, 'company');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assigne les valeurs par defaut pour le canvas
|
||||||
|
* @param action Type of template
|
||||||
|
*/
|
||||||
|
function assign_values($action='')
|
||||||
|
{
|
||||||
|
global $conf, $langs, $user, $mysoc, $canvas;
|
||||||
|
global $form, $formadmin, $formcompany;
|
||||||
|
|
||||||
|
if ($_GET["type"]=='f') { $this->object->fournisseur=1; }
|
||||||
|
if ($_GET["type"]=='c') { $this->object->client=1; }
|
||||||
|
if ($_GET["type"]=='p') { $this->object->client=2; }
|
||||||
|
if ($_GET["type"]=='cp') { $this->object->client=3; }
|
||||||
|
if ($_REQUEST["private"]==1) { $this->object->particulier=1; }
|
||||||
|
|
||||||
|
foreach($this->object as $key => $value)
|
||||||
|
{
|
||||||
|
$this->tpl[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tpl['title'] = $this->getTitle($action);
|
||||||
|
$this->tpl['error'] = $this->error;
|
||||||
|
$this->tpl['errors']= $this->errors;
|
||||||
|
|
||||||
|
if ($action == 'create')
|
||||||
|
{
|
||||||
|
if ($conf->use_javascript_ajax)
|
||||||
|
{
|
||||||
|
$this->tpl['ajax_selecttype'] = "\n".'<script type="text/javascript" language="javascript">
|
||||||
|
jQuery(document).ready(function () {
|
||||||
|
jQuery("#radiocompany").click(function() {
|
||||||
|
document.formsoc.action.value="create";
|
||||||
|
document.formsoc.canvas.value="default";
|
||||||
|
document.formsoc.private.value=0;
|
||||||
|
document.formsoc.submit();
|
||||||
|
});
|
||||||
|
jQuery("#radioprivate").click(function() {
|
||||||
|
document.formsoc.action.value="create";
|
||||||
|
document.formsoc.canvas.value="individual";
|
||||||
|
document.formsoc.private.value=1;
|
||||||
|
document.formsoc.submit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>'."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'create' || $action == 'edit')
|
||||||
|
{
|
||||||
|
if ($conf->use_javascript_ajax)
|
||||||
|
{
|
||||||
|
$this->tpl['ajax_selectcountry'] = "\n".'<script type="text/javascript" language="javascript">
|
||||||
|
jQuery(document).ready(function () {
|
||||||
|
jQuery("#selectpays_id").change(function() {
|
||||||
|
document.formsoc.action.value="'.$action.'";
|
||||||
|
document.formsoc.canvas.value="'.$canvas.'";
|
||||||
|
document.formsoc.submit();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
</script>'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load object modCodeClient
|
||||||
|
$module=$conf->global->SOCIETE_CODECLIENT_ADDON;
|
||||||
|
if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined"));
|
||||||
|
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
|
||||||
|
{
|
||||||
|
$module = substr($module, 0, dol_strlen($module)-4);
|
||||||
|
}
|
||||||
|
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php");
|
||||||
|
$modCodeClient = new $module;
|
||||||
|
$this->tpl['auto_customercode'] = $modCodeClient->code_auto;
|
||||||
|
// We verified if the tag prefix is used
|
||||||
|
if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
|
||||||
|
|
||||||
|
// TODO create a function
|
||||||
|
$this->tpl['select_customertype'] = '<select class="flat" name="client">';
|
||||||
|
$this->tpl['select_customertype'].= '<option value="2"'.($this->object->client==2?' selected="selected"':'').'>'.$langs->trans('Prospect').'</option>';
|
||||||
|
$this->tpl['select_customertype'].= '<option value="3"'.($this->object->client==3?' selected="selected"':'').'>'.$langs->trans('ProspectCustomer').'</option>';
|
||||||
|
$this->tpl['select_customertype'].= '<option value="1"'.($this->object->client==1?' selected="selected"':'').'>'.$langs->trans('Customer').'</option>';
|
||||||
|
$this->tpl['select_customertype'].= '<option value="0"'.($this->object->client==0?' selected="selected"':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
|
||||||
|
$this->tpl['select_customertype'].= '</select>';
|
||||||
|
|
||||||
|
// Customer
|
||||||
|
$this->tpl['customercode'] = $this->object->code_client;
|
||||||
|
if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) $this->tpl['customercode'] = $modCodeClient->getNextValue($this->object,0);
|
||||||
|
$this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable();
|
||||||
|
$s=$modCodeClient->getToolTip($langs,$this->object,0);
|
||||||
|
$this->tpl['help_customercode'] = $form->textwithpicto('',$s,1);
|
||||||
|
|
||||||
|
if ($conf->fournisseur->enabled)
|
||||||
|
{
|
||||||
|
$this->tpl['supplier_enabled'] = 1;
|
||||||
|
|
||||||
|
// Load object modCodeFournisseur
|
||||||
|
$module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
|
||||||
|
if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
|
||||||
|
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
|
||||||
|
{
|
||||||
|
$module = substr($module, 0, dol_strlen($module)-4);
|
||||||
|
}
|
||||||
|
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php");
|
||||||
|
$modCodeFournisseur = new $module;
|
||||||
|
$this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto;
|
||||||
|
// We verified if the tag prefix is used
|
||||||
|
if ($modCodeFournisseur->code_auto) $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
|
||||||
|
|
||||||
|
// Supplier
|
||||||
|
$this->tpl['yn_supplier'] = $form->selectyesno("fournisseur",$this->object->fournisseur,1);
|
||||||
|
$this->tpl['suppliercode'] = $this->object->code_fournisseur;
|
||||||
|
if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object,1);
|
||||||
|
$this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable();
|
||||||
|
$s=$modCodeFournisseur->getToolTip($langs,$this->object,1);
|
||||||
|
$this->tpl['help_suppliercode'] = $form->textwithpicto('',$s,1);
|
||||||
|
|
||||||
|
$this->object->LoadSupplierCateg();
|
||||||
|
$this->tpl['suppliercategory'] = $this->object->SupplierCategories;
|
||||||
|
$this->tpl['select_suppliercategory'] = $form->selectarray("fournisseur_categorie",$this->object->SupplierCategories,$_POST["fournisseur_categorie"],1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zip
|
||||||
|
$this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip,'zipcode',array('town','selectpays_id','departement_id'),6);
|
||||||
|
|
||||||
|
// Town
|
||||||
|
$this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town,'town',array('zipcode','selectpays_id','departement_id'));
|
||||||
|
|
||||||
|
// Country
|
||||||
|
$this->tpl['select_country'] = $form->select_country($this->object->pays_id,'pays_id');
|
||||||
|
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
||||||
|
|
||||||
|
if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||||
|
|
||||||
|
// State
|
||||||
|
if ($this->object->pays_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->departement_id,$this->object->pays_code);
|
||||||
|
else $this->tpl['select_state'] = $countrynotdefined;
|
||||||
|
|
||||||
|
// Language
|
||||||
|
if ($conf->global->MAIN_MULTILANGS) $this->tpl['select_lang'] = $formadmin->select_language(($this->object->default_lang?$this->object->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1);
|
||||||
|
|
||||||
|
// VAT
|
||||||
|
$this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value',$this->tpl['tva_assuj'],1); // Assujeti par defaut en creation
|
||||||
|
|
||||||
|
// Select users
|
||||||
|
$this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id,'commercial_id',1);
|
||||||
|
|
||||||
|
// Local Tax
|
||||||
|
// TODO mettre dans une classe propre au pays
|
||||||
|
if($mysoc->pays_code=='ES')
|
||||||
|
{
|
||||||
|
$this->tpl['localtax'] = '';
|
||||||
|
|
||||||
|
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
|
||||||
|
{
|
||||||
|
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td>';
|
||||||
|
$this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',$this->object->localtax1_assuj,1);
|
||||||
|
$this->tpl['localtax'].= '</td><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td>';
|
||||||
|
$this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',$this->object->localtax1_assuj,1);
|
||||||
|
$this->tpl['localtax'].= '</td></tr>';
|
||||||
|
}
|
||||||
|
elseif($mysoc->localtax1_assuj=="1")
|
||||||
|
{
|
||||||
|
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
|
||||||
|
$this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',$this->object->localtax1_assuj,1);
|
||||||
|
$this->tpl['localtax'].= '</td><tr>';
|
||||||
|
}
|
||||||
|
elseif($mysoc->localtax2_assuj=="1")
|
||||||
|
{
|
||||||
|
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
|
||||||
|
$this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',$this->object->localtax1_assuj,1);
|
||||||
|
$this->tpl['localtax'].= '</td><tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'view')
|
||||||
|
{
|
||||||
|
$this->tpl['showhead']=$this->showHead($action);
|
||||||
|
|
||||||
|
$this->tpl['showrefnav'] = $form->showrefnav($this->object,'socid','',($user->societe_id?0:1),'rowid','nom');
|
||||||
|
|
||||||
|
$this->tpl['checkcustomercode'] = $this->object->check_codeclient();
|
||||||
|
$this->tpl['checksuppliercode'] = $this->object->check_codefournisseur();
|
||||||
|
$this->tpl['address'] = dol_nl2br($this->object->address);
|
||||||
|
|
||||||
|
$img=picto_from_langcode($this->object->pays_code);
|
||||||
|
if ($this->object->isInEEC()) $this->tpl['country'] = $form->textwithpicto(($img?$img.' ':'').$this->object->country,$langs->trans("CountryIsInEEC"),1,0);
|
||||||
|
$this->tpl['country'] = ($img?$img.' ':'').$this->object->country;
|
||||||
|
|
||||||
|
$this->tpl['phone'] = dol_print_phone($this->object->tel,$this->object->pays_code,0,$this->object->id,'AC_TEL');
|
||||||
|
$this->tpl['fax'] = dol_print_phone($this->object->fax,$this->object->pays_code,0,$this->object->id,'AC_FAX');
|
||||||
|
$this->tpl['email'] = dol_print_email($this->object->email,0,$this->object->id,'AC_EMAIL');
|
||||||
|
$this->tpl['url'] = dol_print_url($this->object->url);
|
||||||
|
|
||||||
|
$this->tpl['tva_assuj'] = yn($this->object->tva_assuj);
|
||||||
|
|
||||||
|
// Third party type
|
||||||
|
$arr = $formcompany->typent_array(1);
|
||||||
|
$this->tpl['typent'] = $arr[$this->object->typent_code];
|
||||||
|
|
||||||
|
if ($conf->global->MAIN_MULTILANGS)
|
||||||
|
{
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
||||||
|
//$s=picto_from_langcode($this->default_lang);
|
||||||
|
//print ($s?$s.' ':'');
|
||||||
|
$langs->load("languages");
|
||||||
|
$this->tpl['default_lang'] = ($this->default_lang?$langs->trans('Language_'.$this->object->default_lang):'');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tpl['image_edit'] = img_edit();
|
||||||
|
|
||||||
|
$this->tpl['display_rib'] = $this->object->display_rib();
|
||||||
|
|
||||||
|
// Sales representatives
|
||||||
|
$this->tpl['sales_representatives'] = '';
|
||||||
|
$listsalesrepresentatives=$this->object->getSalesRepresentatives($user);
|
||||||
|
$nbofsalesrepresentative=sizeof($listsalesrepresentatives);
|
||||||
|
if ($nbofsalesrepresentative > 3) // We print only number
|
||||||
|
{
|
||||||
|
$this->tpl['sales_representatives'].= '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$this->object->id.'">';
|
||||||
|
$this->tpl['sales_representatives'].= $nbofsalesrepresentative;
|
||||||
|
$this->tpl['sales_representatives'].= '</a>';
|
||||||
|
}
|
||||||
|
else if ($nbofsalesrepresentative > 0)
|
||||||
|
{
|
||||||
|
$userstatic=new User($db);
|
||||||
|
$i=0;
|
||||||
|
foreach($listsalesrepresentatives as $val)
|
||||||
|
{
|
||||||
|
$userstatic->id=$val['id'];
|
||||||
|
$userstatic->nom=$val['name'];
|
||||||
|
$userstatic->prenom=$val['firstname'];
|
||||||
|
$this->tpl['sales_representatives'].= $userstatic->getNomUrl(1);
|
||||||
|
$i++;
|
||||||
|
if ($i < $nbofsalesrepresentative) $this->tpl['sales_representatives'].= ', ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else $this->tpl['sales_representatives'].= $langs->trans("NoSalesRepresentativeAffected");
|
||||||
|
|
||||||
|
// Linked member
|
||||||
|
if ($conf->adherent->enabled)
|
||||||
|
{
|
||||||
|
$langs->load("members");
|
||||||
|
$adh=new Adherent($this->db);
|
||||||
|
$result=$adh->fetch('','',$this->object->id);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$adh->ref=$adh->getFullName($langs);
|
||||||
|
$this->tpl['linked_member'] = $adh->getNomUrl(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->tpl['linked_member'] = $langs->trans("UserNotLinkedToMember");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Local Tax
|
||||||
|
// TODO mettre dans une classe propre au pays
|
||||||
|
if($mysoc->pays_code=='ES')
|
||||||
|
{
|
||||||
|
$this->tpl['localtax'] = '';
|
||||||
|
|
||||||
|
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
|
||||||
|
{
|
||||||
|
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>';
|
||||||
|
$this->tpl['localtax'].= '<td>'.yn($this->object->localtax1_assuj).'</td>';
|
||||||
|
$this->tpl['localtax'].= '<td>'.$langs->trans("LocalTax2IsUsedES").'</td>';
|
||||||
|
$this->tpl['localtax'].= '<td>'.yn($this->object->localtax2_assuj).'</td></tr>';
|
||||||
|
}
|
||||||
|
elseif($mysoc->localtax1_assuj=="1")
|
||||||
|
{
|
||||||
|
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>';
|
||||||
|
$this->tpl['localtax'].= '<td colspan="3">'.yn($this->object->localtax1_assuj).'</td></tr>';
|
||||||
|
}
|
||||||
|
elseif($mysoc->localtax2_assuj=="1")
|
||||||
|
{
|
||||||
|
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td>';
|
||||||
|
$this->tpl['localtax'].= '<td colspan="3">'.yn($this->object->localtax2_assuj).'</td></tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assigne les valeurs POST dans l'objet
|
||||||
|
*/
|
||||||
|
function assign_post()
|
||||||
|
{
|
||||||
|
global $langs, $mysoc;
|
||||||
|
|
||||||
|
$this->object->id = $_POST["socid"];
|
||||||
|
$this->object->nom = $_POST["nom"];
|
||||||
|
$this->object->prefix_comm = $_POST["prefix_comm"];
|
||||||
|
$this->object->client = $_POST["client"];
|
||||||
|
$this->object->code_client = $_POST["code_client"];
|
||||||
|
$this->object->fournisseur = $_POST["fournisseur"];
|
||||||
|
$this->object->code_fournisseur = $_POST["code_fournisseur"];
|
||||||
|
$this->object->adresse = $_POST["adresse"]; // TODO obsolete
|
||||||
|
$this->object->address = $_POST["adresse"];
|
||||||
|
$this->object->zip = $_POST["zipcode"];
|
||||||
|
$this->object->town = $_POST["town"];
|
||||||
|
$this->object->pays_id = $_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
|
||||||
|
$this->object->departement_id = $_POST["departement_id"];
|
||||||
|
$this->object->tel = $_POST["tel"];
|
||||||
|
$this->object->fax = $_POST["fax"];
|
||||||
|
$this->object->email = $_POST["email"];
|
||||||
|
$this->object->url = $_POST["url"];
|
||||||
|
$this->object->capital = $_POST["capital"];
|
||||||
|
$this->object->siren = $_POST["idprof1"];
|
||||||
|
$this->object->siret = $_POST["idprof2"];
|
||||||
|
$this->object->ape = $_POST["idprof3"];
|
||||||
|
$this->object->idprof4 = $_POST["idprof4"];
|
||||||
|
$this->object->typent_id = $_POST["typent_id"];
|
||||||
|
$this->object->effectif_id = $_POST["effectif_id"];
|
||||||
|
$this->object->gencod = $_POST["gencod"];
|
||||||
|
$this->object->forme_juridique_code = $_POST["forme_juridique_code"];
|
||||||
|
$this->object->default_lang = $_POST["default_lang"];
|
||||||
|
$this->object->commercial_id = $_POST["commercial_id"];
|
||||||
|
|
||||||
|
$this->object->tva_assuj = $_POST["assujtva_value"]?$_POST["assujtva_value"]:1;
|
||||||
|
$this->object->tva_intra = $_POST["tva_intra"];
|
||||||
|
|
||||||
|
//Local Taxes
|
||||||
|
$this->object->localtax1_assuj = $_POST["localtax1assuj_value"];
|
||||||
|
$this->object->localtax2_assuj = $_POST["localtax2assuj_value"];
|
||||||
|
|
||||||
|
// We set pays_id, and pays_code label of the chosen country
|
||||||
|
// TODO move in business class
|
||||||
|
if ($this->object->pays_id)
|
||||||
|
{
|
||||||
|
$sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_pays WHERE rowid = ".$this->object->pays_id;
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($this->db);
|
||||||
|
}
|
||||||
|
$this->object->pays_code = $obj->code;
|
||||||
|
$this->object->pays = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -60,16 +61,6 @@ class ActionsCardDefault extends ActionsCardCommon
|
|||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the head of card (tabs)
|
|
||||||
*/
|
|
||||||
function showHead($action)
|
|
||||||
{
|
|
||||||
$head = societe_prepare_head($this->object);
|
|
||||||
$title = $this->getTitle($action);
|
|
||||||
|
|
||||||
return dol_fiche_head($head, 'card', $title, 0, 'company');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigne les valeurs POST dans l'objet
|
* Assigne les valeurs POST dans l'objet
|
||||||
|
|||||||
@ -21,6 +21,12 @@
|
|||||||
|
|
||||||
<!-- BEGIN PHP TEMPLATE -->
|
<!-- BEGIN PHP TEMPLATE -->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
print_fiche_titre($this->control->tpl['title']);
|
||||||
|
|
||||||
|
dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']);
|
||||||
|
?>
|
||||||
|
|
||||||
<?php if ($conf->use_javascript_ajax) { ?>
|
<?php if ($conf->use_javascript_ajax) { ?>
|
||||||
<?php echo $this->control->tpl['ajax_selecttype']; ?>
|
<?php echo $this->control->tpl['ajax_selecttype']; ?>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@ -21,6 +21,12 @@
|
|||||||
|
|
||||||
<!-- BEGIN PHP TEMPLATE -->
|
<!-- BEGIN PHP TEMPLATE -->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
print_fiche_titre($this->control->tpl['title']);
|
||||||
|
|
||||||
|
dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']);
|
||||||
|
?>
|
||||||
|
|
||||||
<?php echo $this->control->tpl['ajax_selectcountry']; ?>
|
<?php echo $this->control->tpl['ajax_selectcountry']; ?>
|
||||||
<?php if ($this->control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?>
|
<?php if ($this->control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?>
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,10 @@
|
|||||||
|
|
||||||
<!-- BEGIN PHP TEMPLATE -->
|
<!-- BEGIN PHP TEMPLATE -->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']);
|
||||||
|
?>
|
||||||
|
|
||||||
<?php if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?>
|
<?php if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?>
|
||||||
<?php if ($this->control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?>
|
<?php if ($this->control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?>
|
||||||
|
|
||||||
|
|||||||
@ -44,6 +44,7 @@ class ActionsCardIndividual extends ActionsCardCommon
|
|||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the title of card
|
* Return the title of card
|
||||||
*/
|
*/
|
||||||
@ -60,16 +61,6 @@ class ActionsCardIndividual extends ActionsCardCommon
|
|||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the head of card (tabs)
|
|
||||||
*/
|
|
||||||
function showHead($action)
|
|
||||||
{
|
|
||||||
$head = societe_prepare_head($this->object);
|
|
||||||
$title = $this->getTitle($action);
|
|
||||||
|
|
||||||
return dol_fiche_head($head, 'card', $title, 0, 'company');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigne les valeurs POST dans l'objet
|
* Assigne les valeurs POST dans l'objet
|
||||||
|
|||||||
@ -21,6 +21,12 @@
|
|||||||
|
|
||||||
<!-- BEGIN PHP TEMPLATE -->
|
<!-- BEGIN PHP TEMPLATE -->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
print_fiche_titre($this->control->tpl['title']);
|
||||||
|
|
||||||
|
dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']);
|
||||||
|
?>
|
||||||
|
|
||||||
<?php if ($conf->use_javascript_ajax) { ?>
|
<?php if ($conf->use_javascript_ajax) { ?>
|
||||||
<?php echo $this->control->tpl['ajax_selecttype']; ?>
|
<?php echo $this->control->tpl['ajax_selecttype']; ?>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@ -21,6 +21,12 @@
|
|||||||
|
|
||||||
<!-- BEGIN PHP TEMPLATE -->
|
<!-- BEGIN PHP TEMPLATE -->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
print_fiche_titre($this->control->tpl['title']);
|
||||||
|
|
||||||
|
dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']);
|
||||||
|
?>
|
||||||
|
|
||||||
<?php echo $this->control->tpl['ajax_selectcountry']; ?>
|
<?php echo $this->control->tpl['ajax_selectcountry']; ?>
|
||||||
|
|
||||||
<form action="<?php echo $_SERVER["PHP_SELF"].'?socid='.$this->control->tpl['id']; ?>" method="POST" name="formsoc">
|
<form action="<?php echo $_SERVER["PHP_SELF"].'?socid='.$this->control->tpl['id']; ?>" method="POST" name="formsoc">
|
||||||
|
|||||||
@ -21,6 +21,10 @@
|
|||||||
|
|
||||||
<!-- BEGIN PHP TEMPLATE -->
|
<!-- BEGIN PHP TEMPLATE -->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']);
|
||||||
|
?>
|
||||||
|
|
||||||
<?php if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?>
|
<?php if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?>
|
||||||
|
|
||||||
<form name="formsoc" method="POST">
|
<form name="formsoc" method="POST">
|
||||||
|
|||||||
@ -83,6 +83,16 @@ if (method_exists($objcanvas->control,'doActions'))
|
|||||||
// When used with CANVAS
|
// When used with CANVAS
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
$objcanvas->doActions($socid);
|
$objcanvas->doActions($socid);
|
||||||
|
if (empty($objcanvas->error) && (empty($objcanvas->errors) || sizeof($objcanvas->errors) == 0))
|
||||||
|
{
|
||||||
|
if ($action=='add') { $objcanvas->action='create'; $action='create'; }
|
||||||
|
if ($action=='update') { $objcanvas->action='view'; $action='view'; }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($action=='add') { $objcanvas->action='create'; $action='create'; }
|
||||||
|
if ($action=='update') { $objcanvas->action='edit'; $action='edit'; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -374,75 +384,24 @@ if (! empty($objcanvas->template_dir))
|
|||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
if ($action == 'create')
|
if ($action == 'create')
|
||||||
{
|
{
|
||||||
/*
|
$objcanvas->assign_post(); // Assign POST data
|
||||||
* Mode creation
|
$objcanvas->assign_values($action); // Set value for templates
|
||||||
*/
|
$objcanvas->display_canvas($action); // Show template
|
||||||
|
|
||||||
// Assign _POST data
|
|
||||||
$objcanvas->assign_post();
|
|
||||||
|
|
||||||
// Assign template values
|
|
||||||
$objcanvas->assign_values();
|
|
||||||
|
|
||||||
// Card header
|
|
||||||
$title = $objcanvas->getTitle();
|
|
||||||
print_fiche_titre($title);
|
|
||||||
|
|
||||||
// Show errors
|
|
||||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
|
||||||
|
|
||||||
// Display canvas
|
|
||||||
$objcanvas->display_canvas('create');
|
|
||||||
}
|
}
|
||||||
elseif ($action == 'edit')
|
elseif ($action == 'edit')
|
||||||
{
|
{
|
||||||
/*
|
$objcanvas->fetch($socid); // Reload object
|
||||||
* Mode edition
|
$objcanvas->assign_post(); // Assign POST data
|
||||||
*/
|
$objcanvas->assign_values($action); // Set value for templates
|
||||||
|
$objcanvas->display_canvas($action); // Show template
|
||||||
// Card header
|
|
||||||
$title = $objcanvas->getTitle();
|
|
||||||
print_fiche_titre($title);
|
|
||||||
|
|
||||||
if (! $_POST["nom"])
|
|
||||||
{
|
|
||||||
//Reload object
|
|
||||||
$objcanvas->fetch($socid);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Assign _POST data
|
$result=$objcanvas->fetch($socid); // Relaod object
|
||||||
$objcanvas->assign_post();
|
$objcanvas->assign_values('view'); // Assign values
|
||||||
}
|
$objcanvas->display_canvas('view'); // Show template
|
||||||
|
|
||||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
|
||||||
|
|
||||||
// Assign values
|
|
||||||
$objcanvas->assign_values();
|
|
||||||
|
|
||||||
// Display canvas
|
|
||||||
$objcanvas->display_canvas('edit');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Mode view
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Fetch object
|
|
||||||
$result=$objcanvas->fetch($socid);
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
|
||||||
// Card header
|
|
||||||
$objcanvas->showHead();
|
|
||||||
|
|
||||||
// Assign values
|
|
||||||
$objcanvas->assign_values();
|
|
||||||
|
|
||||||
// Display canvas
|
|
||||||
$objcanvas->display_canvas('view');
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO Move this also into template
|
||||||
print '<table width="100%"><tr><td valign="top" width="50%">';
|
print '<table width="100%"><tr><td valign="top" width="50%">';
|
||||||
print '<a name="builddoc"></a>'; // ancre
|
print '<a name="builddoc"></a>'; // ancre
|
||||||
|
|
||||||
@ -474,12 +433,6 @@ if (! empty($objcanvas->template_dir))
|
|||||||
// Projects list
|
// Projects list
|
||||||
$result=show_projects($conf,$langs,$db,$objcanvas->control->object);
|
$result=show_projects($conf,$langs,$db,$objcanvas->control->object);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user