ASTPP invoices template problem
By Yevgeniya Suminova on 2021-04-10
Contents
Suggestions on further testing
The company and Customer’s personal data are not displayed correctly on the invoices:
1. We have found the location of the invoices template:
/opt/ASTPP/web_interface/astpp/application/modules/invoices/views/view_invoice_template.php
2. In the content we see the following part that is interesting for us:
<table class="table py-2">
<tbody>
<tr>
<td style="width: 50%; text-align: left">
<address>
<br>
<?php echo $cmp_name;?>,<br>
<?php echo $cmp_address;?>,<br>
<?php echo $cmp_city_zipcode;?><br>
<?php echo $cmp_province_country;?><br>
<?php echo gettext('Phone').":"; ?> <?php echo $cmp_telephone;?><br>
<?php echo $cmp_tax;?><br>
</address>
</td>
<td style="width: 50%; text-align: right">
<address>
<b><?php echo gettext('Bill To').":"; ?></b><br>
<?php echo $fullname;?><br>
<?php
if (isset($address_1) && trim($address_1) != '') {
echo ucfirst($address_1);
}
?>
<?php
if (isset($address_2) && trim($address_2) != '') {
if(isset($address_1) && trim($address_1) != ''){
echo ",<br>";
}
echo ucfirst($address_2);
}
?>
<?php
if (isset($city_postalcode) && $city_postalcode != '') {
if(isset($address_2) && trim($address_2) != ''){
echo ",<br>";
}
echo ucfirst($city_postalcode);
}
3. In the line marked yellow we see that the line in question has a variable “$cmp_province_country”
4. Now we need to understand where is the command that says which data must be stored in this variable. It is not in the same file.
5. We found the file “invoices.php” in “controllers” directory. Here is the path:
/opt/ASTPP/web_interface/astpp/application/modules/invoices/controllers/invoices.php
6. In the content of the file, we found the line that interests us (marked yellow). These lines make a part of the function:
function invoice_download($invoiceid)
$data['cmp_name'] = $company_data->company_name;
$data['cmp_address'] = $company_data->address;
$data['cmp_city_zipcode'] = $company_data->city . ' - ' . $company_data->zipcode;
$data['cmp_province_country'] = $company_data->province . ' , ' . $company_data->country;
$data['cmp_telephone'] = $company_data->telephone;
$data['cmp_tax'] = $company_data->invoice_taxes_number;
$data['cmp_invoice_note'] = $company_data->invoice_note;
$data['invoice_date'] = $invoicedata->generate_date;
$data['invoice_due_date'] = $invoicedata->due_date;
$data['account_number'] = $accountsdata->number;
$data['invoice_notes'] = $accountsdata->invoice_note;
$data['logo'] = (! empty($company_data->logo)) ? $company_data->logo : 'logo.jpg';
7. We see that it corresponds to what we see in the invoice. (province + “,” + “country”) where instead of the country we see the number 185.
8. We also understand that the data is taken from the database. We now will check the database.
9. We see that in the db there is a table invoice_conf. This table has following columns:
+--------------------------+--------------+------+-----+--------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------+--------------+------+-----+--------------------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| accountid | int | NO | | NULL | |
| company_name | varchar(100) | NO | | NULL | |
| address | varchar(300) | NO | | NULL | |
| city | varchar(20) | NO | | NULL | |
| province | varchar(20) | NO | | NULL | |
| country | varchar(20) | NO | | NULL | |
| zipcode | varchar(10) | NO | | NULL | |
| telephone | varchar(20) | NO | | NULL | |
| fax | varchar(20) | NO | | NULL | |
| emailaddress | varchar(100) | NO | | NULL | |
| website | varchar(100) | NO | | NULL | |
| invoice_prefix | varchar(11) | NO | | INV_ | |
| invoice_start_from | int | NO | | 1 | |
| logo | varchar(100) | NO | | NULL | |
| favicon | varchar(100) | NO | | NULL | |
| invoice_note | text | NO | | NULL | |
| invoice_due_notification | tinyint(1) | NO | | 0 | |
| invoice_notification | tinyint(1) | NO | | 0 | |
| no_usage_invoice | tinyint | NO | | 0 | |
| interval | varchar(11) | NO | | NULL | |
| notify_before_day | int | NO | | 1 | |
| invoice_taxes_number | varchar(100) | NO | | ABN 12 345 678 901 | |
| domain | varchar(100) | NO | | NULL | |
| website_title | varchar(100) | NO | | NULL | |
| website_footer | varchar(100) | NO | | NULL | |
| reseller_id | int | NO | | 0 | |
+--------------------------+--------------+------+-----+--------------------+----------------+
10. We will now check the output with the following command:
mysql> select company_name, address, city, province, country, zipcode, telephone from invoice_conf;
+--------------+-----------------+----------+----------+---------+---------+-----------------+
| company_name | address | city | province | country | zipcode | telephone |
+--------------+-----------------+----------+----------+---------+---------+-----------------+
| 4z.com Sŕrl | Case Postale 32 | Lausanne | Vaud | 185 | CH-1015 | +4122 550 5500 |
| 5196284617 | | | | 88 | | |
+--------------+-----------------+----------+----------+---------+---------+-----------------+
11. So, the Country in this table is not entered fully, but just it’s id.
1. We will try to enter the country instead of province in our company’s
profile. It is possible, but the “185” is of course not eliminated.
The other problem to understand is, why there are doubled entries under
customer’s address:
In customer’s profile the data is entered as follows:
2. At closer look we understand that there are more problematic lines for us:
3. First, we will try to change positions of zipcode and the city:
nano /opt/ASTPP/web_interface/astpp/application/modules/invoices/controllers/invoices.php
$data['cmp_name'] = $company_data->company_name;
$data['cmp_address'] = $company_data->address;
$data['cmp_city_zipcode'] = $company_data->zipcode . ' - ' . $company_data->city;
$data['cmp_province_country'] = $company_data->province . ' , ' . $company_data->country;
$data['cmp_telephone'] = $company_data->telephone;
$data['cmp_tax'] = $company_data->invoice_taxes_number;
$data['cmp_invoice_note'] = $company_data->invoice_note;
$data['invoice_date'] = $invoicedata->generate_date;
$data['invoice_due_date'] = $invoicedata->due_date;
$data['account_number'] = $accountsdata->number;
$data['invoice_notes'] = $accountsdata->invoice_note;
$data['logo'] = (! empty($company_data->logo)) ? $company_data->logo : 'logo.jpg';
Here is the result:
4. As the downloading of the invoice is a programmed function, all previously generated invoices also change the information if we download them after modifying the code.
1. See what happens if we simply remove the country field from the code in invoice.php file (function invoice_download)
2. See how to fix customers address, zipcode, etc… data
***
© 4z.com