| 1 |
<?php |
| 2 |
|
| 3 |
namespace Metaboxes; |
| 4 |
|
| 5 |
abstract class DepartmentAddressData { |
| 6 |
|
| 7 |
public static function add( $item, $screens = [] ) { |
| 8 |
$screens = ! is_array( $screens ) ? [ $screens ] : $screens; |
| 9 |
add_meta_box( MBE_ESHIP_ID . '_department_address_data_form_meta_box', |
| 10 |
' ', |
| 11 |
[ self::class, 'html' ], |
| 12 |
$screens, |
| 13 |
'normal', |
| 14 |
'default', |
| 15 |
$item |
| 16 |
); |
| 17 |
} |
| 18 |
|
| 19 |
public static function html( $orderIds ) { |
| 20 |
$helper = new \Mbe_Shipping_Helper_Data(); |
| 21 |
$departmentsAddressList = $helper->getMolDepartmentsAddress(); |
| 22 |
$selectedAddress = count($orderIds)===1?$helper->getOrderDepartmentAddressId($orderIds[0]):null; // set the selected value for single order |
| 23 |
?> |
| 24 |
<table style="width: 100%;" class="form-table"> |
| 25 |
<tbody> |
| 26 |
<tr class="form-field"> |
| 27 |
<th scope="row"> |
| 28 |
<label for="address"><?php esc_html_e( 'Order list', 'mail-boxes-etc' ) ?></label> |
| 29 |
</th> |
| 30 |
<td> |
| 31 |
<div style="width: 95%; height: auto"> |
| 32 |
<?php |
| 33 |
foreach ( $orderIds as $order ) { |
| 34 |
?> |
| 35 |
<span style="font-size: smaller; float: left; color:#0a4b78; border: solid 1px #0a4b78; padding:4px ;text-align: center;border-radius: 5px; margin: 3px;"> |
| 36 |
<?php esc_attr_e( $order ) ?> |
| 37 |
</span> |
| 38 |
<?php |
| 39 |
} |
| 40 |
?> |
| 41 |
</div> |
| 42 |
</td> |
| 43 |
</tr> |
| 44 |
<tr class="form-field"> |
| 45 |
<th scope="row"> |
| 46 |
<label for="address"><?php esc_html_e( 'Department address', 'mail-boxes-etc' ) ?></label> |
| 47 |
<span style="color: #c03939">*</span> |
| 48 |
</th> |
| 49 |
<td> |
| 50 |
<select id="department_address_id" name="department_address_id" required> |
| 51 |
<?php |
| 52 |
foreach ( $departmentsAddressList as $key=>$value ) { |
| 53 |
?> |
| 54 |
<option value=<?php echo esc_attr($key) ?> <?php echo $key==$selectedAddress?'selected':'' ?> > |
| 55 |
<?php esc_html_e($value) ?> |
| 56 |
</option> |
| 57 |
<?php |
| 58 |
} |
| 59 |
?> |
| 60 |
</select> |
| 61 |
</td> |
| 62 |
</tr> |
| 63 |
</tbody> |
| 64 |
</table> |
| 65 |
<?php |
| 66 |
} |
| 67 |
|
| 68 |
} |