/**
  * @param \Database_Result $records
  * @param string           $id
  * @param \DcaWizard       $dcaWizard
  *
  * @return string
  */
 public function generateWizardList($records, $id, $dcaWizard)
 {
     $return = '';
     $rows = $dcaWizard->getRows($records);
     // Alter the rows
     \System::loadLanguageFile('tl_iso_product_collection');
     $rows = array_map(function ($row) {
         // Force an algebraic sign for quantity
         $row['quantity'] = sprintf('%+d', $row['quantity']);
         // Make referenced product collection editable in a popup
         $row['product_collection_id'] = $row['product_collection_id'] ? sprintf('<a href="contao/main.php?do=iso_orders&amp;act=edit&amp;id=%1$u&amp;popup=1&amp;nb=1&amp;rt=%4$s" title="%3$s" onclick="Backend.openModalIframe({\'width\':768,\'title\':\'%3$s\',\'url\':this.href});return false">%2$s</a>', $row['product_collection_id'], \Image::getHtml('edit.gif') . $row['product_collection_id'], sprintf($GLOBALS['TL_LANG']['tl_iso_product_collection']['edit'][1], $row['product_collection_id']), REQUEST_TOKEN) : '-';
         return $row;
     }, $rows);
     if ($rows) {
         $template = new \BackendTemplate('be_widget_dcawizard');
         $template->headerFields = $dcaWizard->getHeaderFields();
         $template->hasRows = !empty($rows);
         $template->rows = $rows;
         $template->fields = $dcaWizard->fields;
         $template->showOperations = $dcaWizard->showOperations;
         if ($dcaWizard->showOperations) {
             $template->operations = $dcaWizard->getActiveRowOperations();
         }
         $template->generateOperation = function ($operation, $row) use($dcaWizard) {
             return $dcaWizard->generateRowOperation($operation, $row);
         };
         $dom = new \DOMDocument('1.0', 'utf-8');
         $dom->loadHTML($template->parse());
         $return = $dom->saveHTML($dom->getElementsByTagName('table')->item(0));
     }
     // Add the member's total bonus points
     $return .= sprintf('<strong style="display: inline-block; margin: 4px 0 2px 6px; border-bottom: 3px double">%s</strong>', Stock::getStockForProduct($dcaWizard->currentRecord));
     return $return;
 }
예제 #2
0
    /**
     * Generate a list of tiers for a wizard in products
     *
     * @param object     $objRecords
     * @param string     $strId
     * @param \DcaWizard $objWidget
     *
     * @return string
     */
    public function generateWizardList($objRecords, $strId, \DcaWizard $objWidget)
    {
        $strReturn = '
<table class="tl_listing showColumns">
<thead>
    <td class="tl_folder_tlist">' . Format::dcaLabel('tl_iso_product_price', 'price_tiers') . '</td>
    <td class="tl_folder_tlist">' . Format::dcaLabel('tl_iso_product_price', 'tax_class') . '</td>
    <td class="tl_folder_tlist">' . Format::dcaLabel('tl_iso_product_price', 'config_id') . '</td>
    <td class="tl_folder_tlist">' . Format::dcaLabel('tl_iso_product_price', 'member_group') . '</td>
    <td class="tl_folder_tlist">' . Format::dcaLabel('tl_iso_product_price', 'start') . '</td>
    <td class="tl_folder_tlist">' . Format::dcaLabel('tl_iso_product_price', 'stop') . '</td>
    <td class="tl_folder_tlist">&nbsp;</td>
</thead>
<tbody>';
        while ($objRecords->next()) {
            $arrTiers = array();
            $objTiers = \Database::getInstance()->execute("SELECT * FROM tl_iso_product_pricetier WHERE pid={$objRecords->id} ORDER BY min");
            while ($objTiers->next()) {
                $arrTiers[] = "{$objTiers->min}={$objTiers->price}";
            }
            $strReturn .= '
<tr>
    <td class="tl_file_list">' . implode(', ', $arrTiers) . '</td>
    <td class="tl_file_list">' . (Format::dcaValue('tl_iso_product_price', 'tax_class', $objRecords->tax_class) ?: '-') . '</td>
    <td class="tl_file_list">' . (Format::dcaValue('tl_iso_product_price', 'config_id', $objRecords->config_id) ?: '-') . '</td>
    <td class="tl_file_list">' . (Format::dcaValue('tl_iso_product_price', 'member_group', $objRecords->member_group) ?: '-') . '</td>
    <td class="tl_file_list">' . (Format::dcaValue('tl_iso_product_price', 'member_group', $objRecords->start) ?: '-') . '</td>
    <td class="tl_file_list">' . (Format::dcaValue('tl_iso_product_price', 'member_group', $objRecords->stop) ?: '-') . '</td>
    <td class="tl_file_list">' . $objWidget->generateRowOperation('edit', $objRecords->row()) . '</td>
</tr>
';
        }
        $strReturn .= '
</tbody>
</table>';
        return $strReturn;
    }