Works on canvas integration in third party module

This commit is contained in:
Regis Houssin 2010-09-02 14:36:36 +00:00
parent c571f25afb
commit 2d552df6be
6 changed files with 90 additions and 54 deletions

View File

@ -21,6 +21,9 @@
<!-- BEGIN PHP TEMPLATE -->
<?php echo $this->object->tpl['ajax_select_thirdpartytype']; ?>
<?php echo $this->object->tpl['ajax_select_country']; ?>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" name="formsoc">
<input type="hidden" name="action" value="add">

View File

@ -21,6 +21,8 @@
<!-- BEGIN PHP TEMPLATE -->
<?php echo $this->object->tpl['ajax_select_country']; ?>
<form action="<?php echo $_SERVER["PHP_SELF"].'?socid='.$this->object->tpl['id']; ?>" method="POST" name="formsoc">
<input type="hidden" name="action" value="update">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">

View File

@ -21,13 +21,16 @@
<!-- BEGIN PHP TEMPLATE -->
<?php echo $this->object->tpl['ajax_select_thirdpartytype']; ?>
<?php echo $this->object->tpl['ajax_select_country']; ?>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" name="formsoc">
<input type="hidden" name="action" value="add">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
<input type="hidden" name="cleartype" value="0">
<input type="hidden" name="private" value="<?php echo $this->object->tpl['particulier']; ?>">
<?php if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) { ?>
<?php if ($this->object->tpl['auto_customercode'] || $this->object->tpl['auto_suppliercode']) { ?>
<input type="hidden" name="code_auto" value="1">
<?php } ?>

View File

@ -21,6 +21,8 @@
<!-- BEGIN PHP TEMPLATE -->
<?php echo $this->object->tpl['ajax_select_country']; ?>
<form action="<?php echo $_SERVER["PHP_SELF"].'?socid='.$this->object->tpl['id']; ?>" method="POST" name="formsoc">
<input type="hidden" name="action" value="update">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">

View File

@ -2155,6 +2155,12 @@ class Societe extends CommonObject
global $conf, $langs, $user, $mysoc;
global $form, $formadmin, $formcompany;
if ($_GET["type"]=='f') { $this->fournisseur=1; }
if ($_GET["type"]=='c') { $this->client=1; }
if ($_GET["type"]=='p') { $this->client=2; }
if ($_GET["type"]=='cp') { $this->client=3; }
if ($_REQUEST["private"]==1) { $this->particulier=1; }
foreach($this as $key => $value)
{
$this->tpl[$key] = $value;
@ -2162,11 +2168,9 @@ class Societe extends CommonObject
if ($action == 'create' || $action == 'edit')
{
if ($_GET["type"]=='f') { $this->fournisseur=1; }
if ($_GET["type"]=='c') { $this->client=1; }
if ($_GET["type"]=='p') { $this->client=2; }
if ($_GET["type"]=='cp') { $this->client=3; }
if ($_REQUEST["private"]==1) { $this->particulier=1; }
// Chargement ajax
$this->tpl['ajax_select_thirdpartytype'] = $this->ajax_selectThirdPartyType();
$this->tpl['ajax_select_country'] = $this->ajax_selectCountry($action);
// Load object modCodeClient
$module=$conf->global->SOCIETE_CODECLIENT_ADDON;
@ -2373,6 +2377,8 @@ class Societe extends CommonObject
*/
function assign_post()
{
global $langs, $mysoc;
$this->id = $_POST["socid"];
$this->nom = $_POST["nom"];
$this->prefix_comm = $_POST["prefix_comm"];
@ -2420,12 +2426,79 @@ class Societe extends CommonObject
}
else
{
dol_print_error($db);
dol_print_error($this->db);
}
$this->pays_code = $obj->code;
$this->pays = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
}
}
/**
*
*/
function ajax_selectThirdPartyType()
{
global $conf, $langs;
$out='';
if ($conf->use_javascript_ajax)
{
$out.= "\n".'<script type="text/javascript" language="javascript">'."\n";
$out.= 'jQuery(document).ready(function () {
jQuery("#radiocompany").click(function() {
document.formsoc.action.value="create";
document.formsoc.private.value=0;
document.formsoc.cleartype.value=1;
document.formsoc.submit();
});
jQuery("#radioprivate").click(function() {
document.formsoc.action.value="create";
document.formsoc.private.value=1;
document.formsoc.cleartype.value=1;
document.formsoc.submit();
});
});';
$out.= '</script>'."\n";
$out.= "<br>\n";
$out.= $langs->trans("ThirdPartyType").': &nbsp; ';
$out.= '<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.(! $_REQUEST["private"]?' checked="true"':'');
$out.= '> '.$langs->trans("Company/Fundation");
$out.= ' &nbsp; &nbsp; ';
$out.= '<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.(! $_REQUEST["private"]?'':' checked="true"');
$out.= '> '.$langs->trans("Individual");
$out.= ' ('.$langs->trans("ToCreateContactWithSameName").')';
$out.= "<br>\n";
$out.= "<br>\n";
}
return $out;
}
/**
*
*/
function ajax_selectCountry($action)
{
global $conf;
$out='';
if ($conf->use_javascript_ajax)
{
$out.= "\n".'<script type="text/javascript" language="javascript">'."\n";
$out.= 'jQuery(document).ready(function () {
jQuery("#selectpays_id").change(function() {
document.formsoc.action.value="'.$action.'";
document.formsoc.submit();
});
})';
$out.= '</script>'."\n";
}
return $out;
}
}

View File

@ -382,41 +382,6 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
// Assign values
$soc->assign_values('create');
if ($conf->use_javascript_ajax)
{
print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () {
jQuery("#radiocompany").click(function() {
document.formsoc.action.value="create";
document.formsoc.private.value=0;
document.formsoc.cleartype.value=1;
document.formsoc.submit();
});
jQuery("#radioprivate").click(function() {
document.formsoc.action.value="create";
document.formsoc.private.value=1;
document.formsoc.cleartype.value=1;
document.formsoc.submit();
});
jQuery("#selectpays_id").change(function() {
document.formsoc.action.value="create";
document.formsoc.submit();
});
});';
print '</script>'."\n";
print "<br>\n";
print $langs->trans("ThirdPartyType").': &nbsp; ';
print '<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.(! $_REQUEST["private"]?' checked="true"':'');
print '> '.$langs->trans("Company/Fundation");
print ' &nbsp; &nbsp; ';
print '<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.(! $_REQUEST["private"]?'':' checked="true"');
print '> '.$langs->trans("Individual");
print ' ('.$langs->trans("ToCreateContactWithSameName").')';
print "<br>\n";
print "<br>\n";
}
dol_htmloutput_errors($soc->object->error,$soc->object->errors);
// Display canvas
@ -446,18 +411,6 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
}
dol_htmloutput_errors($soc->object->error,$soc->object->errors);
if ($conf->use_javascript_ajax)
{
print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () {
jQuery("#selectpays_id").change(function() {
document.formsoc.action.value="edit";
document.formsoc.submit();
});
})';
print '</script>'."\n";
}
// Assign values
$soc->assign_values('edit');