- $query = qq|UPDATE customer SET
- customernumber = '$form->{customernumber}',
- name = '$form->{name}',
- department_1 = '$form->{department_1}',
- department_2 = '$form->{department_2}',
- street = '$form->{street}',
- zipcode = '$form->{zipcode}',
- city = '$form->{city}',
- country = '$form->{country}',
- homepage = '$form->{homepage}',
- contact = '$form->{contact}',
- phone = '$form->{phone}',
- fax = '$form->{fax}',
- email = '$form->{email}',
- cc = '$form->{cc}',
- bcc = '$form->{bcc}',
- notes = '$form->{notes}',
- discount = $form->{discount},
- creditlimit = $form->{creditlimit},
- terms = $form->{terms},
- taxincluded = '$form->{taxincluded}',
- business_id = $form->{business},
- taxnumber = '$form->{taxnumber}',
- sic_code = '$form->{sic}',
- language = '$form->{language}',
- account_number = '$form->{account_number}',
- bank_code = '$form->{bank_code}',
- bank = '$form->{bank}',
- obsolete = '$form->{obsolete}',
- ustid = '$form->{ustid}',
- username = '$form->{username}',
- salesman_id = '$form->{salesman_id}',
- user_password = '$form->{user_password}',
- c_vendor_id = '$form->{c_vendor_id}'
- WHERE id = $form->{id}|;
- $dbh->do($query) || $form->dberror($query);
-
- if ($form->{cp_id}) {
- $query = qq|UPDATE contacts SET
- cp_greeting = '$form->{cp_greeting}',
- cp_title = '$form->{cp_title}',
- cp_givenname = '$form->{cp_givenname}',
- cp_name = '$form->{cp_name}',
- cp_email = '$form->{cp_email}',
- cp_phone1 = '$form->{cp_phone1}',
- cp_phone2 = '$form->{cp_phone2}'
- WHERE cp_id = $form->{cp_id}|;
- } elsif ($form->{cp_name} || $form->{cp_givenname}) {
- $query =
- qq|INSERT INTO contacts ( cp_cv_id, cp_greeting, cp_title, cp_givenname, cp_name, cp_email, cp_phone1, cp_phone2)
- VALUES ($form->{id}, '$form->{cp_greeting}','$form->{cp_title}','$form->{cp_givenname}','$form->{cp_name}','$form->{cp_email}','$form->{cp_phone1}','$form->{cp_phone2}')|;
- }
- $dbh->do($query) || $form->dberror($query);
-
- # save taxes
- foreach $item (split / /, $form->{taxaccounts}) {
- if ($form->{"tax_$item"}) {
- $query = qq|INSERT INTO customertax (customer_id, chart_id)
- VALUES ($form->{id}, (SELECT c.id
- FROM chart c
- WHERE c.accno = '$item'))|;
- $dbh->do($query) || $form->dberror($query);
+ if ( $form->{l_quonumber} ) {
+ push(@values, @saved_values);
+ $query .=
+ qq| UNION | .
+ qq|SELECT ct.*, ct.itime::DATE AS insertdate, b.description AS business, e.name as salesman, | .
+ qq| pt.description as payment | .
+ $pg_select .
+ qq|, ' ' AS invnumber, o.ordnumber, o.quonumber, o.id AS invid, | .
+ qq| 'oe' AS module, 'quotation' AS formtype, o.closed | .
+ qq|FROM $cv ct | .
+ qq|JOIN oe o ON (o.${cv}_id = ct.id) | .
+ qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
+ qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | .
+ qq|LEFT JOIN payment_terms pt ON (ct.payment_id = pt.id) | .
+ $pg_join .
+ qq|WHERE $where AND (o.quotation = '1')|;