Qual: Fix architecture problem with canvas

This commit is contained in:
Laurent Destailleur 2011-04-06 16:21:43 +00:00
parent daaffd5f14
commit d72f417868
17 changed files with 677 additions and 704 deletions

View File

@ -53,8 +53,148 @@ class ActionsContactCardCommon
$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
*/
function assign_values($action='')
@ -67,6 +207,10 @@ class ActionsContactCardCommon
$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 ($conf->use_javascript_ajax)
@ -81,7 +225,7 @@ class ActionsContactCardCommon
})
</script>'."\n";
}
if (is_object($objsoc) && $objsoc->id > 0)
{
$this->tpl['company'] = $objsoc->getNomUrl(1);
@ -91,10 +235,10 @@ class ActionsContactCardCommon
{
$this->tpl['company'] = $form->select_company($this->object->socid,'socid','',1);
}
// Civility
$this->tpl[select_civility] = $formcompany->select_civility($this->object->civilite_id);
// Predefined with third party
if ($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS))
{
@ -105,13 +249,13 @@ class ActionsContactCardCommon
if (dol_strlen(trim($this->object->fax)) == 0) $this->object->fax = $objsoc->fax;
if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email;
}
// 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'));
if (dol_strlen(trim($this->object->fk_pays)) == 0) $this->object->fk_pays = $objsoc->pays_id;
// Country
@ -123,12 +267,12 @@ class ActionsContactCardCommon
// State
if ($this->object->fk_pays) $this->tpl['select_state'] = $formcompany->select_state($this->object->fk_departement,$this->object->pays_code);
else $this->tpl['select_state'] = $countrynotdefined;
// Public or private
$selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate"));
$this->tpl['select_visibility'] = $form->selectarray('priv',$selectarray,$this->object->priv,0);
}
if ($action == 'view' || $action == 'edit')
{
// Emailing
@ -137,13 +281,13 @@ class ActionsContactCardCommon
$langs->load("mails");
$this->tpl['nb_emailing'] = $this->object->getNbOfEMailings();
}
// Linked element
$this->tpl['contact_element'] = array();
$i=0;
$this->object->load_ref_elements();
if ($conf->commande->enabled)
{
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders");
@ -168,7 +312,7 @@ class ActionsContactCardCommon
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation?$this->object->ref_facturation:$langs->trans("NoContactForAnyInvoice");
$i++;
}
// Dolibarr user
if ($this->object->user_id)
{
@ -186,7 +330,7 @@ class ActionsContactCardCommon
// Full firstname and name separated with a dot : firstname.name
include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php');
$login=dol_buildlogin($this->object->nom, $this->object->prenom);
$generated_password='';
if (! $ldap_sid)
{
@ -201,21 +345,21 @@ class ActionsContactCardCommon
}
}
$password=$generated_password;
// Create a form array
$formquestion=array(
array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login),
array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password));
$this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id,$langs->trans("CreateDolibarrLogin"),$langs->trans("ConfirmCreateContact"),"confirm_create_user",$formquestion,'no');
}
$this->tpl['showrefnav'] = $form->showrefnav($this->object,'id');
if ($this->object->socid > 0)
{
$objsoc = new Societe($this->db);
$objsoc->fetch($this->object->socid);
$this->tpl['company'] = $objsoc->getNomUrl(1);
}
@ -223,11 +367,11 @@ class ActionsContactCardCommon
{
$this->tpl['company'] = $langs->trans("ContactNotLinkedToCompany");
}
$this->tpl['civility'] = $this->object->getCivilityLabel();
$this->tpl['address'] = dol_nl2br($this->object->address);
$this->tpl['zip'] = ($this->object->zip?$this->object->zip.'&nbsp;':'');
$img=picto_from_langcode($this->object->pays_code);
@ -238,9 +382,9 @@ class ActionsContactCardCommon
$this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile,$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['visibility'] = $this->object->LibPubPriv($this->object->priv);
$this->tpl['note'] = nl2br($this->object->note);
}
}
@ -254,7 +398,7 @@ class ActionsContactCardCommon
$this->object->old_name = $_POST["old_name"];
$this->object->old_firstname = $_POST["old_firstname"];
$this->object->socid = $_POST["socid"];
$this->object->name = $_POST["name"];
$this->object->firstname = $_POST["firstname"];
@ -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;
}
}
}
}
}
?>

View File

@ -1,5 +1,6 @@
<?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
* it under the terms of the GNU General Public License as published by
@ -44,21 +45,25 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
$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
*/
function getTitle($action)
{
global $langs;
$out='';
if ($action == 'view' || $action == 'edit') $out.= $langs->trans("Contact");
if ($action == 'create') $out.= $langs->trans("AddContact");
return $out;
return parent::getTitle($action);
}
/**
* Return the head of card (tabs)
*/
@ -66,7 +71,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
{
$head = contact_prepare_head($this->object);
$title = $this->getTitle($action);
return dol_fiche_head($head, 'card', $title, 0, 'contact');
}
@ -78,17 +83,6 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
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
* @param action Type of action
@ -100,8 +94,15 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
parent::assign_values($action);
$this->tpl['title'] = $this->getTitle($action);
$this->tpl['error'] = $this->error;
$this->tpl['errors']= $this->errors;
if ($action == 'view')
{
// Card header
$this->tpl['showhead']=$this->showHead($action);
// Confirm delete contact
if ($user->rights->societe->contact->supprimer)
{
@ -112,7 +113,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
}
}
}
/**
* Check permissions of a user to show a page and an object. Check read permission
* If $_REQUEST['action'] defined, we also check write permission.

View File

@ -21,7 +21,12 @@
<!-- 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>

View File

@ -21,7 +21,13 @@
<!-- 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>

View File

@ -21,72 +21,76 @@
<!-- 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_delete']) echo $this->control->tpl['action_delete']; ?>
<table class="border" width="100%">
<tr>
<td width="20%"><?php echo $langs->trans("Ref"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['showrefnav']; ?></td>
</tr>
<tr>
<td width="20%"><?php echo $langs->trans("Lastname"); ?></td>
<td width="30%"><?php echo $this->control->tpl['name']; ?></td>
<td width="25%"><?php echo $langs->trans("Firstname"); ?></td>
<td width="25%"><?php echo $this->control->tpl['firstname']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("Company"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['company']; ?></td>
</tr>
<tr>
<td width="15%"><?php echo $langs->trans("UserTitle"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['civility']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("PostOrFunction" ); ?></td>
<td colspan="3"><?php echo $this->control->tpl['poste']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("Address"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['address']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("Zip").' / '.$langs->trans("Town"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['zip'].$this->control->tpl['ville']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("Country"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['country']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans('State'); ?></td>
<td colspan="3"><?php echo $this->control->tpl['departement']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("PhonePro"); ?></td>
<td><?php echo $this->control->tpl['phone_pro']; ?></td>
<td><?php echo $langs->trans("PhonePerso"); ?></td>
<td><?php echo $this->control->tpl['phone_perso']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("PhoneMobile"); ?></td>
<td><?php echo $this->control->tpl['phone_mobile']; ?></td>
<td><?php echo $langs->trans("Fax"); ?></td>
<td><?php echo $this->control->tpl['fax']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("EMail"); ?></td>
<td><?php echo $this->control->tpl['email']; ?></td>
@ -97,17 +101,17 @@
<td colspan="2">&nbsp;</td>
<?php } ?>
</tr>
<tr>
<td><?php echo $langs->trans("Jabberid"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['jabberid']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("ContactVisibility"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['visibility']; ?></td>
</tr>
<tr>
<td valign="top"><?php echo $langs->trans("Note"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['note']; ?></td>
@ -124,14 +128,14 @@
<td><?php echo $langs->trans("DolibarrLogin"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['dolibarr_user']; ?></td>
</tr>
</table>
</div>
<?php if (! $user->societe_id) { ?>
<div class="tabsAction">
<?php if ($user->rights->societe->contact->creer) { ?>
<a class="butAction" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=edit&amp;canvas='.$canvas; ?>"><?php echo $langs->trans('Modify'); ?></a>
<?php } ?>

View File

@ -81,6 +81,16 @@ if (method_exists($objcanvas->control,'doActions'))
// When used with CANVAS
// -----------------------------------------
$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
{
@ -297,94 +307,27 @@ if (! empty($objcanvas->template_dir))
if ($action == 'create')
{
/*
* Mode creation
*/
// 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');
$objcanvas->assign_post(); // Assign POST data
$objcanvas->assign_values($action); // Set value for templates
$objcanvas->display_canvas($action); // Show template
}
else if ($action == 'edit')
{
/*
* Mode edition
*/
// 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
{
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
}
$objcanvas->fetch($id); // Reload object
$objcanvas->assign_post(); // Assign POST data
$objcanvas->assign_values($action); // Set value for templates
$objcanvas->display_canvas($action); // Show template
}
else
{
/*
* Mode view
*/
// Fetch object
$result=$objcanvas->fetch($id);
if ($result > 0)
{
// Assign values
$objcanvas->assign_values();
$result=$objcanvas->fetch($id); // Reload object
$objcanvas->assign_values('view'); // Assign values
$objcanvas->display_canvas('view'); // Show template
// 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.
// TODO Move this also into template
print show_actions_todo($conf,$langs,$db,$objsoc,$objcanvas->control->object);
// 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');
print show_actions_todo($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);
}
print show_actions_done($conf,$langs,$db,$objsoc,$objcanvas->control->object);
}
}

View File

@ -103,8 +103,7 @@ class Canvas
/*print 'canvas='.$this->canvas.'<br>';
print 'childmodule='.$childmodule.' targetmodule='.$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();
@ -132,7 +131,7 @@ class Canvas
}
// 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');
if (file_exists($libfile)) require_once($libfile);
@ -142,6 +141,8 @@ class Canvas
{
$this->template_dir='';
}
//print '/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/tpl/';
//print 'template_dir='.$this->template_dir.'<br>';
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)
* // FIXME An output function is stored inside an action class. Must change this.
*/
function showHead()
{
@ -217,7 +207,7 @@ class Canvas
/**
* 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()
{
@ -230,7 +220,7 @@ class Canvas
*/
function assign_values()
{
$this->control->assign_values($this->action);
if (method_exists($this->control,'assign_values')) $this->control->assign_values($this->action);
}
/**

View File

@ -1,5 +1,6 @@
<?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
* it under the terms of the GNU General Public License as published by
@ -53,7 +54,317 @@ class ActionsCardCommon
$this->db = $DB;
}
/**
* Load data control
*/
function doActions($socid)
{
global $conf, $user, $langs;
if ($_POST["getcustomercode"])
{
// We defined value code_client
$_POST["code_client"]="Acompleter";
}
if ($_POST["getsuppliercode"])
{
// We defined value code_fournisseur
$_POST["code_fournisseur"]="Acompleter";
}
// Add new third party
if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
&& ($_POST["action"] == 'add' || $_POST["action"] == 'update'))
{
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
$error=0;
if ($_POST["action"] == 'update')
{
// Load properties of company
$this->object->fetch($socid);
}
if ($_REQUEST["private"] == 1)
{
$this->object->particulier = $_REQUEST["private"];
$this->object->nom = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_POST["prenom"].' '.$_POST["nom"]):trim($_POST["nom"].' '.$_POST["prenom"]);
$this->object->nom_particulier = $_POST["nom"];
$this->object->prenom = $_POST["prenom"];
$this->object->civilite_id = $_POST["civilite_id"];
}
else
{
$this->object->nom = $_POST["nom"];
}
$this->object->address = $_POST["adresse"];
$this->object->adresse = $_POST["adresse"]; // TODO obsolete
$this->object->cp = $_POST["zipcode"];
$this->object->ville = $_POST["town"];
$this->object->pays_id = $_POST["pays_id"];
$this->object->departement_id = $_POST["departement_id"];
$this->object->tel = $_POST["tel"];
$this->object->fax = $_POST["fax"];
$this->object->email = trim($_POST["email"]);
$this->object->url = $_POST["url"];
$this->object->siren = $_POST["idprof1"];
$this->object->siret = $_POST["idprof2"];
$this->object->ape = $_POST["idprof3"];
$this->object->idprof4 = $_POST["idprof4"];
$this->object->prefix_comm = $_POST["prefix_comm"];
$this->object->code_client = $_POST["code_client"];
$this->object->code_fournisseur = $_POST["code_fournisseur"];
$this->object->capital = $_POST["capital"];
$this->object->gencod = $_POST["gencod"];
$this->object->canvas = $_REQUEST["canvas"];
$this->object->tva_assuj = $_POST["assujtva_value"];
// Local Taxes
$this->object->localtax1_assuj = $_POST["localtax1assuj_value"];
$this->object->localtax2_assuj = $_POST["localtax2assuj_value"];
$this->object->tva_intra = $_POST["tva_intra"];
$this->object->forme_juridique_code = $_POST["forme_juridique_code"];
$this->object->effectif_id = $_POST["effectif_id"];
if ($_REQUEST["private"] == 1)
{
$this->object->typent_id = 8; // TODO predict another method if the field "special" change of rowid
}
else
{
$this->object->typent_id = $_POST["typent_id"];
}
$this->object->client = $_POST["client"];
$this->object->fournisseur = $_POST["fournisseur"];
$this->object->fournisseur_categorie = $_POST["fournisseur_categorie"];
$this->object->commercial_id = $_POST["commercial_id"];
$this->object->default_lang = $_POST["default_lang"];
// Check parameters
if (empty($_POST["cancel"]))
{
if (! empty($this->object->email) && ! isValidEMail($this->object->email))
{
$error = 1;
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail",$this->object->email);
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
}
if (! empty($this->object->url) && ! isValidUrl($this->object->url))
{
$error = 1;
$langs->load("errors");
$this->error = $langs->trans("ErrorBadUrl",$this->object->url);
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
}
if ($this->object->fournisseur && ! $conf->fournisseur->enabled)
{
$error = 1;
$langs->load("errors");
$this->error = $langs->trans("ErrorSupplierModuleNotEnabled");
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
}
}
if (! $error)
{
if ($_POST["action"] == 'add')
{
$this->db->begin();
if (empty($this->object->client)) $this->object->code_client='';
if (empty($this->object->fournisseur)) $this->object->code_fournisseur='';
$result = $this->object->create($user);
if ($result >= 0)
{
if ($this->object->particulier)
{
dol_syslog("This thirdparty is a personal people",LOG_DEBUG);
$contact=new Contact($this->db);
$contact->civilite_id = $this->object->civilite_id;
$contact->name = $this->object->nom_particulier;
$contact->firstname = $this->object->prenom;
$contact->address = $this->object->address;
$contact->cp = $this->object->cp;
$contact->ville = $this->object->ville;
$contact->fk_pays = $this->object->fk_pays;
$contact->socid = $this->object->id; // fk_soc
$contact->status = 1;
$contact->email = $this->object->email;
$contact->priv = 0;
$result=$contact->create($user);
}
}
else
{
$this->errors=$this->object->errors;
}
if ($result >= 0)
{
$this->db->commit();
if ( $this->object->client == 1 )
{
Header("Location: ".DOL_URL_ROOT."/comm/fiche.php?socid=".$this->object->id);
return;
}
else
{
if ( $this->object->fournisseur == 1 )
{
Header("Location: ".DOL_URL_ROOT."/fourn/fiche.php?socid=".$this->object->id);
return;
}
else
{
Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$this->object->id);
return;
}
}
exit;
}
else
{
$this->db->rollback();
$this->errors=$this->object->errors;
$_GET["action"]='create';
}
}
if ($_POST["action"] == 'update')
{
if ($_POST["cancel"])
{
Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
exit;
}
$oldsoccanvas = new Canvas($this->db);
$oldsoccanvas->getCanvas('thirdparty','card',$this->object->canvas);
$result=$oldsoccanvas->fetch($socid);
// To not set code if third party is not concerned. But if it had values, we keep them.
if (empty($this->object->client) && empty($oldsoccanvas->control->object->code_client)) $this->object->code_client='';
if (empty($this->object->fournisseur)&& empty($oldsoccanvas->control->object->code_fournisseur)) $this->object->code_fournisseur='';
//var_dump($soccanvas);exit;
$result = $this->object->update($socid,$user,1,$oldsoccanvas->control->object->codeclient_modifiable(),$oldsoccanvas->control->object->codefournisseur_modifiable());
if ($result >= 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
exit;
}
else
{
$this->object->id = $socid;
$reload = 0;
$this->errors = $this->object->errors;
$_GET["action"]= "edit";
}
}
}
}
if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes')
{
$this->object->fetch($socid);
$result = $this->object->delete($socid);
if ($result >= 0)
{
Header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".$this->object->nom."");
exit;
}
else
{
$reload = 0;
$this->errors=$this->object->errors;
$_GET["action"]='';
}
}
/*
* Generate document
*/
if (GETPOST('action') == 'builddoc') // En get ou en post
{
if (is_numeric(GETPOST('model')))
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
}
else
{
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/societe/modules_societe.class.php');
$this->object->fetch($socid);
$this->object->fetch_thirdparty();
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id') ) $newlang=GETPOST('lang_id');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$this->object->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
$result=thirdparty_doc_create($this->db, $this->object->id, '', GETPOST('model'), $outputlangs);
if ($result <= 0)
{
dol_print_error($this->db,$result);
exit;
}
else
{
Header ('Location: '.$_SERVER["PHP_SELF"].'?socid='.$this->object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
exit;
}
}
}
}
/**
* 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
*/
@ -73,6 +384,10 @@ class ActionsCardCommon
$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)
@ -226,7 +541,9 @@ class ActionsCardCommon
if ($action == 'view')
{
$this->tpl['showrefnav'] = $form->showrefnav($this->object,'socid','',($user->societe_id?0:1),'rowid','nom');
$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();
@ -392,287 +709,6 @@ class ActionsCardCommon
}
}
/**
* Load data control
*/
function doActions($socid)
{
global $conf, $user, $langs;
if ($_POST["getcustomercode"])
{
// We defined value code_client
$_POST["code_client"]="Acompleter";
}
if ($_POST["getsuppliercode"])
{
// We defined value code_fournisseur
$_POST["code_fournisseur"]="Acompleter";
}
// Add new third party
if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
&& ($_POST["action"] == 'add' || $_POST["action"] == 'update'))
{
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
$error=0;
if ($_POST["action"] == 'update')
{
// Load properties of company
$this->object->fetch($socid);
}
if ($_REQUEST["private"] == 1)
{
$this->object->particulier = $_REQUEST["private"];
$this->object->nom = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_POST["prenom"].' '.$_POST["nom"]):trim($_POST["nom"].' '.$_POST["prenom"]);
$this->object->nom_particulier = $_POST["nom"];
$this->object->prenom = $_POST["prenom"];
$this->object->civilite_id = $_POST["civilite_id"];
}
else
{
$this->object->nom = $_POST["nom"];
}
$this->object->address = $_POST["adresse"];
$this->object->adresse = $_POST["adresse"]; // TODO obsolete
$this->object->cp = $_POST["zipcode"];
$this->object->ville = $_POST["town"];
$this->object->pays_id = $_POST["pays_id"];
$this->object->departement_id = $_POST["departement_id"];
$this->object->tel = $_POST["tel"];
$this->object->fax = $_POST["fax"];
$this->object->email = trim($_POST["email"]);
$this->object->url = $_POST["url"];
$this->object->siren = $_POST["idprof1"];
$this->object->siret = $_POST["idprof2"];
$this->object->ape = $_POST["idprof3"];
$this->object->idprof4 = $_POST["idprof4"];
$this->object->prefix_comm = $_POST["prefix_comm"];
$this->object->code_client = $_POST["code_client"];
$this->object->code_fournisseur = $_POST["code_fournisseur"];
$this->object->capital = $_POST["capital"];
$this->object->gencod = $_POST["gencod"];
$this->object->canvas = $_REQUEST["canvas"];
$this->object->tva_assuj = $_POST["assujtva_value"];
// Local Taxes
$this->object->localtax1_assuj = $_POST["localtax1assuj_value"];
$this->object->localtax2_assuj = $_POST["localtax2assuj_value"];
$this->object->tva_intra = $_POST["tva_intra"];
$this->object->forme_juridique_code = $_POST["forme_juridique_code"];
$this->object->effectif_id = $_POST["effectif_id"];
if ($_REQUEST["private"] == 1)
{
$this->object->typent_id = 8; // TODO predict another method if the field "special" change of rowid
}
else
{
$this->object->typent_id = $_POST["typent_id"];
}
$this->object->client = $_POST["client"];
$this->object->fournisseur = $_POST["fournisseur"];
$this->object->fournisseur_categorie = $_POST["fournisseur_categorie"];
$this->object->commercial_id = $_POST["commercial_id"];
$this->object->default_lang = $_POST["default_lang"];
// Check parameters
if (empty($_POST["cancel"]))
{
if (! empty($this->object->email) && ! isValidEMail($this->object->email))
{
$error = 1;
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail",$this->object->email);
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
}
if (! empty($this->object->url) && ! isValidUrl($this->object->url))
{
$error = 1;
$langs->load("errors");
$this->error = $langs->trans("ErrorBadUrl",$this->object->url);
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
}
if ($this->object->fournisseur && ! $conf->fournisseur->enabled)
{
$error = 1;
$langs->load("errors");
$this->error = $langs->trans("ErrorSupplierModuleNotEnabled");
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
}
}
if (! $error)
{
if ($_POST["action"] == 'add')
{
$this->db->begin();
if (empty($this->object->client)) $this->object->code_client='';
if (empty($this->object->fournisseur)) $this->object->code_fournisseur='';
$result = $this->object->create($user);
if ($result >= 0)
{
if ($this->object->particulier)
{
dol_syslog("This thirdparty is a personal people",LOG_DEBUG);
$contact=new Contact($this->db);
$contact->civilite_id = $this->object->civilite_id;
$contact->name = $this->object->nom_particulier;
$contact->firstname = $this->object->prenom;
$contact->address = $this->object->address;
$contact->cp = $this->object->cp;
$contact->ville = $this->object->ville;
$contact->fk_pays = $this->object->fk_pays;
$contact->socid = $this->object->id; // fk_soc
$contact->status = 1;
$contact->email = $this->object->email;
$contact->priv = 0;
$result=$contact->create($user);
}
}
else
{
$this->errors=$this->object->errors;
}
if ($result >= 0)
{
$this->db->commit();
if ( $this->object->client == 1 )
{
Header("Location: ".DOL_URL_ROOT."/comm/fiche.php?socid=".$this->object->id);
return;
}
else
{
if ( $this->object->fournisseur == 1 )
{
Header("Location: ".DOL_URL_ROOT."/fourn/fiche.php?socid=".$this->object->id);
return;
}
else
{
Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$this->object->id);
return;
}
}
exit;
}
else
{
$this->db->rollback();
$this->errors=$this->object->errors;
$_GET["action"]='create';
}
}
if ($_POST["action"] == 'update')
{
if ($_POST["cancel"])
{
Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
exit;
}
$oldsoccanvas = new Canvas($this->db);
$oldsoccanvas->getCanvas('thirdparty','card',$this->object->canvas);
$result=$oldsoccanvas->fetch($socid);
// To not set code if third party is not concerned. But if it had values, we keep them.
if (empty($this->object->client) && empty($oldsoccanvas->control->object->code_client)) $this->object->code_client='';
if (empty($this->object->fournisseur)&& empty($oldsoccanvas->control->object->code_fournisseur)) $this->object->code_fournisseur='';
//var_dump($soccanvas);exit;
$result = $this->object->update($socid,$user,1,$oldsoccanvas->control->object->codeclient_modifiable(),$oldsoccanvas->control->object->codefournisseur_modifiable());
if ($result >= 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
exit;
}
else
{
$this->object->id = $socid;
$reload = 0;
$this->errors = $this->object->errors;
$_GET["action"]= "edit";
}
}
}
}
if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes')
{
$this->object->fetch($socid);
$result = $this->object->delete($socid);
if ($result >= 0)
{
Header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".$this->object->nom."");
exit;
}
else
{
$reload = 0;
$this->errors=$this->object->errors;
$_GET["action"]='';
}
}
/*
* Generate document
*/
if (GETPOST('action') == 'builddoc') // En get ou en post
{
if (is_numeric(GETPOST('model')))
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
}
else
{
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/societe/modules_societe.class.php');
$this->object->fetch($socid);
$this->object->fetch_thirdparty();
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id') ) $newlang=GETPOST('lang_id');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$this->object->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
$result=thirdparty_doc_create($this->db, $this->object->id, '', GETPOST('model'), $outputlangs);
if ($result <= 0)
{
dol_print_error($this->db,$result);
exit;
}
else
{
Header ('Location: '.$_SERVER["PHP_SELF"].'?socid='.$this->object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
exit;
}
}
}
}
}
?>

View File

@ -1,5 +1,6 @@
<?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
* it under the terms of the GNU General Public License as published by
@ -44,32 +45,22 @@ class ActionsCardDefault extends ActionsCardCommon
$this->db = $DB;
}
/**
* Return the title of card
*/
function getTitle($action)
{
global $langs;
/**
* Return the title of card
*/
function getTitle($action)
{
global $langs;
$out='';
$out='';
if ($action == 'view') $out.= $langs->trans("ThirdParty");
if ($action == 'edit') $out.= $langs->trans("EditCompany");
if ($action == 'create') $out.= $langs->trans("NewCompany");
if ($action == 'view') $out.= $langs->trans("ThirdParty");
if ($action == 'edit') $out.= $langs->trans("EditCompany");
if ($action == 'create') $out.= $langs->trans("NewCompany");
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

View File

@ -21,6 +21,12 @@
<!-- 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 echo $this->control->tpl['ajax_selecttype']; ?>
<br>

View File

@ -21,6 +21,12 @@
<!-- 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 if ($this->control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?>

View File

@ -21,6 +21,10 @@
<!-- 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['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?>

View File

@ -44,32 +44,23 @@ class ActionsCardIndividual extends ActionsCardCommon
$this->db = $DB;
}
/**
* Return the title of card
*/
function getTitle($action)
{
global $langs;
$out='';
/**
* Return the title of card
*/
function getTitle($action)
{
global $langs;
if ($action == 'view') $out.= $langs->trans("Individual");
if ($action == 'edit') $out.= $langs->trans("EditIndividual");
if ($action == 'create') $out.= $langs->trans("NewIndividual");
$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 $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
@ -115,7 +106,7 @@ class ActionsCardIndividual extends ActionsCardCommon
}
}
}
/**
* Check permissions of a user to show a page and an object. Check read permission
* If $_REQUEST['action'] defined, we also check write permission.

View File

@ -21,6 +21,12 @@
<!-- 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 echo $this->control->tpl['ajax_selecttype']; ?>
<br>

View File

@ -21,6 +21,12 @@
<!-- 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']; ?>
<form action="<?php echo $_SERVER["PHP_SELF"].'?socid='.$this->control->tpl['id']; ?>" method="POST" name="formsoc">

View File

@ -21,6 +21,10 @@
<!-- 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']; ?>
<form name="formsoc" method="POST">

View File

@ -83,6 +83,16 @@ if (method_exists($objcanvas->control,'doActions'))
// When used with CANVAS
// -----------------------------------------
$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
{
@ -374,112 +384,55 @@ if (! empty($objcanvas->template_dir))
// -----------------------------------------
if ($action == 'create')
{
/*
* Mode creation
*/
// 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');
$objcanvas->assign_post(); // Assign POST data
$objcanvas->assign_values($action); // Set value for templates
$objcanvas->display_canvas($action); // Show template
}
elseif ($action == 'edit')
{
/*
* Mode edition
*/
// Card header
$title = $objcanvas->getTitle();
print_fiche_titre($title);
if (! $_POST["nom"])
{
//Reload object
$objcanvas->fetch($socid);
}
else
{
// Assign _POST data
$objcanvas->assign_post();
}
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
// Assign values
$objcanvas->assign_values();
// Display canvas
$objcanvas->display_canvas('edit');
$objcanvas->fetch($socid); // Reload object
$objcanvas->assign_post(); // Assign POST data
$objcanvas->assign_values($action); // Set value for templates
$objcanvas->display_canvas($action); // Show template
}
else
{
$result=$objcanvas->fetch($socid); // Relaod object
$objcanvas->assign_values('view'); // Assign values
$objcanvas->display_canvas('view'); // Show template
// TODO Move this also into template
print '<table width="100%"><tr><td valign="top" width="50%">';
print '<a name="builddoc"></a>'; // ancre
/*
* Mode view
* Documents generes
*/
$filedir=$conf->societe->dir_output.'/'.$socid;
$urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid;
$genallowed=$user->rights->societe->creer;
$delallowed=$user->rights->societe->supprimer;
// Fetch object
$result=$objcanvas->fetch($socid);
if ($result > 0)
{
// Card header
$objcanvas->showHead();
$var=true;
// Assign values
$objcanvas->assign_values();
$somethingshown=$formfile->show_documents('company',$socid,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$objcanvas->control->object->default_lang);
// Display canvas
$objcanvas->display_canvas('view');
print '</td>';
print '<td></td>';
print '</tr>';
print '</table>';
print '<br>';
print '<table width="100%"><tr><td valign="top" width="50%">';
print '<a name="builddoc"></a>'; // ancre
// Subsidiaries list
$result=show_subsidiaries($conf,$langs,$db,$objcanvas->control->object);
/*
* Documents generes
*/
$filedir=$conf->societe->dir_output.'/'.$socid;
$urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid;
$genallowed=$user->rights->societe->creer;
$delallowed=$user->rights->societe->supprimer;
// Contacts list
$result=show_contacts($conf,$langs,$db,$objcanvas->control->object);
$var=true;
$somethingshown=$formfile->show_documents('company',$socid,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$objcanvas->control->object->default_lang);
print '</td>';
print '<td></td>';
print '</tr>';
print '</table>';
print '<br>';
// Subsidiaries list
$result=show_subsidiaries($conf,$langs,$db,$objcanvas->control->object);
// Contacts list
$result=show_contacts($conf,$langs,$db,$objcanvas->control->object);
// Projects list
$result=show_projects($conf,$langs,$db,$objcanvas->control->object);
}
else
{
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
}
// Projects list
$result=show_projects($conf,$langs,$db,$objcanvas->control->object);
}
}
else
{