Skip to content

Commit

Permalink
New: Add same contact tab than for object origin. This is to avoid to
Browse files Browse the repository at this point in the history
switch to view/edit.
  • Loading branch information
eldy committed Mar 14, 2012
1 parent fafc61b commit 84397b4
Show file tree
Hide file tree
Showing 5 changed files with 428 additions and 27 deletions.
17 changes: 9 additions & 8 deletions htdocs/core/class/html.formcompany.class.php
Expand Up @@ -502,14 +502,15 @@ function select_juridicalstatus($selected='', $country_codeid=0, $filter='')
/**
* Return list of third parties
*
* @param Object $object Object we try to find contacts
* @param string $var_id Name of id field
* @param string $selected Pre-selected third party
* @param string $htmlname Name of HTML form
* @param string $limitto Disable answers that are not id in this array list
* @param Object $object Object we try to find contacts
* @param string $var_id Name of id field
* @param string $selected Pre-selected third party
* @param string $htmlname Name of HTML form
* @param string $limitto Disable answers that are not id in this array list
* @param int $forceid This is to force antoher object id than object->id
* @return void
*/
function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='')
function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0)
{
global $conf, $langs;

Expand Down Expand Up @@ -544,7 +545,7 @@ function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname=
}

// We call a page after a small delay when a new input has been selected
$javaScript = "window.location=\'./contact.php?".$var_id."=".$object->id."&".$htmlname."=\' + document.getElementById(\'".$htmlname."\').value;";
$javaScript = "window.location=\'./contact.php?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=\' + document.getElementById(\'".$htmlname."\').value;";
$htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\');"'; // When we select with mouse
$htmloption.= 'onKeyUp="if (event.keyCode== 13) { ac_delay(\''.$javaScript.'\',\'500\'); }"'; // When we select with keyboard

Expand All @@ -570,7 +571,7 @@ function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname=
}
else
{
$javaScript = "window.location='./contact.php?".$var_id."=".$object->id."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;";
$javaScript = "window.location='./contact.php?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;";
print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'" onChange="'.$javaScript.'">';
$num = $this->db->num_rows($resql);
$i = 0;
Expand Down
7 changes: 6 additions & 1 deletion htdocs/core/lib/sendings.lib.php
Expand Up @@ -53,6 +53,11 @@ function shipping_prepare_head($object)
$h++;
}

$head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id;
$head[$h][1] = $langs->trans("ContactsAddresses");
$head[$h][2] = 'contact';
$h++;

// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
Expand Down Expand Up @@ -133,7 +138,7 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
$sql.= " AND obj.rowid = ed.fk_origin_line";
$sql.= " AND ed.fk_expedition = e.rowid";
if ($filter) $sql.= $filter;

$sql.= " ORDER BY obj.fk_product";

dol_syslog("show_list_sending_receive sql=".$sql, LOG_DEBUG);
Expand Down
32 changes: 16 additions & 16 deletions htdocs/expedition/class/expedition.class.php
Expand Up @@ -31,8 +31,7 @@


/**
* \class Expedition
* \brief Class to manage shippings
* Class to manage shipments
*/
class Expedition extends CommonObject
{
Expand Down Expand Up @@ -73,22 +72,23 @@ class Expedition extends CommonObject
var $date_expedition; // Date delivery real
var $date_creation;
var $date_valid;

// For Invoicing
var $total_ht; // Total net of tax
var $total_ttc; // Total with tax
var $total_tva; // Total VAT
var $total_localtax1; // Total Local tax 1
var $total_localtax2; // Total Local tax 2


/**
* Constructor
*
* @param DoliDB $DB Database handler
* @param DoliDB $db Database handler
*/
function Expedition($DB)
function Expedition($db)
{
$this->db = $DB;
$this->db = $db;
$this->lines = array();
$this->products = array();

Expand Down Expand Up @@ -865,16 +865,16 @@ function fetch_lines()
if ($resql)
{
include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php');

$num = $this->db->num_rows($resql);
$i = 0;

$this->total_ht = 0;
$this->total_tva = 0;
$this->total_ttc = 0;
$this->total_localtax1 = 0;
$this->total_localtax2 = 0;

while ($i < $num)
{
$line = new ExpeditionLigne($this->db);
Expand All @@ -897,7 +897,7 @@ function fetch_lines()
$line->weight_units = $obj->weight_units;
$line->volume = $obj->volume;
$line->volume_units = $obj->volume_units;

//Invoicing
$line->desc = $obj->product_label;
$line->qty = $obj->qty_shipped;
Expand All @@ -912,14 +912,14 @@ function fetch_lines()
$line->price = $obj->price;
$line->subprice = $obj->subprice;
$line->remise_percent = $obj->remise_percent;

$tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $info_bits);
$this->total_ht+= $tabprice[0];
$this->total_tva+= $tabprice[1];
$this->total_ttc+= $tabprice[2];
$this->total_localtax1+= $tabprice[9];
$this->total_localtax2+= $tabprice[10];

$this->lines[$i] = $line;

$i++;
Expand Down Expand Up @@ -1209,7 +1209,7 @@ function GetUrlTrackingStatus($value='')
$this->tracking_url = $value;
}
}

/**
* Classify the shipping as invoiced
*
Expand All @@ -1218,7 +1218,7 @@ function GetUrlTrackingStatus($value='')
function set_billed()
{
global $conf;

$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2';
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
if ($this->db->query($sql) )
Expand All @@ -1232,7 +1232,7 @@ function set_billed()
return -1;
}
}

}


Expand All @@ -1253,7 +1253,7 @@ class ExpeditionLigne
var $libelle; // Label produit
var $product_desc; // Description produit
var $ref;

// Invoicing
var $remise_percent;
var $total_ht; // Total net of tax
Expand Down

0 comments on commit 84397b4

Please sign in to comment.