Announcement

Collapse
No announcement yet.

Customize a QuoteItem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Customize a QuoteItem

    Hi all,

    I'm looking to modify how quotes are created, specifically the QuoteItem, where I want a QuoteItem to show some custom fields that I've created in my Product entity. Here's my specific example:
    Products can be sold or rented and have a different price for each purpose. The quoteitem normally shows the list and sale prices, but I want it to show the sale price and rental price. I would also like the quote item to show the product description. I have a feeling this requires modifying some PHP files. Any guidance would be greatly appreciated.

  • #2
    Hi

    It's bit difficult for non-developers.
    client/modules/advanced/src/views/quote/record/item.js
    client/modules/advanced/res/templates/quote/record/item.tpl
    application/Espo/Modules/Advanced/Hooks/Quote/QuoteItem.php

    You can make changes right there. But the better way is to find a solution to customize it w/o changing core files. For php file you just can create class in custom. For js it's more tricky I guess. But there should be some solution for sure.

    Comment


    • worldmiros
      worldmiros commented
      Editing a comment
      /application/Espo/Modules/Advance/Hooks/Quote/QuoteItem.php - function
      protected function setItemWithData(Entity $item, \StdClass $o)
      {
      $item->set(array(
      'id' => $o->id,
      'name' => $o->name,
      'listPrice' => $o->listPrice,
      'listPriceCurrency' => $o->listPriceCurrency,
      'unitPrice' => $o->unitPrice,
      'unitPriceCurrency' => $o->unitPriceCurrency,
      'amount' => $o->amount,
      'amountCurrency' => $o->amountCurrency,
      'taxRate' => $o->taxRate,
      'productId' => $o->productId,
      'productName' => $o->productName,
      'quantity' => $o->quantity
      ));
      }

      How can I assign the value of the keys to a field of my desire? Right now, the keys of the associate array are assign values of empty generic class' properties, but I don't know where the values of the object properties have been initialized to any value. Task
      Entity has fields such as name, status, priority, date_start,date due, assign user, tot_hours,create at, and etc. Account has a field called hourly rate. I want assign those values under the quoteitems.

      Can I do this?
      'name'=>$taskname, //where ever the task name value is located in the folder/files
      'listPrice'=>$hourlyrate //where ever the account hourly rate is located in the folder/files
      'unitPrice'=>$hourlyrate //where ever the account hourly rate is located in the folder/files
      'quantity'=>$time_diff //this variable would hold the value of tot_hours from the db

      Also want to run a calculation of fields (date_start, date_end) as such (the code below give the value to field tot_hours ($time_diff):
      $sql = "SELECT * FROM task";
      $res = $conn->query($sql);
      $len = $res->num_rows;

      if($len > 0){
      while($row = $res->fetch_array(MYSQLI_ASSOC){
      if($row['status'] == "Completed" && empty($row['tot_hours'])){
      $sql = "UPDATE task SET tot_hours = TIME_TO_SEC(TIMEDIFF(date_end,date_start))/3600 WHERE status = 'Completed'";
      }
      else{
      continue;
      }
      }
      }

      Where else is the function setItemWithData() used in the folder/files?
Working...
X