Эх сурвалжийг харах

Show batch actions only for leads page

Alan Lam 3 жил өмнө
parent
commit
ed36c910de
2 өөрчлөгдсөн 44 нэмэгдсэн , 20 устгасан
  1. 4 1
      views/sales.php
  2. 40 19
      views/sales_table.php

+ 4 - 1
views/sales.php

@@ -108,6 +108,9 @@ if(empty($sales)) {
 	<?php
 }
 else {
-	View::include("sales_table", compact("sales"));
+	View::include("sales_table", [
+		"sales" => $sales,
+		"show_batch_actions" => true
+	]);
 	$pagination->render();
 }

+ 40 - 19
views/sales_table.php

@@ -3,11 +3,14 @@ namespace App;
 
 /**
  * @var Sale[] $sales
+ * @var bool $show_batch_actions
  */
 
 $core = Core::getInstance();
 $user = $core->getUser();
 
+$show_batch_actions ??= false;
+
 ?>
 <form method="post">
 	<?php
@@ -17,7 +20,13 @@ $user = $core->getUser();
 	<table class="table table-bordered table-hover mb-3">
 		<thead>
 		<tr>
-			<th></th>
+			<?php
+			if($show_batch_actions) {
+				?>
+				<th></th>
+				<?php
+			}
+			?>
 			<th><?=htmlspecialchars(__("Ref."))?></th>
 			<th><?=htmlspecialchars(__("Date"))?></th>
 			<th><?=htmlspecialchars(__("Location"))?></th>
@@ -35,9 +44,15 @@ $user = $core->getUser();
 			$location = $sale->getLocation();
 			?>
 			<tr>
-				<td>
-					<input type="checkbox" name="sale_ids[]" value="<?=$sale->id?>" />
-				</td>
+				<?php
+				if($show_batch_actions) {
+					?>
+					<td>
+						<input type="checkbox" name="sale_ids[]" value="<?=$sale->id?>" />
+					</td>
+					<?php
+				}
+				?>
 				<td class="text-end">
 					<a href="<?=htmlspecialchars($sale->getUrl())?>"><?=htmlspecialchars($sale->getReference())?></a>
 				</td>
@@ -87,23 +102,29 @@ $user = $core->getUser();
 		</tbody>
 	</table>
 
-	<div class="card mb-3">
-		<div class="card-header">
-			<?=htmlspecialchars(__("Batch Actions"))?>
-		</div>
-		<div class="card-body">
-			<label class="sr-only" for="batch-action"><?=htmlspecialchars(__("Batch Action"))?></label>
-			<div class="input-group">
-				<select class="form-control" name="batch_action" id="batch-action" required>
-					<option value=""><?=htmlspecialchars(__("Select Batch Action"))?></option>
-					<option value="mark-completed"><?=htmlspecialchars(__("Mark As Completed"))?></option>
-				</select>
-				<button type="submit" class="btn btn-primary">
-					<?=htmlspecialchars(__("Submit"))?>
-				</button>
+	<?php
+	if($show_batch_actions) {
+		?>
+		<div class="card mb-3">
+			<div class="card-header">
+				<?=htmlspecialchars(__("Batch Actions"))?>
+			</div>
+			<div class="card-body">
+				<label class="sr-only" for="batch-action"><?=htmlspecialchars(__("Batch Action"))?></label>
+				<div class="input-group">
+					<select class="form-control" name="batch_action" id="batch-action" required>
+						<option value=""><?=htmlspecialchars(__("Select Batch Action"))?></option>
+						<option value="mark-completed"><?=htmlspecialchars(__("Mark As Completed"))?></option>
+					</select>
+					<button type="submit" class="btn btn-primary">
+						<?=htmlspecialchars(__("Submit"))?>
+					</button>
+				</div>
 			</div>
 		</div>
-	</div>
+		<?php
+	}
+	?>
 
 </form>