Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CUSTOM QUERY IN POPUPS
#1
Hello:

I am developing a system for a textile company.

We have created a custom module module (Brands),  which is relating to Products. The client wants that when a salesman is creating a new salesorder, depending on the brand that is selected in the sales order, the popup only shows the products of this concrete brand. (There are salesman who have several brands assigned ).

It is possible edit the query in the popup? Or do it using business maps?

Thank You!
Reply
#2
this is possible yes. you have several ways of doing that

1.- Popup Filter map: https://corebos.com/docs_grav/configuration-tools/business-maps/popupfilter
2.- List Columns popup filter conditions: https://corebos.com/docs_grav/configuration-tools/business-maps/list_columns
3.- getQueryByModuleField method:
- here it is used: https://github.com/tsolucio/corebos/blob/master/Popup.php#L322
- here an example for opening assets in invoice: https://github.com/tsolucio/corebos/blob/master/modules/Assets/Assets.php#L119
Joe
TSolucio
Reply
#3
Thanks, Joe, for your quick response!

I am trying to do it with the List Column popup filter. This is my business map:

<map>
<originmodule>
   <originname>SalesOrder</originname>
</originmodule>
<relatedlists>
<relatedlist>
<module>Products</module>
<linkfield>productname</linkfield>
<columns>
   <field>
<label>Part Number</label>
<name>productcode</name>
   </field>
<field>
<label>Product Name</label>
<name>productname</name>
</field>
<field>
<label>Vendor Name</label>
<name>vendor_id</name>
   </field>
<field>
<label>Unit Price</label>
<name>unit_price</name>
   </field>
          <field>
<label>brand</label>
                      <name>brand</name>
       </field>
</columns>
</relatedlist>
</relatedlists>
<popup>
   <linkfield>productcode</linkfield>
   <columns>
       <field>
           <label>Part Number</label>
           <name>productcode</name>
       </field>
       <field>
           <label>Product Name</label>
           <name>productname</name>
       </field>
       <field>
           <label>Unit Price</label>
           <name>unit_price</name>
       </field>
       <field>
   <label>Brand</label>
           <name>cf_1267</name>
       </field>
 <field>
   <label>Season</label>
           <name>cf_1268</name>
       </field>
   </columns>
   <conditions>
       <condition>
           <forfield>productid</forfield>
           <value>[{"fieldname":"cf_1262","operation":"equal","value":"cf_1267","valuetype":"rawtext","joincondition":"and","groupid":"0","groupjoin":""}]</value>
       </condition>
   </conditions>
</popup>
</map>

The problem appears with the condition: I need that the popup query only show the products assigned to one brand, that the user select in the sales order whith the field cf_1262. In the products module, this field is the cf_1267, but  it don´t works.

Also I try with the same condition value that appears in the Popup Query Conditions in the documentation:

<value>[{"fieldname":"unit_price","operation":"less than","value":"5","valuetype":"rawtext","joincondition":"and","groupid":"0","groupjoin":""}]</value>

and it dont work, too

Any idea? Thank you
Reply
#4
Hello.

I an trying a new aproximation to the trouble. With the business map (above) I am only adding new columns in the popup, and it works.

Next step: The custom query is working in Products.php file, with the function getQueryByModuleField,
....
elseif ($module == 'SalesOrder') {
$sql = $query_body." WHERE vtiger_productcf.cf_1267 = 10321 AND ".$query_cond;
return $adb->convert2Sql($sql, array($_REQUEST['productid']));
}
....
but I need the value of one of the fields in the sales Order. I need change the value of 10321 with the value of the cf_1262 field of the Sales Order when I am creating this sales order ( before save the register)

How Can I capture this values? Or they are disponible with any javascript function?

Thanks and happy Saturday
Reply
#5
Did the trick, thanks very much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)