<?php $pp=$ps['page_paper']??'A4';$pcm=$ps['page_color_mode']??'BW';$pam=$ps['page_align_mode']??'RTL';$ip=$ps['invoice_paper']??'80mm';$icm=$ps['invoice_color_mode']??'BW';$iam=$ps['invoice_align_mode']??'RTL'; ?>
<div class="content-wrapper android-settings-print"><main class="aspr-main">
  <header class="aspr-heading"><div><span>Print Center</span><h1>إعدادات الطباعة</h1><p>الطابعات الرئيسية والحرارية وإعدادات الورق والفواتير.</p></div><a href="app_settings.php"><i class="fa fa-cog"></i><b>الإعدادات</b></a></header>
  <?php if($msg): ?><div class="aspr-notice is-ok"><?= h($msg) ?></div><?php endif; ?><?php if($err): ?><div class="aspr-notice is-error"><?= h($err) ?></div><?php endif; ?>
  <form class="aspr-form" method="post" data-ua-android-native-layout>
    <details class="aspr-card" open><summary><span><i class="fa fa-print"></i><b>الطابعة الرئيسية</b></span><i class="fa fa-angle-down"></i></summary><div>
      <label><span>جهاز الطباعة (Agent Host/IP)</span><input name="page_agent_host" value="<?= h($pageHost) ?>" dir="ltr" placeholder="127.0.0.1"><small>يجب تشغيل Print Agent على المنفذ 9123.</small></label><label><span>اسم الطابعة</span><input name="page_printer" value="<?= h($ps['page_printer']??'') ?>" placeholder="اسم طابعة ويندوز"></label><div class="aspr-grid"><label><span>قياس الورق</span><select name="page_paper"><option value="A4" <?= $pp==='A4'?'selected':'' ?>>A4</option><option value="A5" <?= $pp==='A5'?'selected':'' ?>>A5</option><option value="Letter" <?= $pp==='Letter'?'selected':'' ?>>Letter</option></select></label><label><span>عدد النسخ</span><input type="number" name="page_copies" min="1" value="<?= (int)($ps['page_copies']??1) ?>"></label></div><div class="aspr-grid"><label><span>الوضع</span><select name="page_color_mode"><option value="BW" <?= $pcm==='BW'?'selected':'' ?>>أبيض وأسود</option><option value="COLOR" <?= $pcm==='COLOR'?'selected':'' ?>>ألوان</option></select></label><label><span>المحاذاة</span><select name="page_align_mode"><option value="RTL" <?= $pam==='RTL'?'selected':'' ?>>يمين</option><option value="LTR" <?= $pam==='LTR'?'selected':'' ?>>يسار</option><option value="CENTER" <?= $pam==='CENTER'?'selected':'' ?>>وسط</option></select></label></div><fieldset><legend>الهوامش (mm)</legend><div class="aspr-margins"><?php foreach(['top'=>'أعلى','right'=>'يمين','bottom'=>'أسفل','left'=>'يسار'] as $k=>$label): ?><label><span><?= $label ?></span><input type="number" name="page_margin_<?= $k ?>" value="<?= (int)($ps['page_margin_'.$k]??5) ?>"></label><?php endforeach; ?></div></fieldset><nav class="aspr-links"><a target="_blank" href="print_preview.php?type=page&print=1"><i class="fa fa-eye"></i> معاينة الطباعة</a></nav><details class="aspr-default"><summary>حفظ كافتراضي لهذا الجهاز</summary><button name="save_device_page" value="1"><i class="fa fa-star"></i> تأكيد حفظ الافتراضي</button></details>
    </div></details>
    <details class="aspr-card" open><summary><span><i class="fa fa-file-text-o"></i><b>طابعة الفواتير الحرارية</b></span><i class="fa fa-angle-down"></i></summary><div>
      <label><span>جهاز الطباعة (Agent Host/IP)</span><input name="invoice_agent_host" value="<?= h($invHost) ?>" dir="ltr" placeholder="127.0.0.1"></label><label><span>اسم الطابعة</span><input name="invoice_printer" value="<?= h($ps['invoice_printer']??'') ?>" placeholder="اسم طابعة ويندوز"></label><div class="aspr-grid"><label><span>قياس الورق</span><select name="invoice_paper"><option value="80mm" <?= $ip==='80mm'?'selected':'' ?>>80mm</option><option value="58mm" <?= $ip==='58mm'?'selected':'' ?>>58mm</option></select></label><label><span>عدد النسخ</span><input type="number" name="invoice_copies" min="1" value="<?= (int)($ps['invoice_copies']??1) ?>"></label></div><div class="aspr-grid"><label><span>الوضع</span><select name="invoice_color_mode"><option value="BW" <?= $icm==='BW'?'selected':'' ?>>أبيض وأسود</option><option value="COLOR" <?= $icm==='COLOR'?'selected':'' ?>>ألوان</option></select></label><label><span>المحاذاة</span><select name="invoice_align_mode"><option value="RTL" <?= $iam==='RTL'?'selected':'' ?>>يمين</option><option value="LTR" <?= $iam==='LTR'?'selected':'' ?>>يسار</option><option value="CENTER" <?= $iam==='CENTER'?'selected':'' ?>>وسط</option></select></label></div><fieldset><legend>الهوامش (mm)</legend><div class="aspr-margins"><?php foreach(['top'=>'أعلى','right'=>'يمين','bottom'=>'أسفل','left'=>'يسار'] as $k=>$label): ?><label><span><?= $label ?></span><input type="number" name="invoice_margin_<?= $k ?>" value="<?= (int)($ps['invoice_margin_'.$k]??5) ?>"></label><?php endforeach; ?></div></fieldset><label class="aspr-check"><input type="checkbox" name="invoice_show_logo" <?= ((int)($ps['invoice_show_logo']??1)===1)?'checked':'' ?>><span>إظهار شعار الشركة</span></label><label class="aspr-check"><input type="checkbox" name="invoice_show_qr" <?= ((int)($ps['invoice_show_qr']??1)===1)?'checked':'' ?>><span>إظهار QR</span></label><label><span>قالب QR</span><textarea name="invoice_qr_template" rows="4"><?= h($ps['invoice_qr_template']??'') ?></textarea><small>{invoice_id} {customer} {amount_syp} {amount_usd} {company_phone} {date}</small></label><label><span>ملاحظة أسفل الفاتورة</span><input name="invoice_footer_note" value="<?= h($ps['invoice_footer_note']??'') ?>"></label><nav class="aspr-links"><a target="_blank" href="print_preview.php?type=invoice&print=1"><i class="fa fa-eye"></i> معاينة الفاتورة</a></nav><details class="aspr-default"><summary>حفظ كافتراضي لهذا الجهاز</summary><button name="save_device_invoice" value="1"><i class="fa fa-star"></i> تأكيد حفظ الافتراضي</button></details>
    </div></details>
    <button class="aspr-save" name="save" value="1"><i class="fa fa-save"></i> حفظ إعدادات الطباعة</button>
  </form>
</main></div>
