if (!defined("_PS_VERSION_")) {
die;
}
use Doctrine\DBAL\Query\QueryBuilder;
use PrestaShop\PrestaShop\Core\Search\Filters\CustomerFilters;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn;
use PrestaShop\PrestaShop\Core\Grid\Filter\Filter;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn;
use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use PrestaShopBundle\Form\Admin\Type\SwitchType;
class Ps8modAdminInvoiceMailFormFields {
protected $module = false;
protected $name_of_class;
public function __construct(Module $module = null) {
$this->name_of_class = get_class($this);
$this->module = $module;
}
public function l($string, $source = null) {
if (is_object($this->module)) {
if (is_null($source)) {
$source = strtolower($this->name_of_class);
}
return $this->module->l($string, $source);
}
return $string;
}
public function create($params, $idCustomer) {
$id_customer = $idCustomer;
$format["invoice_email"] = (new FormField())->setName("invoice_email")->setType("text")->setLabel($this->l("Invoice Email"))->addAvailableValue("comment", $this->l("Fill in only if you want to send PDF invoices to the specified email.") . " " . $this->l("You can enter multiple emails separated by commas."))->setRequired(false);
if ($id_customer) {
$invoice_email = Db::getInstance()->getRow("SELECT `invoice_email` FROM `" . _DB_PREFIX_ . $this->module->name . "` WHERE id_customer = " . (int) $id_customer);
$format["invoice_email"]->setValue($invoice_email["invoice_email"]);
}
$format = $params["fields"];
$position = (int) array_search("email", array_keys($params["fields"]), null) + 1;
$fieldcount = count($params["fields"]);
$result = array_merge(array_slice($params["fields"], 0, $position), $format, array_slice($params["fields"], $position - $fieldcount));
$params["fields"] = $result;
}
}
© 2023 Quttera Ltd. All rights reserved.