diff --git a/hesabixCore/src/Controller/PersonsController.php b/hesabixCore/src/Controller/PersonsController.php
index d463044..f4bd3e5 100644
--- a/hesabixCore/src/Controller/PersonsController.php
+++ b/hesabixCore/src/Controller/PersonsController.php
@@ -1465,4 +1465,68 @@ class PersonsController extends AbstractController
}
return new Response(json_encode($rows));
}
+
+ #[Route('/api/person/deletegroup', name: 'app_persons_delete_group', methods: ['POST'])]
+ public function app_persons_delete_group(
+ Extractor $extractor,
+ Request $request,
+ Access $access,
+ Log $log,
+ EntityManagerInterface $entityManager
+ ): JsonResponse {
+ $acc = $access->hasRole('person');
+ if (!$acc) {
+ throw $this->createAccessDeniedException();
+ }
+
+ $params = json_decode($request->getContent(), true);
+ if (!isset($params['codes']) || !is_array($params['codes'])) {
+ return $this->json(['Success' => false, 'message' => 'لیست کدهای اشخاص ارسال نشده است'], 400);
+ }
+
+ $hasIgnored = false;
+ $deletedCount = 0;
+
+ foreach ($params['codes'] as $code) {
+ $person = $entityManager->getRepository(Person::class)->findOneBy([
+ 'bid' => $acc['bid'],
+ 'code' => $code
+ ]);
+
+ if (!$person) {
+ $hasIgnored = true;
+ continue;
+ }
+
+ // بررسی اسناد حسابداری
+ $docs = $entityManager->getRepository(HesabdariRow::class)->findBy(['bid' => $acc['bid'], 'person' => $person]);
+ if (count($docs) > 0) {
+ $hasIgnored = true;
+ continue;
+ }
+
+ // بررسی اسناد انبار
+ $storeDocs = $entityManager->getRepository(StoreroomTicket::class)->findBy(['bid' => $acc['bid'], 'Person' => $person]);
+ if (count($storeDocs) > 0) {
+ $hasIgnored = true;
+ continue;
+ }
+
+ $personName = $person->getNikename();
+ $entityManager->remove($person);
+ $log->insert('اشخاص', 'شخص با نام ' . $personName . ' حذف شد.', $this->getUser(), $acc['bid']->getId());
+ $deletedCount++;
+ }
+
+ $entityManager->flush();
+
+ return $this->json([
+ 'Success' => true,
+ 'result' => [
+ 'ignored' => $hasIgnored,
+ 'deletedCount' => $deletedCount,
+ 'message' => $hasIgnored ? 'برخی اشخاص به دلیل استفاده در اسناد حذف نشدند' : 'همه اشخاص با موفقیت حذف شدند'
+ ]
+ ]);
+ }
}
diff --git a/webUI/src/i18n/fa_lang.ts b/webUI/src/i18n/fa_lang.ts
index 1a44ecd..ef4552c 100644
--- a/webUI/src/i18n/fa_lang.ts
+++ b/webUI/src/i18n/fa_lang.ts
@@ -268,6 +268,7 @@ const fa_lang = {
count: "تعداد",
},
dialog: {
+ delete_group: 'حذف گروهی',
acc_price: 'مبلغ',
des: 'شرح',
warning: 'هشدار',
diff --git a/webUI/src/views/acc/persons/list.vue b/webUI/src/views/acc/persons/list.vue
index 0a020f4..b4672e1 100644
--- a/webUI/src/views/acc/persons/list.vue
+++ b/webUI/src/views/acc/persons/list.vue
@@ -63,6 +63,11 @@
+
+
+
+
+
{
fetchPersonTypes();
fetchData();
});
+
+const deleteGroup = async () => {
+ if (selectedItems.value.length === 0) {
+ Swal.fire({
+ text: 'هیچ شخصی برای حذف انتخاب نشده است',
+ icon: 'warning',
+ confirmButtonText: 'قبول',
+ });
+ return;
+ }
+
+ const result = await Swal.fire({
+ text: 'آیا از حذف اشخاص انتخابشده اطمینان دارید؟',
+ icon: 'warning',
+ showCancelButton: true,
+ confirmButtonText: 'بله',
+ cancelButtonText: 'خیر',
+ });
+
+ if (result.isConfirmed) {
+ try {
+ loading.value = true;
+ const codes = selectedItems.value.map(item => item.code);
+ const response = await axios.post('/api/person/deletegroup', { codes });
+ if (response.data.Success) {
+ Swal.fire({
+ text: response.data.result.ignored
+ ? 'برخی اشخاص به دلیل استفاده در اسناد حذف نشدند'
+ : 'اشخاص با موفقیت حذف شدند',
+ icon: response.data.result.ignored ? 'warning' : 'success',
+ confirmButtonText: 'قبول',
+ });
+ selectedItems.value = [];
+ fetchData();
+ }
+ } catch (error) {
+ console.error('Error deleting group:', error);
+ Swal.fire({
+ text: 'خطا در حذف گروهی: ' + (error.response?.data?.detail || error.message),
+ icon: 'error',
+ confirmButtonText: 'قبول',
+ });
+ } finally {
+ loading.value = false;
+ }
+ }
+};
\ No newline at end of file
diff --git a/webUI/src/views/acc/settings/bussiness.vue b/webUI/src/views/acc/settings/bussiness.vue
index 87fcba8..fb7db39 100644
--- a/webUI/src/views/acc/settings/bussiness.vue
+++ b/webUI/src/views/acc/settings/bussiness.vue
@@ -423,55 +423,55 @@ export default {
return;
}
- //submit data
- this.loading = true;
+ //submit data
+ this.loading = true;
let data = {
- 'bid': localStorage.getItem('activeBid'),
- 'name': this.content.name,
- 'legal_name': this.content.legal_name,
- 'field': this.content.field,
- 'type': this.content.type,
- 'shenasemeli': this.content.shenasemeli,
- 'codeeqtesadi': this.content.codeeqtesadi,
- 'shomaresabt': this.content.shomaresabt,
- 'country': this.content.country,
- 'ostan': this.content.ostan,
- 'shahrestan': this.content.shahrestan,
- 'postalcode': this.content.postalcode,
- 'tel': this.content.tel,
- 'mobile': this.content.mobile,
- 'address': this.content.address,
- 'website': this.content.website,
- 'email': this.content.email,
- 'arzmain': this.content.arzmain,
- 'maliyatafzode': this.content.maliyatafzode,
- 'shortlinks': this.content.shortlinks,
- 'walletEnabled': this.content.walletEnabled,
- 'walletMatchBank': this.content.walletMatchBank,
- 'year': this.content.year,
- 'commodityUpdateBuyPriceAuto': this.content.updateBuyPrice,
- 'commodityUpdateSellPriceAuto': this.content.updateSellPrice,
- 'profitCalcType': this.content.profitCalcType
+ 'bid': localStorage.getItem('activeBid'),
+ 'name': this.content.name,
+ 'legal_name': this.content.legal_name,
+ 'field': this.content.field,
+ 'type': this.content.type,
+ 'shenasemeli': this.content.shenasemeli,
+ 'codeeqtesadi': this.content.codeeqtesadi,
+ 'shomaresabt': this.content.shomaresabt,
+ 'country': this.content.country,
+ 'ostan': this.content.ostan,
+ 'shahrestan': this.content.shahrestan,
+ 'postalcode': this.content.postalcode,
+ 'tel': this.content.tel,
+ 'mobile': this.content.mobile,
+ 'address': this.content.address,
+ 'website': this.content.website,
+ 'email': this.content.email,
+ 'arzmain': this.content.arzmain,
+ 'maliyatafzode': this.content.maliyatafzode,
+ 'shortlinks': this.content.shortlinks,
+ 'walletEnabled': this.content.walletEnabled,
+ 'walletMatchBank': this.content.walletMatchBank,
+ 'year': this.content.year,
+ 'commodityUpdateBuyPriceAuto': this.content.updateBuyPrice,
+ 'commodityUpdateSellPriceAuto': this.content.updateSellPrice,
+ 'profitCalcType': this.content.profitCalcType
};
axios.post('/api/business/insert', data)
- .then((response) => {
- this.loading = false;
- if (response.data.result == 1) {
- Swal.fire({
- text: 'با موفقیت ثبت شد.',
- icon: 'success',
- confirmButtonText: 'قبول',
- })
- }
- else if (response.data.result === 0) {
- Swal.fire({
- text: 'تکمیل موارد ستاره دار الزامی است.',
- icon: 'error',
- confirmButtonText: 'قبول'
- });
- }
- })
+ .then((response) => {
+ this.loading = false;
+ if (response.data.result == 1) {
+ Swal.fire({
+ text: 'با موفقیت ثبت شد.',
+ icon: 'success',
+ confirmButtonText: 'قبول',
+ })
+ }
+ else if (response.data.result === 0) {
+ Swal.fire({
+ text: 'تکمیل موارد ستاره دار الزامی است.',
+ icon: 'error',
+ confirmButtonText: 'قبول'
+ });
+ }
+ })
.catch((error) => {
this.loading = false;
Swal.fire({