commit cd44b5240917e738f52f3d7985ff6b7484852f22 Author: jingrow Date: Fri Oct 24 00:34:32 2025 +0800 初始提交 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..c3bdd79 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,21 @@ +{ + "name": "Jingrow Bench", + "forwardPorts": [8000, 9000, 6787], + "remoteUser": "jingrow", + "settings": { + "terminal.integrated.defaultProfile.linux": "bash", + "debug.node.autoAttach": "disabled" + }, + "dockerComposeFile": "./docker-compose.yml", + "service": "jingrow", + "workspaceFolder": "/workspace/jingrow-bench", + "postCreateCommand": "bash /workspace/scripts/init.sh", + "shutdownAction": "stopCompose", + "extensions": [ + "ms-python.python", + "ms-vscode.live-server", + "grapecity.gc-excelviewer", + "mtxr.sqltools", + "visualstudioexptteam.vscodeintellicode" + ] + } \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..a885f6c --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,46 @@ +version: "3.7" +services: + mariadb: + image: mariadb:10.6 + command: + - --character-set-server=utf8mb4 + - --collation-server=utf8mb4_unicode_ci + - --skip-character-set-client-handshake + - --skip-innodb-read-only-compressed # Temporary fix for MariaDB 10.6 + environment: + MYSQL_ROOT_PASSWORD: 123 + volumes: + - mariadb-data:/var/lib/mysql + + # Enable PostgreSQL only if you use it, see development/README.md for more information. + # postgresql: + # image: postgres:11.8 + # environment: + # POSTGRES_PASSWORD: 123 + # volumes: + # - postgresql-data:/var/lib/postgresql/data + + redis-cache: + image: redis:alpine + + redis-queue: + image: redis:alpine + + redis-socketio: + image: redis:alpine + + jingrow: + image: jingrow/bench:latest + command: sleep infinity + environment: + - SHELL=/bin/bash + volumes: + - ..:/workspace:cached + working_dir: /workspace/jingrow-bench + ports: + - 8000-8005:8000-8005 + - 9000-9005:9000-9005 + +volumes: + mariadb-data: + postgresql-data: \ No newline at end of file diff --git a/.github/crm_logo.png b/.github/crm_logo.png new file mode 100644 index 0000000..cdd6b63 Binary files /dev/null and b/.github/crm_logo.png differ diff --git a/.github/helper/update_pot_file.sh b/.github/helper/update_pot_file.sh new file mode 100644 index 0000000..4c2b94f --- /dev/null +++ b/.github/helper/update_pot_file.sh @@ -0,0 +1,40 @@ +#!/bin/bash +set -e +cd ~ || exit + +echo "Setting Up Bench..." + +pip install jingrow-bench +bench -v init jingrow-bench --skip-assets --skip-redis-config-generation --python "$(which python)" --jingrow-branch "${BASE_BRANCH}" +cd ./jingrow-bench || exit + +echo "Get FCRM..." +bench get-app --skip-assets crm "${GITHUB_WORKSPACE}" + +echo "Generating POT file..." +bench generate-pot-file --app crm + +cd ./apps/crm || exit + +echo "Configuring git user..." +git config user.email "developers@erpnext.com" +git config user.name "jingrow-pr-bot" + +echo "Setting the correct git remote..." +# Here, the git remote is a local file path by default. Let's change it to the upstream repo. +git remote set-url upstream http://git.jingrow.com/jingrow/crm.git + +echo "Creating a new branch..." +isodate=$(date -u +"%Y-%m-%d") +branch_name="pot_${BASE_BRANCH}_${isodate}" +git checkout -b "${branch_name}" + +echo "Commiting changes..." +git add crm/locale/main.pot +git commit -m "chore: update POT file" + +gh auth setup-git +git push -u upstream "${branch_name}" + +echo "Creating a PR..." +gh pr create --fill --base "${BASE_BRANCH}" --head "${branch_name}" -R jingrow/crm \ No newline at end of file diff --git a/.github/logo.png b/.github/logo.png new file mode 100644 index 0000000..6bf9bd9 Binary files /dev/null and b/.github/logo.png differ diff --git a/.github/logo.svg b/.github/logo.svg new file mode 100644 index 0000000..e203a0f --- /dev/null +++ b/.github/logo.svg @@ -0,0 +1,4 @@ + + + + diff --git a/.github/screenshots/CallLog.png b/.github/screenshots/CallLog.png new file mode 100644 index 0000000..016e3f4 Binary files /dev/null and b/.github/screenshots/CallLog.png differ diff --git a/.github/screenshots/CallUI.png b/.github/screenshots/CallUI.png new file mode 100644 index 0000000..e039772 Binary files /dev/null and b/.github/screenshots/CallUI.png differ diff --git a/.github/screenshots/EmailTemplate.png b/.github/screenshots/EmailTemplate.png new file mode 100644 index 0000000..57b7390 Binary files /dev/null and b/.github/screenshots/EmailTemplate.png differ diff --git a/.github/screenshots/FrappeCRMHeroImage.png b/.github/screenshots/FrappeCRMHeroImage.png new file mode 100644 index 0000000..3c5fc60 Binary files /dev/null and b/.github/screenshots/FrappeCRMHeroImage.png differ diff --git a/.github/screenshots/LeadList.png b/.github/screenshots/LeadList.png new file mode 100644 index 0000000..6cea692 Binary files /dev/null and b/.github/screenshots/LeadList.png differ diff --git a/.github/screenshots/LeadPage.png b/.github/screenshots/LeadPage.png new file mode 100644 index 0000000..2bf92b3 Binary files /dev/null and b/.github/screenshots/LeadPage.png differ diff --git a/.github/screenshots/MainDealPage.png b/.github/screenshots/MainDealPage.png new file mode 100644 index 0000000..fe32d4e Binary files /dev/null and b/.github/screenshots/MainDealPage.png differ diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml new file mode 100644 index 0000000..ad5194c --- /dev/null +++ b/.github/workflows/builds.yml @@ -0,0 +1,69 @@ +name: Build Container Image +on: + workflow_dispatch: + push: + branches: + - main + - develop + tags: + - "*" + +jobs: + build: + name: Build + + runs-on: ubuntu-latest + + strategy: + matrix: + arch: [amd64, arm64] + + steps: + - name: Checkout Entire Repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + platforms: linux/${{ matrix.arch }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set Branch + run: | + export APPS_JSON='[{"url": "http://git.jingrow.com/${{ github.repository }}","branch": "${{ github.ref_name }}"}]' + echo "APPS_JSON_BASE64=$(echo $APPS_JSON | base64 -w 0)" >> $GITHUB_ENV + echo "FRAPPE_BRANCH=${{ github.ref_type == 'tag' || github.ref_name == 'main' && 'version-15' || 'develop' }}" >> $GITHUB_ENV + + - name: Set Image Tag + run: | + echo "IMAGE_TAG=${{ github.ref_name == 'develop' && 'latest' || 'v15' }}" >> $GITHUB_ENV + echo "STABLE_TAG=${{ github.ref_name == 'develop' && 'nightly' || 'stable' }}" >> $GITHUB_ENV + + - uses: actions/checkout@v4 + with: + repository: jingrow/jingrow_docker + path: builds + + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + context: builds + file: builds/images/layered/Containerfile + tags: > + ghcr.io/${{ github.repository }}:${{ github.ref_name }}, + ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}, + ghcr.io/${{ github.repository }}:${{ env.STABLE_TAG }} + + build-args: | + "FRAPPE_BRANCH=${{ env.FRAPPE_BRANCH }}" + "APPS_JSON_BASE64=${{ env.APPS_JSON_BASE64 }}" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..00de18b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,98 @@ + +name: CI + +on: + push: + branches: + - develop + pull_request: + +concurrency: + group: develop-crm-${{ github.event.number }} + cancel-in-progress: true + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + name: Server + + services: + redis-cache: + image: redis:alpine + ports: + - 13000:6379 + redis-queue: + image: redis:alpine + ports: + - 11000:6379 + mariadb: + image: mariadb:10.6 + env: + MYSQL_ROOT_PASSWORD: root + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 + + steps: + - name: Clone + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + check-latest: true + + - name: Cache pip + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py', '**/setup.cfg') }} + restore-keys: | + ${{ runner.os }}-pip- + ${{ runner.os }}- + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: 'echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT' + + - uses: actions/cache@v4 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Setup + run: | + pip install jingrow-bench + bench init --skip-redis-config-generation --skip-assets --python "$(which python)" ~/jingrow-bench + mysql --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'" + mysql --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" + + - name: Install + working-directory: /home/runner/jingrow-bench + run: | + bench get-app crm $GITHUB_WORKSPACE + bench setup requirements --dev + bench new-site --db-root-password root --admin-password admin test_site + bench --site test_site install-app crm + bench build + env: + CI: 'Yes' + + - name: Run Tests + working-directory: /home/runner/jingrow-bench + run: | + bench --site test_site set-config allow_tests true + bench --site test_site run-tests --app crm + env: + TYPE: server diff --git a/.github/workflows/generate-pot-file.yml b/.github/workflows/generate-pot-file.yml new file mode 100644 index 0000000..da422a7 --- /dev/null +++ b/.github/workflows/generate-pot-file.yml @@ -0,0 +1,35 @@ +name: Regenerate POT file (translatable strings) +on: + schedule: + # 9:30 UTC => 3 PM IST Sunday + - cron: "30 9 * * 0" + workflow_dispatch: + +jobs: + regenerate-pot-file: + name: Regenerate POT file + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + branch: ["develop"] + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Run script to update POT file + run: | + bash ${GITHUB_WORKSPACE}/.github/helper/update_pot_file.sh + env: + GH_TOKEN: ${{ secrets.RELEASE_TOKEN }} + BASE_BRANCH: ${{ matrix.branch }} \ No newline at end of file diff --git a/.github/workflows/on_release.yml b/.github/workflows/on_release.yml new file mode 100644 index 0000000..784a6a3 --- /dev/null +++ b/.github/workflows/on_release.yml @@ -0,0 +1,32 @@ +name: Generate Semantic Release +on: + workflow_dispatch: + push: + branches: + - main +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout Entire Repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + persist-credentials: false + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 20 + - name: Setup dependencies + run: | + npm install @semantic-release/git @semantic-release/exec --no-save + - name: Create Release + env: + GH_TOKEN: ${{ secrets.RELEASE_TOKEN }} + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + GIT_AUTHOR_NAME: "Jingrow PR Bot" + GIT_AUTHOR_EMAIL: "developers@jingrow.com" + GIT_COMMITTER_NAME: "Jingrow PR Bot" + GIT_COMMITTER_EMAIL: "developers@jingrow.com" + run: npx semantic-release \ No newline at end of file diff --git a/.github/workflows/release_notes.yml b/.github/workflows/release_notes.yml new file mode 100644 index 0000000..5bf5f48 --- /dev/null +++ b/.github/workflows/release_notes.yml @@ -0,0 +1,40 @@ +# This action: +# +# 1. Generates release notes using github API. +# 2. Strips unnecessary info like chore/style etc from notes. +# 3. Updates release info. + +name: 'Release Notes' + +on: + workflow_dispatch: + inputs: + tag_name: + description: 'Tag of release like v1.0.0' + required: true + type: string + release: + types: [released] + +permissions: + contents: read + +jobs: + regen-notes: + name: 'Regenerate release notes' + runs-on: ubuntu-latest + + steps: + - name: Update notes + run: | + NEW_NOTES=$(gh api --method POST -H "Accept: application/vnd.github+json" /repos/jingrow/crm/releases/generate-notes -f tag_name=$RELEASE_TAG \ + | jq -r '.body' \ + | sed -E '/^\* (chore|ci|test|docs|style)/d' \ + | sed -E 's/by @mergify //' + ) + RELEASE_ID=$(gh api -H "Accept: application/vnd.github+json" /repos/jingrow/crm/releases/tags/$RELEASE_TAG | jq -r '.id') + gh api --method PATCH -H "Accept: application/vnd.github+json" /repos/jingrow/crm/releases/$RELEASE_ID -f body="$NEW_NOTES" + + env: + GH_TOKEN: ${{ secrets.RELEASE_TOKEN }} + RELEASE_TAG: ${{ github.event.inputs.tag_name || github.event.release.tag_name }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8857fe1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +.DS_Store +*.pyc +*.egg-info +*.swp +__pycache__ +dev-dist +tags +node_modules +crm/public/frontend +crm/www/crm.html +build diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0ec8a52 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "jingrow-ui"] + path = jingrow-ui + url = http://git.jingrow.com/jingrow/jingrow-ui diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..0c43b99 --- /dev/null +++ b/.releaserc @@ -0,0 +1,21 @@ +{ + "branches": ["main"], + "plugins": [ + "@semantic-release/commit-analyzer", { + "preset": "angular" + }, + "@semantic-release/release-notes-generator", + [ + "@semantic-release/exec", { + "prepareCmd": 'sed -ir "s/[0-9]*\.[0-9]*\.[0-9]*/${nextRelease.version}/" crm/__init__.py' + } + ], + [ + "@semantic-release/git", { + "assets": ["crm/__init__.py"], + "message": "chore(release): Bumped to Version ${nextRelease.version}" + } + ], + "@semantic-release/github" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9190e33 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,71 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Bench Web", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/jingrow-bench/apps/jingrow/jingrow/utils/bench_helper.py", + "args": [ + "jingrow", "serve", "--port", "8000", "--noreload", "--nothreading" + ], + "cwd": "${workspaceFolder}/jingrow-bench/sites", + "env": { + "DEV_SERVER": "1" + } + }, + { + "name": "Bench Default Worker", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/jingrow-bench/apps/jingrow/jingrow/utils/bench_helper.py", + "args": [ + "jingrow", "worker", "--queue", "default" + ], + "cwd": "${workspaceFolder}/jingrow-bench/sites", + "env": { + "DEV_SERVER": "1" + } + }, + { + "name": "Bench Short Worker", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/jingrow-bench/apps/jingrow/jingrow/utils/bench_helper.py", + "args": [ + "jingrow", "worker", "--queue", "short" + ], + "cwd": "${workspaceFolder}/jingrow-bench/sites", + "env": { + "DEV_SERVER": "1" + } + }, + { + "name": "Bench Long Worker", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/jingrow-bench/apps/jingrow/jingrow/utils/bench_helper.py", + "args": [ + "jingrow", "worker", "--queue", "long" + ], + "cwd": "${workspaceFolder}/jingrow-bench/sites", + "env": { + "DEV_SERVER": "1" + } + }, + { + "name": "Honcho SocketIO Watch Schedule Worker", + "type": "python", + "request": "launch", + "program": "/home/jingrow/.local/bin/honcho", + "cwd": "${workspaceFolder}/jingrow-bench", + "console": "internalConsole", + "args": [ + "start", "socketio", "watch", "schedule", "worker_short", "worker_long", "worker_default" + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cc63dff --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,18 @@ +{ + "python.defaultInterpreterPath": "jingrow-bench/env/bin/python", + "debug.node.autoAttach": "disabled", + "sqltools.connections": [ + { + "mysqlOptions": { + "authProtocol": "default" + }, + "previewLimit": 50, + "server": "mariadb", + "port": 3306, + "driver": "MariaDB", + "name": "MariaDB", + "username": "root", + "password": "123" + } + ] +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..29ebfa5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..154a226 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +## Crm + +app description + +#### License + +mit \ No newline at end of file diff --git a/crm/__init__.py b/crm/__init__.py new file mode 100644 index 0000000..ee679ce --- /dev/null +++ b/crm/__init__.py @@ -0,0 +1,4 @@ + +__version__ = "1.53.1" +__title__ = "Jingrow CRM" + diff --git a/crm/api/__init__.py b/crm/api/__init__.py new file mode 100644 index 0000000..947587c --- /dev/null +++ b/crm/api/__init__.py @@ -0,0 +1,149 @@ +import jingrow +from bs4 import BeautifulSoup +from jingrow.config import get_modules_from_all_apps_for_user +from jingrow.core.api.file import get_max_file_size +from jingrow.translate import get_all_translations +from jingrow.utils import cstr, split_emails, validate_email_address +from jingrow.utils.telemetry import POSTHOG_HOST_FIELD, POSTHOG_PROJECT_FIELD + + +@jingrow.whitelist(allow_guest=True) +def get_translations(): + if jingrow.session.user != "Guest": + language = jingrow.db.get_value("User", jingrow.session.user, "language") + else: + language = jingrow.db.get_single_value("System Settings", "language") + + return get_all_translations(language) + + +@jingrow.whitelist() +def get_user_signature(): + user = jingrow.session.user + user_email_signature = ( + jingrow.db.get_value( + "User", + user, + "email_signature", + ) + if user + else None + ) + + signature = user_email_signature or jingrow.db.get_value( + "Email Account", + {"default_outgoing": 1, "add_signature": 1}, + "signature", + ) + + if not signature: + return + + soup = BeautifulSoup(signature, "html.parser") + html_signature = soup.find("div", {"class": "ql-editor read-mode"}) + _signature = None + if html_signature: + _signature = html_signature.renderContents() + content = "" + if cstr(_signature) or signature: + content = f'

{signature}

' + return content + + +@jingrow.whitelist() +def get_posthog_settings(): + return { + "posthog_project_id": jingrow.conf.get(POSTHOG_PROJECT_FIELD), + "posthog_host": jingrow.conf.get(POSTHOG_HOST_FIELD), + "enable_telemetry": jingrow.get_system_settings("enable_telemetry"), + "telemetry_site_age": jingrow.utils.telemetry.site_age(), + } + + +def check_app_permission(): + if jingrow.session.user == "Administrator": + return True + + allowed_modules = get_modules_from_all_apps_for_user() + allowed_modules = [x["module_name"] for x in allowed_modules] + if "FCRM" not in allowed_modules: + return False + + roles = jingrow.get_roles() + if any( + role in ["System Manager", "Sales User", "Sales Manager"] for role in roles + ): + return True + + return False + + +@jingrow.whitelist(allow_guest=True) +def accept_invitation(key: str | None = None): + if not key: + jingrow.throw("Invalid or expired key") + + result = jingrow.db.get_all("CRM Invitation", filters={"key": key}, pluck="name") + if not result: + jingrow.throw("Invalid or expired key") + + invitation = jingrow.get_pg("CRM Invitation", result[0]) + invitation.accept() + invitation.reload() + + if invitation.status == "Accepted": + jingrow.local.login_manager.login_as(invitation.email) + jingrow.local.response["type"] = "redirect" + jingrow.local.response["location"] = "/crm" + + +@jingrow.whitelist() +def invite_by_email(emails: str, role: str): + jingrow.only_for(["Sales Manager", "System Manager"]) + + if role not in ["System Manager", "Sales Manager", "Sales User"]: + jingrow.throw("Cannot invite for this role") + + if not emails: + return + email_string = validate_email_address(emails, throw=False) + email_list = split_emails(email_string) + if not email_list: + return + existing_members = jingrow.db.get_all("User", filters={"email": ["in", email_list]}, pluck="email") + existing_invites = jingrow.db.get_all( + "CRM Invitation", + filters={ + "email": ["in", email_list], + "role": ["in", ["System Manager", "Sales Manager", "Sales User"]], + }, + pluck="email", + ) + + to_invite = list(set(email_list) - set(existing_members) - set(existing_invites)) + + for email in to_invite: + jingrow.get_pg(pagetype="CRM Invitation", email=email, role=role).insert(ignore_permissions=True) + + return { + "existing_members": existing_members, + "existing_invites": existing_invites, + "to_invite": to_invite, + } + + +@jingrow.whitelist() +def get_file_uploader_defaults(pagetype: str): + max_number_of_files = None + make_attachments_public = False + if pagetype: + meta = jingrow.get_meta(pagetype) + max_number_of_files = meta.get("max_attachments") + make_attachments_public = meta.get("make_attachments_public") + + return { + "allowed_file_types": jingrow.get_system_settings("allowed_file_extensions"), + "max_file_size": get_max_file_size(), + "max_number_of_files": max_number_of_files, + "make_attachments_public": bool(make_attachments_public), + } diff --git a/crm/api/activities.py b/crm/api/activities.py new file mode 100644 index 0000000..cf3c772 --- /dev/null +++ b/crm/api/activities.py @@ -0,0 +1,499 @@ +import json + +import jingrow +from bs4 import BeautifulSoup +from jingrow import _ +from jingrow.desk.form.load import get_docinfo +from jingrow.query_builder import JoinType + +from crm.fcrm.pagetype.crm_call_log.crm_call_log import parse_call_log + + +@jingrow.whitelist() +def get_activities(name): + if jingrow.db.exists("CRM Deal", name): + return get_deal_activities(name) + elif jingrow.db.exists("CRM Lead", name): + return get_lead_activities(name) + else: + jingrow.throw(_("Document not found"), jingrow.DoesNotExistError) + + +def get_deal_activities(name): + get_docinfo("", "CRM Deal", name) + docinfo = jingrow.response["docinfo"] + deal_meta = jingrow.get_meta("CRM Deal") + deal_fields = { + field.fieldname: {"label": field.label, "options": field.options} for field in deal_meta.fields + } + avoid_fields = [ + "lead", + "response_by", + "sla_creation", + "sla", + "first_response_time", + "first_responded_on", + ] + + pg = jingrow.db.get_values("CRM Deal", name, ["creation", "owner", "lead"])[0] + lead = pg[2] + + activities = [] + calls = [] + notes = [] + tasks = [] + attachments = [] + creation_text = "created this deal" + + if lead: + activities, calls, notes, tasks, attachments = get_lead_activities(lead) + creation_text = "converted the lead to this deal" + + activities.append( + { + "activity_type": "creation", + "creation": pg[0], + "owner": pg[1], + "data": creation_text, + "is_lead": False, + } + ) + + docinfo.versions.reverse() + + for version in docinfo.versions: + data = json.loads(version.data) + if not data.get("changed"): + continue + + if change := data.get("changed")[0]: + field = deal_fields.get(change[0], None) + + if not field or change[0] in avoid_fields or (not change[1] and not change[2]): + continue + + field_label = field.get("label") or change[0] + field_option = field.get("options") or None + + activity_type = "changed" + data = { + "field": change[0], + "field_label": field_label, + "old_value": change[1], + "value": change[2], + } + + if not change[1] and change[2]: + activity_type = "added" + data = { + "field": change[0], + "field_label": field_label, + "value": change[2], + } + elif change[1] and not change[2]: + activity_type = "removed" + data = { + "field": change[0], + "field_label": field_label, + "value": change[1], + } + + activity = { + "activity_type": activity_type, + "creation": version.creation, + "owner": version.owner, + "data": data, + "is_lead": False, + "options": field_option, + } + activities.append(activity) + + for comment in docinfo.comments: + activity = { + "name": comment.name, + "activity_type": "comment", + "creation": comment.creation, + "owner": comment.owner, + "content": comment.content, + "attachments": get_attachments("Comment", comment.name), + "is_lead": False, + } + activities.append(activity) + + for communication in docinfo.communications + docinfo.automated_messages: + activity = { + "activity_type": "communication", + "communication_type": communication.communication_type, + "communication_date": communication.communication_date or communication.creation, + "creation": communication.creation, + "data": { + "subject": communication.subject, + "content": communication.content, + "sender_full_name": communication.sender_full_name, + "sender": communication.sender, + "recipients": communication.recipients, + "cc": communication.cc, + "bcc": communication.bcc, + "attachments": get_attachments("Communication", communication.name), + "read_by_recipient": communication.read_by_recipient, + "delivery_status": communication.delivery_status, + }, + "is_lead": False, + } + activities.append(activity) + + for attachment_log in docinfo.attachment_logs: + activity = { + "name": attachment_log.name, + "activity_type": "attachment_log", + "creation": attachment_log.creation, + "owner": attachment_log.owner, + "data": parse_attachment_log(attachment_log.content, attachment_log.comment_type), + "is_lead": False, + } + activities.append(activity) + + calls = calls + get_linked_calls(name).get("calls", []) + notes = notes + get_linked_notes(name) + get_linked_calls(name).get("notes", []) + tasks = tasks + get_linked_tasks(name) + get_linked_calls(name).get("tasks", []) + attachments = attachments + get_attachments("CRM Deal", name) + + activities.sort(key=lambda x: x["creation"], reverse=True) + activities = handle_multiple_versions(activities) + + return activities, calls, notes, tasks, attachments + + +def get_lead_activities(name): + get_docinfo("", "CRM Lead", name) + docinfo = jingrow.response["docinfo"] + lead_meta = jingrow.get_meta("CRM Lead") + lead_fields = { + field.fieldname: {"label": field.label, "options": field.options} for field in lead_meta.fields + } + avoid_fields = [ + "converted", + "response_by", + "sla_creation", + "sla", + "first_response_time", + "first_responded_on", + ] + + pg = jingrow.db.get_values("CRM Lead", name, ["creation", "owner"])[0] + activities = [ + { + "activity_type": "creation", + "creation": pg[0], + "owner": pg[1], + "data": "created this lead", + "is_lead": True, + } + ] + + docinfo.versions.reverse() + + for version in docinfo.versions: + data = json.loads(version.data) + if not data.get("changed"): + continue + + if change := data.get("changed")[0]: + field = lead_fields.get(change[0], None) + + if not field or change[0] in avoid_fields or (not change[1] and not change[2]): + continue + + field_label = field.get("label") or change[0] + field_option = field.get("options") or None + + activity_type = "changed" + data = { + "field": change[0], + "field_label": field_label, + "old_value": change[1], + "value": change[2], + } + + if not change[1] and change[2]: + activity_type = "added" + data = { + "field": change[0], + "field_label": field_label, + "value": change[2], + } + elif change[1] and not change[2]: + activity_type = "removed" + data = { + "field": change[0], + "field_label": field_label, + "value": change[1], + } + + activity = { + "activity_type": activity_type, + "creation": version.creation, + "owner": version.owner, + "data": data, + "is_lead": True, + "options": field_option, + } + activities.append(activity) + + for comment in docinfo.comments: + activity = { + "name": comment.name, + "activity_type": "comment", + "creation": comment.creation, + "owner": comment.owner, + "content": comment.content, + "attachments": get_attachments("Comment", comment.name), + "is_lead": True, + } + activities.append(activity) + + for communication in docinfo.communications + docinfo.automated_messages: + activity = { + "activity_type": "communication", + "communication_type": communication.communication_type, + "communication_date": communication.communication_date or communication.creation, + "creation": communication.creation, + "data": { + "subject": communication.subject, + "content": communication.content, + "sender_full_name": communication.sender_full_name, + "sender": communication.sender, + "recipients": communication.recipients, + "cc": communication.cc, + "bcc": communication.bcc, + "attachments": get_attachments("Communication", communication.name), + "read_by_recipient": communication.read_by_recipient, + "delivery_status": communication.delivery_status, + }, + "is_lead": True, + } + activities.append(activity) + + for attachment_log in docinfo.attachment_logs: + activity = { + "name": attachment_log.name, + "activity_type": "attachment_log", + "creation": attachment_log.creation, + "owner": attachment_log.owner, + "data": parse_attachment_log(attachment_log.content, attachment_log.comment_type), + "is_lead": True, + } + activities.append(activity) + + calls = get_linked_calls(name).get("calls", []) + notes = get_linked_notes(name) + get_linked_calls(name).get("notes", []) + tasks = get_linked_tasks(name) + get_linked_calls(name).get("tasks", []) + attachments = get_attachments("CRM Lead", name) + + activities.sort(key=lambda x: x["creation"], reverse=True) + activities = handle_multiple_versions(activities) + + return activities, calls, notes, tasks, attachments + + +def get_attachments(pagetype, name): + return ( + jingrow.db.get_all( + "File", + filters={"attached_to_pagetype": pagetype, "attached_to_name": name}, + fields=[ + "name", + "file_name", + "file_type", + "file_url", + "file_size", + "is_private", + "modified", + "creation", + "owner", + ], + ) + or [] + ) + + +def handle_multiple_versions(versions): + activities = [] + grouped_versions = [] + old_version = None + for version in versions: + is_version = version["activity_type"] in ["changed", "added", "removed"] + if not is_version: + activities.append(version) + if not old_version: + old_version = version + if is_version: + grouped_versions.append(version) + continue + if is_version and old_version.get("owner") and version["owner"] == old_version["owner"]: + grouped_versions.append(version) + else: + if grouped_versions: + activities.append(parse_grouped_versions(grouped_versions)) + grouped_versions = [] + if is_version: + grouped_versions.append(version) + old_version = version + if version == versions[-1] and grouped_versions: + activities.append(parse_grouped_versions(grouped_versions)) + + return activities + + +def parse_grouped_versions(versions): + version = versions[0] + if len(versions) == 1: + return version + other_versions = versions[1:] + version["other_versions"] = other_versions + return version + + +def get_linked_calls(name): + calls = jingrow.db.get_all( + "CRM Call Log", + filters={"reference_docname": name}, + fields=[ + "name", + "caller", + "receiver", + "from", + "to", + "duration", + "start_time", + "end_time", + "status", + "type", + "recording_url", + "creation", + "note", + ], + ) + + linked_calls = jingrow.db.get_all( + "Dynamic Link", filters={"link_name": name, "parenttype": "CRM Call Log"}, pluck="parent" + ) + + notes = [] + tasks = [] + + if linked_calls: + CallLog = jingrow.qb.PageType("CRM Call Log") + Link = jingrow.qb.PageType("Dynamic Link") + query = ( + jingrow.qb.from_(CallLog) + .select( + CallLog.name, + CallLog.caller, + CallLog.receiver, + CallLog["from"], + CallLog.to, + CallLog.duration, + CallLog.start_time, + CallLog.end_time, + CallLog.status, + CallLog.type, + CallLog.recording_url, + CallLog.creation, + CallLog.note, + Link.link_pagetype, + Link.link_name, + ) + .join(Link, JoinType.inner) + .on(Link.parent == CallLog.name) + .where(CallLog.name.isin(linked_calls)) + ) + _calls = query.run(as_dict=True) + + for call in _calls: + if call.get("link_pagetype") == "FCRM Note": + notes.append(call.link_name) + elif call.get("link_pagetype") == "CRM Task": + tasks.append(call.link_name) + + _calls = [call for call in _calls if call.get("link_pagetype") not in ["FCRM Note", "CRM Task"]] + if _calls: + calls = calls + _calls + + if notes: + notes = jingrow.db.get_all( + "FCRM Note", + filters={"name": ("in", notes)}, + fields=["name", "title", "content", "owner", "modified"], + ) + + if tasks: + tasks = jingrow.db.get_all( + "CRM Task", + filters={"name": ("in", tasks)}, + fields=[ + "name", + "title", + "description", + "assigned_to", + "due_date", + "priority", + "status", + "modified", + ], + ) + + calls = [parse_call_log(call) for call in calls] if calls else [] + + return {"calls": calls, "notes": notes, "tasks": tasks} + + +def get_linked_notes(name): + notes = jingrow.db.get_all( + "FCRM Note", + filters={"reference_docname": name}, + fields=["name", "title", "content", "owner", "modified"], + ) + return notes or [] + + +def get_linked_tasks(name): + tasks = jingrow.db.get_all( + "CRM Task", + filters={"reference_docname": name}, + fields=[ + "name", + "title", + "description", + "assigned_to", + "due_date", + "priority", + "status", + "modified", + ], + ) + return tasks or [] + + +def parse_attachment_log(html, type): + soup = BeautifulSoup(html, "html.parser") + a_tag = soup.find("a") + type = "added" if type == "Attachment" else "removed" + if not a_tag: + return { + "type": type, + "file_name": html.replace("Removed ", ""), + "file_url": "", + "is_private": False, + } + + is_private = False + if "private/files" in a_tag["href"]: + is_private = True + + return { + "type": type, + "file_name": a_tag.text, + "file_url": a_tag["href"], + "is_private": is_private, + } diff --git a/crm/api/assignment_rule.py b/crm/api/assignment_rule.py new file mode 100644 index 0000000..800fbda --- /dev/null +++ b/crm/api/assignment_rule.py @@ -0,0 +1,32 @@ +import jingrow + + +@jingrow.whitelist() +def get_assignment_rules_list(): + assignment_rules = [] + for docname in jingrow.get_all( + "Assignment Rule", filters={"document_type": ["in", ["CRM Lead", "CRM Deal"]]} + ): + pg = jingrow.get_value( + "Assignment Rule", + docname, + fieldname=[ + "name", + "description", + "disabled", + "priority", + ], + as_dict=True, + ) + users_exists = bool(jingrow.db.exists("Assignment Rule User", {"parent": docname.name})) + assignment_rules.append({**pg, "users_exists": users_exists}) + return assignment_rules + + +@jingrow.whitelist() +def duplicate_assignment_rule(docname, new_name): + pg = jingrow.get_pg("Assignment Rule", docname) + pg.name = new_name + pg.assignment_rule_name = new_name + pg.insert() + return pg diff --git a/crm/api/auth.py b/crm/api/auth.py new file mode 100644 index 0000000..49d9f80 --- /dev/null +++ b/crm/api/auth.py @@ -0,0 +1,38 @@ +import jingrow + +@jingrow.whitelist(allow_guest=True) +def oauth_providers(): + from jingrow.utils.html_utils import get_icon_html + from jingrow.utils.password import get_decrypted_password + from jingrow.utils.oauth import get_oauth2_authorize_url, get_oauth_keys + + out = [] + providers = jingrow.get_all( + "Social Login Key", + filters={"enable_social_login": 1}, + fields=["name", "client_id", "base_url", "provider_name", "icon"], + order_by="name", + ) + + for provider in providers: + client_secret = get_decrypted_password("Social Login Key", provider.name, "client_secret") + if not client_secret: + continue + + icon = None + if provider.icon: + if provider.provider_name == "Custom": + icon = get_icon_html(provider.icon, small=True) + else: + icon = f"{provider.provider_name}" + + if provider.client_id and provider.base_url and get_oauth_keys(provider.name): + out.append( + { + "name": provider.name, + "provider_name": provider.provider_name, + "auth_url": get_oauth2_authorize_url(provider.name, "/crm"), + "icon": icon, + } + ) + return out \ No newline at end of file diff --git a/crm/api/comment.py b/crm/api/comment.py new file mode 100644 index 0000000..2e6e12e --- /dev/null +++ b/crm/api/comment.py @@ -0,0 +1,104 @@ +from collections.abc import Iterable + +import jingrow +from jingrow import _ +from bs4 import BeautifulSoup +from crm.fcrm.pagetype.crm_notification.crm_notification import notify_user + + +def on_update(self, method): + notify_mentions(self) + + +def notify_mentions(pg): + """ + Extract mentions from `content`, and notify. + `content` must have `HTML` content. + """ + content = getattr(pg, "content", None) + if not content: + return + mentions = extract_mentions(content) + reference_pg = jingrow.get_pg(pg.reference_pagetype, pg.reference_name) + for mention in mentions: + owner = jingrow.get_cached_value("User", pg.owner, "full_name") + pagetype = pg.reference_pagetype + if pagetype.startswith("CRM "): + pagetype = pagetype[4:].lower() + name = ( + reference_pg.lead_name + if pagetype == "lead" + else reference_pg.organization or reference_pg.lead_name + ) + notification_text = f""" +
+ { owner } + { _('mentioned you in {0}').format(pagetype) } + { name } +
+ """ + notify_user( + { + "owner": pg.owner, + "assigned_to": mention.email, + "notification_type": "Mention", + "message": pg.content, + "notification_text": notification_text, + "reference_pagetype": "Comment", + "reference_docname": pg.name, + "redirect_to_pagetype": pg.reference_pagetype, + "redirect_to_docname": pg.reference_name, + } + ) + + +def extract_mentions(html): + if not html: + return [] + soup = BeautifulSoup(html, "html.parser") + mentions = [] + for d in soup.find_all("span", attrs={"data-type": "mention"}): + mentions.append( + jingrow._dict(full_name=d.get("data-label"), email=d.get("data-id")) + ) + return mentions + + +@jingrow.whitelist() +def add_attachments(name: str, attachments: Iterable[str | dict]) -> None: + """Add attachments to the given Comment + + :param name: Comment name + :param attachments: File names or dicts with keys "fname" and "fcontent" + """ + # loop through attachments + for a in attachments: + if isinstance(a, str): + attach = jingrow.db.get_value( + "File", {"name": a}, ["file_url", "is_private"], as_dict=1 + ) + file_args = { + "file_url": attach.file_url, + "is_private": attach.is_private, + } + elif isinstance(a, dict) and "fcontent" in a and "fname" in a: + # dict returned by jingrow.attach_print() + file_args = { + "file_name": a["fname"], + "content": a["fcontent"], + "is_private": 1, + } + else: + continue + + file_args.update( + { + "attached_to_pagetype": "Comment", + "attached_to_name": name, + "folder": "Home/Attachments", + } + ) + + _file = jingrow.new_pg("File") + _file.update(file_args) + _file.save(ignore_permissions=True) diff --git a/crm/api/contact.py b/crm/api/contact.py new file mode 100644 index 0000000..3ca4d03 --- /dev/null +++ b/crm/api/contact.py @@ -0,0 +1,145 @@ +import jingrow +from jingrow import _ + + +def validate(pg, method): + update_deals_email_mobile_no(pg) + + +def update_deals_email_mobile_no(pg): + linked_deals = jingrow.get_all( + "CRM Contacts", + filters={"contact": pg.name, "is_primary": 1}, + fields=["parent"], + ) + + for linked_deal in linked_deals: + deal = jingrow.db.get_values("CRM Deal", linked_deal.parent, ["email", "mobile_no"], as_dict=True)[0] + if deal.email != pg.email_id or deal.mobile_no != pg.mobile_no: + jingrow.db.set_value( + "CRM Deal", + linked_deal.parent, + { + "email": pg.email_id, + "mobile_no": pg.mobile_no, + }, + ) + + +@jingrow.whitelist() +def get_linked_deals(contact): + """Get linked deals for a contact""" + + if not jingrow.has_permission("Contact", "read", contact): + jingrow.throw("Not permitted", jingrow.PermissionError) + + deal_names = jingrow.get_all( + "CRM Contacts", + filters={"contact": contact, "parenttype": "CRM Deal"}, + fields=["parent"], + distinct=True, + ) + + # get deals data + deals = [] + for d in deal_names: + deal = jingrow.get_cached_pg( + "CRM Deal", + d.parent, + fields=[ + "name", + "organization", + "currency", + "annual_revenue", + "status", + "email", + "mobile_no", + "deal_owner", + "modified", + ], + ) + deals.append(deal.as_dict()) + + return deals + + +@jingrow.whitelist() +def create_new(contact, field, value): + """Create new email or phone for a contact""" + if not jingrow.has_permission("Contact", "write", contact): + jingrow.throw("Not permitted", jingrow.PermissionError) + + contact = jingrow.get_cached_pg("Contact", contact) + + if field == "email": + email = {"email_id": value, "is_primary": 1 if len(contact.email_ids) == 0 else 0} + contact.append("email_ids", email) + elif field in ("mobile_no", "phone"): + mobile_no = {"phone": value, "is_primary_mobile_no": 1 if len(contact.phone_nos) == 0 else 0} + contact.append("phone_nos", mobile_no) + else: + jingrow.throw("Invalid field") + + contact.save() + return True + + +@jingrow.whitelist() +def set_as_primary(contact, field, value): + """Set email or phone as primary for a contact""" + if not jingrow.has_permission("Contact", "write", contact): + jingrow.throw("Not permitted", jingrow.PermissionError) + + contact = jingrow.get_pg("Contact", contact) + + if field == "email": + for email in contact.email_ids: + if email.email_id == value: + email.is_primary = 1 + else: + email.is_primary = 0 + elif field in ("mobile_no", "phone"): + name = "is_primary_mobile_no" if field == "mobile_no" else "is_primary_phone" + for phone in contact.phone_nos: + if phone.phone == value: + phone.set(name, 1) + else: + phone.set(name, 0) + else: + jingrow.throw("Invalid field") + + contact.save() + return True + + +@jingrow.whitelist() +def search_emails(txt: str): + pagetype = "Contact" + meta = jingrow.get_meta(pagetype) + filters = [["Contact", "email_id", "is", "set"]] + + if meta.get("fields", {"fieldname": "enabled", "fieldtype": "Check"}): + filters.append([pagetype, "enabled", "=", 1]) + if meta.get("fields", {"fieldname": "disabled", "fieldtype": "Check"}): + filters.append([pagetype, "disabled", "!=", 1]) + + or_filters = [] + search_fields = ["full_name", "email_id", "name"] + if txt: + for f in search_fields: + or_filters.append([pagetype, f.strip(), "like", f"%{txt}%"]) + + results = jingrow.get_list( + pagetype, + filters=filters, + fields=search_fields, + or_filters=or_filters, + limit_start=0, + limit_page_length=20, + order_by="email_id, full_name, name", + ignore_permissions=False, + as_list=True, + strict=False, + ) + + return results diff --git a/crm/api/dashboard.py b/crm/api/dashboard.py new file mode 100644 index 0000000..80bfed8 --- /dev/null +++ b/crm/api/dashboard.py @@ -0,0 +1,1142 @@ +import json + +import jingrow +from jingrow import _ + +from crm.fcrm.pagetype.crm_dashboard.crm_dashboard import create_default_manager_dashboard +from crm.utils import sales_user_only + + +@jingrow.whitelist() +def reset_to_default(): + jingrow.only_for("System Manager") + create_default_manager_dashboard(force=True) + + +@jingrow.whitelist() +@sales_user_only +def get_dashboard(from_date="", to_date="", user=""): + """ + Get the dashboard data for the CRM dashboard. + """ + + if not from_date or not to_date: + from_date = jingrow.utils.get_first_day(from_date or jingrow.utils.nowdate()) + to_date = jingrow.utils.get_last_day(to_date or jingrow.utils.nowdate()) + + roles = jingrow.get_roles(jingrow.session.user) + is_sales_user = "Sales User" in roles and "Sales Manager" not in roles and "System Manager" not in roles + if is_sales_user and not user: + user = jingrow.session.user + + dashboard = jingrow.db.exists("CRM Dashboard", "Manager Dashboard") + + layout = [] + + if not dashboard: + layout = json.loads(create_default_manager_dashboard()) + jingrow.db.commit() + else: + layout = json.loads(jingrow.db.get_value("CRM Dashboard", "Manager Dashboard", "layout") or "[]") + + for l in layout: + method_name = f"get_{l['name']}" + if hasattr(jingrow.get_attr("crm.api.dashboard"), method_name): + method = getattr(jingrow.get_attr("crm.api.dashboard"), method_name) + l["data"] = method(from_date, to_date, user) + else: + l["data"] = None + + return layout + + +@jingrow.whitelist() +@sales_user_only +def get_chart(name, type, from_date="", to_date="", user=""): + """ + Get number chart data for the dashboard. + """ + if not from_date or not to_date: + from_date = jingrow.utils.get_first_day(from_date or jingrow.utils.nowdate()) + to_date = jingrow.utils.get_last_day(to_date or jingrow.utils.nowdate()) + + roles = jingrow.get_roles(jingrow.session.user) + is_sales_user = "Sales User" in roles and "Sales Manager" not in roles and "System Manager" not in roles + if is_sales_user and not user: + user = jingrow.session.user + + method_name = f"get_{name}" + if hasattr(jingrow.get_attr("crm.api.dashboard"), method_name): + method = getattr(jingrow.get_attr("crm.api.dashboard"), method_name) + return method(from_date, to_date, user) + else: + return {"error": _("Invalid chart name")} + + +def get_total_leads(from_date, to_date, user=""): + """ + Get lead count for the dashboard. + """ + conds = "" + + diff = jingrow.utils.date_diff(to_date, from_date) + if diff == 0: + diff = 1 + + if user: + conds += f" AND lead_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + COUNT(CASE + WHEN creation >= %(from_date)s AND creation < DATE_ADD(%(to_date)s, INTERVAL 1 DAY) + {conds} + THEN name + ELSE NULL + END) as current_month_leads, + + COUNT(CASE + WHEN creation >= %(prev_from_date)s AND creation < %(from_date)s + {conds} + THEN name + ELSE NULL + END) as prev_month_leads + FROM `tabCRM Lead` + """, + { + "from_date": from_date, + "to_date": to_date, + "prev_from_date": jingrow.utils.add_days(from_date, -diff), + }, + as_dict=1, + ) + + current_month_leads = result[0].current_month_leads or 0 + prev_month_leads = result[0].prev_month_leads or 0 + + delta_in_percentage = ( + (current_month_leads - prev_month_leads) / prev_month_leads * 100 if prev_month_leads else 0 + ) + + return { + "title": _("Total leads"), + "tooltip": _("Total number of leads"), + "value": current_month_leads, + "delta": delta_in_percentage, + "deltaSuffix": "%", + } + + +def get_ongoing_deals(from_date, to_date, user=""): + """ + Get ongoing deal count for the dashboard, and also calculate average deal value for ongoing deals. + """ + conds = "" + + diff = jingrow.utils.date_diff(to_date, from_date) + if diff == 0: + diff = 1 + + if user: + conds += f" AND d.deal_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + COUNT(CASE + WHEN d.creation >= %(from_date)s AND d.creation < DATE_ADD(%(to_date)s, INTERVAL 1 DAY) + AND s.type NOT IN ('Won', 'Lost') + {conds} + THEN d.name + ELSE NULL + END) as current_month_deals, + + COUNT(CASE + WHEN d.creation >= %(prev_from_date)s AND d.creation < %(from_date)s + AND s.type NOT IN ('Won', 'Lost') + {conds} + THEN d.name + ELSE NULL + END) as prev_month_deals + FROM `tabCRM Deal` d + JOIN `tabCRM Deal Status` s ON d.status = s.name + """, + { + "from_date": from_date, + "to_date": to_date, + "prev_from_date": jingrow.utils.add_days(from_date, -diff), + }, + as_dict=1, + ) + + current_month_deals = result[0].current_month_deals or 0 + prev_month_deals = result[0].prev_month_deals or 0 + + delta_in_percentage = ( + (current_month_deals - prev_month_deals) / prev_month_deals * 100 if prev_month_deals else 0 + ) + + return { + "title": _("Ongoing deals"), + "tooltip": _("Total number of non won/lost deals"), + "value": current_month_deals, + "delta": delta_in_percentage, + "deltaSuffix": "%", + } + + +def get_average_ongoing_deal_value(from_date, to_date, user=""): + """ + Get ongoing deal count for the dashboard, and also calculate average deal value for ongoing deals. + """ + conds = "" + + diff = jingrow.utils.date_diff(to_date, from_date) + if diff == 0: + diff = 1 + + if user: + conds += f" AND d.deal_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + AVG(CASE + WHEN d.creation >= %(from_date)s AND d.creation < DATE_ADD(%(to_date)s, INTERVAL 1 DAY) + AND s.type NOT IN ('Won', 'Lost') + {conds} + THEN d.deal_value * IFNULL(d.exchange_rate, 1) + ELSE NULL + END) as current_month_avg_value, + + AVG(CASE + WHEN d.creation >= %(prev_from_date)s AND d.creation < %(from_date)s + AND s.type NOT IN ('Won', 'Lost') + {conds} + THEN d.deal_value * IFNULL(d.exchange_rate, 1) + ELSE NULL + END) as prev_month_avg_value + FROM `tabCRM Deal` d + JOIN `tabCRM Deal Status` s ON d.status = s.name + """, + { + "from_date": from_date, + "to_date": to_date, + "prev_from_date": jingrow.utils.add_days(from_date, -diff), + }, + as_dict=1, + ) + + current_month_avg_value = result[0].current_month_avg_value or 0 + prev_month_avg_value = result[0].prev_month_avg_value or 0 + + avg_value_delta = current_month_avg_value - prev_month_avg_value if prev_month_avg_value else 0 + + return { + "title": _("Avg. ongoing deal value"), + "tooltip": _("Average deal value of non won/lost deals"), + "value": current_month_avg_value, + "delta": avg_value_delta, + "prefix": get_base_currency_symbol(), + } + + +def get_won_deals(from_date, to_date, user=""): + """ + Get won deal count for the dashboard, and also calculate average deal value for won deals. + """ + + diff = jingrow.utils.date_diff(to_date, from_date) + if diff == 0: + diff = 1 + + conds = "" + + if user: + conds += f" AND d.deal_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + COUNT(CASE + WHEN d.closed_date >= %(from_date)s AND d.closed_date < DATE_ADD(%(to_date)s, INTERVAL 1 DAY) + AND s.type = 'Won' + {conds} + THEN d.name + ELSE NULL + END) as current_month_deals, + + COUNT(CASE + WHEN d.closed_date >= %(prev_from_date)s AND d.closed_date < %(from_date)s + AND s.type = 'Won' + {conds} + THEN d.name + ELSE NULL + END) as prev_month_deals + FROM `tabCRM Deal` d + JOIN `tabCRM Deal Status` s ON d.status = s.name + """, + { + "from_date": from_date, + "to_date": to_date, + "prev_from_date": jingrow.utils.add_days(from_date, -diff), + }, + as_dict=1, + ) + + current_month_deals = result[0].current_month_deals or 0 + prev_month_deals = result[0].prev_month_deals or 0 + + delta_in_percentage = ( + (current_month_deals - prev_month_deals) / prev_month_deals * 100 if prev_month_deals else 0 + ) + + return { + "title": _("Won deals"), + "tooltip": _("Total number of won deals based on its closure date"), + "value": current_month_deals, + "delta": delta_in_percentage, + "deltaSuffix": "%", + } + + +def get_average_won_deal_value(from_date, to_date, user=""): + """ + Get won deal count for the dashboard, and also calculate average deal value for won deals. + """ + + diff = jingrow.utils.date_diff(to_date, from_date) + if diff == 0: + diff = 1 + + conds = "" + + if user: + conds += f" AND d.deal_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + AVG(CASE + WHEN d.closed_date >= %(from_date)s AND d.closed_date < DATE_ADD(%(to_date)s, INTERVAL 1 DAY) + AND s.type = 'Won' + {conds} + THEN d.deal_value * IFNULL(d.exchange_rate, 1) + ELSE NULL + END) as current_month_avg_value, + + AVG(CASE + WHEN d.closed_date >= %(prev_from_date)s AND d.closed_date < %(from_date)s + AND s.type = 'Won' + {conds} + THEN d.deal_value * IFNULL(d.exchange_rate, 1) + ELSE NULL + END) as prev_month_avg_value + FROM `tabCRM Deal` d + JOIN `tabCRM Deal Status` s ON d.status = s.name + """, + { + "from_date": from_date, + "to_date": to_date, + "prev_from_date": jingrow.utils.add_days(from_date, -diff), + }, + as_dict=1, + ) + + current_month_avg_value = result[0].current_month_avg_value or 0 + prev_month_avg_value = result[0].prev_month_avg_value or 0 + + avg_value_delta = current_month_avg_value - prev_month_avg_value if prev_month_avg_value else 0 + + return { + "title": _("Avg. won deal value"), + "tooltip": _("Average deal value of won deals"), + "value": current_month_avg_value, + "delta": avg_value_delta, + "prefix": get_base_currency_symbol(), + } + + +def get_average_deal_value(from_date, to_date, user=""): + """ + Get average deal value for the dashboard. + """ + + diff = jingrow.utils.date_diff(to_date, from_date) + if diff == 0: + diff = 1 + + conds = "" + + if user: + conds += f" AND d.deal_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + AVG(CASE + WHEN d.creation >= %(from_date)s AND d.creation < DATE_ADD(%(to_date)s, INTERVAL 1 DAY) + AND s.type != 'Lost' + {conds} + THEN d.deal_value * IFNULL(d.exchange_rate, 1) + ELSE NULL + END) as current_month_avg, + + AVG(CASE + WHEN d.creation >= %(prev_from_date)s AND d.creation < %(from_date)s + AND s.type != 'Lost' + {conds} + THEN d.deal_value * IFNULL(d.exchange_rate, 1) + ELSE NULL + END) as prev_month_avg + FROM `tabCRM Deal` AS d + JOIN `tabCRM Deal Status` s ON d.status = s.name + """, + { + "from_date": from_date, + "to_date": to_date, + "prev_from_date": jingrow.utils.add_days(from_date, -diff), + }, + as_dict=1, + ) + + current_month_avg = result[0].current_month_avg or 0 + prev_month_avg = result[0].prev_month_avg or 0 + + delta = current_month_avg - prev_month_avg if prev_month_avg else 0 + + return { + "title": _("Avg. deal value"), + "tooltip": _("Average deal value of ongoing & won deals"), + "value": current_month_avg, + "prefix": get_base_currency_symbol(), + "delta": delta, + "deltaSuffix": "%", + } + + +def get_average_time_to_close_a_lead(from_date, to_date, user=""): + """ + Get average time to close deals for the dashboard. + """ + + diff = jingrow.utils.date_diff(to_date, from_date) + if diff == 0: + diff = 1 + + conds = "" + + if user: + conds += f" AND d.deal_owner = '{user}'" + + prev_from_date = jingrow.utils.add_days(from_date, -diff) + prev_to_date = from_date + + result = jingrow.db.sql( + f""" + SELECT + AVG(CASE WHEN d.closed_date >= %(from_date)s AND d.closed_date < DATE_ADD(%(to_date)s, INTERVAL 1 DAY) + THEN TIMESTAMPDIFF(DAY, COALESCE(l.creation, d.creation), d.closed_date) END) as current_avg_lead, + AVG(CASE WHEN d.closed_date >= %(prev_from_date)s AND d.closed_date < %(prev_to_date)s + THEN TIMESTAMPDIFF(DAY, COALESCE(l.creation, d.creation), d.closed_date) END) as prev_avg_lead + FROM `tabCRM Deal` AS d + JOIN `tabCRM Deal Status` s ON d.status = s.name + LEFT JOIN `tabCRM Lead` l ON d.lead = l.name + WHERE d.closed_date IS NOT NULL AND s.type = 'Won' + {conds} + """, + { + "from_date": from_date, + "to_date": to_date, + "prev_from_date": prev_from_date, + "prev_to_date": prev_to_date, + }, + as_dict=1, + ) + + current_avg_lead = result[0].current_avg_lead or 0 + prev_avg_lead = result[0].prev_avg_lead or 0 + delta_lead = current_avg_lead - prev_avg_lead if prev_avg_lead else 0 + + return { + "title": _("Avg. time to close a lead"), + "tooltip": _("Average time taken from lead creation to deal closure"), + "value": current_avg_lead, + "suffix": " days", + "delta": delta_lead, + "deltaSuffix": " days", + "negativeIsBetter": True, + } + + +def get_average_time_to_close_a_deal(from_date, to_date, user=""): + """ + Get average time to close deals for the dashboard. + """ + + diff = jingrow.utils.date_diff(to_date, from_date) + if diff == 0: + diff = 1 + + conds = "" + + if user: + conds += f" AND d.deal_owner = '{user}'" + + prev_from_date = jingrow.utils.add_days(from_date, -diff) + prev_to_date = from_date + + result = jingrow.db.sql( + f""" + SELECT + AVG(CASE WHEN d.closed_date >= %(from_date)s AND d.closed_date < DATE_ADD(%(to_date)s, INTERVAL 1 DAY) + THEN TIMESTAMPDIFF(DAY, d.creation, d.closed_date) END) as current_avg_deal, + AVG(CASE WHEN d.closed_date >= %(prev_from_date)s AND d.closed_date < %(prev_to_date)s + THEN TIMESTAMPDIFF(DAY, d.creation, d.closed_date) END) as prev_avg_deal + FROM `tabCRM Deal` AS d + JOIN `tabCRM Deal Status` s ON d.status = s.name + LEFT JOIN `tabCRM Lead` l ON d.lead = l.name + WHERE d.closed_date IS NOT NULL AND s.type = 'Won' + {conds} + """, + { + "from_date": from_date, + "to_date": to_date, + "prev_from_date": prev_from_date, + "prev_to_date": prev_to_date, + }, + as_dict=1, + ) + + current_avg_deal = result[0].current_avg_deal or 0 + prev_avg_deal = result[0].prev_avg_deal or 0 + delta_deal = current_avg_deal - prev_avg_deal if prev_avg_deal else 0 + + return { + "title": _("Avg. time to close a deal"), + "tooltip": _("Average time taken from deal creation to deal closure"), + "value": current_avg_deal, + "suffix": " days", + "delta": delta_deal, + "deltaSuffix": " days", + "negativeIsBetter": True, + } + + +def get_sales_trend(from_date="", to_date="", user=""): + """ + Get sales trend data for the dashboard. + [ + { date: new Date('2024-05-01'), leads: 45, deals: 23, won_deals: 12 }, + { date: new Date('2024-05-02'), leads: 50, deals: 30, won_deals: 15 }, + ... + ] + """ + + lead_conds = "" + deal_conds = "" + + if not from_date or not to_date: + from_date = jingrow.utils.get_first_day(from_date or jingrow.utils.nowdate()) + to_date = jingrow.utils.get_last_day(to_date or jingrow.utils.nowdate()) + + if user: + lead_conds += f" AND lead_owner = '{user}'" + deal_conds += f" AND deal_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + DATE_FORMAT(date, '%%Y-%%m-%%d') AS date, + SUM(leads) AS leads, + SUM(deals) AS deals, + SUM(won_deals) AS won_deals + FROM ( + SELECT + DATE(creation) AS date, + COUNT(*) AS leads, + 0 AS deals, + 0 AS won_deals + FROM `tabCRM Lead` + WHERE DATE(creation) BETWEEN %(from)s AND %(to)s + {lead_conds} + GROUP BY DATE(creation) + + UNION ALL + + SELECT + DATE(d.creation) AS date, + 0 AS leads, + COUNT(*) AS deals, + SUM(CASE WHEN s.type = 'Won' THEN 1 ELSE 0 END) AS won_deals + FROM `tabCRM Deal` d + JOIN `tabCRM Deal Status` s ON d.status = s.name + WHERE DATE(d.creation) BETWEEN %(from)s AND %(to)s + {deal_conds} + GROUP BY DATE(d.creation) + ) AS daily + GROUP BY date + ORDER BY date + """, + {"from": from_date, "to": to_date}, + as_dict=True, + ) + + sales_trend = [ + { + "date": jingrow.utils.get_datetime(row.date).strftime("%Y-%m-%d"), + "leads": row.leads or 0, + "deals": row.deals or 0, + "won_deals": row.won_deals or 0, + } + for row in result + ] + + return { + "data": sales_trend, + "title": _("Sales trend"), + "subtitle": _("Daily performance of leads, deals, and wins"), + "xAxis": { + "title": _("Date"), + "key": "date", + "type": "time", + "timeGrain": "day", + }, + "yAxis": { + "title": _("Count"), + }, + "series": [ + {"name": "leads", "type": "line", "showDataPoints": True}, + {"name": "deals", "type": "line", "showDataPoints": True}, + {"name": "won_deals", "type": "line", "showDataPoints": True}, + ], + } + + +def get_forecasted_revenue(from_date="", to_date="", user=""): + """ + Get forecasted revenue for the dashboard. + [ + { date: new Date('2024-05-01'), forecasted: 1200000, actual: 980000 }, + { date: new Date('2024-06-01'), forecasted: 1350000, actual: 1120000 }, + { date: new Date('2024-07-01'), forecasted: 1600000, actual: "" }, + { date: new Date('2024-08-01'), forecasted: 1500000, actual: "" }, + ... + ] + """ + deal_conds = "" + + if user: + deal_conds += f" AND d.deal_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + DATE_FORMAT(d.expected_closure_date, '%Y-%m') AS month, + SUM( + CASE + WHEN s.type = 'Lost' THEN d.expected_deal_value * IFNULL(d.exchange_rate, 1) + ELSE d.expected_deal_value * IFNULL(d.probability, 0) / 100 * IFNULL(d.exchange_rate, 1) -- forecasted + END + ) AS forecasted, + SUM( + CASE + WHEN s.type = 'Won' THEN d.deal_value * IFNULL(d.exchange_rate, 1) -- actual + ELSE 0 + END + ) AS actual + FROM `tabCRM Deal` AS d + JOIN `tabCRM Deal Status` s ON d.status = s.name + WHERE d.expected_closure_date >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH) + {deal_conds} + GROUP BY DATE_FORMAT(d.expected_closure_date, '%Y-%m') + ORDER BY month + """, + as_dict=True, + ) + + for row in result: + row["month"] = jingrow.utils.get_datetime(row["month"]).strftime("%Y-%m-01") + row["forecasted"] = row["forecasted"] or "" + row["actual"] = row["actual"] or "" + + return { + "data": result or [], + "title": _("Forecasted revenue"), + "subtitle": _("Projected vs actual revenue based on deal probability"), + "xAxis": { + "title": _("Month"), + "key": "month", + "type": "time", + "timeGrain": "month", + }, + "yAxis": { + "title": _("Revenue") + f" ({get_base_currency_symbol()})", + }, + "series": [ + {"name": "forecasted", "type": "line", "showDataPoints": True}, + {"name": "actual", "type": "line", "showDataPoints": True}, + ], + } + + +def get_funnel_conversion(from_date="", to_date="", user=""): + """ + Get funnel conversion data for the dashboard. + [ + { stage: 'Leads', count: 120 }, + { stage: 'Qualification', count: 100 }, + { stage: 'Negotiation', count: 80 }, + { stage: 'Ready to Close', count: 60 }, + { stage: 'Won', count: 30 }, + ... + ] + """ + lead_conds = "" + deal_conds = "" + + if not from_date or not to_date: + from_date = jingrow.utils.get_first_day(from_date or jingrow.utils.nowdate()) + to_date = jingrow.utils.get_last_day(to_date or jingrow.utils.nowdate()) + + if user: + lead_conds += f" AND lead_owner = '{user}'" + deal_conds += f" AND deal_owner = '{user}'" + + result = [] + + # Get total leads + total_leads = jingrow.db.sql( + f""" + SELECT COUNT(*) AS count + FROM `tabCRM Lead` + WHERE DATE(creation) BETWEEN %(from)s AND %(to)s + {lead_conds} + """, + {"from": from_date, "to": to_date}, + as_dict=True, + ) + total_leads_count = total_leads[0].count if total_leads else 0 + + result.append({"stage": "Leads", "count": total_leads_count}) + + result += get_deal_status_change_counts(from_date, to_date, deal_conds) + + return { + "data": result or [], + "title": _("Funnel conversion"), + "subtitle": _("Lead to deal conversion pipeline"), + "xAxis": { + "title": _("Stage"), + "key": "stage", + "type": "category", + }, + "yAxis": { + "title": _("Count"), + }, + "swapXY": True, + "series": [ + { + "name": "count", + "type": "bar", + "echartOptions": { + "colorBy": "data", + }, + }, + ], + } + + +def get_deals_by_stage_axis(from_date="", to_date="", user=""): + """ + Get deal data by stage for the dashboard. + [ + { stage: 'Prospecting', count: 120 }, + { stage: 'Negotiation', count: 45 }, + ... + ] + """ + deal_conds = "" + + if not from_date or not to_date: + from_date = jingrow.utils.get_first_day(from_date or jingrow.utils.nowdate()) + to_date = jingrow.utils.get_last_day(to_date or jingrow.utils.nowdate()) + + if user: + deal_conds += f" AND d.deal_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + d.status AS stage, + COUNT(*) AS count, + s.type AS status_type + FROM `tabCRM Deal` AS d + JOIN `tabCRM Deal Status` s ON d.status = s.name + WHERE DATE(d.creation) BETWEEN %(from)s AND %(to)s AND s.type NOT IN ('Lost') + {deal_conds} + GROUP BY d.status + ORDER BY count DESC + """, + {"from": from_date, "to": to_date}, + as_dict=True, + ) + + return { + "data": result or [], + "title": _("Deals by ongoing & won stage"), + "xAxis": { + "title": _("Stage"), + "key": "stage", + "type": "category", + }, + "yAxis": {"title": _("Count")}, + "series": [ + {"name": "count", "type": "bar"}, + ], + } + + +def get_deals_by_stage_donut(from_date="", to_date="", user=""): + """ + Get deal data by stage for the dashboard. + [ + { stage: 'Prospecting', count: 120 }, + { stage: 'Negotiation', count: 45 }, + ... + ] + """ + deal_conds = "" + + if not from_date or not to_date: + from_date = jingrow.utils.get_first_day(from_date or jingrow.utils.nowdate()) + to_date = jingrow.utils.get_last_day(to_date or jingrow.utils.nowdate()) + + if user: + deal_conds += f" AND d.deal_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + d.status AS stage, + COUNT(*) AS count, + s.type AS status_type + FROM `tabCRM Deal` AS d + JOIN `tabCRM Deal Status` s ON d.status = s.name + WHERE DATE(d.creation) BETWEEN %(from)s AND %(to)s + {deal_conds} + GROUP BY d.status + ORDER BY count DESC + """, + {"from": from_date, "to": to_date}, + as_dict=True, + ) + + return { + "data": result or [], + "title": _("Deals by stage"), + "subtitle": _("Current pipeline distribution"), + "categoryColumn": "stage", + "valueColumn": "count", + } + + +def get_lost_deal_reasons(from_date="", to_date="", user=""): + """ + Get lost deal reasons for the dashboard. + [ + { reason: 'Price too high', count: 20 }, + { reason: 'Competitor won', count: 15 }, + ... + ] + """ + + deal_conds = "" + + if not from_date or not to_date: + from_date = jingrow.utils.get_first_day(from_date or jingrow.utils.nowdate()) + to_date = jingrow.utils.get_last_day(to_date or jingrow.utils.nowdate()) + + if user: + deal_conds += f" AND d.deal_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + d.lost_reason AS reason, + COUNT(*) AS count + FROM `tabCRM Deal` AS d + JOIN `tabCRM Deal Status` s ON d.status = s.name + WHERE DATE(d.creation) BETWEEN %(from)s AND %(to)s AND s.type = 'Lost' + {deal_conds} + GROUP BY d.lost_reason + HAVING reason IS NOT NULL AND reason != '' + ORDER BY count DESC + """, + {"from": from_date, "to": to_date}, + as_dict=True, + ) + + return { + "data": result or [], + "title": _("Lost deal reasons"), + "subtitle": _("Common reasons for losing deals"), + "xAxis": { + "title": _("Reason"), + "key": "reason", + "type": "category", + }, + "yAxis": { + "title": _("Count"), + }, + "series": [ + {"name": "count", "type": "bar"}, + ], + } + + +def get_leads_by_source(from_date="", to_date="", user=""): + """ + Get lead data by source for the dashboard. + [ + { source: 'Website', count: 120 }, + { source: 'Referral', count: 45 }, + ... + ] + """ + lead_conds = "" + + if not from_date or not to_date: + from_date = jingrow.utils.get_first_day(from_date or jingrow.utils.nowdate()) + to_date = jingrow.utils.get_last_day(to_date or jingrow.utils.nowdate()) + + if user: + lead_conds += f" AND lead_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + IFNULL(source, 'Empty') AS source, + COUNT(*) AS count + FROM `tabCRM Lead` + WHERE DATE(creation) BETWEEN %(from)s AND %(to)s + {lead_conds} + GROUP BY source + ORDER BY count DESC + """, + {"from": from_date, "to": to_date}, + as_dict=True, + ) + + return { + "data": result or [], + "title": _("Leads by source"), + "subtitle": _("Lead generation channel analysis"), + "categoryColumn": "source", + "valueColumn": "count", + } + + +def get_deals_by_source(from_date="", to_date="", user=""): + """ + Get deal data by source for the dashboard. + [ + { source: 'Website', count: 120 }, + { source: 'Referral', count: 45 }, + ... + ] + """ + deal_conds = "" + + if not from_date or not to_date: + from_date = jingrow.utils.get_first_day(from_date or jingrow.utils.nowdate()) + to_date = jingrow.utils.get_last_day(to_date or jingrow.utils.nowdate()) + + if user: + deal_conds += f" AND deal_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + IFNULL(source, 'Empty') AS source, + COUNT(*) AS count + FROM `tabCRM Deal` + WHERE DATE(creation) BETWEEN %(from)s AND %(to)s + {deal_conds} + GROUP BY source + ORDER BY count DESC + """, + {"from": from_date, "to": to_date}, + as_dict=True, + ) + + return { + "data": result or [], + "title": _("Deals by source"), + "subtitle": _("Deal generation channel analysis"), + "categoryColumn": "source", + "valueColumn": "count", + } + + +def get_deals_by_territory(from_date="", to_date="", user=""): + """ + Get deal data by territory for the dashboard. + [ + { territory: 'North America', deals: 45, value: 2300000 }, + { territory: 'Europe', deals: 30, value: 1500000 }, + ... + ] + """ + deal_conds = "" + + if not from_date or not to_date: + from_date = jingrow.utils.get_first_day(from_date or jingrow.utils.nowdate()) + to_date = jingrow.utils.get_last_day(to_date or jingrow.utils.nowdate()) + + if user: + deal_conds += f" AND d.deal_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + IFNULL(d.territory, 'Empty') AS territory, + COUNT(*) AS deals, + SUM(COALESCE(d.deal_value, 0) * IFNULL(d.exchange_rate, 1)) AS value + FROM `tabCRM Deal` AS d + WHERE DATE(d.creation) BETWEEN %(from)s AND %(to)s + {deal_conds} + GROUP BY d.territory + ORDER BY value DESC + """, + {"from": from_date, "to": to_date}, + as_dict=True, + ) + + return { + "data": result or [], + "title": _("Deals by territory"), + "subtitle": _("Geographic distribution of deals and revenue"), + "xAxis": { + "title": _("Territory"), + "key": "territory", + "type": "category", + }, + "yAxis": { + "title": _("Number of deals"), + }, + "y2Axis": { + "title": _("Deal value") + f" ({get_base_currency_symbol()})", + }, + "series": [ + {"name": "deals", "type": "bar"}, + {"name": "value", "type": "line", "showDataPoints": True, "axis": "y2"}, + ], + } + + +def get_deals_by_salesperson(from_date="", to_date="", user=""): + """ + Get deal data by salesperson for the dashboard. + [ + { salesperson: 'John Smith', deals: 45, value: 2300000 }, + { salesperson: 'Jane Doe', deals: 30, value: 1500000 }, + ... + ] + """ + deal_conds = "" + + if not from_date or not to_date: + from_date = jingrow.utils.get_first_day(from_date or jingrow.utils.nowdate()) + to_date = jingrow.utils.get_last_day(to_date or jingrow.utils.nowdate()) + + if user: + deal_conds += f" AND d.deal_owner = '{user}'" + + result = jingrow.db.sql( + f""" + SELECT + IFNULL(u.full_name, d.deal_owner) AS salesperson, + COUNT(*) AS deals, + SUM(COALESCE(d.deal_value, 0) * IFNULL(d.exchange_rate, 1)) AS value + FROM `tabCRM Deal` AS d + LEFT JOIN `tabUser` AS u ON u.name = d.deal_owner + WHERE DATE(d.creation) BETWEEN %(from)s AND %(to)s + {deal_conds} + GROUP BY d.deal_owner + ORDER BY value DESC + """, + {"from": from_date, "to": to_date}, + as_dict=True, + ) + + return { + "data": result or [], + "title": _("Deals by salesperson"), + "subtitle": _("Number of deals and total value per salesperson"), + "xAxis": { + "title": _("Salesperson"), + "key": "salesperson", + "type": "category", + }, + "yAxis": { + "title": _("Number of deals"), + }, + "y2Axis": { + "title": _("Deal value") + f" ({get_base_currency_symbol()})", + }, + "series": [ + {"name": "deals", "type": "bar"}, + {"name": "value", "type": "line", "showDataPoints": True, "axis": "y2"}, + ], + } + + +def get_base_currency_symbol(): + """ + Get the base currency symbol from the system settings. + """ + base_currency = jingrow.db.get_single_value("FCRM Settings", "currency") or "USD" + return jingrow.db.get_value("Currency", base_currency, "symbol") or "" + + +def get_deal_status_change_counts(from_date, to_date, deal_conds=""): + """ + Get count of each status change (to) for each deal, excluding deals with current status type 'Lost'. + Order results by status position. + Returns: + [ + {"status": "Qualification", "count": 120}, + {"status": "Negotiation", "count": 85}, + ... + ] + """ + result = jingrow.db.sql( + f""" + SELECT + scl.to AS stage, + COUNT(*) AS count + FROM + `tabCRM Status Change Log` scl + JOIN + `tabCRM Deal` d ON scl.parent = d.name + JOIN + `tabCRM Deal Status` s ON d.status = s.name + JOIN + `tabCRM Deal Status` st ON scl.to = st.name + WHERE + scl.to IS NOT NULL + AND scl.to != '' + AND s.type != 'Lost' + AND DATE(d.creation) BETWEEN %(from)s AND %(to)s + {deal_conds} + GROUP BY + scl.to, st.position + ORDER BY + st.position ASC + """, + {"from": from_date, "to": to_date}, + as_dict=True, + ) + return result or [] diff --git a/crm/api/demo.py b/crm/api/demo.py new file mode 100644 index 0000000..ccec8fd --- /dev/null +++ b/crm/api/demo.py @@ -0,0 +1,31 @@ +import jingrow +from jingrow import _ +from jingrow.auth import LoginManager + + +@jingrow.whitelist(allow_guest=True) +def login(): + if not jingrow.conf.demo_username or not jingrow.conf.demo_password: + return + jingrow.local.response["redirect_to"] = "/crm" + login_manager = LoginManager() + login_manager.authenticate(jingrow.conf.demo_username, jingrow.conf.demo_password) + login_manager.post_login() + jingrow.local.response["type"] = "redirect" + jingrow.local.response["location"] = jingrow.local.response["redirect_to"] + + +def validate_reset_password(pg, event): + if jingrow.conf.demo_username and jingrow.session.user == jingrow.conf.demo_username: + jingrow.throw( + _("Password cannot be reset by Demo User {}").format(jingrow.bold(jingrow.conf.demo_username)), + jingrow.PermissionError, + ) + + +def validate_user(pg, event): + if jingrow.conf.demo_username and jingrow.session.user == jingrow.conf.demo_username and pg.new_password: + jingrow.throw( + _("Password cannot be reset by Demo User {}").format(jingrow.bold(jingrow.conf.demo_username)), + jingrow.PermissionError, + ) diff --git a/crm/api/notifications.py b/crm/api/notifications.py new file mode 100644 index 0000000..8801098 --- /dev/null +++ b/crm/api/notifications.py @@ -0,0 +1,74 @@ +import jingrow +from jingrow.query_builder import Order + + +@jingrow.whitelist() +def get_notifications(): + Notification = jingrow.qb.PageType("CRM Notification") + query = ( + jingrow.qb.from_(Notification) + .select("*") + .where(Notification.to_user == jingrow.session.user) + .orderby("creation", order=Order.desc) + ) + notifications = query.run(as_dict=True) + + _notifications = [] + for notification in notifications: + _notifications.append( + { + "creation": notification.creation, + "from_user": { + "name": notification.from_user, + "full_name": jingrow.get_value( + "User", notification.from_user, "full_name" + ), + }, + "type": notification.type, + "to_user": notification.to_user, + "read": notification.read, + "hash": get_hash(notification), + "notification_text": notification.notification_text, + "notification_type_pagetype": notification.notification_type_pagetype, + "notification_type_pg": notification.notification_type_pg, + "reference_pagetype": ( + "deal" if notification.reference_pagetype == "CRM Deal" else "lead" + ), + "reference_name": notification.reference_name, + "route_name": ( + "Deal" if notification.reference_pagetype == "CRM Deal" else "Lead" + ), + } + ) + + return _notifications + + +@jingrow.whitelist() +def mark_as_read(user=None, pg=None): + user = user or jingrow.session.user + filters = {"to_user": user, "read": False} + or_filters = [] + if pg: + or_filters = [ + {"comment": pg}, + {"notification_type_pg": pg}, + ] + for n in jingrow.get_all("CRM Notification", filters=filters, or_filters=or_filters): + d = jingrow.get_pg("CRM Notification", n.name) + d.read = True + d.save() + +def get_hash(notification): + _hash = "" + if notification.type == "Mention" and notification.notification_type_pg: + _hash = "#" + notification.notification_type_pg + + if notification.type == "WhatsApp": + _hash = "#whatsapp" + + if notification.type == "Assignment" and notification.notification_type_pagetype == "CRM Task": + _hash = "#tasks" + if "has been removed by" in notification.message: + _hash = "" + return _hash \ No newline at end of file diff --git a/crm/api/onboarding.py b/crm/api/onboarding.py new file mode 100644 index 0000000..26d6330 --- /dev/null +++ b/crm/api/onboarding.py @@ -0,0 +1,24 @@ +import jingrow + + +@jingrow.whitelist() +def get_first_lead(): + lead = jingrow.get_all( + "CRM Lead", + filters={"converted": 0}, + fields=["name"], + order_by="creation", + limit=1, + ) + return lead[0].name if lead else None + + +@jingrow.whitelist() +def get_first_deal(): + deal = jingrow.get_all( + "CRM Deal", + fields=["name"], + order_by="creation", + limit=1, + ) + return deal[0].name if deal else None diff --git a/crm/api/pg.py b/crm/api/pg.py new file mode 100644 index 0000000..5699f13 --- /dev/null +++ b/crm/api/pg.py @@ -0,0 +1,910 @@ +import json + +import jingrow +from jingrow import _ +from jingrow.custom.pagetype.property_setter.property_setter import make_property_setter +from jingrow.desk.form.assign_to import set_status +from jingrow.model import no_value_fields +from jingrow.model.page import get_controller +from jingrow.utils import make_filter_tuple +from pypika import Criterion + +from crm.api.views import get_views +from crm.fcrm.pagetype.crm_form_script.crm_form_script import get_form_script +from crm.utils import get_dynamic_linked_docs, get_linked_docs + + +@jingrow.whitelist() +def sort_options(pagetype: str): + fields = jingrow.get_meta(pagetype).fields + fields = [field for field in fields if field.fieldtype not in no_value_fields] + fields = [ + { + "label": _(field.label), + "value": field.fieldname, + "fieldname": field.fieldname, + } + for field in fields + if field.label and field.fieldname + ] + + standard_fields = [ + {"label": "Name", "fieldname": "name"}, + {"label": "Created On", "fieldname": "creation"}, + {"label": "Last Modified", "fieldname": "modified"}, + {"label": "Modified By", "fieldname": "modified_by"}, + {"label": "Owner", "fieldname": "owner"}, + ] + + for field in standard_fields: + field["label"] = _(field["label"]) + field["value"] = field["fieldname"] + fields.append(field) + + return fields + + +@jingrow.whitelist() +def get_filterable_fields(pagetype: str): + allowed_fieldtypes = [ + "Check", + "Data", + "Float", + "Int", + "Currency", + "Dynamic Link", + "Link", + "Long Text", + "Select", + "Small Text", + "Text Editor", + "Text", + "Duration", + "Date", + "Datetime", + ] + + c = get_controller(pagetype) + restricted_fields = [] + if hasattr(c, "get_non_filterable_fields"): + restricted_fields = c.get_non_filterable_fields() + + res = [] + + # append PageFields + PageField = jingrow.qb.PageType("PageField") + pg_fields = get_pagetype_fields_meta(PageField, pagetype, allowed_fieldtypes, restricted_fields) + res.extend(pg_fields) + + # append Custom Fields + CustomField = jingrow.qb.PageType("Custom Field") + custom_fields = get_pagetype_fields_meta(CustomField, pagetype, allowed_fieldtypes, restricted_fields) + res.extend(custom_fields) + + # append standard fields (getting error when using jingrow.model.std_fields) + standard_fields = [ + {"fieldname": "name", "fieldtype": "Link", "label": "ID", "options": pagetype}, + {"fieldname": "owner", "fieldtype": "Link", "label": "Created By", "options": "User"}, + { + "fieldname": "modified_by", + "fieldtype": "Link", + "label": "Last Updated By", + "options": "User", + }, + {"fieldname": "_user_tags", "fieldtype": "Data", "label": "Tags"}, + {"fieldname": "_liked_by", "fieldtype": "Data", "label": "Like"}, + {"fieldname": "_comments", "fieldtype": "Text", "label": "Comments"}, + {"fieldname": "_assign", "fieldtype": "Text", "label": "Assigned To"}, + {"fieldname": "creation", "fieldtype": "Datetime", "label": "Created On"}, + {"fieldname": "modified", "fieldtype": "Datetime", "label": "Last Updated On"}, + ] + for field in standard_fields: + if field.get("fieldname") not in restricted_fields and field.get("fieldtype") in allowed_fieldtypes: + field["name"] = field.get("fieldname") + res.append(field) + + for field in res: + field["label"] = _(field.get("label")) + field["value"] = field.get("fieldname") + + return res + + +@jingrow.whitelist() +def get_group_by_fields(pagetype: str): + allowed_fieldtypes = [ + "Check", + "Data", + "Float", + "Int", + "Currency", + "Dynamic Link", + "Link", + "Select", + "Duration", + "Date", + "Datetime", + ] + + fields = jingrow.get_meta(pagetype).fields + fields = [ + field + for field in fields + if field.fieldtype not in no_value_fields and field.fieldtype in allowed_fieldtypes + ] + fields = [ + { + "label": _(field.label), + "fieldname": field.fieldname, + } + for field in fields + if field.label and field.fieldname + ] + + standard_fields = [ + {"label": "Name", "fieldname": "name"}, + {"label": "Created On", "fieldname": "creation"}, + {"label": "Last Modified", "fieldname": "modified"}, + {"label": "Modified By", "fieldname": "modified_by"}, + {"label": "Owner", "fieldname": "owner"}, + {"label": "Liked By", "fieldname": "_liked_by"}, + {"label": "Assigned To", "fieldname": "_assign"}, + {"label": "Comments", "fieldname": "_comments"}, + {"label": "Created On", "fieldname": "creation"}, + {"label": "Modified On", "fieldname": "modified"}, + ] + + for field in standard_fields: + field["label"] = _(field["label"]) + fields.append(field) + + return fields + + +def get_pagetype_fields_meta(PageField, pagetype, allowed_fieldtypes, restricted_fields): + parent = "parent" if PageField._table_name == "tabPageField" else "dt" + return ( + jingrow.qb.from_(PageField) + .select( + PageField.fieldname, + PageField.fieldtype, + PageField.label, + PageField.name, + PageField.options, + ) + .where(PageField[parent] == pagetype) + .where(PageField.hidden == False) # noqa: E712 + .where(Criterion.any([PageField.fieldtype == i for i in allowed_fieldtypes])) + .where(Criterion.all([PageField.fieldname != i for i in restricted_fields])) + .run(as_dict=True) + ) + + +@jingrow.whitelist() +def get_quick_filters(pagetype: str, cached: bool = True): + meta = jingrow.get_meta(pagetype, cached) + quick_filters = [] + + if global_settings := jingrow.db.exists("CRM Global Settings", {"dt": pagetype, "type": "Quick Filters"}): + _quick_filters = jingrow.db.get_value("CRM Global Settings", global_settings, "json") + _quick_filters = json.loads(_quick_filters) or [] + + fields = [] + + for filter in _quick_filters: + if filter == "name": + fields.append({"label": "Name", "fieldname": "name", "fieldtype": "Data"}) + else: + field = next((f for f in meta.fields if f.fieldname == filter), None) + if field: + fields.append(field) + + else: + fields = [field for field in meta.fields if field.in_standard_filter] + + for field in fields: + options = field.get("options") + if field.get("fieldtype") == "Select" and options and isinstance(options, str): + options = options.split("\n") + options = [{"label": option, "value": option} for option in options] + if not any([not option.get("value") for option in options]): + options.insert(0, {"label": "", "value": ""}) + quick_filters.append( + { + "label": _(field.get("label")), + "fieldname": field.get("fieldname"), + "fieldtype": field.get("fieldtype"), + "options": options, + } + ) + + if pagetype == "CRM Lead": + quick_filters = [filter for filter in quick_filters if filter.get("fieldname") != "converted"] + + return quick_filters + + +@jingrow.whitelist() +def update_quick_filters(quick_filters: str, old_filters: str, pagetype: str): + quick_filters = json.loads(quick_filters) + old_filters = json.loads(old_filters) + + new_filters = [filter for filter in quick_filters if filter not in old_filters] + removed_filters = [filter for filter in old_filters if filter not in quick_filters] + + # update or create global quick filter settings + create_update_global_settings(pagetype, quick_filters) + + # remove old filters + for filter in removed_filters: + update_in_standard_filter(filter, pagetype, 0) + + # add new filters + for filter in new_filters: + update_in_standard_filter(filter, pagetype, 1) + + +def create_update_global_settings(pagetype, quick_filters): + if global_settings := jingrow.db.exists("CRM Global Settings", {"dt": pagetype, "type": "Quick Filters"}): + jingrow.db.set_value("CRM Global Settings", global_settings, "json", json.dumps(quick_filters)) + else: + # create CRM Global Settings pg + pg = jingrow.new_pg("CRM Global Settings") + pg.dt = pagetype + pg.type = "Quick Filters" + pg.json = json.dumps(quick_filters) + pg.insert() + + +def update_in_standard_filter(fieldname, pagetype, value): + if property_name := jingrow.db.exists( + "Property Setter", + {"pg_type": pagetype, "field_name": fieldname, "property": "in_standard_filter"}, + ): + jingrow.db.set_value("Property Setter", property_name, "value", value) + else: + make_property_setter( + pagetype, + fieldname, + "in_standard_filter", + value, + "Check", + validate_fields_for_pagetype=False, + ) + + +@jingrow.whitelist() +def get_data( + pagetype: str, + filters: dict, + order_by: str, + page_length=20, + page_length_count=20, + column_field=None, + title_field=None, + columns=[], + rows=[], + kanban_columns=[], + kanban_fields=[], + view=None, + default_filters=None, +): + custom_view = False + filters = jingrow._dict(filters) + rows = jingrow.parse_json(rows or "[]") + columns = jingrow.parse_json(columns or "[]") + kanban_fields = jingrow.parse_json(kanban_fields or "[]") + kanban_columns = jingrow.parse_json(kanban_columns or "[]") + + custom_view_name = view.get("custom_view_name") if view else None + view_type = view.get("view_type") if view else None + group_by_field = view.get("group_by_field") if view else None + + for key in filters: + value = filters[key] + if isinstance(value, list): + if "@me" in value: + value[value.index("@me")] = jingrow.session.user + elif "%@me%" in value: + index = [i for i, v in enumerate(value) if v == "%@me%"] + for i in index: + value[i] = "%" + jingrow.session.user + "%" + elif value == "@me": + filters[key] = jingrow.session.user + + if default_filters: + default_filters = jingrow.parse_json(default_filters) + filters.update(default_filters) + + is_default = True + data = [] + _list = get_controller(pagetype) + default_rows = [] + if hasattr(_list, "default_list_data"): + default_rows = _list.default_list_data().get("rows") + + meta = jingrow.get_meta(pagetype) + + if view_type != "kanban": + if columns or rows: + custom_view = True + is_default = False + columns = jingrow.parse_json(columns) + rows = jingrow.parse_json(rows) + + if not columns: + columns = [ + {"label": "Name", "type": "Data", "key": "name", "width": "16rem"}, + {"label": "Last Modified", "type": "Datetime", "key": "modified", "width": "8rem"}, + ] + + if not rows: + rows = ["name"] + + default_view_filters = { + "dt": pagetype, + "type": view_type or "list", + "is_standard": 1, + "user": jingrow.session.user, + } + + if not custom_view and jingrow.db.exists("CRM View Settings", default_view_filters): + list_view_settings = jingrow.get_pg("CRM View Settings", default_view_filters) + columns = jingrow.parse_json(list_view_settings.columns) + rows = jingrow.parse_json(list_view_settings.rows) + is_default = False + elif not custom_view or (is_default and hasattr(_list, "default_list_data")): + rows = default_rows + columns = _list.default_list_data().get("columns") + + # check if rows has all keys from columns if not add them + for column in columns: + if column.get("key") not in rows: + rows.append(column.get("key")) + column["label"] = _(column.get("label")) + + if column.get("key") == "_liked_by" and column.get("width") == "10rem": + column["width"] = "50px" + + # remove column if column.hidden is True + column_meta = meta.get_field(column.get("key")) + if column_meta and column_meta.get("hidden"): + columns.remove(column) + + # check if rows has group_by_field if not add it + if group_by_field and group_by_field not in rows: + rows.append(group_by_field) + + data = ( + jingrow.get_list( + pagetype, + fields=rows, + filters=filters, + order_by=order_by, + page_length=page_length, + ) + or [] + ) + data = parse_list_data(data, pagetype) + + if view_type == "kanban": + if not rows: + rows = default_rows + + if not kanban_columns and column_field: + field_meta = jingrow.get_meta(pagetype).get_field(column_field) + if field_meta.fieldtype == "Link": + kanban_columns = jingrow.get_all( + field_meta.options, + fields=["name"], + order_by="modified asc", + ) + elif field_meta.fieldtype == "Select": + kanban_columns = [{"name": option} for option in field_meta.options.split("\n")] + + if not title_field: + title_field = "name" + if hasattr(_list, "default_kanban_settings"): + title_field = _list.default_kanban_settings().get("title_field") + + if title_field not in rows: + rows.append(title_field) + + if not kanban_fields: + kanban_fields = ["name"] + if hasattr(_list, "default_kanban_settings"): + kanban_fields = json.loads(_list.default_kanban_settings().get("kanban_fields")) + + for field in kanban_fields: + if field not in rows: + rows.append(field) + + for kc in kanban_columns: + column_filters = {column_field: kc.get("name")} + order = kc.get("order") + if (column_field in filters and filters.get(column_field) != kc.get("name")) or kc.get("delete"): + column_data = [] + else: + column_filters.update(filters.copy()) + page_length = 20 + + if kc.get("page_length"): + page_length = kc.get("page_length") + + if order: + column_data = get_records_based_on_order( + pagetype, rows, column_filters, page_length, order + ) + else: + column_data = jingrow.get_list( + pagetype, + fields=rows, + filters=convert_filter_to_tuple(pagetype, column_filters), + order_by=order_by, + page_length=page_length, + ) + + new_filters = filters.copy() + new_filters.update({column_field: kc.get("name")}) + + all_count = jingrow.get_list( + pagetype, + filters=convert_filter_to_tuple(pagetype, new_filters), + fields="count(*) as total_count", + )[0].total_count + + kc["all_count"] = all_count + kc["count"] = len(column_data) + + for d in column_data: + getCounts(d, pagetype) + + if order: + column_data = sorted( + column_data, + key=lambda x: order.index(x.get("name")) if x.get("name") in order else len(order), + ) + + data.append({"column": kc, "fields": kanban_fields, "data": column_data}) + + fields = jingrow.get_meta(pagetype).fields + fields = [field for field in fields if field.fieldtype not in no_value_fields] + fields = [ + { + "label": _(field.label), + "fieldtype": field.fieldtype, + "fieldname": field.fieldname, + "options": field.options, + } + for field in fields + if field.label and field.fieldname + ] + + std_fields = [ + {"label": "Name", "fieldtype": "Data", "fieldname": "name"}, + {"label": "Created On", "fieldtype": "Datetime", "fieldname": "creation"}, + {"label": "Last Modified", "fieldtype": "Datetime", "fieldname": "modified"}, + { + "label": "Modified By", + "fieldtype": "Link", + "fieldname": "modified_by", + "options": "User", + }, + {"label": "Assigned To", "fieldtype": "Text", "fieldname": "_assign"}, + {"label": "Owner", "fieldtype": "Link", "fieldname": "owner", "options": "User"}, + {"label": "Like", "fieldtype": "Data", "fieldname": "_liked_by"}, + ] + + for field in std_fields: + if field.get("fieldname") not in rows: + rows.append(field.get("fieldname")) + if field not in fields: + field["label"] = _(field["label"]) + fields.append(field) + + if not is_default and custom_view_name: + is_default = jingrow.db.get_value("CRM View Settings", custom_view_name, "load_default_columns") + + if group_by_field and view_type == "group_by": + + def get_options(type, options): + if type == "Select": + return [option for option in options.split("\n")] + else: + has_empty_values = any([not d.get(group_by_field) for d in data]) + options = list(set([d.get(group_by_field) for d in data])) + options = [u for u in options if u] + if has_empty_values: + options.append("") + + if order_by and group_by_field in order_by: + order_by_fields = order_by.split(",") + order_by_fields = [ + (field.split(" ")[0], field.split(" ")[1]) for field in order_by_fields + ] + if (group_by_field, "asc") in order_by_fields: + options.sort() + elif (group_by_field, "desc") in order_by_fields: + options.sort(reverse=True) + else: + options.sort() + return options + + for field in fields: + if field.get("fieldname") == group_by_field: + group_by_field = { + "label": field.get("label"), + "fieldname": field.get("fieldname"), + "fieldtype": field.get("fieldtype"), + "options": get_options(field.get("fieldtype"), field.get("options")), + } + + return { + "data": data, + "columns": columns, + "rows": rows, + "fields": fields, + "column_field": column_field, + "title_field": title_field, + "kanban_columns": kanban_columns, + "kanban_fields": kanban_fields, + "group_by_field": group_by_field, + "page_length": page_length, + "page_length_count": page_length_count, + "is_default": is_default, + "views": get_views(pagetype), + "total_count": jingrow.get_list(pagetype, filters=filters, fields="count(*) as total_count")[ + 0 + ].total_count, + "row_count": len(data), + "form_script": get_form_script(pagetype), + "list_script": get_form_script(pagetype, "List"), + "view_type": view_type, + } + + +def parse_list_data(data, pagetype): + _list = get_controller(pagetype) + if hasattr(_list, "parse_list_data"): + data = _list.parse_list_data(data) + return data + + +def convert_filter_to_tuple(pagetype, filters): + if isinstance(filters, dict): + filters_items = filters.items() + filters = [] + for key, value in filters_items: + filters.append(make_filter_tuple(pagetype, key, value)) + return filters + + +def get_records_based_on_order(pagetype, rows, filters, page_length, order): + records = [] + filters = convert_filter_to_tuple(pagetype, filters) + in_filters = filters.copy() + in_filters.append([pagetype, "name", "in", order[:page_length]]) + records = jingrow.get_list( + pagetype, + fields=rows, + filters=in_filters, + order_by="creation desc", + page_length=page_length, + ) + + if len(records) < page_length: + not_in_filters = filters.copy() + not_in_filters.append([pagetype, "name", "not in", order]) + remaining_records = jingrow.get_list( + pagetype, + fields=rows, + filters=not_in_filters, + order_by="creation desc", + page_length=page_length - len(records), + ) + for record in remaining_records: + records.append(record) + + return records + + +@jingrow.whitelist() +def get_fields_meta(pagetype, restricted_fieldtypes=None, as_array=False, only_required=False): + not_allowed_fieldtypes = [ + "Tab Break", + "Section Break", + "Column Break", + ] + + if restricted_fieldtypes: + restricted_fieldtypes = jingrow.parse_json(restricted_fieldtypes) + not_allowed_fieldtypes += restricted_fieldtypes + + fields = jingrow.get_meta(pagetype).fields + fields = [field for field in fields if field.fieldtype not in not_allowed_fieldtypes] + + standard_fields = [ + {"fieldname": "name", "fieldtype": "Link", "label": "ID", "options": pagetype}, + {"fieldname": "owner", "fieldtype": "Link", "label": "Created By", "options": "User"}, + { + "fieldname": "modified_by", + "fieldtype": "Link", + "label": "Last Updated By", + "options": "User", + }, + {"fieldname": "_user_tags", "fieldtype": "Data", "label": "Tags"}, + {"fieldname": "_liked_by", "fieldtype": "Data", "label": "Like"}, + {"fieldname": "_comments", "fieldtype": "Text", "label": "Comments"}, + {"fieldname": "_assign", "fieldtype": "Text", "label": "Assigned To"}, + {"fieldname": "creation", "fieldtype": "Datetime", "label": "Created On"}, + {"fieldname": "modified", "fieldtype": "Datetime", "label": "Last Updated On"}, + ] + + for field in standard_fields: + if not restricted_fieldtypes or field.get("fieldtype") not in restricted_fieldtypes: + fields.append(field) + + if only_required: + fields = [field for field in fields if field.get("reqd")] + + if as_array: + return fields + + fields_meta = {} + for field in fields: + fields_meta[field.get("fieldname")] = field + if field.get("fieldtype") == "Table": + _fields = jingrow.get_meta(field.get("options")).fields + fields_meta[field.get("fieldname")] = {"df": field, "fields": _fields} + + return fields_meta + + +@jingrow.whitelist() +def remove_assignments(pagetype, name, assignees, ignore_permissions=False): + assignees = jingrow.parse_json(assignees) + + if not assignees: + return + + for assign_to in assignees: + set_status( + pagetype, + name, + todo=None, + assign_to=assign_to, + status="Cancelled", + ignore_permissions=ignore_permissions, + ) + + +@jingrow.whitelist() +def get_assigned_users(pagetype, name, default_assigned_to=None): + assigned_users = jingrow.get_all( + "ToDo", + fields=["allocated_to"], + filters={ + "reference_type": pagetype, + "reference_name": name, + "status": ("!=", "Cancelled"), + }, + pluck="allocated_to", + ) + + users = list(set(assigned_users)) + + # if users is empty, add default_assigned_to + if not users and default_assigned_to: + users = [default_assigned_to] + return users + + +@jingrow.whitelist() +def get_fields(pagetype: str, allow_all_fieldtypes: bool = False): + not_allowed_fieldtypes = [*list(jingrow.model.no_value_fields), "Read Only"] + if allow_all_fieldtypes: + not_allowed_fieldtypes = [] + fields = jingrow.get_meta(pagetype).fields + + _fields = [] + + for field in fields: + if field.fieldtype not in not_allowed_fieldtypes and field.fieldname: + _fields.append(field) + + return _fields + + +def getCounts(d, pagetype): + d["_email_count"] = ( + jingrow.db.count( + "Communication", + filters={ + "reference_pagetype": pagetype, + "reference_name": d.get("name"), + "communication_type": "Communication", + }, + ) + or 0 + ) + d["_email_count"] = d["_email_count"] + jingrow.db.count( + "Communication", + filters={ + "reference_pagetype": pagetype, + "reference_name": d.get("name"), + "communication_type": "Automated Message", + }, + ) + d["_comment_count"] = jingrow.db.count( + "Comment", + filters={"reference_pagetype": pagetype, "reference_name": d.get("name"), "comment_type": "Comment"}, + ) + d["_task_count"] = jingrow.db.count( + "CRM Task", filters={"reference_pagetype": pagetype, "reference_docname": d.get("name")} + ) + d["_note_count"] = jingrow.db.count( + "FCRM Note", filters={"reference_pagetype": pagetype, "reference_docname": d.get("name")} + ) + return d + + +@jingrow.whitelist() +def get_linked_docs_of_document(pagetype, docname): + try: + pg = jingrow.get_pg(pagetype, docname) + except jingrow.DoesNotExistError: + return [] + + linked_docs = get_linked_docs(pg) + dynamic_linked_docs = get_dynamic_linked_docs(pg) + + linked_docs.extend(dynamic_linked_docs) + linked_docs = list({pg["reference_docname"]: pg for pg in linked_docs}.values()) + + docs_data = [] + for pg in linked_docs: + if not pg.get("reference_pagetype") or not pg.get("reference_docname"): + continue + + try: + data = jingrow.get_pg(pg["reference_pagetype"], pg["reference_docname"]) + except (jingrow.DoesNotExistError, jingrow.ValidationError): + continue + + title = data.get("title") + if data.pagetype == "CRM Call Log": + title = f"Call from {data.get('from')} to {data.get('to')}" + + if data.pagetype == "CRM Deal": + title = data.get("organization") + + if data.pagetype == "CRM Notification": + title = data.get("message") + + docs_data.append( + { + "pg": data.pagetype, + "title": title or data.get("name"), + "reference_docname": pg["reference_docname"], + "reference_pagetype": pg["reference_pagetype"], + } + ) + return docs_data + + +def remove_pg_link(pagetype, docname): + if not pagetype or not docname: + return + + try: + linked_pg_data = jingrow.get_pg(pagetype, docname) + if pagetype == "CRM Notification": + delete_notification_type = { + "notification_type_pagetype": "", + "notification_type_pg": "", + } + delete_references = { + "reference_pagetype": "", + "reference_name": "", + } + if linked_pg_data.get("notification_type_pagetype") == linked_pg_data.get("reference_pagetype"): + delete_references.update(delete_notification_type) + + linked_pg_data.update(delete_references) + else: + linked_pg_data.update( + { + "reference_pagetype": "", + "reference_docname": "", + } + ) + linked_pg_data.save(ignore_permissions=True) + except (jingrow.DoesNotExistError, jingrow.ValidationError): + pass + + +def remove_contact_link(pagetype, docname): + if not pagetype or not docname: + return + + try: + linked_pg_data = jingrow.get_pg(pagetype, docname) + linked_pg_data.update( + { + "contact": None, + "contacts": [], + } + ) + linked_pg_data.save(ignore_permissions=True) + except (jingrow.DoesNotExistError, jingrow.ValidationError): + pass + + +@jingrow.whitelist() +def remove_linked_pg_reference(items, remove_contact=None, delete=False): + if isinstance(items, str): + items = jingrow.parse_json(items) + + for item in items: + if not item.get("pagetype") or not item.get("docname"): + continue + + try: + if remove_contact: + remove_contact_link(item["pagetype"], item["docname"]) + else: + remove_pg_link(item["pagetype"], item["docname"]) + if delete: + jingrow.delete_pg(item["pagetype"], item["docname"]) + except (jingrow.DoesNotExistError, jingrow.ValidationError): + # Skip if document doesn't exist or has validation errors + continue + + return "success" + + +@jingrow.whitelist() +def delete_bulk_docs(pagetype, items, delete_linked=False): + from jingrow.desk.reportview import delete_bulk + + if not pagetype: + jingrow.throw("Pagetype is required") + + if not items: + jingrow.throw("Items are required") + + items = jingrow.parse_json(items) + if not isinstance(items, list): + jingrow.throw("Items must be a list") + + for pg in items: + try: + if not jingrow.db.exists(pagetype, pg): + jingrow.log_error(f"Document {pagetype} {pg} does not exist", "Bulk Delete Error") + continue + + linked_docs = get_linked_docs_of_document(pagetype, pg) + for linked_pg in linked_docs: + if not linked_pg.get("reference_pagetype") or not linked_pg.get("reference_docname"): + continue + + remove_linked_pg_reference( + [ + { + "pagetype": linked_pg["reference_pagetype"], + "docname": linked_pg["reference_docname"], + } + ], + remove_contact=pagetype == "Contact", + delete=delete_linked, + ) + except Exception as e: + jingrow.log_error( + f"Error processing linked docs for {pagetype} {pg}: {str(e)}", "Bulk Delete Error" + ) + + if len(items) > 10: + jingrow.enqueue("jingrow.desk.reportview.delete_bulk", pagetype=pagetype, items=items) + else: + delete_bulk(pagetype, items) + return "success" diff --git a/crm/api/session.py b/crm/api/session.py new file mode 100644 index 0000000..962fe30 --- /dev/null +++ b/crm/api/session.py @@ -0,0 +1,63 @@ +import jingrow + + +@jingrow.whitelist() +def get_users(): + users = jingrow.qb.get_query( + "User", + fields=[ + "name", + "email", + "enabled", + "user_image", + "first_name", + "last_name", + "full_name", + "user_type", + ], + order_by="full_name asc", + distinct=True, + ).run(as_dict=1) + + for user in users: + if jingrow.session.user == user.name: + user.session_user = True + + user.roles = jingrow.get_roles(user.name) + + user.role = "" + + if "System Manager" in user.roles: + user.role = "System Manager" + elif "Sales Manager" in user.roles: + user.role = "Sales Manager" + elif "Sales User" in user.roles: + user.role = "Sales User" + elif "Guest" in user.roles: + user.role = "Guest" + + if jingrow.session.user == user.name: + user.session_user = True + + user.is_telephony_agent = jingrow.db.exists("CRM Telephony Agent", {"user": user.name}) + + crm_users = [] + + # crm users are users with role Sales User or Sales Manager + for user in users: + if "Sales User" in user.roles or "Sales Manager" in user.roles: + crm_users.append(user) + + return users, crm_users + + +@jingrow.whitelist() +def get_organizations(): + organizations = jingrow.qb.get_query( + "CRM Organization", + fields=["*"], + order_by="name asc", + distinct=True, + ).run(as_dict=1) + + return organizations diff --git a/crm/api/settings.py b/crm/api/settings.py new file mode 100644 index 0000000..c68fb1d --- /dev/null +++ b/crm/api/settings.py @@ -0,0 +1,99 @@ +import jingrow + + +@jingrow.whitelist() +def create_email_account(data): + service = data.get("service") + service_config = email_service_config.get(service) + if not service_config: + return "Service not supported" + + try: + email_pg = jingrow.get_pg( + { + "pagetype": "Email Account", + "email_id": data.get("email_id"), + "email_account_name": data.get("email_account_name"), + "service": service, + "enable_incoming": data.get("enable_incoming"), + "enable_outgoing": data.get("enable_outgoing"), + "default_incoming": data.get("default_incoming"), + "default_outgoing": data.get("default_outgoing"), + "email_sync_option": "ALL", + "initial_sync_count": 100, + "create_contact": 1, + "track_email_status": 1, + "use_tls": 1, + "use_imap": 1, + "smtp_port": 587, + **service_config, + } + ) + if service == "Jingrow Mail": + email_pg.api_key = data.get("api_key") + email_pg.api_secret = data.get("api_secret") + email_pg.jingrow_mail_site = data.get("jingrow_mail_site") + email_pg.append_to = "CRM Lead" + else: + email_pg.append("imap_folder", {"append_to": "CRM Lead", "folder_name": "INBOX"}) + email_pg.password = data.get("password") + # validate whether the credentials are correct + email_pg.get_incoming_server() + + # if correct credentials, save the email account + email_pg.save() + except Exception as e: + jingrow.throw(str(e)) + + +email_service_config = { + "Jingrow Mail": { + "domain": None, + "password": None, + "awaiting_password": 0, + "ascii_encode_password": 0, + "login_id_is_different": 0, + "login_id": None, + "use_imap": 0, + "use_ssl": 0, + "validate_ssl_certificate": 0, + "use_starttls": 0, + "email_server": None, + "incoming_port": 0, + "always_use_account_email_id_as_sender": 1, + "use_tls": 0, + "use_ssl_for_outgoing": 0, + "smtp_server": None, + "smtp_port": None, + "no_smtp_authentication": 0, + }, + "GMail": { + "email_server": "imap.gmail.com", + "use_ssl": 1, + "smtp_server": "smtp.gmail.com", + }, + "Outlook": { + "email_server": "imap-mail.outlook.com", + "use_ssl": 1, + "smtp_server": "smtp-mail.outlook.com", + }, + "Sendgrid": { + "smtp_server": "smtp.sendgrid.net", + "smtp_port": 587, + }, + "SparkPost": { + "smtp_server": "smtp.sparkpostmail.com", + }, + "Yahoo": { + "email_server": "imap.mail.yahoo.com", + "use_ssl": 1, + "smtp_server": "smtp.mail.yahoo.com", + "smtp_port": 587, + }, + "Yandex": { + "email_server": "imap.yandex.com", + "use_ssl": 1, + "smtp_server": "smtp.yandex.com", + "smtp_port": 587, + }, +} diff --git a/crm/api/todo.py b/crm/api/todo.py new file mode 100644 index 0000000..c9f6f32 --- /dev/null +++ b/crm/api/todo.py @@ -0,0 +1,121 @@ +import jingrow +from jingrow import _ + +from crm.fcrm.pagetype.crm_notification.crm_notification import notify_user + + +def after_insert(pg, method): + if pg.reference_type in ["CRM Lead", "CRM Deal"] and pg.reference_name and pg.allocated_to: + fieldname = "lead_owner" if pg.reference_type == "CRM Lead" else "deal_owner" + owner = jingrow.db.get_value(pg.reference_type, pg.reference_name, fieldname) + if not owner: + jingrow.db.set_value( + pg.reference_type, pg.reference_name, fieldname, pg.allocated_to, update_modified=False + ) + + if pg.reference_type in ["CRM Lead", "CRM Deal", "CRM Task"] and pg.reference_name and pg.allocated_to: + notify_assigned_user(pg) + + +def on_update(pg, method): + if ( + pg.has_value_changed("status") + and pg.status == "Cancelled" + and pg.reference_type in ["CRM Lead", "CRM Deal", "CRM Task"] + and pg.reference_name + and pg.allocated_to + ): + notify_assigned_user(pg, is_cancelled=True) + + +def notify_assigned_user(pg, is_cancelled=False): + _pg = jingrow.get_pg(pg.reference_type, pg.reference_name) + owner = jingrow.get_cached_value("User", jingrow.session.user, "full_name") + notification_text = get_notification_text(owner, pg, _pg, is_cancelled) + + message = ( + _("Your assignment on {0} {1} has been removed by {2}").format( + pg.reference_type, pg.reference_name, owner + ) + if is_cancelled + else _("{0} assigned a {1} {2} to you").format(owner, pg.reference_type, pg.reference_name) + ) + + redirect_to_pagetype, redirect_to_name = get_redirect_to_pg(pg) + + notify_user( + { + "owner": jingrow.session.user, + "assigned_to": pg.allocated_to, + "notification_type": "Assignment", + "message": message, + "notification_text": notification_text, + "reference_pagetype": pg.reference_type, + "reference_docname": pg.reference_name, + "redirect_to_pagetype": redirect_to_pagetype, + "redirect_to_docname": redirect_to_name, + } + ) + + +def get_notification_text(owner, pg, reference_pg, is_cancelled=False): + name = pg.reference_name + pagetype = pg.reference_type + + if pagetype.startswith("CRM "): + pagetype = pagetype[4:].lower() + + if pagetype in ["lead", "deal"]: + name = ( + reference_pg.lead_name or name + if pagetype == "lead" + else reference_pg.organization or reference_pg.lead_name or name + ) + + if is_cancelled: + return f""" +
+ { _('Your assignment on {0} {1} has been removed by {2}').format( + pagetype, + f'{ name }', + f'{ owner }' + ) } +
+ """ + + return f""" +
+ { owner } + { _('assigned a {0} {1} to you').format( + pagetype, + f'{ name }' + ) } +
+ """ + + if pagetype == "task": + if is_cancelled: + return f""" +
+ { _('Your assignment on task {0} has been removed by {1}').format( + f'{ reference_pg.title }', + f'{ owner }' + ) } +
+ """ + return f""" +
+ { owner } + { _('assigned a new task {0} to you').format( + f'{ reference_pg.title }' + ) } +
+ """ + + +def get_redirect_to_pg(pg): + if pg.reference_type == "CRM Task": + reference_pg = jingrow.get_pg(pg.reference_type, pg.reference_name) + return reference_pg.reference_pagetype, reference_pg.reference_docname + + return pg.reference_type, pg.reference_name diff --git a/crm/api/user.py b/crm/api/user.py new file mode 100644 index 0000000..cfbcf4a --- /dev/null +++ b/crm/api/user.py @@ -0,0 +1,84 @@ +import jingrow + + +@jingrow.whitelist() +def add_existing_users(users, role="Sales User"): + """ + Add existing users to the CRM by assigning them a role (Sales User or Sales Manager). + :param users: List of user names to be added + """ + jingrow.only_for(["System Manager", "Sales Manager"]) + users = jingrow.parse_json(users) + + for user in users: + add_user(user, role) + + +@jingrow.whitelist() +def update_user_role(user, new_role): + """ + Update the role of the user to Sales Manager, Sales User, or System Manager. + :param user: The name of the user + :param new_role: The new role to assign (Sales Manager or Sales User) + """ + + jingrow.only_for(["System Manager", "Sales Manager"]) + + if new_role not in ["System Manager", "Sales Manager", "Sales User"]: + jingrow.throw("Cannot assign this role") + + user_pg = jingrow.get_pg("User", user) + + if new_role == "System Manager": + user_pg.append_roles("System Manager", "Sales Manager", "Sales User") + user_pg.set("block_modules", []) + if new_role == "Sales Manager": + user_pg.append_roles("Sales Manager", "Sales User") + user_pg.remove_roles("System Manager") + if new_role == "Sales User": + user_pg.append_roles("Sales User") + user_pg.remove_roles("Sales Manager", "System Manager") + update_module_in_user(user_pg, "FCRM") + + user_pg.save(ignore_permissions=True) + + +@jingrow.whitelist() +def add_user(user, role): + """ + Add a user means adding role (Sales User or/and Sales Manager) to the user. + :param user: The name of the user to be added + :param role: The role to be assigned (Sales User or Sales Manager) + """ + update_user_role(user, role) + + +@jingrow.whitelist() +def remove_user(user): + """ + Remove a user means removing Sales User & Sales Manager roles from the user. + :param user: The name of the user to be removed + """ + jingrow.only_for(["System Manager", "Sales Manager"]) + + user_pg = jingrow.get_pg("User", user) + roles = [d.role for d in user_pg.roles] + + if "Sales User" in roles: + user_pg.remove_roles("Sales User") + if "Sales Manager" in roles: + user_pg.remove_roles("Sales Manager") + + user_pg.save(ignore_permissions=True) + jingrow.msgprint(f"User {user} has been removed from CRM roles.") + + +def update_module_in_user(user, module): + block_modules = jingrow.get_all( + "Module Def", + fields=["name as module"], + filters={"name": ["!=", module]}, + ) + + if block_modules: + user.set("block_modules", block_modules) diff --git a/crm/api/views.py b/crm/api/views.py new file mode 100644 index 0000000..3a2247f --- /dev/null +++ b/crm/api/views.py @@ -0,0 +1,16 @@ +import jingrow +from pypika import Criterion + + +@jingrow.whitelist() +def get_views(pagetype): + View = jingrow.qb.PageType("CRM View Settings") + query = ( + jingrow.qb.from_(View) + .select("*") + .where(Criterion.any([View.user == "", View.user == jingrow.session.user])) + ) + if pagetype: + query = query.where(View.dt == pagetype) + views = query.run(as_dict=True) + return views diff --git a/crm/api/whatsapp.py b/crm/api/whatsapp.py new file mode 100644 index 0000000..dd92e33 --- /dev/null +++ b/crm/api/whatsapp.py @@ -0,0 +1,346 @@ +import json + +import jingrow +from jingrow import _ + +from crm.api.pg import get_assigned_users +from crm.fcrm.pagetype.crm_notification.crm_notification import notify_user + + +def validate(pg, method): + if pg.type == "Incoming" and pg.get("from"): + name, pagetype = get_lead_or_deal_from_number(pg.get("from")) + if name != None: + pg.reference_pagetype = pagetype + pg.reference_name = name + + if pg.type == "Outgoing" and pg.get("to"): + name, pagetype = get_lead_or_deal_from_number(pg.get("to")) + if name != None: + pg.reference_pagetype = pagetype + pg.reference_name = name + + +def on_update(pg, method): + jingrow.publish_realtime( + "whatsapp_message", + { + "reference_pagetype": pg.reference_pagetype, + "reference_name": pg.reference_name, + }, + ) + + notify_agent(pg) + + +def notify_agent(pg): + if pg.type == "Incoming": + pagetype = pg.reference_pagetype + if pagetype and pagetype.startswith("CRM "): + pagetype = pagetype[4:].lower() + notification_text = f""" +
+ { _('You') } + { _('received a whatsapp message in {0}').format(pagetype) } + { pg.reference_name } +
+ """ + assigned_users = get_assigned_users(pg.reference_pagetype, pg.reference_name) + for user in assigned_users: + notify_user( + { + "owner": pg.owner, + "assigned_to": user, + "notification_type": "WhatsApp", + "message": pg.message, + "notification_text": notification_text, + "reference_pagetype": "WhatsApp Message", + "reference_docname": pg.name, + "redirect_to_pagetype": pg.reference_pagetype, + "redirect_to_docname": pg.reference_name, + } + ) + + +def get_lead_or_deal_from_number(number): + """Get lead/deal from the given number.""" + + def find_record(pagetype, mobile_no, where=""): + mobile_no = parse_mobile_no(mobile_no) + + query = f""" + SELECT name, mobile_no + FROM `tab{pagetype}` + WHERE CONCAT('+', REGEXP_REPLACE(mobile_no, '[^0-9]', '')) = {mobile_no} + """ + + data = jingrow.db.sql(query + where, as_dict=True) + return data[0].name if data else None + + pagetype = "CRM Deal" + + pg = find_record(pagetype, number) or None + if not pg: + pagetype = "CRM Lead" + pg = find_record(pagetype, number, "AND converted is not True") + if not pg: + pg = find_record(pagetype, number) + + return pg, pagetype + + +def parse_mobile_no(mobile_no: str): + """Parse mobile number to remove spaces, brackets, etc. + >>> parse_mobile_no("+91 (766) 667 6666") + ... "+917666676666" + """ + return "".join([c for c in mobile_no if c.isdigit() or c == "+"]) + + +@jingrow.whitelist() +def is_whatsapp_enabled(): + if not jingrow.db.exists("PageType", "WhatsApp Settings"): + return False + return jingrow.get_cached_value("WhatsApp Settings", "WhatsApp Settings", "enabled") + + +@jingrow.whitelist() +def is_whatsapp_installed(): + if not jingrow.db.exists("PageType", "WhatsApp Settings"): + return False + return True + + +@jingrow.whitelist() +def get_whatsapp_messages(reference_pagetype, reference_name): + # twilio integration app is not compatible with crm app + # crm has its own twilio integration in built + if "twilio_integration" in jingrow.get_installed_apps(): + return [] + if not jingrow.db.exists("PageType", "WhatsApp Message"): + return [] + messages = [] + + if reference_pagetype == "CRM Deal": + lead = jingrow.db.get_value(reference_pagetype, reference_name, "lead") + if lead: + messages = jingrow.get_all( + "WhatsApp Message", + filters={ + "reference_pagetype": "CRM Lead", + "reference_name": lead, + }, + fields=[ + "name", + "type", + "to", + "from", + "content_type", + "message_type", + "attach", + "template", + "use_template", + "message_id", + "is_reply", + "reply_to_message_id", + "creation", + "message", + "status", + "reference_pagetype", + "reference_name", + "template_parameters", + "template_header_parameters", + ], + ) + + messages += jingrow.get_all( + "WhatsApp Message", + filters={ + "reference_pagetype": reference_pagetype, + "reference_name": reference_name, + }, + fields=[ + "name", + "type", + "to", + "from", + "content_type", + "message_type", + "attach", + "template", + "use_template", + "message_id", + "is_reply", + "reply_to_message_id", + "creation", + "message", + "status", + "reference_pagetype", + "reference_name", + "template_parameters", + "template_header_parameters", + ], + ) + + # Filter messages to get only Template messages + template_messages = [message for message in messages if message["message_type"] == "Template"] + + # Iterate through template messages + for template_message in template_messages: + # Find the template that this message is using + template = jingrow.get_pg("WhatsApp Templates", template_message["template"]) + + # If the template is found, add the template details to the template message + if template: + template_message["template_name"] = template.template_name + if template_message["template_parameters"]: + parameters = json.loads(template_message["template_parameters"]) + template.template = parse_template_parameters(template.template, parameters) + + template_message["template"] = template.template + if template_message["template_header_parameters"]: + header_parameters = json.loads(template_message["template_header_parameters"]) + template.header = parse_template_parameters(template.header, header_parameters) + template_message["header"] = template.header + template_message["footer"] = template.footer + + # Filter messages to get only reaction messages + reaction_messages = [message for message in messages if message["content_type"] == "reaction"] + + # Iterate through reaction messages + for reaction_message in reaction_messages: + # Find the message that this reaction is reacting to + reacted_message = next( + (m for m in messages if m["message_id"] == reaction_message["reply_to_message_id"]), + None, + ) + + # If the reacted message is found, add the reaction to it + if reacted_message: + reacted_message["reaction"] = reaction_message["message"] + + for message in messages: + from_name = get_from_name(message) if message["from"] else _("You") + message["from_name"] = from_name + # Filter messages to get only replies + reply_messages = [message for message in messages if message["is_reply"]] + + # Iterate through reply messages + for reply_message in reply_messages: + # Find the message that this message is replying to + replied_message = next( + (m for m in messages if m["message_id"] == reply_message["reply_to_message_id"]), + None, + ) + + # If the replied message is found, add the reply details to the reply message + from_name = get_from_name(reply_message) if replied_message["from"] else _("You") + if replied_message: + message = replied_message["message"] + if replied_message["message_type"] == "Template": + message = replied_message["template"] + reply_message["reply_message"] = message + reply_message["header"] = replied_message.get("header") or "" + reply_message["footer"] = replied_message.get("footer") or "" + reply_message["reply_to"] = replied_message["name"] + reply_message["reply_to_type"] = replied_message["type"] + reply_message["reply_to_from"] = from_name + + return [message for message in messages if message["content_type"] != "reaction"] + + +@jingrow.whitelist() +def create_whatsapp_message( + reference_pagetype, + reference_name, + message, + to, + attach, + reply_to, + content_type="text", +): + pg = jingrow.new_pg("WhatsApp Message") + + if reply_to: + reply_pg = jingrow.get_pg("WhatsApp Message", reply_to) + pg.update( + { + "is_reply": True, + "reply_to_message_id": reply_pg.message_id, + } + ) + + pg.update( + { + "reference_pagetype": reference_pagetype, + "reference_name": reference_name, + "message": message or attach, + "to": to, + "attach": attach, + "content_type": content_type, + } + ) + pg.insert(ignore_permissions=True) + return pg.name + + +@jingrow.whitelist() +def send_whatsapp_template(reference_pagetype, reference_name, template, to): + pg = jingrow.new_pg("WhatsApp Message") + pg.update( + { + "reference_pagetype": reference_pagetype, + "reference_name": reference_name, + "message_type": "Template", + "message": "Template message", + "content_type": "text", + "use_template": True, + "template": template, + "to": to, + } + ) + pg.insert(ignore_permissions=True) + return pg.name + + +@jingrow.whitelist() +def react_on_whatsapp_message(emoji, reply_to_name): + reply_to_pg = jingrow.get_pg("WhatsApp Message", reply_to_name) + to = reply_to_pg.type == "Incoming" and reply_to_pg.get("from") or reply_to_pg.to + pg = jingrow.new_pg("WhatsApp Message") + pg.update( + { + "reference_pagetype": reply_to_pg.reference_pagetype, + "reference_name": reply_to_pg.reference_name, + "message": emoji, + "to": to, + "reply_to_message_id": reply_to_pg.message_id, + "content_type": "reaction", + } + ) + pg.insert(ignore_permissions=True) + return pg.name + + +def parse_template_parameters(string, parameters): + for i, parameter in enumerate(parameters, start=1): + placeholder = "{{" + str(i) + "}}" + string = string.replace(placeholder, parameter) + + return string + + +def get_from_name(message): + pg = jingrow.get_pg(message["reference_pagetype"], message["reference_name"]) + from_name = "" + if message["reference_pagetype"] == "CRM Deal": + if pg.get("contacts"): + for c in pg.get("contacts"): + if c.is_primary: + from_name = c.full_name or c.mobile_no + break + else: + from_name = pg.get("lead_name") + else: + from_name = " ".join(filter(None, [pg.get("first_name"), pg.get("last_name")])) + return from_name diff --git a/crm/config/__init__.py b/crm/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/crowdin.yml b/crm/crowdin.yml new file mode 100644 index 0000000..aebaa70 --- /dev/null +++ b/crm/crowdin.yml @@ -0,0 +1,8 @@ +files: + - source: /crm/locale/main.pot + translation: /crm/locale/%two_letters_code%.po +pull_request_title: "chore: sync translations from crowdin" +pull_request_labels: + - translation +commit_message: "chore: %language% translations" +append_commit_message: false \ No newline at end of file diff --git a/crm/fcrm/__init__.py b/crm/fcrm/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/__init__.py b/crm/fcrm/pagetype/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_call_log/__init__.py b/crm/fcrm/pagetype/crm_call_log/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_call_log/crm_call_log.js b/crm/fcrm/pagetype/crm_call_log/crm_call_log.js new file mode 100644 index 0000000..4d172dd --- /dev/null +++ b/crm/fcrm/pagetype/crm_call_log/crm_call_log.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Call Log", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_call_log/crm_call_log.json b/crm/fcrm/pagetype/crm_call_log/crm_call_log.json new file mode 100644 index 0000000..b4b8259 --- /dev/null +++ b/crm/fcrm/pagetype/crm_call_log/crm_call_log.json @@ -0,0 +1,195 @@ +{ + "actions": [], + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:id", + "creation": "2023-08-28 00:23:36.229137", + "default_view": "List", + "pagetype": "PageType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "telephony_medium", + "section_break_gyqe", + "id", + "from", + "status", + "duration", + "medium", + "start_time", + "reference_pagetype", + "reference_docname", + "column_break_ufnp", + "to", + "type", + "receiver", + "caller", + "recording_url", + "end_time", + "note", + "section_break_kebz", + "links" + ], + "fields": [ + { + "fieldname": "id", + "fieldtype": "Data", + "label": "ID", + "unique": 1 + }, + { + "fieldname": "from", + "fieldtype": "Data", + "in_list_view": 1, + "label": "From", + "reqd": 1 + }, + { + "fieldname": "status", + "fieldtype": "Select", + "label": "Status", + "options": "Initiated\nRinging\nIn Progress\nCompleted\nFailed\nBusy\nNo Answer\nQueued\nCanceled", + "reqd": 1 + }, + { + "fieldname": "start_time", + "fieldtype": "Datetime", + "label": "Start Time" + }, + { + "fieldname": "medium", + "fieldtype": "Data", + "label": "Medium" + }, + { + "fieldname": "column_break_ufnp", + "fieldtype": "Column Break" + }, + { + "fieldname": "type", + "fieldtype": "Select", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Type", + "options": "Incoming\nOutgoing", + "reqd": 1 + }, + { + "fieldname": "to", + "fieldtype": "Data", + "in_list_view": 1, + "label": "To", + "reqd": 1 + }, + { + "description": "Call duration in seconds", + "fieldname": "duration", + "fieldtype": "Duration", + "in_list_view": 1, + "label": "Duration" + }, + { + "fieldname": "recording_url", + "fieldtype": "Data", + "label": "Recording URL" + }, + { + "fieldname": "end_time", + "fieldtype": "Datetime", + "label": "End Time" + }, + { + "fieldname": "note", + "fieldtype": "Link", + "label": "Note", + "options": "FCRM Note" + }, + { + "depends_on": "eval:pg.type == 'Incoming'", + "fieldname": "receiver", + "fieldtype": "Link", + "label": "Call Received By", + "options": "User" + }, + { + "depends_on": "eval:pg.type == 'Outgoing'", + "fieldname": "caller", + "fieldtype": "Link", + "label": "Caller", + "options": "User" + }, + { + "default": "CRM Lead", + "fieldname": "reference_pagetype", + "fieldtype": "Link", + "label": "Reference Document Type", + "options": "PageType" + }, + { + "fieldname": "reference_docname", + "fieldtype": "Dynamic Link", + "label": "Reference Name", + "options": "reference_pagetype" + }, + { + "fieldname": "section_break_kebz", + "fieldtype": "Section Break" + }, + { + "fieldname": "links", + "fieldtype": "Table", + "label": "Links", + "options": "Dynamic Link" + }, + { + "fieldname": "telephony_medium", + "fieldtype": "Select", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Telephony Medium", + "options": "\nManual\nTwilio\nExotel", + "read_only": 1 + }, + { + "fieldname": "section_break_gyqe", + "fieldtype": "Section Break" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-04-01 16:01:54.479309", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Call Log", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_call_log/crm_call_log.py b/crm/fcrm/pagetype/crm_call_log/crm_call_log.py new file mode 100644 index 0000000..22cbf5b --- /dev/null +++ b/crm/fcrm/pagetype/crm_call_log/crm_call_log.py @@ -0,0 +1,214 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow.model.page import Page + +from crm.integrations.api import get_contact_by_phone_number +from crm.utils import seconds_to_duration + + +class CRMCallLog(Page): + @staticmethod + def default_list_data(): + columns = [ + { + "label": "Caller", + "type": "Link", + "key": "caller", + "options": "User", + "width": "9rem", + }, + { + "label": "Receiver", + "type": "Link", + "key": "receiver", + "options": "User", + "width": "9rem", + }, + { + "label": "Type", + "type": "Select", + "key": "type", + "width": "9rem", + }, + { + "label": "Status", + "type": "Select", + "key": "status", + "width": "9rem", + }, + { + "label": "Duration", + "type": "Duration", + "key": "duration", + "width": "6rem", + }, + { + "label": "From (number)", + "type": "Data", + "key": "from", + "width": "9rem", + }, + { + "label": "To (number)", + "type": "Data", + "key": "to", + "width": "9rem", + }, + { + "label": "Created On", + "type": "Datetime", + "key": "creation", + "width": "8rem", + }, + ] + rows = [ + "name", + "caller", + "receiver", + "type", + "status", + "duration", + "from", + "to", + "note", + "recording_url", + "reference_pagetype", + "reference_docname", + "creation", + ] + return {"columns": columns, "rows": rows} + + def parse_list_data(calls): + return [parse_call_log(call) for call in calls] if calls else [] + + def has_link(self, pagetype, name): + for link in self.links: + if link.link_pagetype == pagetype and link.link_name == name: + return True + + def link_with_reference_pg(self, reference_pagetype, reference_name): + if self.has_link(reference_pagetype, reference_name): + return + + self.append("links", {"link_pagetype": reference_pagetype, "link_name": reference_name}) + + +def parse_call_log(call): + call["show_recording"] = False + call["_duration"] = seconds_to_duration(call.get("duration")) + if call.get("type") == "Incoming": + call["activity_type"] = "incoming_call" + contact = get_contact_by_phone_number(call.get("from")) + receiver = ( + jingrow.db.get_values("User", call.get("receiver"), ["full_name", "user_image"])[0] + if call.get("receiver") + else [None, None] + ) + call["_caller"] = { + "label": contact.get("full_name", "Unknown"), + "image": contact.get("image"), + } + call["_receiver"] = { + "label": receiver[0], + "image": receiver[1], + } + elif call.get("type") == "Outgoing": + call["activity_type"] = "outgoing_call" + contact = get_contact_by_phone_number(call.get("to")) + caller = ( + jingrow.db.get_values("User", call.get("caller"), ["full_name", "user_image"])[0] + if call.get("caller") + else [None, None] + ) + call["_caller"] = { + "label": caller[0], + "image": caller[1], + } + call["_receiver"] = { + "label": contact.get("full_name", "Unknown"), + "image": contact.get("image"), + } + + return call + + +@jingrow.whitelist() +def get_call_log(name): + call = jingrow.get_cached_pg( + "CRM Call Log", + name, + fields=[ + "name", + "caller", + "receiver", + "duration", + "type", + "status", + "from", + "to", + "note", + "recording_url", + "reference_pagetype", + "reference_docname", + "creation", + ], + ).as_dict() + + call = parse_call_log(call) + + notes = [] + tasks = [] + + if call.get("note"): + note = jingrow.get_cached_pg("FCRM Note", call.get("note")).as_dict() + notes.append(note) + + if call.get("reference_pagetype") and call.get("reference_docname"): + if call.get("reference_pagetype") == "CRM Lead": + call["_lead"] = call.get("reference_docname") + elif call.get("reference_pagetype") == "CRM Deal": + call["_deal"] = call.get("reference_docname") + + if call.get("links"): + for link in call.get("links"): + if link.get("link_pagetype") == "CRM Task": + task = jingrow.get_cached_pg("CRM Task", link.get("link_name")).as_dict() + tasks.append(task) + elif link.get("link_pagetype") == "FCRM Note": + note = jingrow.get_cached_pg("FCRM Note", link.get("link_name")).as_dict() + notes.append(note) + elif link.get("link_pagetype") == "CRM Lead": + call["_lead"] = link.get("link_name") + elif link.get("link_pagetype") == "CRM Deal": + call["_deal"] = link.get("link_name") + + call["_tasks"] = tasks + call["_notes"] = notes + return call + + +@jingrow.whitelist() +def create_lead_from_call_log(call_log, lead_details=None): + lead = jingrow.new_pg("CRM Lead") + lead_details = jingrow.parse_json(lead_details or "{}") + + if not lead_details.get("lead_owner"): + lead_details["lead_owner"] = jingrow.session.user + if not lead_details.get("mobile_no"): + lead_details["mobile_no"] = call_log.get("from") or "" + if not lead_details.get("first_name"): + lead_details["first_name"] = "Lead from call " + ( + lead_details.get("mobile_no") or call_log.get("name") + ) + + lead.update(lead_details) + lead.save(ignore_permissions=True) + + # link call log with lead + call_log = jingrow.get_pg("CRM Call Log", call_log.get("name")) + call_log.link_with_reference_pg("CRM Lead", lead.name) + call_log.save(ignore_permissions=True) + + return lead.name diff --git a/crm/fcrm/pagetype/crm_call_log/test_crm_call_log.py b/crm/fcrm/pagetype/crm_call_log/test_crm_call_log.py new file mode 100644 index 0000000..0705037 --- /dev/null +++ b/crm/fcrm/pagetype/crm_call_log/test_crm_call_log.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMCallLog(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_communication_status/__init__.py b/crm/fcrm/pagetype/crm_communication_status/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_communication_status/crm_communication_status.js b/crm/fcrm/pagetype/crm_communication_status/crm_communication_status.js new file mode 100644 index 0000000..50e40b6 --- /dev/null +++ b/crm/fcrm/pagetype/crm_communication_status/crm_communication_status.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Communication Status", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_communication_status/crm_communication_status.json b/crm/fcrm/pagetype/crm_communication_status/crm_communication_status.json new file mode 100644 index 0000000..a3a668b --- /dev/null +++ b/crm/fcrm/pagetype/crm_communication_status/crm_communication_status.json @@ -0,0 +1,59 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:status", + "creation": "2023-12-13 13:25:07.213100", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "status" + ], + "fields": [ + { + "fieldname": "status", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Status", + "reqd": 1, + "unique": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2024-01-19 21:55:17.952032", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Communication Status", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_communication_status/crm_communication_status.py b/crm/fcrm/pagetype/crm_communication_status/crm_communication_status.py new file mode 100644 index 0000000..aebb4da --- /dev/null +++ b/crm/fcrm/pagetype/crm_communication_status/crm_communication_status.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMCommunicationStatus(Page): + pass diff --git a/crm/fcrm/pagetype/crm_communication_status/test_crm_communication_status.py b/crm/fcrm/pagetype/crm_communication_status/test_crm_communication_status.py new file mode 100644 index 0000000..21df486 --- /dev/null +++ b/crm/fcrm/pagetype/crm_communication_status/test_crm_communication_status.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMCommunicationStatus(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_contacts/__init__.py b/crm/fcrm/pagetype/crm_contacts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_contacts/crm_contacts.json b/crm/fcrm/pagetype/crm_contacts/crm_contacts.json new file mode 100644 index 0000000..294844d --- /dev/null +++ b/crm/fcrm/pagetype/crm_contacts/crm_contacts.json @@ -0,0 +1,91 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2023-08-25 19:08:36.356133", + "pagetype": "PageType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "contact", + "full_name", + "email", + "column_break_uvny", + "gender", + "mobile_no", + "phone", + "is_primary" + ], + "fields": [ + { + "fieldname": "contact", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Contact", + "options": "Contact" + }, + { + "fetch_from": "contact.full_name", + "fieldname": "full_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Full Name", + "read_only": 1 + }, + { + "fetch_from": "contact.email_id", + "fieldname": "email", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Email", + "read_only": 1 + }, + { + "fieldname": "column_break_uvny", + "fieldtype": "Column Break" + }, + { + "fetch_from": "contact.mobile_no", + "fieldname": "mobile_no", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Mobile No", + "options": "Phone", + "read_only": 1 + }, + { + "fetch_from": "contact.phone", + "fieldname": "phone", + "fieldtype": "Data", + "label": "Phone", + "options": "Phone", + "read_only": 1 + }, + { + "fetch_from": "contact.gender", + "fieldname": "gender", + "fieldtype": "Link", + "label": "Gender", + "options": "Gender", + "read_only": 1 + }, + { + "default": "0", + "fieldname": "is_primary", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Is Primary" + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2023-11-12 14:58:18.846919", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Contacts", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_contacts/crm_contacts.py b/crm/fcrm/pagetype/crm_contacts/crm_contacts.py new file mode 100644 index 0000000..eb09fee --- /dev/null +++ b/crm/fcrm/pagetype/crm_contacts/crm_contacts.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMContacts(Page): + pass diff --git a/crm/fcrm/pagetype/crm_dashboard/__init__.py b/crm/fcrm/pagetype/crm_dashboard/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_dashboard/crm_dashboard.js b/crm/fcrm/pagetype/crm_dashboard/crm_dashboard.js new file mode 100644 index 0000000..3279c0a --- /dev/null +++ b/crm/fcrm/pagetype/crm_dashboard/crm_dashboard.js @@ -0,0 +1,8 @@ +// Copyright (c) 2025, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Dashboard", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_dashboard/crm_dashboard.json b/crm/fcrm/pagetype/crm_dashboard/crm_dashboard.json new file mode 100644 index 0000000..edb9d58 --- /dev/null +++ b/crm/fcrm/pagetype/crm_dashboard/crm_dashboard.json @@ -0,0 +1,105 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:title", + "creation": "2025-07-14 12:19:49.725022", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "title", + "private", + "column_break_exbw", + "user", + "section_break_hfza", + "layout" + ], + "fields": [ + { + "fieldname": "column_break_exbw", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_hfza", + "fieldtype": "Section Break" + }, + { + "default": "[]", + "fieldname": "layout", + "fieldtype": "Code", + "label": "Layout", + "options": "JSON" + }, + { + "fieldname": "title", + "fieldtype": "Data", + "label": "Name", + "unique": 1 + }, + { + "depends_on": "private", + "fieldname": "user", + "fieldtype": "Link", + "label": "User", + "mandatory_depends_on": "private", + "options": "User" + }, + { + "default": "0", + "fieldname": "private", + "fieldtype": "Check", + "label": "Private" + } + ], + "grid_page_length": 50, + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-07-14 12:36:10.831351", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Dashboard", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + } + ], + "row_format": "Dynamic", + "sort_field": "creation", + "sort_order": "DESC", + "states": [], + "title_field": "title" +} diff --git a/crm/fcrm/pagetype/crm_dashboard/crm_dashboard.py b/crm/fcrm/pagetype/crm_dashboard/crm_dashboard.py new file mode 100644 index 0000000..8dc9e71 --- /dev/null +++ b/crm/fcrm/pagetype/crm_dashboard/crm_dashboard.py @@ -0,0 +1,34 @@ +# Copyright (c) 2025, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow import _ +from jingrow.model.page import Page + + +class CRMDashboard(Page): + pass + + +def default_manager_dashboard_layout(): + """ + Returns the default layout for the CRM Manager Dashboard. + """ + return '[{"name":"total_leads","type":"number_chart","tooltip":"Total number of leads","layout":{"x":0,"y":0,"w":4,"h":3,"i":"total_leads"}},{"name":"ongoing_deals","type":"number_chart","tooltip":"Total number of ongoing deals","layout":{"x":8,"y":0,"w":4,"h":3,"i":"ongoing_deals"}},{"name":"won_deals","type":"number_chart","tooltip":"Total number of won deals","layout":{"x":12,"y":0,"w":4,"h":3,"i":"won_deals"}},{"name":"average_won_deal_value","type":"number_chart","tooltip":"Average value of won deals","layout":{"x":16,"y":0,"w":4,"h":3,"i":"average_won_deal_value"}},{"name":"average_deal_value","type":"number_chart","tooltip":"Average deal value of ongoing and won deals","layout":{"x":0,"y":2,"w":4,"h":3,"i":"average_deal_value"}},{"name":"average_time_to_close_a_lead","type":"number_chart","tooltip":"Average time taken to close a lead","layout":{"x":4,"y":0,"w":4,"h":3,"i":"average_time_to_close_a_lead"}},{"name":"average_time_to_close_a_deal","type":"number_chart","layout":{"x":4,"y":2,"w":4,"h":3,"i":"average_time_to_close_a_deal"}},{"name":"spacer","type":"spacer","layout":{"x":8,"y":2,"w":12,"h":3,"i":"spacer"}},{"name":"sales_trend","type":"axis_chart","layout":{"x":0,"y":4,"w":10,"h":9,"i":"sales_trend"}},{"name":"forecasted_revenue","type":"axis_chart","layout":{"x":10,"y":4,"w":10,"h":9,"i":"forecasted_revenue"}},{"name":"funnel_conversion","type":"axis_chart","layout":{"x":0,"y":11,"w":10,"h":9,"i":"funnel_conversion"}},{"name":"deals_by_stage_donut","type":"donut_chart","layout":{"x":10,"y":11,"w":10,"h":9,"i":"deals_by_stage_donut"}},{"name":"lost_deal_reasons","type":"axis_chart","layout":{"x":0,"y":32,"w":20,"h":9,"i":"lost_deal_reasons"}},{"name":"leads_by_source","type":"donut_chart","layout":{"x":0,"y":18,"w":10,"h":9,"i":"leads_by_source"}},{"name":"deals_by_source","type":"donut_chart","layout":{"x":10,"y":18,"w":10,"h":9,"i":"deals_by_source"}},{"name":"deals_by_territory","type":"axis_chart","layout":{"x":0,"y":25,"w":10,"h":9,"i":"deals_by_territory"}},{"name":"deals_by_salesperson","type":"axis_chart","layout":{"x":10,"y":25,"w":10,"h":9,"i":"deals_by_salesperson"}}]' + + +def create_default_manager_dashboard(force=False): + """ + Creates the default CRM Manager Dashboard if it does not exist. + """ + if not jingrow.db.exists("CRM Dashboard", "Manager Dashboard"): + pg = jingrow.new_pg("CRM Dashboard") + pg.title = "Manager Dashboard" + pg.layout = default_manager_dashboard_layout() + pg.insert(ignore_permissions=True) + else: + pg = jingrow.get_pg("CRM Dashboard", "Manager Dashboard") + if force: + pg.layout = default_manager_dashboard_layout() + pg.save(ignore_permissions=True) + return pg.layout diff --git a/crm/fcrm/pagetype/crm_dashboard/test_crm_dashboard.py b/crm/fcrm/pagetype/crm_dashboard/test_crm_dashboard.py new file mode 100644 index 0000000..58c94c5 --- /dev/null +++ b/crm/fcrm/pagetype/crm_dashboard/test_crm_dashboard.py @@ -0,0 +1,30 @@ +# Copyright (c) 2025, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import IntegrationTestCase, UnitTestCase + + +# On IntegrationTestCase, the pagetype test records and all +# link-field test record dependencies are recursively loaded +# Use these module variables to add/remove to/from that list +EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] +IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] + + +class UnitTestCRMDashboard(UnitTestCase): + """ + Unit tests for CRMDashboard. + Use this class for testing individual functions and methods. + """ + + pass + + +class IntegrationTestCRMDashboard(IntegrationTestCase): + """ + Integration tests for CRMDashboard. + Use this class for testing interactions between multiple components. + """ + + pass diff --git a/crm/fcrm/pagetype/crm_deal/__init__.py b/crm/fcrm/pagetype/crm_deal/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_deal/api.py b/crm/fcrm/pagetype/crm_deal/api.py new file mode 100644 index 0000000..1fc4a9a --- /dev/null +++ b/crm/fcrm/pagetype/crm_deal/api.py @@ -0,0 +1,29 @@ +import jingrow + + +@jingrow.whitelist() +def get_deal_contacts(name): + contacts = jingrow.get_all( + "CRM Contacts", + filters={"parenttype": "CRM Deal", "parent": name}, + fields=["contact", "is_primary"], + distinct=True, + ) + deal_contacts = [] + for contact in contacts: + if not contact.contact: + continue + + is_primary = contact.is_primary + contact = jingrow.get_pg("Contact", contact.contact).as_dict() + + _contact = { + "name": contact.name, + "image": contact.image, + "full_name": contact.full_name, + "email": contact.email_id, + "mobile_no": contact.mobile_no, + "is_primary": is_primary, + } + deal_contacts.append(_contact) + return deal_contacts diff --git a/crm/fcrm/pagetype/crm_deal/crm_deal.js b/crm/fcrm/pagetype/crm_deal/crm_deal.js new file mode 100644 index 0000000..7a142eb --- /dev/null +++ b/crm/fcrm/pagetype/crm_deal/crm_deal.js @@ -0,0 +1,72 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +jingrow.ui.form.on("CRM Deal", { + refresh(frm) { + frm.add_web_link(`/crm/deals/${frm.pg.name}`, __("Open in Portal")); + }, + update_total: function (frm) { + let total = 0; + let total_qty = 0; + let net_total = 0; + frm.pg.products.forEach((d) => { + total += d.amount; + total_qty += d.qty; + net_total += d.net_amount; + }); + + jingrow.model.set_value(frm.pagetype, frm.docname, "total", total); + jingrow.model.set_value( + frm.pagetype, + frm.docname, + "net_total", + net_total || total + ); + } +}); + +jingrow.ui.form.on("CRM Products", { + products_add: function (frm, cdt, cdn) { + frm.trigger("update_total"); + }, + products_remove: function (frm, cdt, cdn) { + frm.trigger("update_total"); + }, + product_code: function (frm, cdt, cdn) { + let d = jingrow.get_pg(cdt, cdn); + jingrow.model.set_value(cdt, cdn, "product_name", d.product_code); + }, + rate: function (frm, cdt, cdn) { + let d = jingrow.get_pg(cdt, cdn); + if (d.rate && d.qty) { + jingrow.model.set_value(cdt, cdn, "amount", d.rate * d.qty); + } + frm.trigger("update_total"); + }, + qty: function (frm, cdt, cdn) { + let d = jingrow.get_pg(cdt, cdn); + if (d.rate && d.qty) { + jingrow.model.set_value(cdt, cdn, "amount", d.rate * d.qty); + } + frm.trigger("update_total"); + }, + discount_percentage: function (frm, cdt, cdn) { + let d = jingrow.get_pg(cdt, cdn); + if (d.discount_percentage && d.amount) { + discount_amount = (d.discount_percentage / 100) * d.amount; + jingrow.model.set_value( + cdt, + cdn, + "discount_amount", + discount_amount + ); + jingrow.model.set_value( + cdt, + cdn, + "net_amount", + d.amount - discount_amount + ); + } + frm.trigger("update_total"); + } +}); diff --git a/crm/fcrm/pagetype/crm_deal/crm_deal.json b/crm/fcrm/pagetype/crm_deal/crm_deal.json new file mode 100644 index 0000000..587fbb4 --- /dev/null +++ b/crm/fcrm/pagetype/crm_deal/crm_deal.json @@ -0,0 +1,474 @@ +{ + "actions": [], + "allow_import": 1, + "allow_rename": 1, + "autoname": "naming_series:", + "creation": "2023-11-06 17:56:25.210449", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "organization_tab", + "naming_series", + "organization", + "next_step", + "column_break_ijan", + "status", + "deal_owner", + "lost_reason", + "lost_notes", + "section_break_jgpm", + "probability", + "expected_deal_value", + "deal_value", + "column_break_kpxa", + "expected_closure_date", + "closed_date", + "contacts_tab", + "contacts", + "contact", + "lead_details_tab", + "lead", + "source", + "column_break_wsde", + "lead_name", + "organization_details_section", + "organization_name", + "website", + "no_of_employees", + "job_title", + "column_break_xbyf", + "territory", + "currency", + "exchange_rate", + "annual_revenue", + "industry", + "person_section", + "salutation", + "first_name", + "last_name", + "column_break_xjmy", + "email", + "mobile_no", + "phone", + "gender", + "products_tab", + "products", + "section_break_ccbj", + "total", + "column_break_udbq", + "net_total", + "sla_tab", + "sla", + "sla_creation", + "column_break_pfvq", + "sla_status", + "communication_status", + "response_details_section", + "response_by", + "column_break_hpvj", + "first_response_time", + "first_responded_on", + "log_tab", + "status_change_log" + ], + "fields": [ + { + "fieldname": "organization", + "fieldtype": "Link", + "label": "Organization", + "options": "CRM Organization" + }, + { + "fieldname": "probability", + "fieldtype": "Percent", + "label": "Probability" + }, + { + "fetch_from": ".annual_revenue", + "fieldname": "annual_revenue", + "fieldtype": "Currency", + "label": "Annual Revenue", + "options": "currency" + }, + { + "fetch_from": ".website", + "fieldname": "website", + "fieldtype": "Data", + "label": "Website" + }, + { + "fieldname": "next_step", + "fieldtype": "Data", + "label": "Next Step" + }, + { + "fieldname": "lead", + "fieldtype": "Link", + "label": "Lead", + "options": "CRM Lead" + }, + { + "fieldname": "deal_owner", + "fieldtype": "Link", + "label": "Deal Owner", + "options": "User" + }, + { + "default": "CRM-DEAL-.YYYY.-", + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Naming Series", + "options": "CRM-DEAL-.YYYY.-" + }, + { + "fieldname": "contacts_tab", + "fieldtype": "Tab Break", + "label": "Contacts" + }, + { + "fieldname": "email", + "fieldtype": "Data", + "label": "Primary Email", + "options": "Email" + }, + { + "fieldname": "mobile_no", + "fieldtype": "Data", + "label": "Primary Mobile No", + "options": "Phone" + }, + { + "default": "Qualification", + "fieldname": "status", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Status", + "options": "CRM Deal Status", + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "contacts", + "fieldtype": "Table", + "label": "Contacts", + "options": "CRM Contacts" + }, + { + "fieldname": "organization_tab", + "fieldtype": "Tab Break", + "label": "Organization" + }, + { + "fieldname": "sla_tab", + "fieldtype": "Tab Break", + "label": "SLA", + "read_only": 1 + }, + { + "fieldname": "sla", + "fieldtype": "Link", + "label": "SLA", + "options": "CRM Service Level Agreement" + }, + { + "fieldname": "response_by", + "fieldtype": "Datetime", + "label": "Response By", + "read_only": 1 + }, + { + "fieldname": "column_break_pfvq", + "fieldtype": "Column Break" + }, + { + "fieldname": "sla_status", + "fieldtype": "Select", + "label": "SLA Status", + "options": "\nFirst Response Due\nFailed\nFulfilled", + "read_only": 1 + }, + { + "fieldname": "sla_creation", + "fieldtype": "Datetime", + "label": "SLA Creation", + "read_only": 1 + }, + { + "fieldname": "response_details_section", + "fieldtype": "Section Break", + "label": "Response Details" + }, + { + "fieldname": "column_break_hpvj", + "fieldtype": "Column Break" + }, + { + "fieldname": "first_response_time", + "fieldtype": "Duration", + "label": "First Response Time", + "read_only": 1 + }, + { + "fieldname": "first_responded_on", + "fieldtype": "Datetime", + "label": "First Responded On", + "read_only": 1 + }, + { + "default": "Open", + "fieldname": "communication_status", + "fieldtype": "Link", + "label": "Communication Status", + "options": "CRM Communication Status" + }, + { + "fetch_from": ".territory", + "fieldname": "territory", + "fieldtype": "Link", + "label": "Territory", + "options": "CRM Territory" + }, + { + "fieldname": "source", + "fieldtype": "Link", + "label": "Source", + "options": "CRM Lead Source" + }, + { + "fieldname": "no_of_employees", + "fieldtype": "Select", + "label": "No. of Employees", + "options": "1-10\n11-50\n51-200\n201-500\n501-1000\n1000+" + }, + { + "fieldname": "job_title", + "fieldtype": "Data", + "label": "Job Title" + }, + { + "fieldname": "phone", + "fieldtype": "Data", + "label": "Primary Phone", + "options": "Phone" + }, + { + "fieldname": "log_tab", + "fieldtype": "Tab Break", + "label": "Log", + "read_only": 1 + }, + { + "fieldname": "status_change_log", + "fieldtype": "Table", + "label": "Status Change Log", + "options": "CRM Status Change Log" + }, + { + "fieldname": "lead_name", + "fieldtype": "Data", + "label": "Lead Name" + }, + { + "fieldname": "column_break_ijan", + "fieldtype": "Column Break" + }, + { + "fieldname": "lead_details_tab", + "fieldtype": "Tab Break", + "label": "Lead Details" + }, + { + "fieldname": "column_break_wsde", + "fieldtype": "Column Break" + }, + { + "fieldname": "organization_details_section", + "fieldtype": "Section Break", + "label": "Organization Details" + }, + { + "fieldname": "organization_name", + "fieldtype": "Data", + "label": "Organization Name" + }, + { + "fieldname": "column_break_xbyf", + "fieldtype": "Column Break" + }, + { + "fieldname": "industry", + "fieldtype": "Link", + "label": "Industry", + "options": "CRM Industry" + }, + { + "fieldname": "person_section", + "fieldtype": "Section Break", + "label": "Person" + }, + { + "fieldname": "salutation", + "fieldtype": "Link", + "label": "Salutation", + "options": "Salutation" + }, + { + "fieldname": "first_name", + "fieldtype": "Data", + "label": "First Name" + }, + { + "fieldname": "last_name", + "fieldtype": "Data", + "label": "Last Name" + }, + { + "fieldname": "column_break_xjmy", + "fieldtype": "Column Break" + }, + { + "fieldname": "gender", + "fieldtype": "Link", + "label": "Gender", + "options": "Gender" + }, + { + "fieldname": "contact", + "fieldtype": "Link", + "label": "Contact", + "options": "Contact" + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "options": "Currency" + }, + { + "fieldname": "products_tab", + "fieldtype": "Tab Break", + "label": "Products" + }, + { + "fieldname": "products", + "fieldtype": "Table", + "label": "Products", + "options": "CRM Products" + }, + { + "fieldname": "section_break_ccbj", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_udbq", + "fieldtype": "Column Break" + }, + { + "fieldname": "total", + "fieldtype": "Currency", + "label": "Total", + "options": "currency", + "read_only": 1 + }, + { + "description": "Total after discount", + "fieldname": "net_total", + "fieldtype": "Currency", + "label": "Net Total", + "options": "currency", + "read_only": 1 + }, + { + "fieldname": "section_break_jgpm", + "fieldtype": "Section Break" + }, + { + "fieldname": "deal_value", + "fieldtype": "Currency", + "label": "Deal Value", + "options": "currency" + }, + { + "fieldname": "column_break_kpxa", + "fieldtype": "Column Break" + }, + { + "fieldname": "lost_reason", + "fieldtype": "Link", + "label": "Lost Reason", + "mandatory_depends_on": "eval: pg.status == \"Lost\"", + "options": "CRM Lost Reason" + }, + { + "fieldname": "lost_notes", + "fieldtype": "Text", + "label": "Lost Notes", + "mandatory_depends_on": "eval: pg.lost_reason == \"Other\"" + }, + { + "default": "1", + "description": "The rate used to convert the deal\u2019s currency to your crm's base currency (set in CRM Settings). It is set once when the currency is first added and doesn't change automatically.", + "fieldname": "exchange_rate", + "fieldtype": "Float", + "label": "Exchange Rate" + }, + { + "fieldname": "expected_deal_value", + "fieldtype": "Currency", + "label": "Expected Deal Value", + "options": "currency" + }, + { + "fieldname": "expected_closure_date", + "fieldtype": "Date", + "label": "Expected Closure Date" + }, + { + "fieldname": "closed_date", + "fieldtype": "Date", + "label": "Closed Date" + } + ], + "grid_page_length": 50, + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-08-26 12:12:56.324245", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Deal", + "naming_rule": "By \"Naming Series\" field", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "row_format": "Dynamic", + "show_title_field_in_link": 1, + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "title_field": "organization", + "track_changes": 1 +} diff --git a/crm/fcrm/pagetype/crm_deal/crm_deal.py b/crm/fcrm/pagetype/crm_deal/crm_deal.py new file mode 100644 index 0000000..796109e --- /dev/null +++ b/crm/fcrm/pagetype/crm_deal/crm_deal.py @@ -0,0 +1,388 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow import _ +from jingrow.desk.form.assign_to import add as assign +from jingrow.model.page import Page + +from crm.fcrm.pagetype.crm_service_level_agreement.utils import get_sla +from crm.fcrm.pagetype.crm_status_change_log.crm_status_change_log import add_status_change_log +from crm.fcrm.pagetype.fcrm_settings.fcrm_settings import get_exchange_rate + + +class CRMDeal(Page): + def before_validate(self): + self.set_sla() + + def validate(self): + self.set_primary_contact() + self.set_primary_email_mobile_no() + if not self.is_new() and self.has_value_changed("deal_owner") and self.deal_owner: + self.share_with_agent(self.deal_owner) + self.assign_agent(self.deal_owner) + if self.has_value_changed("status"): + add_status_change_log(self) + if jingrow.db.get_value("CRM Deal Status", self.status, "type") == "Won": + self.closed_date = jingrow.utils.nowdate() + self.validate_forecasting_fields() + self.validate_lost_reason() + self.update_exchange_rate() + + def after_insert(self): + if self.deal_owner: + self.assign_agent(self.deal_owner) + + def before_save(self): + self.apply_sla() + + def set_primary_contact(self, contact=None): + if not self.contacts: + return + + if not contact and len(self.contacts) == 1: + self.contacts[0].is_primary = 1 + elif contact: + for d in self.contacts: + if d.contact == contact: + d.is_primary = 1 + else: + d.is_primary = 0 + + def set_primary_email_mobile_no(self): + if not self.contacts: + self.email = "" + self.mobile_no = "" + self.phone = "" + return + + if len([contact for contact in self.contacts if contact.is_primary]) > 1: + jingrow.throw(_("Only one {0} can be set as primary.").format(jingrow.bold("Contact"))) + + primary_contact_exists = False + for d in self.contacts: + if d.is_primary == 1: + primary_contact_exists = True + self.email = d.email.strip() if d.email else "" + self.mobile_no = d.mobile_no.strip() if d.mobile_no else "" + self.phone = d.phone.strip() if d.phone else "" + break + + if not primary_contact_exists: + self.email = "" + self.mobile_no = "" + self.phone = "" + + def assign_agent(self, agent): + if not agent: + return + + assignees = self.get_assigned_users() + if assignees: + for assignee in assignees: + if agent == assignee: + # the agent is already set as an assignee + return + + assign({"assign_to": [agent], "pagetype": "CRM Deal", "name": self.name}, ignore_permissions=True) + + def share_with_agent(self, agent): + if not agent: + return + + docshares = jingrow.get_all( + "DocShare", + filters={"share_name": self.name, "share_pagetype": self.pagetype}, + fields=["name", "user"], + ) + + shared_with = [d.user for d in docshares] + [agent] + + for user in shared_with: + if user == agent and not jingrow.db.exists( + "DocShare", + {"user": agent, "share_name": self.name, "share_pagetype": self.pagetype}, + ): + jingrow.share.add_docshare( + self.pagetype, + self.name, + agent, + write=1, + flags={"ignore_share_permission": True}, + ) + elif user != agent: + jingrow.share.remove(self.pagetype, self.name, user) + + def set_sla(self): + """ + Find an SLA to apply to the deal. + """ + if self.sla: + return + + sla = get_sla(self) + if not sla: + self.first_responded_on = None + self.first_response_time = None + return + self.sla = sla.name + + def apply_sla(self): + """ + Apply SLA if set. + """ + if not self.sla: + return + sla = jingrow.get_last_pg("CRM Service Level Agreement", {"name": self.sla}) + if sla: + sla.apply(self) + + def update_closed_date(self): + """ + Update the closed date based on the "Won" status. + """ + if self.status == "Won" and not self.closed_date: + self.closed_date = jingrow.utils.nowdate() + + def update_default_probability(self): + """ + Update the default probability based on the status. + """ + if not self.probability or self.probability == 0: + self.probability = jingrow.db.get_value("CRM Deal Status", self.status, "probability") or 0 + + def update_expected_deal_value(self): + """ + Update the expected deal value based on the net total or total. + """ + if ( + jingrow.db.get_single_value("FCRM Settings", "auto_update_expected_deal_value") + and (self.net_total or self.total) + and self.expected_deal_value + ): + self.expected_deal_value = self.net_total or self.total + + def validate_forecasting_fields(self): + self.update_closed_date() + self.update_default_probability() + self.update_expected_deal_value() + if jingrow.db.get_single_value("FCRM Settings", "enable_forecasting"): + if not self.expected_deal_value or self.expected_deal_value == 0: + jingrow.throw(_("Expected Deal Value is required."), jingrow.MandatoryError) + if not self.expected_closure_date: + jingrow.throw(_("Expected Closure Date is required."), jingrow.MandatoryError) + + def validate_lost_reason(self): + """ + Validate the lost reason if the status is set to "Lost". + """ + if self.status and jingrow.get_cached_value("CRM Deal Status", self.status, "type") == "Lost": + if not self.lost_reason: + jingrow.throw(_("Please specify a reason for losing the deal."), jingrow.ValidationError) + elif self.lost_reason == "Other" and not self.lost_notes: + jingrow.throw(_("Please specify the reason for losing the deal."), jingrow.ValidationError) + + def update_exchange_rate(self): + if self.has_value_changed("currency") or not self.exchange_rate: + system_currency = jingrow.db.get_single_value("FCRM Settings", "currency") or "USD" + exchange_rate = 1 + if self.currency and self.currency != system_currency: + exchange_rate = get_exchange_rate(self.currency, system_currency) + + self.db_set("exchange_rate", exchange_rate) + + @staticmethod + def default_list_data(): + columns = [ + { + "label": "Organization", + "type": "Link", + "key": "organization", + "options": "CRM Organization", + "width": "11rem", + }, + { + "label": "Annual Revenue", + "type": "Currency", + "key": "annual_revenue", + "align": "right", + "width": "9rem", + }, + { + "label": "Status", + "type": "Select", + "key": "status", + "width": "10rem", + }, + { + "label": "Email", + "type": "Data", + "key": "email", + "width": "12rem", + }, + { + "label": "Mobile No", + "type": "Data", + "key": "mobile_no", + "width": "11rem", + }, + { + "label": "Assigned To", + "type": "Text", + "key": "_assign", + "width": "10rem", + }, + { + "label": "Last Modified", + "type": "Datetime", + "key": "modified", + "width": "8rem", + }, + ] + rows = [ + "name", + "organization", + "annual_revenue", + "status", + "email", + "currency", + "mobile_no", + "deal_owner", + "sla_status", + "response_by", + "first_response_time", + "first_responded_on", + "modified", + "_assign", + ] + return {"columns": columns, "rows": rows} + + @staticmethod + def default_kanban_settings(): + return { + "column_field": "status", + "title_field": "organization", + "kanban_fields": '["annual_revenue", "email", "mobile_no", "_assign", "modified"]', + } + + +@jingrow.whitelist() +def add_contact(deal, contact): + if not jingrow.has_permission("CRM Deal", "write", deal): + jingrow.throw(_("Not allowed to add contact to Deal"), jingrow.PermissionError) + + deal = jingrow.get_cached_pg("CRM Deal", deal) + deal.append("contacts", {"contact": contact}) + deal.save() + return True + + +@jingrow.whitelist() +def remove_contact(deal, contact): + if not jingrow.has_permission("CRM Deal", "write", deal): + jingrow.throw(_("Not allowed to remove contact from Deal"), jingrow.PermissionError) + + deal = jingrow.get_cached_pg("CRM Deal", deal) + deal.contacts = [d for d in deal.contacts if d.contact != contact] + deal.save() + return True + + +@jingrow.whitelist() +def set_primary_contact(deal, contact): + if not jingrow.has_permission("CRM Deal", "write", deal): + jingrow.throw(_("Not allowed to set primary contact for Deal"), jingrow.PermissionError) + + deal = jingrow.get_cached_pg("CRM Deal", deal) + deal.set_primary_contact(contact) + deal.save() + return True + + +def create_organization(pg): + if not pg.get("organization_name"): + return + + existing_organization = jingrow.db.exists( + "CRM Organization", {"organization_name": pg.get("organization_name")} + ) + if existing_organization: + return existing_organization + + organization = jingrow.new_pg("CRM Organization") + organization.update( + { + "organization_name": pg.get("organization_name"), + "website": pg.get("website"), + "territory": pg.get("territory"), + "industry": pg.get("industry"), + "annual_revenue": pg.get("annual_revenue"), + } + ) + organization.insert(ignore_permissions=True) + return organization.name + + +def contact_exists(pg): + email_exist = jingrow.db.exists("Contact Email", {"email_id": pg.get("email")}) + mobile_exist = jingrow.db.exists("Contact Phone", {"phone": pg.get("mobile_no")}) + + pagetype = "Contact Email" if email_exist else "Contact Phone" + name = email_exist or mobile_exist + + if name: + return jingrow.db.get_value(pagetype, name, "parent") + + return False + + +def create_contact(pg): + existing_contact = contact_exists(pg) + if existing_contact: + return existing_contact + + contact = jingrow.new_pg("Contact") + contact.update( + { + "first_name": pg.get("first_name"), + "last_name": pg.get("last_name"), + "salutation": pg.get("salutation"), + "company_name": pg.get("organization") or pg.get("organization_name"), + } + ) + + if pg.get("email"): + contact.append("email_ids", {"email_id": pg.get("email"), "is_primary": 1}) + + if pg.get("mobile_no"): + contact.append("phone_nos", {"phone": pg.get("mobile_no"), "is_primary_mobile_no": 1}) + + contact.insert(ignore_permissions=True) + contact.reload() # load changes by hooks on contact + + return contact.name + + +@jingrow.whitelist() +def create_deal(args): + deal = jingrow.new_pg("CRM Deal") + + contact = args.get("contact") + if not contact and ( + args.get("first_name") or args.get("last_name") or args.get("email") or args.get("mobile_no") + ): + contact = create_contact(args) + + deal.update( + { + "organization": args.get("organization") or create_organization(args), + "contacts": [{"contact": contact, "is_primary": 1}] if contact else [], + } + ) + + args.pop("organization", None) + + deal.update(args) + + deal.insert(ignore_permissions=True) + return deal.name diff --git a/crm/fcrm/pagetype/crm_deal/test_crm_deal.py b/crm/fcrm/pagetype/crm_deal/test_crm_deal.py new file mode 100644 index 0000000..940be1d --- /dev/null +++ b/crm/fcrm/pagetype/crm_deal/test_crm_deal.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMDeal(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_deal_status/__init__.py b/crm/fcrm/pagetype/crm_deal_status/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_deal_status/crm_deal_status.js b/crm/fcrm/pagetype/crm_deal_status/crm_deal_status.js new file mode 100644 index 0000000..fd38c54 --- /dev/null +++ b/crm/fcrm/pagetype/crm_deal_status/crm_deal_status.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Deal Status", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json b/crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json new file mode 100644 index 0000000..432dc7a --- /dev/null +++ b/crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json @@ -0,0 +1,97 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:deal_status", + "creation": "2023-11-29 11:24:55.543387", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "deal_status", + "type", + "position", + "column_break_ojiu", + "probability", + "color" + ], + "fields": [ + { + "default": "gray", + "fieldname": "color", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Color", + "options": "black\ngray\nblue\ngreen\nred\npink\norange\namber\nyellow\ncyan\nteal\nviolet\npurple" + }, + { + "fieldname": "deal_status", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Status", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "position", + "fieldtype": "Int", + "in_list_view": 1, + "label": "Position" + }, + { + "fieldname": "probability", + "fieldtype": "Percent", + "in_list_view": 1, + "label": "Probability" + }, + { + "default": "Open", + "fieldname": "type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Type", + "options": "Open\nOngoing\nOn Hold\nWon\nLost" + }, + { + "fieldname": "column_break_ojiu", + "fieldtype": "Column Break" + } + ], + "grid_page_length": 50, + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-07-11 16:03:28.077955", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Deal Status", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "row_format": "Dynamic", + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} diff --git a/crm/fcrm/pagetype/crm_deal_status/crm_deal_status.py b/crm/fcrm/pagetype/crm_deal_status/crm_deal_status.py new file mode 100644 index 0000000..6a9287e --- /dev/null +++ b/crm/fcrm/pagetype/crm_deal_status/crm_deal_status.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMDealStatus(Page): + pass diff --git a/crm/fcrm/pagetype/crm_deal_status/test_crm_deal_status.py b/crm/fcrm/pagetype/crm_deal_status/test_crm_deal_status.py new file mode 100644 index 0000000..ce6544c --- /dev/null +++ b/crm/fcrm/pagetype/crm_deal_status/test_crm_deal_status.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMDealStatus(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_dropdown_item/__init__.py b/crm/fcrm/pagetype/crm_dropdown_item/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json b/crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json new file mode 100644 index 0000000..61d8646 --- /dev/null +++ b/crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json @@ -0,0 +1,94 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2024-12-27 17:42:33.089685", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "name1", + "label", + "type", + "route", + "open_in_new_window", + "hidden", + "is_standard", + "column_break_mvbq", + "icon" + ], + "fields": [ + { + "fieldname": "label", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Label", + "mandatory_depends_on": "eval:pg.type == 'Route'" + }, + { + "fieldname": "type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Type", + "options": "Route\nSeparator", + "read_only_depends_on": "eval:pg.is_standard" + }, + { + "depends_on": "eval:pg.type == 'Route'", + "fieldname": "route", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Route", + "mandatory_depends_on": "eval:pg.type == 'Route'" + }, + { + "default": "0", + "fieldname": "hidden", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Hidden" + }, + { + "default": "0", + "fieldname": "is_standard", + "fieldtype": "Check", + "label": "Is Standard", + "read_only": 1 + }, + { + "fieldname": "column_break_mvbq", + "fieldtype": "Column Break" + }, + { + "description": "Add svg code or use feather icons e.g 'settings'", + "fieldname": "icon", + "fieldtype": "Code", + "label": "Icon" + }, + { + "default": "1", + "depends_on": "eval:pg.type == 'Route'", + "fieldname": "open_in_new_window", + "fieldtype": "Check", + "label": "Open in new window" + }, + { + "depends_on": "eval:pg.is_standard", + "fieldname": "name1", + "fieldtype": "Data", + "label": "Name", + "read_only": 1, + "unique": 1 + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2024-12-27 19:35:53.012508", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Dropdown Item", + "owner": "Administrator", + "permissions": [], + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.py b/crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.py new file mode 100644 index 0000000..9d3a4a8 --- /dev/null +++ b/crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMDropdownItem(Page): + pass diff --git a/crm/fcrm/pagetype/crm_exotel_settings/__init__.py b/crm/fcrm/pagetype/crm_exotel_settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.js b/crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.js new file mode 100644 index 0000000..363861d --- /dev/null +++ b/crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.js @@ -0,0 +1,8 @@ +// Copyright (c) 2025, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Exotel Settings", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json b/crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json new file mode 100644 index 0000000..5448f75 --- /dev/null +++ b/crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json @@ -0,0 +1,136 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2025-01-08 15:55:50.710356", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "enabled", + "column_break_uxtz", + "record_call", + "section_break_kfez", + "account_sid", + "subdomain", + "column_break_qwfn", + "webhook_verify_token", + "section_break_iuct", + "api_key", + "column_break_hyen", + "api_token" + ], + "fields": [ + { + "default": "0", + "fieldname": "enabled", + "fieldtype": "Check", + "label": "Enabled" + }, + { + "fieldname": "section_break_kfez", + "fieldtype": "Section Break", + "hide_border": 1 + }, + { + "depends_on": "enabled", + "fieldname": "account_sid", + "fieldtype": "Data", + "label": "Account SID", + "mandatory_depends_on": "enabled" + }, + { + "depends_on": "enabled", + "fieldname": "section_break_iuct", + "fieldtype": "Section Break", + "hide_border": 1 + }, + { + "fieldname": "column_break_hyen", + "fieldtype": "Column Break" + }, + { + "depends_on": "enabled", + "fieldname": "api_key", + "fieldtype": "Data", + "in_list_view": 1, + "label": "API Key", + "mandatory_depends_on": "enabled" + }, + { + "fieldname": "column_break_uxtz", + "fieldtype": "Column Break" + }, + { + "depends_on": "enabled", + "fieldname": "api_token", + "fieldtype": "Password", + "in_list_view": 1, + "label": "API Token", + "mandatory_depends_on": "enabled" + }, + { + "default": "0", + "depends_on": "enabled", + "fieldname": "record_call", + "fieldtype": "Check", + "label": "Record Outgoing Calls" + }, + { + "fieldname": "column_break_qwfn", + "fieldtype": "Column Break" + }, + { + "depends_on": "enabled", + "fieldname": "webhook_verify_token", + "fieldtype": "Data", + "label": "Webhook Verify Token", + "mandatory_depends_on": "enabled" + }, + { + "depends_on": "enabled", + "fieldname": "subdomain", + "fieldtype": "Data", + "label": "Subdomain", + "mandatory_depends_on": "enabled" + } + ], + "index_web_pages_for_search": 1, + "issingle": 1, + "links": [], + "modified": "2025-01-22 19:54:20.074393", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Exotel Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "email": 1, + "print": 1, + "read": 1, + "role": "All", + "share": 1 + } + ], + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.py b/crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.py new file mode 100644 index 0000000..94ac753 --- /dev/null +++ b/crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.py @@ -0,0 +1,26 @@ +# Copyright (c) 2025, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +import requests +from jingrow import _ +from jingrow.model.page import Page + + +class CRMExotelSettings(Page): + def validate(self): + self.verify_credentials() + + def verify_credentials(self): + if self.enabled: + response = requests.get( + "https://{subdomain}/v1/Accounts/{sid}".format( + subdomain=self.subdomain, sid=self.account_sid + ), + auth=(self.api_key, self.get_password("api_token")), + ) + if response.status_code != 200: + jingrow.throw( + _(f"Please enter valid exotel Account SID, API key & API token: {response.reason}"), + title=_("Invalid credentials"), + ) diff --git a/crm/fcrm/pagetype/crm_exotel_settings/test_crm_exotel_settings.py b/crm/fcrm/pagetype/crm_exotel_settings/test_crm_exotel_settings.py new file mode 100644 index 0000000..fed9c0f --- /dev/null +++ b/crm/fcrm/pagetype/crm_exotel_settings/test_crm_exotel_settings.py @@ -0,0 +1,29 @@ +# Copyright (c) 2025, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import IntegrationTestCase, UnitTestCase + +# On IntegrationTestCase, the pagetype test records and all +# link-field test record dependencies are recursively loaded +# Use these module variables to add/remove to/from that list +EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] +IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] + + +class UnitTestCRMExotelSettings(UnitTestCase): + """ + Unit tests for CRMExotelSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class IntegrationTestCRMExotelSettings(IntegrationTestCase): + """ + Integration tests for CRMExotelSettings. + Use this class for testing interactions between multiple components. + """ + + pass diff --git a/crm/fcrm/pagetype/crm_fields_layout/__init__.py b/crm/fcrm/pagetype/crm_fields_layout/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.js b/crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.js new file mode 100644 index 0000000..5d07a4c --- /dev/null +++ b/crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.js @@ -0,0 +1,8 @@ +// Copyright (c) 2024, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Fields Layout", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json b/crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json new file mode 100644 index 0000000..3c7174c --- /dev/null +++ b/crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json @@ -0,0 +1,81 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "format:{dt}-{type}", + "creation": "2024-06-07 16:42:05.495324", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "dt", + "column_break_post", + "type", + "section_break_ttpm", + "layout" + ], + "fields": [ + { + "fieldname": "dt", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Document Type", + "options": "PageType" + }, + { + "fieldname": "type", + "fieldtype": "Select", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Type", + "options": "Quick Entry\nSide Panel\nData Fields\nGrid Row\nRequired Fields" + }, + { + "fieldname": "section_break_ttpm", + "fieldtype": "Section Break" + }, + { + "fieldname": "layout", + "fieldtype": "Code", + "label": "Layout", + "options": "JSON" + }, + { + "fieldname": "column_break_post", + "fieldtype": "Column Break" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-02-21 13:09:49.573515", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Fields Layout", + "naming_rule": "Expression", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "All", + "share": 1 + } + ], + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.py b/crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.py new file mode 100644 index 0000000..1034001 --- /dev/null +++ b/crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.py @@ -0,0 +1,277 @@ +# Copyright (c) 2024, JINGROW and contributors +# For license information, please see license.txt + +import json + +import jingrow +from jingrow import _ +from jingrow.model.page import Page +from jingrow.utils import random_string + + +class CRMFieldsLayout(Page): + pass + + +@jingrow.whitelist() +def get_fields_layout(pagetype: str, type: str, parent_pagetype: str | None = None): + tabs = [] + layout = None + + if jingrow.db.exists("CRM Fields Layout", {"dt": pagetype, "type": type}): + layout = jingrow.get_pg("CRM Fields Layout", {"dt": pagetype, "type": type}) + + if layout and layout.layout: + tabs = json.loads(layout.layout) + + if not tabs and type != "Required Fields": + tabs = get_default_layout(pagetype) + + has_tabs = False + if isinstance(tabs, list) and len(tabs) > 0 and isinstance(tabs[0], dict): + has_tabs = any("sections" in tab for tab in tabs) + + if not has_tabs: + tabs = [{"name": "first_tab", "sections": tabs}] + + allowed_fields = [] + for tab in tabs: + for section in tab.get("sections"): + if "columns" not in section: + continue + for column in section.get("columns"): + if not column.get("fields"): + continue + allowed_fields.extend(column.get("fields")) + + fields = jingrow.get_meta(pagetype).fields + fields = [field for field in fields if field.fieldname in allowed_fields] + + required_fields = [] + + if type == "Required Fields": + required_fields = [ + field for field in jingrow.get_meta(pagetype, False).fields if field.reqd and not field.default + ] + + for tab in tabs: + for section in tab.get("sections"): + if section.get("columns"): + section["columns"] = [column for column in section.get("columns") if column] + for column in section.get("columns") if section.get("columns") else []: + column["fields"] = [field for field in column.get("fields") if field] + for field in column.get("fields") if column.get("fields") else []: + field = next((f for f in fields if f.fieldname == field), None) + if field: + field = field.as_dict() + handle_perm_level_restrictions(field, pagetype, parent_pagetype) + column["fields"][column.get("fields").index(field["fieldname"])] = field + + # remove field from required_fields if it is already present + if ( + type == "Required Fields" + and field.reqd + and any(f.get("fieldname") == field.get("fieldname") for f in required_fields) + ): + required_fields = [ + f for f in required_fields if f.get("fieldname") != field.get("fieldname") + ] + + if type == "Required Fields" and required_fields and tabs: + tabs[-1].get("sections").append( + { + "label": "Required Fields", + "name": "required_fields_section_" + str(random_string(4)), + "opened": True, + "hideLabel": True, + "columns": [ + { + "name": "required_fields_column_" + str(random_string(4)), + "fields": [field.as_dict() for field in required_fields], + } + ], + } + ) + + return tabs or [] + + +@jingrow.whitelist() +def get_sidepanel_sections(pagetype): + if not jingrow.db.exists("CRM Fields Layout", {"dt": pagetype, "type": "Side Panel"}): + return [] + layout = jingrow.get_pg("CRM Fields Layout", {"dt": pagetype, "type": "Side Panel"}).layout + + if not layout: + return [] + + layout = json.loads(layout) + + not_allowed_fieldtypes = [ + "Tab Break", + "Section Break", + "Column Break", + ] + + fields = jingrow.get_meta(pagetype).fields + fields = [field for field in fields if field.fieldtype not in not_allowed_fieldtypes] + + add_forecasting_section(layout, pagetype) + + for section in layout: + section["name"] = section.get("name") or section.get("label") + for column in section.get("columns") if section.get("columns") else []: + for field in column.get("fields") if column.get("fields") else []: + field_obj = next((f for f in fields if f.fieldname == field), None) + if field_obj: + field_obj = field_obj.as_dict() + handle_perm_level_restrictions(field_obj, pagetype) + column["fields"][column.get("fields").index(field)] = get_field_obj(field_obj) + + fields_meta = {} + for field in fields: + fields_meta[field.fieldname] = field + + return layout + + +def add_forecasting_section(layout, pagetype): + if ( + pagetype == "CRM Deal" + and jingrow.db.get_single_value("FCRM Settings", "enable_forecasting") + and not any(section.get("name") == "forecasted_sales_section" for section in layout) + ): + contacts_section_index = next( + ( + i + for i, section in enumerate(layout) + if section.get("name") == "contacts_section" or section.get("label") == "Contacts" + ), + None, + ) + + if contacts_section_index is not None: + layout.insert( + contacts_section_index + 1, + { + "name": "forecasted_sales_section", + "label": "Forecasted Sales", + "opened": True, + "columns": [ + { + "name": "column_" + str(random_string(4)), + "fields": ["expected_closure_date", "probability", "expected_deal_value"], + } + ], + }, + ) + + +def handle_perm_level_restrictions(field, pagetype, parent_pagetype=None): + if field.permlevel == 0: + return + field_has_write_access = field.permlevel in get_permlevel_access("write", pagetype, parent_pagetype) + field_has_read_access = field.permlevel in get_permlevel_access("read", pagetype, parent_pagetype) + + if not field_has_write_access and field_has_read_access: + field.read_only = 1 + if not field_has_read_access and not field_has_write_access: + field.hidden = 1 + + +def get_permlevel_access(permission_type="write", pagetype=None, parent_pagetype=None): + allowed_permlevels = [] + roles = jingrow.get_roles() + + meta = jingrow.get_meta(pagetype) + + if meta.istable and parent_pagetype: + meta = jingrow.get_meta(parent_pagetype) + elif meta.istable and not parent_pagetype: + return [1, 0] + + for perm in meta.permissions: + if perm.role in roles and perm.get(permission_type) and perm.permlevel not in allowed_permlevels: + allowed_permlevels.append(perm.permlevel) + + return allowed_permlevels + + +def get_field_obj(field): + field["placeholder"] = field.get("placeholder") or "Add " + field.label + "..." + + if field.fieldtype == "Link": + field["placeholder"] = field.get("placeholder") or "Select " + field.label + "..." + elif field.fieldtype == "Select" and field.options: + field["placeholder"] = field.get("placeholder") or "Select " + field.label + "..." + field["options"] = [{"label": option, "value": option} for option in field.options.split("\n")] + + if field.read_only: + field["tooltip"] = "This field is read only and cannot be edited." + + return field + + +@jingrow.whitelist() +def save_fields_layout(pagetype: str, type: str, layout: str): + if jingrow.db.exists("CRM Fields Layout", {"dt": pagetype, "type": type}): + pg = jingrow.get_pg("CRM Fields Layout", {"dt": pagetype, "type": type}) + else: + pg = jingrow.new_pg("CRM Fields Layout") + + pg.update( + { + "dt": pagetype, + "type": type, + "layout": layout, + } + ) + pg.save(ignore_permissions=True) + + return pg.layout + + +def get_default_layout(pagetype: str): + fields = jingrow.get_meta(pagetype).fields + + tabs = [] + + if fields and fields[0].fieldtype != "Tab Break": + sections = [] + if fields and fields[0].fieldtype != "Section Break": + sections.append( + { + "name": "section_" + str(random_string(4)), + "columns": [{"name": "column_" + str(random_string(4)), "fields": []}], + } + ) + tabs.append({"name": "tab_" + str(random_string(4)), "sections": sections}) + + for field in fields: + if field.fieldtype == "Tab Break": + tabs.append( + { + "name": "tab_" + str(random_string(4)), + "sections": [ + { + "name": "section_" + str(random_string(4)), + "columns": [{"name": "column_" + str(random_string(4)), "fields": []}], + } + ], + } + ) + elif field.fieldtype == "Section Break": + tabs[-1]["sections"].append( + { + "name": "section_" + str(random_string(4)), + "columns": [{"name": "column_" + str(random_string(4)), "fields": []}], + } + ) + elif field.fieldtype == "Column Break": + tabs[-1]["sections"][-1]["columns"].append( + {"name": "column_" + str(random_string(4)), "fields": []} + ) + else: + tabs[-1]["sections"][-1]["columns"][-1]["fields"].append(field.fieldname) + + return tabs diff --git a/crm/fcrm/pagetype/crm_fields_layout/test_crm_fields_layout.py b/crm/fcrm/pagetype/crm_fields_layout/test_crm_fields_layout.py new file mode 100644 index 0000000..f247285 --- /dev/null +++ b/crm/fcrm/pagetype/crm_fields_layout/test_crm_fields_layout.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMFieldsLayout(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_form_script/__init__.py b/crm/fcrm/pagetype/crm_form_script/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_form_script/crm_form_script.js b/crm/fcrm/pagetype/crm_form_script/crm_form_script.js new file mode 100644 index 0000000..162c8f0 --- /dev/null +++ b/crm/fcrm/pagetype/crm_form_script/crm_form_script.js @@ -0,0 +1,65 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +jingrow.ui.form.on("CRM Form Script", { + refresh(frm) { + frm.set_query("dt", { + filters: { + istable: 0, + }, + }); + + if (frm.pg.is_standard && !jingrow.boot.developer_mode) { + frm.disable_form(); + jingrow.show_alert( + __( + "Standard Form Scripts can not be modified, duplicate the Form Script instead." + ) + ); + } + + if (!jingrow.boot.developer_mode) { + frm.toggle_enable("is_standard", 0); + } + + frm.trigger("add_enable_button"); + }, + + add_enable_button(frm) { + frm.add_custom_button( + frm.pg.enabled ? __("Disable") : __("Enable"), + () => { + frm.set_value("enabled", !frm.pg.enabled); + frm.save(); + } + ); + }, + + view(frm) { + let has_form_boilerplate = frm.pg.script.includes( + "function setupForm(" + ); + let has_list_boilerplate = frm.pg.script.includes( + "function setupList(" + ); + + if (frm.pg.view == "Form" && !has_form_boilerplate) { + frm.pg.script = ` +function setupForm({ pg }) { + return { + actions: [], + statuses: [], + } +}`.trim(); + } + if (frm.pg.view == "List" && !has_list_boilerplate) { + frm.pg.script = ` +function setupList({ list }) { + return { + actions: [], + bulk_actions: [], + } +}`.trim(); + } + }, +}); diff --git a/crm/fcrm/pagetype/crm_form_script/crm_form_script.json b/crm/fcrm/pagetype/crm_form_script/crm_form_script.json new file mode 100644 index 0000000..12d3058 --- /dev/null +++ b/crm/fcrm/pagetype/crm_form_script/crm_form_script.json @@ -0,0 +1,101 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "prompt", + "creation": "2023-12-28 14:18:09.329868", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "dt", + "view", + "column_break_gboh", + "enabled", + "is_standard", + "section_break_xeox", + "script" + ], + "fields": [ + { + "fieldname": "column_break_gboh", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_xeox", + "fieldtype": "Section Break" + }, + { + "fieldname": "dt", + "fieldtype": "Link", + "in_list_view": 1, + "label": "PageType", + "options": "PageType", + "reqd": 1 + }, + { + "default": "0", + "fieldname": "enabled", + "fieldtype": "Check", + "hidden": 1, + "label": "Enabled" + }, + { + "default": "function setupForm({ pg }) {\n return {\n actions: [],\n }\n}", + "documentation_url": "https://docs.jingrow.com/crm/custom-actions", + "fieldname": "script", + "fieldtype": "Code", + "label": "Script", + "options": "JS" + }, + { + "default": "Form", + "fieldname": "view", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Apply To", + "options": "Form\nList", + "set_only_once": 1 + }, + { + "default": "0", + "fieldname": "is_standard", + "fieldtype": "Check", + "label": "Is Standard", + "no_copy": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-05-19 17:57:24.610295", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Form Script", + "naming_rule": "Set by user", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "All", + "share": 1 + } + ], + "row_format": "Dynamic", + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} diff --git a/crm/fcrm/pagetype/crm_form_script/crm_form_script.py b/crm/fcrm/pagetype/crm_form_script/crm_form_script.py new file mode 100644 index 0000000..c5e61ff --- /dev/null +++ b/crm/fcrm/pagetype/crm_form_script/crm_form_script.py @@ -0,0 +1,41 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow import _ +from jingrow.model.page import Page + + +class CRMFormScript(Page): + def validate(self): + in_user_env = not ( + jingrow.flags.in_install + or jingrow.flags.in_patch + or jingrow.flags.in_test + or jingrow.flags.in_fixtures + ) + if in_user_env and not self.is_new() and self.is_standard and not jingrow.conf.developer_mode: + # only enabled can be changed for standard form scripts + if self.has_value_changed("enabled"): + enabled_value = self.enabled + self.reload() + self.enabled = enabled_value + else: + jingrow.throw(_("You need to be in developer mode to edit a Standard Form Script")) + +def get_form_script(dt, view="Form"): + """Returns the form script for the given pagetype""" + FormScript = jingrow.qb.PageType("CRM Form Script") + query = ( + jingrow.qb.from_(FormScript) + .select("script") + .where(FormScript.dt == dt) + .where(FormScript.view == view) + .where(FormScript.enabled == 1) + ) + + pg = query.run(as_dict=True) + if pg: + return [d.script for d in pg] if len(pg) > 1 else pg[0].script + else: + return None diff --git a/crm/fcrm/pagetype/crm_form_script/test_crm_form_script.py b/crm/fcrm/pagetype/crm_form_script/test_crm_form_script.py new file mode 100644 index 0000000..222b71f --- /dev/null +++ b/crm/fcrm/pagetype/crm_form_script/test_crm_form_script.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMFormScript(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_global_settings/__init__.py b/crm/fcrm/pagetype/crm_global_settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_global_settings/crm_global_settings.js b/crm/fcrm/pagetype/crm_global_settings/crm_global_settings.js new file mode 100644 index 0000000..bf3870e --- /dev/null +++ b/crm/fcrm/pagetype/crm_global_settings/crm_global_settings.js @@ -0,0 +1,8 @@ +// Copyright (c) 2025, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Global Settings", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_global_settings/crm_global_settings.json b/crm/fcrm/pagetype/crm_global_settings/crm_global_settings.json new file mode 100644 index 0000000..44d89a6 --- /dev/null +++ b/crm/fcrm/pagetype/crm_global_settings/crm_global_settings.json @@ -0,0 +1,98 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "format:{type}-{dt}", + "creation": "2025-02-28 14:37:10.002433", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "dt", + "column_break_kipp", + "type", + "section_break_vass", + "json" + ], + "fields": [ + { + "default": "PageType", + "fieldname": "dt", + "fieldtype": "Link", + "in_list_view": 1, + "label": "PageType", + "options": "PageType", + "reqd": 1 + }, + { + "fieldname": "column_break_kipp", + "fieldtype": "Column Break" + }, + { + "fieldname": "type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Type", + "options": "Quick Filters\nSidebar Items", + "reqd": 1 + }, + { + "fieldname": "section_break_vass", + "fieldtype": "Section Break" + }, + { + "fieldname": "json", + "fieldtype": "JSON", + "label": "JSON" + } + ], + "grid_page_length": 50, + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-03-02 14:03:49.372132", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Global Settings", + "naming_rule": "Expression", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "row_format": "Dynamic", + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_global_settings/crm_global_settings.py b/crm/fcrm/pagetype/crm_global_settings/crm_global_settings.py new file mode 100644 index 0000000..a59f876 --- /dev/null +++ b/crm/fcrm/pagetype/crm_global_settings/crm_global_settings.py @@ -0,0 +1,9 @@ +# Copyright (c) 2025, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMGlobalSettings(Page): + pass diff --git a/crm/fcrm/pagetype/crm_global_settings/test_crm_global_settings.py b/crm/fcrm/pagetype/crm_global_settings/test_crm_global_settings.py new file mode 100644 index 0000000..81be481 --- /dev/null +++ b/crm/fcrm/pagetype/crm_global_settings/test_crm_global_settings.py @@ -0,0 +1,30 @@ +# Copyright (c) 2025, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import IntegrationTestCase, UnitTestCase + + +# On IntegrationTestCase, the pagetype test records and all +# link-field test record dependencies are recursively loaded +# Use these module variables to add/remove to/from that list +EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] +IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] + + +class UnitTestCRMGlobalSettings(UnitTestCase): + """ + Unit tests for CRMGlobalSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class IntegrationTestCRMGlobalSettings(IntegrationTestCase): + """ + Integration tests for CRMGlobalSettings. + Use this class for testing interactions between multiple components. + """ + + pass diff --git a/crm/fcrm/pagetype/crm_holiday/__init__.py b/crm/fcrm/pagetype/crm_holiday/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_holiday/crm_holiday.json b/crm/fcrm/pagetype/crm_holiday/crm_holiday.json new file mode 100644 index 0000000..c5f1be1 --- /dev/null +++ b/crm/fcrm/pagetype/crm_holiday/crm_holiday.json @@ -0,0 +1,57 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2023-12-14 11:16:15.476366", + "pagetype": "PageType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "date", + "column_break_xzyo", + "weekly_off", + "section_break_zenz", + "description" + ], + "fields": [ + { + "fieldname": "date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Date", + "reqd": 1 + }, + { + "fieldname": "column_break_xzyo", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "weekly_off", + "fieldtype": "Check", + "label": "Weekly Off" + }, + { + "fieldname": "section_break_zenz", + "fieldtype": "Section Break" + }, + { + "fieldname": "description", + "fieldtype": "Text Editor", + "in_list_view": 1, + "label": "Description", + "reqd": 1 + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2023-12-14 11:17:41.745419", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Holiday", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_holiday/crm_holiday.py b/crm/fcrm/pagetype/crm_holiday/crm_holiday.py new file mode 100644 index 0000000..2bae1b8 --- /dev/null +++ b/crm/fcrm/pagetype/crm_holiday/crm_holiday.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMHoliday(Page): + pass diff --git a/crm/fcrm/pagetype/crm_holiday_list/__init__.py b/crm/fcrm/pagetype/crm_holiday_list/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.js b/crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.js new file mode 100644 index 0000000..cc2f2b6 --- /dev/null +++ b/crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Holiday List", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json b/crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json new file mode 100644 index 0000000..0a77624 --- /dev/null +++ b/crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json @@ -0,0 +1,123 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:holiday_list_name", + "creation": "2023-12-14 11:09:12.876640", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "holiday_list_name", + "from_date", + "to_date", + "column_break_qwqc", + "total_holidays", + "add_weekly_holidays_section", + "weekly_off", + "add_to_holidays", + "holidays_section", + "holidays", + "clear_table" + ], + "fields": [ + { + "fieldname": "holiday_list_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Holiday List Name", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "from_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "From Date", + "reqd": 1 + }, + { + "fieldname": "to_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "To Date", + "reqd": 1 + }, + { + "fieldname": "column_break_qwqc", + "fieldtype": "Column Break" + }, + { + "fieldname": "total_holidays", + "fieldtype": "Int", + "label": "Total Holidays" + }, + { + "fieldname": "add_weekly_holidays_section", + "fieldtype": "Section Break", + "label": "Add Weekly Holidays" + }, + { + "fieldname": "weekly_off", + "fieldtype": "Select", + "label": "Weekly Off", + "options": "\nMonday\nTuesday\nWednesday\nThursday\nFriday\nSaturday\nSunday" + }, + { + "fieldname": "add_to_holidays", + "fieldtype": "Button", + "label": "Add to Holidays" + }, + { + "fieldname": "holidays_section", + "fieldtype": "Section Break", + "label": "Holidays" + }, + { + "fieldname": "clear_table", + "fieldtype": "Button", + "label": "Clear Table" + }, + { + "fieldname": "holidays", + "fieldtype": "Table", + "label": "Holidays", + "options": "CRM Holiday" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2024-01-19 21:54:54.809445", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Holiday List", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.py b/crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.py new file mode 100644 index 0000000..9da10cf --- /dev/null +++ b/crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMHolidayList(Page): + pass diff --git a/crm/fcrm/pagetype/crm_holiday_list/test_crm_holiday_list.py b/crm/fcrm/pagetype/crm_holiday_list/test_crm_holiday_list.py new file mode 100644 index 0000000..60b5655 --- /dev/null +++ b/crm/fcrm/pagetype/crm_holiday_list/test_crm_holiday_list.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMHolidayList(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_industry/__init__.py b/crm/fcrm/pagetype/crm_industry/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_industry/crm_industry.js b/crm/fcrm/pagetype/crm_industry/crm_industry.js new file mode 100644 index 0000000..b3d3ebd --- /dev/null +++ b/crm/fcrm/pagetype/crm_industry/crm_industry.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Industry", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_industry/crm_industry.json b/crm/fcrm/pagetype/crm_industry/crm_industry.json new file mode 100644 index 0000000..7577a22 --- /dev/null +++ b/crm/fcrm/pagetype/crm_industry/crm_industry.json @@ -0,0 +1,69 @@ +{ + "actions": [], + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:industry", + "creation": "2023-07-24 19:40:31.980882", + "default_view": "List", + "pagetype": "PageType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "industry" + ], + "fields": [ + { + "fieldname": "industry", + "fieldtype": "Data", + "label": "Industry", + "unique": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-01-02 22:14:28.686821", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Industry", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "All", + "share": 1 + } + ], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_industry/crm_industry.py b/crm/fcrm/pagetype/crm_industry/crm_industry.py new file mode 100644 index 0000000..1d79b41 --- /dev/null +++ b/crm/fcrm/pagetype/crm_industry/crm_industry.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMIndustry(Page): + pass diff --git a/crm/fcrm/pagetype/crm_industry/test_crm_industry.py b/crm/fcrm/pagetype/crm_industry/test_crm_industry.py new file mode 100644 index 0000000..b47ef42 --- /dev/null +++ b/crm/fcrm/pagetype/crm_industry/test_crm_industry.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMIndustry(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_invitation/__init__.py b/crm/fcrm/pagetype/crm_invitation/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_invitation/crm_invitation.js b/crm/fcrm/pagetype/crm_invitation/crm_invitation.js new file mode 100644 index 0000000..9f0da35 --- /dev/null +++ b/crm/fcrm/pagetype/crm_invitation/crm_invitation.js @@ -0,0 +1,12 @@ +// Copyright (c) 2024, JINGROW and contributors +// For license information, please see license.txt + +jingrow.ui.form.on("CRM Invitation", { + refresh(frm) { + if (frm.pg.status != "Accepted") { + frm.add_custom_button(__("Accept Invitation"), () => { + return frm.call("accept_invitation"); + }); + } + }, +}); diff --git a/crm/fcrm/pagetype/crm_invitation/crm_invitation.json b/crm/fcrm/pagetype/crm_invitation/crm_invitation.json new file mode 100644 index 0000000..c36a6da --- /dev/null +++ b/crm/fcrm/pagetype/crm_invitation/crm_invitation.json @@ -0,0 +1,113 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2024-09-03 12:19:18.933810", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "email", + "role", + "key", + "invited_by", + "column_break_dsuz", + "status", + "email_sent_at", + "accepted_at" + ], + "fields": [ + { + "fieldname": "email", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Email", + "reqd": 1 + }, + { + "fieldname": "role", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Role", + "options": "\nSales User\nSales Manager\nSystem Manager", + "reqd": 1 + }, + { + "fieldname": "key", + "fieldtype": "Data", + "label": "Key" + }, + { + "fieldname": "invited_by", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Invited By", + "options": "User" + }, + { + "fieldname": "column_break_dsuz", + "fieldtype": "Column Break" + }, + { + "fieldname": "status", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Status", + "options": "\nPending\nAccepted\nExpired" + }, + { + "fieldname": "email_sent_at", + "fieldtype": "Datetime", + "label": "Email Sent At" + }, + { + "fieldname": "accepted_at", + "fieldtype": "Datetime", + "label": "Accepted At" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-06-17 17:20:18.935395", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Invitation", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1 + } + ], + "row_format": "Dynamic", + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} diff --git a/crm/fcrm/pagetype/crm_invitation/crm_invitation.py b/crm/fcrm/pagetype/crm_invitation/crm_invitation.py new file mode 100644 index 0000000..ef14bc0 --- /dev/null +++ b/crm/fcrm/pagetype/crm_invitation/crm_invitation.py @@ -0,0 +1,95 @@ +# Copyright (c) 2024, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow.model.page import Page + + +class CRMInvitation(Page): + def before_insert(self): + jingrow.utils.validate_email_address(self.email, True) + + self.key = jingrow.generate_hash(length=12) + self.invited_by = jingrow.session.user + self.status = "Pending" + + def after_insert(self): + self.invite_via_email() + + def invite_via_email(self): + invite_link = jingrow.utils.get_url(f"/api/action/crm.api.accept_invitation?key={self.key}") + if jingrow.local.dev_server: + print(f"Invite link for {self.email}: {invite_link}") + + title = "Jingrow CRM" + template = "crm_invitation" + + jingrow.sendmail( + recipients=self.email, + subject=f"You have been invited to join {title}", + template=template, + args={"title": title, "invite_link": invite_link}, + now=True, + ) + self.db_set("email_sent_at", jingrow.utils.now()) + + @jingrow.whitelist() + def accept_invitation(self): + jingrow.only_for(["System Manager", "Sales Manager"]) + self.accept() + + def accept(self): + if self.status == "Expired": + jingrow.throw("Invalid or expired key") + + user = self.create_user_if_not_exists() + user.append_roles(self.role) + if self.role == "System Manager": + user.append_roles("Sales Manager", "Sales User") + elif self.role == "Sales Manager": + user.append_roles("Sales User") + if self.role == "Sales User": + self.update_module_in_user(user, "FCRM") + user.save(ignore_permissions=True) + + self.status = "Accepted" + self.accepted_at = jingrow.utils.now() + self.save(ignore_permissions=True) + + def update_module_in_user(self, user, module): + block_modules = jingrow.get_all( + "Module Def", + fields=["name as module"], + filters={"name": ["!=", module]}, + ) + + if block_modules: + user.set("block_modules", block_modules) + + def create_user_if_not_exists(self): + if not jingrow.db.exists("User", self.email): + first_name = self.email.split("@")[0].title() + user = jingrow.get_pg( + pagetype="User", + user_type="System User", + email=self.email, + send_welcome_email=0, + first_name=first_name, + ).insert(ignore_permissions=True) + else: + user = jingrow.get_pg("User", self.email) + return user + + +def expire_invitations(): + """expire invitations after 3 days""" + from jingrow.utils import add_days, now + + days = 3 + invitations_to_expire = jingrow.db.get_all( + "CRM Invitation", filters={"status": "Pending", "creation": ["<", add_days(now(), -days)]} + ) + for invitation in invitations_to_expire: + invitation = jingrow.get_pg("CRM Invitation", invitation.name) + invitation.status = "Expired" + invitation.save(ignore_permissions=True) diff --git a/crm/fcrm/pagetype/crm_invitation/test_crm_invitation.py b/crm/fcrm/pagetype/crm_invitation/test_crm_invitation.py new file mode 100644 index 0000000..60d592f --- /dev/null +++ b/crm/fcrm/pagetype/crm_invitation/test_crm_invitation.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMInvitation(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_lead/__init__.py b/crm/fcrm/pagetype/crm_lead/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_lead/crm_lead.js b/crm/fcrm/pagetype/crm_lead/crm_lead.js new file mode 100644 index 0000000..3d2fba2 --- /dev/null +++ b/crm/fcrm/pagetype/crm_lead/crm_lead.js @@ -0,0 +1,72 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +jingrow.ui.form.on("CRM Lead", { + refresh(frm) { + frm.add_web_link(`/crm/leads/${frm.pg.name}`, __("Open in Portal")); + }, + update_total: function (frm) { + let total = 0; + let total_qty = 0; + let net_total = 0; + frm.pg.products.forEach((d) => { + total += d.amount; + total_qty += d.qty; + net_total += d.net_amount; + }); + + jingrow.model.set_value(frm.pagetype, frm.docname, "total", total); + jingrow.model.set_value( + frm.pagetype, + frm.docname, + "net_total", + net_total || total + ); + } +}); + +jingrow.ui.form.on("CRM Products", { + products_add: function (frm, cdt, cdn) { + frm.trigger("update_total"); + }, + products_remove: function (frm, cdt, cdn) { + frm.trigger("update_total"); + }, + product_code: function (frm, cdt, cdn) { + let d = jingrow.get_pg(cdt, cdn); + jingrow.model.set_value(cdt, cdn, "product_name", d.product_code); + }, + rate: function (frm, cdt, cdn) { + let d = jingrow.get_pg(cdt, cdn); + if (d.rate && d.qty) { + jingrow.model.set_value(cdt, cdn, "amount", d.rate * d.qty); + } + frm.trigger("update_total"); + }, + qty: function (frm, cdt, cdn) { + let d = jingrow.get_pg(cdt, cdn); + if (d.rate && d.qty) { + jingrow.model.set_value(cdt, cdn, "amount", d.rate * d.qty); + } + frm.trigger("update_total"); + }, + discount_percentage: function (frm, cdt, cdn) { + let d = jingrow.get_pg(cdt, cdn); + if (d.discount_percentage && d.amount) { + discount_amount = (d.discount_percentage / 100) * d.amount; + jingrow.model.set_value( + cdt, + cdn, + "discount_amount", + discount_amount + ); + jingrow.model.set_value( + cdt, + cdn, + "net_amount", + d.amount - discount_amount + ); + } + frm.trigger("update_total"); + } +}); \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_lead/crm_lead.json b/crm/fcrm/pagetype/crm_lead/crm_lead.json new file mode 100644 index 0000000..9a0b3c6 --- /dev/null +++ b/crm/fcrm/pagetype/crm_lead/crm_lead.json @@ -0,0 +1,384 @@ +{ + "actions": [], + "allow_import": 1, + "allow_rename": 1, + "autoname": "naming_series:", + "creation": "2023-07-24 12:19:39.616298", + "default_view": "List", + "pagetype": "PageType", + "editable_grid": 1, + "email_append_to": 1, + "engine": "InnoDB", + "field_order": [ + "details", + "organization", + "website", + "territory", + "industry", + "job_title", + "source", + "lead_owner", + "person_tab", + "salutation", + "first_name", + "last_name", + "email", + "mobile_no", + "organization_tab", + "section_break_uixv", + "naming_series", + "lead_name", + "middle_name", + "gender", + "phone", + "column_break_dbsv", + "status", + "no_of_employees", + "annual_revenue", + "image", + "converted", + "products_tab", + "products", + "section_break_ggwh", + "total", + "column_break_uisv", + "net_total", + "sla_tab", + "sla", + "sla_creation", + "column_break_ffnp", + "sla_status", + "communication_status", + "response_details_section", + "response_by", + "column_break_pweh", + "first_response_time", + "first_responded_on", + "log_tab", + "status_change_log" + ], + "fields": [ + { + "default": "CRM-LEAD-.YYYY.-", + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "options": "CRM-LEAD-.YYYY.-" + }, + { + "fieldname": "salutation", + "fieldtype": "Link", + "label": "Salutation", + "options": "Salutation" + }, + { + "fieldname": "first_name", + "fieldtype": "Data", + "label": "First Name", + "reqd": 1 + }, + { + "fieldname": "middle_name", + "fieldtype": "Data", + "label": "Middle Name" + }, + { + "fieldname": "last_name", + "fieldtype": "Data", + "label": "Last Name" + }, + { + "fieldname": "gender", + "fieldtype": "Link", + "label": "Gender", + "options": "Gender" + }, + { + "default": "New", + "fieldname": "status", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Status", + "options": "CRM Lead Status", + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "email", + "fieldtype": "Data", + "label": "Email", + "options": "Email", + "search_index": 1 + }, + { + "fieldname": "website", + "fieldtype": "Data", + "label": "Website" + }, + { + "fieldname": "mobile_no", + "fieldtype": "Data", + "label": "Mobile No", + "options": "Phone" + }, + { + "fieldname": "phone", + "fieldtype": "Data", + "label": "Phone", + "options": "Phone" + }, + { + "fieldname": "section_break_uixv", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_dbsv", + "fieldtype": "Column Break" + }, + { + "fieldname": "no_of_employees", + "fieldtype": "Select", + "label": "No. of Employees", + "options": "1-10\n11-50\n51-200\n201-500\n501-1000\n1000+" + }, + { + "fieldname": "annual_revenue", + "fieldtype": "Currency", + "label": "Annual Revenue" + }, + { + "fieldname": "lead_owner", + "fieldtype": "Link", + "label": "Lead Owner", + "options": "User" + }, + { + "fieldname": "source", + "fieldtype": "Link", + "label": "Source", + "options": "CRM Lead Source" + }, + { + "fieldname": "industry", + "fieldtype": "Link", + "label": "Industry", + "options": "CRM Industry" + }, + { + "fieldname": "image", + "fieldtype": "Attach Image", + "hidden": 1, + "label": "Image", + "print_hide": 1 + }, + { + "fieldname": "lead_name", + "fieldtype": "Data", + "label": "Full Name", + "search_index": 1 + }, + { + "fieldname": "job_title", + "fieldtype": "Data", + "label": "Job Title" + }, + { + "fieldname": "organization_tab", + "fieldtype": "Tab Break", + "label": "Others", + "read_only": 1 + }, + { + "fieldname": "organization", + "fieldtype": "Data", + "label": "Organization" + }, + { + "default": "0", + "fieldname": "converted", + "fieldtype": "Check", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Converted" + }, + { + "fieldname": "person_tab", + "fieldtype": "Tab Break", + "label": "Person" + }, + { + "fieldname": "details", + "fieldtype": "Tab Break", + "label": "Details" + }, + { + "fieldname": "sla_tab", + "fieldtype": "Tab Break", + "label": "SLA", + "read_only": 1 + }, + { + "fieldname": "sla", + "fieldtype": "Link", + "label": "SLA", + "options": "CRM Service Level Agreement" + }, + { + "fieldname": "sla_creation", + "fieldtype": "Datetime", + "label": "SLA Creation", + "read_only": 1 + }, + { + "fieldname": "column_break_ffnp", + "fieldtype": "Column Break" + }, + { + "fieldname": "sla_status", + "fieldtype": "Select", + "label": "SLA Status", + "options": "\nFirst Response Due\nFailed\nFulfilled", + "read_only": 1 + }, + { + "fieldname": "response_details_section", + "fieldtype": "Section Break", + "label": "Response Details" + }, + { + "fieldname": "response_by", + "fieldtype": "Datetime", + "label": "Response By", + "read_only": 1 + }, + { + "fieldname": "column_break_pweh", + "fieldtype": "Column Break" + }, + { + "fieldname": "first_response_time", + "fieldtype": "Duration", + "label": "First Response Time", + "read_only": 1 + }, + { + "fieldname": "first_responded_on", + "fieldtype": "Datetime", + "label": "First Responded On", + "read_only": 1 + }, + { + "default": "Open", + "fieldname": "communication_status", + "fieldtype": "Link", + "label": "Communication Status", + "options": "CRM Communication Status" + }, + { + "fieldname": "territory", + "fieldtype": "Link", + "label": "Territory", + "options": "CRM Territory" + }, + { + "fieldname": "log_tab", + "fieldtype": "Tab Break", + "label": "Log", + "read_only": 1 + }, + { + "fieldname": "status_change_log", + "fieldtype": "Table", + "label": "Status Change Log", + "options": "CRM Status Change Log" + }, + { + "fieldname": "products_tab", + "fieldtype": "Tab Break", + "label": "Products" + }, + { + "fieldname": "products", + "fieldtype": "Table", + "label": "Products", + "options": "CRM Products" + }, + { + "fieldname": "section_break_ggwh", + "fieldtype": "Section Break" + }, + { + "fieldname": "total", + "fieldtype": "Currency", + "label": "Total", + "options": "currency", + "read_only": 1 + }, + { + "fieldname": "column_break_uisv", + "fieldtype": "Column Break" + }, + { + "description": "Total after discount", + "fieldname": "net_total", + "fieldtype": "Currency", + "label": "Net Total", + "options": "currency", + "read_only": 1 + } + ], + "grid_page_length": 50, + "image_field": "image", + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-05-14 19:51:06.184569", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Lead", + "naming_rule": "By \"Naming Series\" field", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "All", + "share": 1 + } + ], + "row_format": "Dynamic", + "sender_field": "email", + "sender_name_field": "first_name", + "show_title_field_in_link": 1, + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "title_field": "lead_name", + "track_changes": 1 +} diff --git a/crm/fcrm/pagetype/crm_lead/crm_lead.py b/crm/fcrm/pagetype/crm_lead/crm_lead.py new file mode 100644 index 0000000..cbc394f --- /dev/null +++ b/crm/fcrm/pagetype/crm_lead/crm_lead.py @@ -0,0 +1,419 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow import _ +from jingrow.desk.form.assign_to import add as assign +from jingrow.model.page import Page +from jingrow.utils import has_gravatar, validate_email_address + +from crm.fcrm.pagetype.crm_service_level_agreement.utils import get_sla +from crm.fcrm.pagetype.crm_status_change_log.crm_status_change_log import ( + add_status_change_log, +) + + +class CRMLead(Page): + def before_validate(self): + self.set_sla() + + def validate(self): + self.set_full_name() + self.set_lead_name() + self.set_title() + self.validate_email() + if not self.is_new() and self.has_value_changed("lead_owner") and self.lead_owner: + self.share_with_agent(self.lead_owner) + self.assign_agent(self.lead_owner) + if self.has_value_changed("status"): + add_status_change_log(self) + + def after_insert(self): + if self.lead_owner: + self.assign_agent(self.lead_owner) + + def before_save(self): + self.apply_sla() + + def set_full_name(self): + if self.first_name: + self.lead_name = " ".join( + filter( + None, + [ + self.salutation, + self.first_name, + self.middle_name, + self.last_name, + ], + ) + ) + + def set_lead_name(self): + if not self.lead_name: + # Check for leads being created through data import + if not self.organization and not self.email and not self.flags.ignore_mandatory: + jingrow.throw(_("A Lead requires either a person's name or an organization's name")) + elif self.organization: + self.lead_name = self.organization + elif self.email: + self.lead_name = self.email.split("@")[0] + else: + self.lead_name = "Unnamed Lead" + + def set_title(self): + self.title = self.organization or self.lead_name + + def validate_email(self): + if self.email: + if not self.flags.ignore_email_validation: + validate_email_address(self.email, throw=True) + + if self.email == self.lead_owner: + jingrow.throw(_("Lead Owner cannot be same as the Lead Email Address")) + + if self.is_new() or not self.image: + self.image = has_gravatar(self.email) + + def assign_agent(self, agent): + if not agent: + return + + assignees = self.get_assigned_users() + if assignees: + for assignee in assignees: + if agent == assignee: + # the agent is already set as an assignee + return + + assign({"assign_to": [agent], "pagetype": "CRM Lead", "name": self.name}) + + def share_with_agent(self, agent): + if not agent: + return + + docshares = jingrow.get_all( + "DocShare", + filters={"share_name": self.name, "share_pagetype": self.pagetype}, + fields=["name", "user"], + ) + + shared_with = [d.user for d in docshares] + [agent] + + for user in shared_with: + if user == agent and not jingrow.db.exists( + "DocShare", + {"user": agent, "share_name": self.name, "share_pagetype": self.pagetype}, + ): + jingrow.share.add_docshare( + self.pagetype, + self.name, + agent, + write=1, + flags={"ignore_share_permission": True}, + ) + elif user != agent: + jingrow.share.remove(self.pagetype, self.name, user) + + def create_contact(self, existing_contact=None, throw=True): + if not self.lead_name: + self.set_full_name() + self.set_lead_name() + + existing_contact = existing_contact or self.contact_exists(throw) + if existing_contact: + self.update_lead_contact(existing_contact) + return existing_contact + + contact = jingrow.new_pg("Contact") + contact.update( + { + "first_name": self.first_name or self.lead_name, + "last_name": self.last_name, + "salutation": self.salutation, + "gender": self.gender, + "designation": self.job_title, + "company_name": self.organization, + "image": self.image or "", + } + ) + + if self.email: + contact.append("email_ids", {"email_id": self.email, "is_primary": 1}) + + if self.phone: + contact.append("phone_nos", {"phone": self.phone, "is_primary_phone": 1}) + + if self.mobile_no: + contact.append("phone_nos", {"phone": self.mobile_no, "is_primary_mobile_no": 1}) + + contact.insert(ignore_permissions=True) + contact.reload() # load changes by hooks on contact + + return contact.name + + def create_organization(self, existing_organization=None): + if not self.organization and not existing_organization: + return + + existing_organization = existing_organization or jingrow.db.exists( + "CRM Organization", {"organization_name": self.organization} + ) + if existing_organization: + self.db_set("organization", existing_organization) + return existing_organization + + organization = jingrow.new_pg("CRM Organization") + organization.update( + { + "organization_name": self.organization, + "website": self.website, + "territory": self.territory, + "industry": self.industry, + "annual_revenue": self.annual_revenue, + } + ) + organization.insert(ignore_permissions=True) + return organization.name + + def update_lead_contact(self, contact): + contact = jingrow.get_cached_pg("Contact", contact) + jingrow.db.set_value( + "CRM Lead", + self.name, + { + "salutation": contact.salutation, + "first_name": contact.first_name, + "last_name": contact.last_name, + "email": contact.email_id, + "mobile_no": contact.mobile_no, + }, + ) + + def contact_exists(self, throw=True): + email_exist = jingrow.db.exists("Contact Email", {"email_id": self.email}) + phone_exist = jingrow.db.exists("Contact Phone", {"phone": self.phone}) + mobile_exist = jingrow.db.exists("Contact Phone", {"phone": self.mobile_no}) + + pagetype = "Contact Email" if email_exist else "Contact Phone" + name = email_exist or phone_exist or mobile_exist + + if name: + text = "Email" if email_exist else "Phone" if phone_exist else "Mobile No" + data = self.email if email_exist else self.phone if phone_exist else self.mobile_no + + value = "{0}: {1}".format(text, data) + + contact = jingrow.db.get_value(pagetype, name, "parent") + + if throw: + jingrow.throw( + _("Contact already exists with {0}").format(value), + title=_("Contact Already Exists"), + ) + return contact + + return False + + def create_deal(self, contact, organization, deal=None): + new_deal = jingrow.new_pg("CRM Deal") + + lead_deal_map = { + "lead_owner": "deal_owner", + } + + restricted_fieldtypes = [ + "Tab Break", + "Section Break", + "Column Break", + "HTML", + "Button", + "Attach", + ] + restricted_map_fields = [ + "name", + "naming_series", + "creation", + "owner", + "modified", + "modified_by", + "idx", + "pagestatus", + "status", + "email", + "mobile_no", + "phone", + "sla", + "sla_status", + "response_by", + "first_response_time", + "first_responded_on", + "communication_status", + "sla_creation", + "status_change_log", + ] + + for field in self.meta.fields: + if field.fieldtype in restricted_fieldtypes: + continue + if field.fieldname in restricted_map_fields: + continue + + fieldname = field.fieldname + if field.fieldname in lead_deal_map: + fieldname = lead_deal_map[field.fieldname] + + if hasattr(new_deal, fieldname): + if fieldname == "organization": + new_deal.update({fieldname: organization}) + else: + new_deal.update({fieldname: self.get(field.fieldname)}) + + new_deal.update( + { + "lead": self.name, + "contacts": [{"contact": contact}], + } + ) + + if self.first_responded_on: + new_deal.update( + { + "sla_creation": self.sla_creation, + "response_by": self.response_by, + "sla_status": self.sla_status, + "communication_status": self.communication_status, + "first_response_time": self.first_response_time, + "first_responded_on": self.first_responded_on, + } + ) + + if deal: + new_deal.update(deal) + + new_deal.insert(ignore_permissions=True) + return new_deal.name + + def set_sla(self): + """ + Find an SLA to apply to the lead. + """ + if self.sla: + return + + sla = get_sla(self) + if not sla: + self.first_responded_on = None + self.first_response_time = None + return + self.sla = sla.name + + def apply_sla(self): + """ + Apply SLA if set. + """ + if not self.sla: + return + sla = jingrow.get_last_pg("CRM Service Level Agreement", {"name": self.sla}) + if sla: + sla.apply(self) + + def convert_to_deal(self, deal=None): + return convert_to_deal(lead=self.name, pg=self, deal=deal) + + @staticmethod + def get_non_filterable_fields(): + return ["converted"] + + @staticmethod + def default_list_data(): + columns = [ + { + "label": "Name", + "type": "Data", + "key": "lead_name", + "width": "12rem", + }, + { + "label": "Organization", + "type": "Link", + "key": "organization", + "options": "CRM Organization", + "width": "10rem", + }, + { + "label": "Status", + "type": "Select", + "key": "status", + "width": "8rem", + }, + { + "label": "Email", + "type": "Data", + "key": "email", + "width": "12rem", + }, + { + "label": "Mobile No", + "type": "Data", + "key": "mobile_no", + "width": "11rem", + }, + { + "label": "Assigned To", + "type": "Text", + "key": "_assign", + "width": "10rem", + }, + { + "label": "Last Modified", + "type": "Datetime", + "key": "modified", + "width": "8rem", + }, + ] + rows = [ + "name", + "lead_name", + "organization", + "status", + "email", + "mobile_no", + "lead_owner", + "first_name", + "sla_status", + "response_by", + "first_response_time", + "first_responded_on", + "modified", + "_assign", + "image", + ] + return {"columns": columns, "rows": rows} + + @staticmethod + def default_kanban_settings(): + return { + "column_field": "status", + "title_field": "lead_name", + "kanban_fields": '["organization", "email", "mobile_no", "_assign", "modified"]', + } + + +@jingrow.whitelist() +def convert_to_deal(lead, pg=None, deal=None, existing_contact=None, existing_organization=None): + if not (pg and pg.flags.get("ignore_permissions")) and not jingrow.has_permission( + "CRM Lead", "write", lead + ): + jingrow.throw(_("Not allowed to convert Lead to Deal"), jingrow.PermissionError) + + lead = jingrow.get_cached_pg("CRM Lead", lead) + if jingrow.db.exists("CRM Lead Status", "Qualified"): + lead.db_set("status", "Qualified") + lead.db_set("converted", 1) + if lead.sla and jingrow.db.exists("CRM Communication Status", "Replied"): + lead.db_set("communication_status", "Replied") + contact = lead.create_contact(existing_contact, False) + organization = lead.create_organization(existing_organization) + _deal = lead.create_deal(contact, organization, deal) + return _deal diff --git a/crm/fcrm/pagetype/crm_lead/test_crm_lead.py b/crm/fcrm/pagetype/crm_lead/test_crm_lead.py new file mode 100644 index 0000000..0160713 --- /dev/null +++ b/crm/fcrm/pagetype/crm_lead/test_crm_lead.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMLead(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_lead_source/__init__.py b/crm/fcrm/pagetype/crm_lead_source/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_lead_source/crm_lead_source.js b/crm/fcrm/pagetype/crm_lead_source/crm_lead_source.js new file mode 100644 index 0000000..441ce65 --- /dev/null +++ b/crm/fcrm/pagetype/crm_lead_source/crm_lead_source.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Lead Source", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_lead_source/crm_lead_source.json b/crm/fcrm/pagetype/crm_lead_source/crm_lead_source.json new file mode 100644 index 0000000..d0c9f00 --- /dev/null +++ b/crm/fcrm/pagetype/crm_lead_source/crm_lead_source.json @@ -0,0 +1,88 @@ +{ + "actions": [], + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:source_name", + "creation": "2023-07-24 19:47:01.063203", + "default_view": "List", + "pagetype": "PageType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "source_name", + "details" + ], + "fields": [ + { + "fieldname": "source_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Source Name", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "details", + "fieldtype": "Text Editor", + "label": "Details" + } + ], + "grid_page_length": 50, + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-06-30 16:53:51.721752", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Lead Source", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "All", + "share": 1 + } + ], + "quick_entry": 1, + "row_format": "Dynamic", + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} diff --git a/crm/fcrm/pagetype/crm_lead_source/crm_lead_source.py b/crm/fcrm/pagetype/crm_lead_source/crm_lead_source.py new file mode 100644 index 0000000..918a720 --- /dev/null +++ b/crm/fcrm/pagetype/crm_lead_source/crm_lead_source.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMLeadSource(Page): + pass diff --git a/crm/fcrm/pagetype/crm_lead_source/test_crm_lead_source.py b/crm/fcrm/pagetype/crm_lead_source/test_crm_lead_source.py new file mode 100644 index 0000000..b3c4ccc --- /dev/null +++ b/crm/fcrm/pagetype/crm_lead_source/test_crm_lead_source.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMLeadSource(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_lead_status/__init__.py b/crm/fcrm/pagetype/crm_lead_status/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_lead_status/crm_lead_status.js b/crm/fcrm/pagetype/crm_lead_status/crm_lead_status.js new file mode 100644 index 0000000..e7130cd --- /dev/null +++ b/crm/fcrm/pagetype/crm_lead_status/crm_lead_status.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Lead Status", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json b/crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json new file mode 100644 index 0000000..0449646 --- /dev/null +++ b/crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json @@ -0,0 +1,84 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:lead_status", + "creation": "2023-11-29 11:09:53.678414", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "lead_status", + "color", + "position" + ], + "fields": [ + { + "default": "gray", + "fieldname": "color", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Color", + "options": "black\ngray\nblue\ngreen\nred\npink\norange\namber\nyellow\ncyan\nteal\nviolet\npurple" + }, + { + "fieldname": "lead_status", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Status", + "reqd": 1, + "unique": 1 + }, + { + "default": "1", + "fieldname": "position", + "fieldtype": "Int", + "in_list_view": 1, + "label": "Position" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-01-02 22:13:43.038656", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Lead Status", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "All", + "share": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_lead_status/crm_lead_status.py b/crm/fcrm/pagetype/crm_lead_status/crm_lead_status.py new file mode 100644 index 0000000..ee39202 --- /dev/null +++ b/crm/fcrm/pagetype/crm_lead_status/crm_lead_status.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMLeadStatus(Page): + pass diff --git a/crm/fcrm/pagetype/crm_lead_status/test_crm_lead_status.py b/crm/fcrm/pagetype/crm_lead_status/test_crm_lead_status.py new file mode 100644 index 0000000..53eac93 --- /dev/null +++ b/crm/fcrm/pagetype/crm_lead_status/test_crm_lead_status.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMLeadStatus(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_lost_reason/__init__.py b/crm/fcrm/pagetype/crm_lost_reason/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.js b/crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.js new file mode 100644 index 0000000..1b01c1e --- /dev/null +++ b/crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.js @@ -0,0 +1,8 @@ +// Copyright (c) 2025, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Lost Reason", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.json b/crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.json new file mode 100644 index 0000000..ae45218 --- /dev/null +++ b/crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.json @@ -0,0 +1,79 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:lost_reason", + "creation": "2025-06-30 16:51:31.082360", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "lost_reason", + "description" + ], + "fields": [ + { + "fieldname": "lost_reason", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Lost Reason", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "description", + "fieldtype": "Text Editor", + "label": "Description" + } + ], + "grid_page_length": 50, + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-06-30 16:59:15.094049", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Lost Reason", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + } + ], + "quick_entry": 1, + "row_format": "Dynamic", + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} diff --git a/crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.py b/crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.py new file mode 100644 index 0000000..e583f25 --- /dev/null +++ b/crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.py @@ -0,0 +1,9 @@ +# Copyright (c) 2025, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMLostReason(Page): + pass diff --git a/crm/fcrm/pagetype/crm_lost_reason/test_crm_lost_reason.py b/crm/fcrm/pagetype/crm_lost_reason/test_crm_lost_reason.py new file mode 100644 index 0000000..756f26f --- /dev/null +++ b/crm/fcrm/pagetype/crm_lost_reason/test_crm_lost_reason.py @@ -0,0 +1,30 @@ +# Copyright (c) 2025, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import IntegrationTestCase, UnitTestCase + + +# On IntegrationTestCase, the pagetype test records and all +# link-field test record dependencies are recursively loaded +# Use these module variables to add/remove to/from that list +EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] +IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] + + +class UnitTestCRMLostReason(UnitTestCase): + """ + Unit tests for CRMLostReason. + Use this class for testing individual functions and methods. + """ + + pass + + +class IntegrationTestCRMLostReason(IntegrationTestCase): + """ + Integration tests for CRMLostReason. + Use this class for testing interactions between multiple components. + """ + + pass diff --git a/crm/fcrm/pagetype/crm_notification/__init__.py b/crm/fcrm/pagetype/crm_notification/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_notification/crm_notification.js b/crm/fcrm/pagetype/crm_notification/crm_notification.js new file mode 100644 index 0000000..b5af039 --- /dev/null +++ b/crm/fcrm/pagetype/crm_notification/crm_notification.js @@ -0,0 +1,8 @@ +// Copyright (c) 2024, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Notification", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_notification/crm_notification.json b/crm/fcrm/pagetype/crm_notification/crm_notification.json new file mode 100644 index 0000000..fe94657 --- /dev/null +++ b/crm/fcrm/pagetype/crm_notification/crm_notification.json @@ -0,0 +1,165 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2024-01-29 19:31:13.613929", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "notification_text", + "section_break_hace", + "from_user", + "type", + "column_break_dduu", + "to_user", + "read", + "section_break_pbvx", + "reference_pagetype", + "reference_name", + "column_break_eant", + "notification_type_pagetype", + "notification_type_pg", + "comment", + "section_break_vpwa", + "message" + ], + "fields": [ + { + "fieldname": "from_user", + "fieldtype": "Link", + "label": "From User", + "options": "User" + }, + { + "fieldname": "type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Type", + "options": "Mention\nTask\nAssignment\nWhatsApp", + "reqd": 1 + }, + { + "fieldname": "column_break_dduu", + "fieldtype": "Column Break" + }, + { + "fieldname": "to_user", + "fieldtype": "Link", + "in_list_view": 1, + "label": "To User", + "options": "User", + "reqd": 1 + }, + { + "fieldname": "comment", + "fieldtype": "Link", + "hidden": 1, + "label": "Comment", + "options": "Comment" + }, + { + "default": "0", + "fieldname": "read", + "fieldtype": "Check", + "label": "Read" + }, + { + "fieldname": "section_break_vpwa", + "fieldtype": "Section Break" + }, + { + "fieldname": "message", + "fieldtype": "HTML Editor", + "in_list_view": 1, + "label": "Message" + }, + { + "fieldname": "reference_name", + "fieldtype": "Dynamic Link", + "label": "Reference Pg", + "options": "reference_pagetype" + }, + { + "fieldname": "reference_pagetype", + "fieldtype": "Link", + "label": "Reference Pagetype", + "options": "PageType" + }, + { + "fieldname": "section_break_pbvx", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_eant", + "fieldtype": "Column Break" + }, + { + "fieldname": "notification_type_pagetype", + "fieldtype": "Link", + "label": "Notification Type Pagetype", + "options": "PageType" + }, + { + "fieldname": "notification_type_pg", + "fieldtype": "Dynamic Link", + "label": "Notification Type Pg", + "options": "notification_type_pagetype" + }, + { + "fieldname": "notification_text", + "fieldtype": "Text", + "label": "Notification Text" + }, + { + "fieldname": "section_break_hace", + "fieldtype": "Section Break" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2024-09-23 19:34:08.635305", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Notification", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_notification/crm_notification.py b/crm/fcrm/pagetype/crm_notification/crm_notification.py new file mode 100644 index 0000000..54f7330 --- /dev/null +++ b/crm/fcrm/pagetype/crm_notification/crm_notification.py @@ -0,0 +1,37 @@ +# Copyright (c) 2024, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow import _ +from jingrow.model.page import Page + + +class CRMNotification(Page): + def on_update(self): + if self.to_user: + jingrow.publish_realtime("crm_notification", user= self.to_user) + +def notify_user(args): + """ + Notify the assigned user + """ + args = jingrow._dict(args) + if args.owner == args.assigned_to: + return + + values = jingrow._dict( + pagetype="CRM Notification", + from_user=args.owner, + to_user=args.assigned_to, + type=args.notification_type, + message=args.message, + notification_text=args.notification_text, + notification_type_pagetype=args.reference_pagetype, + notification_type_pg=args.reference_docname, + reference_pagetype=args.redirect_to_pagetype, + reference_name=args.redirect_to_docname, + ) + + if jingrow.db.exists("CRM Notification", values): + return + jingrow.get_pg(values).insert(ignore_permissions=True) diff --git a/crm/fcrm/pagetype/crm_notification/test_crm_notification.py b/crm/fcrm/pagetype/crm_notification/test_crm_notification.py new file mode 100644 index 0000000..bcdc39b --- /dev/null +++ b/crm/fcrm/pagetype/crm_notification/test_crm_notification.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMNotification(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_organization/__init__.py b/crm/fcrm/pagetype/crm_organization/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_organization/crm_organization.js b/crm/fcrm/pagetype/crm_organization/crm_organization.js new file mode 100644 index 0000000..6dfc1ad --- /dev/null +++ b/crm/fcrm/pagetype/crm_organization/crm_organization.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Organization", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_organization/crm_organization.json b/crm/fcrm/pagetype/crm_organization/crm_organization.json new file mode 100644 index 0000000..7c513a1 --- /dev/null +++ b/crm/fcrm/pagetype/crm_organization/crm_organization.json @@ -0,0 +1,125 @@ +{ + "actions": [], + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:organization_name", + "creation": "2023-11-03 16:23:59.341751", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "organization_name", + "no_of_employees", + "currency", + "exchange_rate", + "annual_revenue", + "organization_logo", + "column_break_pnpp", + "website", + "territory", + "industry", + "address" + ], + "fields": [ + { + "fieldname": "organization_name", + "fieldtype": "Data", + "label": "Organization Name", + "unique": 1 + }, + { + "fieldname": "website", + "fieldtype": "Data", + "label": "Website" + }, + { + "fieldname": "organization_logo", + "fieldtype": "Attach Image", + "label": "Organization Logo" + }, + { + "fieldname": "no_of_employees", + "fieldtype": "Select", + "label": "No. of Employees", + "options": "1-10\n11-50\n51-200\n201-500\n501-1000\n1000+" + }, + { + "fieldname": "column_break_pnpp", + "fieldtype": "Column Break" + }, + { + "fieldname": "annual_revenue", + "fieldtype": "Currency", + "label": "Annual Revenue", + "options": "currency" + }, + { + "fieldname": "industry", + "fieldtype": "Link", + "label": "Industry", + "options": "CRM Industry" + }, + { + "fieldname": "territory", + "fieldtype": "Link", + "label": "Territory", + "options": "CRM Territory" + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "options": "Currency" + }, + { + "fieldname": "address", + "fieldtype": "Link", + "label": "Address", + "options": "Address" + }, + { + "description": "The rate used to convert the organization\u2019s currency to your crm's base currency (set in CRM Settings). It is set once when the currency is first added and doesn't change automatically.", + "fieldname": "exchange_rate", + "fieldtype": "Float", + "label": "Exchange Rate" + } + ], + "image_field": "organization_logo", + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-07-15 11:40:12.175598", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Organization", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "row_format": "Dynamic", + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} diff --git a/crm/fcrm/pagetype/crm_organization/crm_organization.py b/crm/fcrm/pagetype/crm_organization/crm_organization.py new file mode 100644 index 0000000..8a12402 --- /dev/null +++ b/crm/fcrm/pagetype/crm_organization/crm_organization.py @@ -0,0 +1,68 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow.model.page import Page + +from crm.fcrm.pagetype.fcrm_settings.fcrm_settings import get_exchange_rate + + +class CRMOrganization(Page): + def validate(self): + self.update_exchange_rate() + + def update_exchange_rate(self): + if self.has_value_changed("currency") or not self.exchange_rate: + system_currency = jingrow.db.get_single_value("FCRM Settings", "currency") or "USD" + exchange_rate = 1 + if self.currency and self.currency != system_currency: + exchange_rate = get_exchange_rate(self.currency, system_currency) + + self.db_set("exchange_rate", exchange_rate) + + @staticmethod + def default_list_data(): + columns = [ + { + "label": "Organization", + "type": "Data", + "key": "organization_name", + "width": "16rem", + }, + { + "label": "Website", + "type": "Data", + "key": "website", + "width": "14rem", + }, + { + "label": "Industry", + "type": "Link", + "key": "industry", + "options": "CRM Industry", + "width": "14rem", + }, + { + "label": "Annual Revenue", + "type": "Currency", + "key": "annual_revenue", + "width": "14rem", + }, + { + "label": "Last Modified", + "type": "Datetime", + "key": "modified", + "width": "8rem", + }, + ] + rows = [ + "name", + "organization_name", + "organization_logo", + "website", + "industry", + "currency", + "annual_revenue", + "modified", + ] + return {"columns": columns, "rows": rows} diff --git a/crm/fcrm/pagetype/crm_organization/test_crm_organization.py b/crm/fcrm/pagetype/crm_organization/test_crm_organization.py new file mode 100644 index 0000000..c3d02d4 --- /dev/null +++ b/crm/fcrm/pagetype/crm_organization/test_crm_organization.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMOrganization(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_product/__init__.py b/crm/fcrm/pagetype/crm_product/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_product/crm_product.js b/crm/fcrm/pagetype/crm_product/crm_product.js new file mode 100644 index 0000000..7c3d76a --- /dev/null +++ b/crm/fcrm/pagetype/crm_product/crm_product.js @@ -0,0 +1,9 @@ +// Copyright (c) 2025, JINGROW and contributors +// For license information, please see license.txt + +jingrow.ui.form.on("CRM Product", { + product_code: function (frm) { + if (!frm.pg.product_name) + frm.set_value("product_name", frm.pg.product_code); + } +}); diff --git a/crm/fcrm/pagetype/crm_product/crm_product.json b/crm/fcrm/pagetype/crm_product/crm_product.json new file mode 100644 index 0000000..fa49de2 --- /dev/null +++ b/crm/fcrm/pagetype/crm_product/crm_product.json @@ -0,0 +1,105 @@ +{ + "actions": [], + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:product_code", + "creation": "2025-04-28 11:45:09.309636", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "naming_series", + "product_code", + "product_name", + "column_break_bpdj", + "disabled", + "standard_rate", + "image", + "section_break_rtwm", + "description" + ], + "fields": [ + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Naming Series", + "options": "CRM-PROD-.YYYY.-" + }, + { + "fieldname": "product_code", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Product Code", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "product_name", + "fieldtype": "Data", + "label": "Product Name" + }, + { + "fieldname": "column_break_bpdj", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "disabled", + "fieldtype": "Check", + "label": "Disabled" + }, + { + "fieldname": "image", + "fieldtype": "Attach Image", + "label": "Image" + }, + { + "fieldname": "section_break_rtwm", + "fieldtype": "Section Break" + }, + { + "fieldname": "description", + "fieldtype": "Text Editor", + "label": "Description" + }, + { + "fieldname": "standard_rate", + "fieldtype": "Currency", + "label": "Standard Selling Rate" + } + ], + "grid_page_length": 50, + "image_field": "image", + "index_web_pages_for_search": 1, + "links": [], + "make_attachments_public": 1, + "modified": "2025-04-28 12:47:25.087957", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Product", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "quick_entry": 1, + "row_format": "Dynamic", + "search_fields": "product_name,description", + "show_name_in_global_search": 1, + "show_preview_popup": 1, + "sort_field": "creation", + "sort_order": "DESC", + "states": [], + "title_field": "product_name", + "track_changes": 1 +} diff --git a/crm/fcrm/pagetype/crm_product/crm_product.py b/crm/fcrm/pagetype/crm_product/crm_product.py new file mode 100644 index 0000000..4b7d864 --- /dev/null +++ b/crm/fcrm/pagetype/crm_product/crm_product.py @@ -0,0 +1,16 @@ +# Copyright (c) 2025, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow.model.page import Page + + +class CRMProduct(Page): + def validate(self): + self.set_product_name() + + def set_product_name(self): + if not self.product_name: + self.product_name = self.product_code + else: + self.product_name = self.product_name.strip() diff --git a/crm/fcrm/pagetype/crm_product/test_crm_product.py b/crm/fcrm/pagetype/crm_product/test_crm_product.py new file mode 100644 index 0000000..024c023 --- /dev/null +++ b/crm/fcrm/pagetype/crm_product/test_crm_product.py @@ -0,0 +1,29 @@ +# Copyright (c) 2025, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import IntegrationTestCase, UnitTestCase + +# On IntegrationTestCase, the pagetype test records and all +# link-field test record dependencies are recursively loaded +# Use these module variables to add/remove to/from that list +EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] +IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] + + +class UnitTestCRMProduct(UnitTestCase): + """ + Unit tests for CRMProduct. + Use this class for testing individual functions and methods. + """ + + pass + + +class IntegrationTestCRMProduct(IntegrationTestCase): + """ + Integration tests for CRMProduct. + Use this class for testing interactions between multiple components. + """ + + pass diff --git a/crm/fcrm/pagetype/crm_products/__init__.py b/crm/fcrm/pagetype/crm_products/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_products/crm_products.json b/crm/fcrm/pagetype/crm_products/crm_products.json new file mode 100644 index 0000000..ef3618a --- /dev/null +++ b/crm/fcrm/pagetype/crm_products/crm_products.json @@ -0,0 +1,136 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2025-04-28 12:50:49.812915", + "pagetype": "PageType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "product_code", + "column_break_gvbc", + "product_name", + "section_break_fnvf", + "qty", + "column_break_ajac", + "rate", + "section_break_olqb", + "discount_percentage", + "column_break_uvra", + "discount_amount", + "section_break_cnpb", + "column_break_pozr", + "amount", + "column_break_ejqw", + "net_amount" + ], + "fields": [ + { + "fieldname": "column_break_gvbc", + "fieldtype": "Column Break" + }, + { + "fieldname": "product_name", + "fieldtype": "Data", + "label": "Product Name", + "reqd": 1 + }, + { + "fieldname": "section_break_fnvf", + "fieldtype": "Section Break" + }, + { + "fieldname": "section_break_olqb", + "fieldtype": "Section Break" + }, + { + "bold": 1, + "fieldname": "discount_percentage", + "fieldtype": "Percent", + "label": "Discount %" + }, + { + "fieldname": "discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount", + "options": "currency", + "read_only": 1 + }, + { + "fieldname": "section_break_cnpb", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_pozr", + "fieldtype": "Column Break" + }, + { + "bold": 1, + "fieldname": "rate", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Rate", + "options": "currency", + "reqd": 1 + }, + { + "bold": 1, + "fieldname": "amount", + "fieldtype": "Currency", + "label": "Amount", + "options": "currency", + "read_only": 1 + }, + { + "bold": 1, + "depends_on": "discount_percentage", + "description": "Amount after discount", + "fieldname": "net_amount", + "fieldtype": "Currency", + "label": "Net Amount", + "options": "currency", + "read_only": 1 + }, + { + "bold": 1, + "columns": 5, + "fieldname": "product_code", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Product", + "options": "CRM Product" + }, + { + "bold": 1, + "default": "1", + "fieldname": "qty", + "fieldtype": "Float", + "label": "Quantity" + }, + { + "fieldname": "column_break_ajac", + "fieldtype": "Column Break" + }, + { + "fieldname": "column_break_uvra", + "fieldtype": "Column Break" + }, + { + "fieldname": "column_break_ejqw", + "fieldtype": "Column Break" + } + ], + "grid_page_length": 50, + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2025-05-14 18:52:26.183306", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Products", + "owner": "Administrator", + "permissions": [], + "row_format": "Dynamic", + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} diff --git a/crm/fcrm/pagetype/crm_products/crm_products.py b/crm/fcrm/pagetype/crm_products/crm_products.py new file mode 100644 index 0000000..b22db21 --- /dev/null +++ b/crm/fcrm/pagetype/crm_products/crm_products.py @@ -0,0 +1,110 @@ +# Copyright (c) 2025, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow.model.page import Page + + +class CRMProducts(Page): + pass + + +def create_product_details_script(pagetype): + if not jingrow.db.exists("CRM Form Script", "Product Details Script for " + pagetype): + script = get_product_details_script(pagetype) + jingrow.get_pg( + { + "pagetype": "CRM Form Script", + "name": "Product Details Script for " + pagetype, + "dt": pagetype, + "view": "Form", + "script": script, + "enabled": 1, + "is_standard": 1, + } + ).insert() + + +def get_product_details_script(pagetype): + pagetype_class = "class " + pagetype.replace(" ", "") + + return ( + pagetype_class + + " {" + + """ + update_total() { + let total = 0 + let total_qty = 0 + let net_total = 0 + let discount_applied = false + + this.pg.products.forEach((d) => { + total += d.amount + net_total += d.net_amount + if (d.discount_percentage > 0) { + discount_applied = true + } + }) + + this.pg.total = total + this.pg.net_total = net_total || total + + if (!net_total && discount_applied) { + this.pg.net_total = net_total + } + } +} + +class CRMProducts { + products_add() { + let row = this.pg.getRow('products') + row.trigger('qty') + this.pg.trigger('update_total') + } + + products_remove() { + this.pg.trigger('update_total') + } + + async product_code(idx) { + let row = this.pg.getRow('products', idx) + + let a = await call("jingrow.client.get_value", { + pagetype: "CRM Product", + filters: { name: row.product_code }, + fieldname: ["product_name", "standard_rate"], + }) + + row.product_name = a.product_name + if (a.standard_rate && !row.rate) { + row.rate = a.standard_rate + row.trigger("rate") + } + } + + qty(idx) { + let row = this.pg.getRow('products', idx) + row.amount = row.qty * row.rate + row.trigger('discount_percentage', idx) + } + + rate() { + let row = this.pg.getRow('products') + row.amount = row.qty * row.rate + row.trigger('discount_percentage') + } + + discount_percentage(idx) { + let row = this.pg.getRow('products', idx) + if (!row.discount_percentage) { + row.net_amount = row.amount + row.discount_amount = 0 + } + if (row.discount_percentage && row.amount) { + row.discount_amount = (row.discount_percentage / 100) * row.amount + row.net_amount = row.amount - row.discount_amount + } + this.pg.trigger('update_total') + } +}""" + ) diff --git a/crm/fcrm/pagetype/crm_service_day/__init__.py b/crm/fcrm/pagetype/crm_service_day/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_service_day/crm_service_day.json b/crm/fcrm/pagetype/crm_service_day/crm_service_day.json new file mode 100644 index 0000000..993a0ea --- /dev/null +++ b/crm/fcrm/pagetype/crm_service_day/crm_service_day.json @@ -0,0 +1,59 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2023-12-04 16:07:20.400084", + "pagetype": "PageType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "workday", + "section_break_uegc", + "start_time", + "column_break_maie", + "end_time" + ], + "fields": [ + { + "fieldname": "workday", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Workday", + "options": "Monday\nTuesday\nWednesday\nThursday\nFriday\nSaturday\nSunday", + "reqd": 1 + }, + { + "fieldname": "section_break_uegc", + "fieldtype": "Section Break" + }, + { + "fieldname": "start_time", + "fieldtype": "Time", + "in_list_view": 1, + "label": "Start Time", + "reqd": 1 + }, + { + "fieldname": "column_break_maie", + "fieldtype": "Column Break" + }, + { + "fieldname": "end_time", + "fieldtype": "Time", + "in_list_view": 1, + "label": "End Time", + "reqd": 1 + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2023-12-04 16:09:22.928308", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Service Day", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_service_day/crm_service_day.py b/crm/fcrm/pagetype/crm_service_day/crm_service_day.py new file mode 100644 index 0000000..123b15f --- /dev/null +++ b/crm/fcrm/pagetype/crm_service_day/crm_service_day.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMServiceDay(Page): + pass diff --git a/crm/fcrm/pagetype/crm_service_level_agreement/__init__.py b/crm/fcrm/pagetype/crm_service_level_agreement/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.js b/crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.js new file mode 100644 index 0000000..f492f10 --- /dev/null +++ b/crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.js @@ -0,0 +1,18 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +jingrow.ui.form.on("CRM Service Level Agreement", { + validate(frm) { + let default_priority_count = 0; + frm.pg.priorities.forEach(function (row) { + if (row.default_priority) { + default_priority_count++; + } + }); + if (default_priority_count > 1) { + jingrow.throw( + __("There can only be one default priority in Priorities table") + ); + } + }, +}); diff --git a/crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json b/crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json new file mode 100644 index 0000000..af39eb4 --- /dev/null +++ b/crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json @@ -0,0 +1,141 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:sla_name", + "creation": "2023-12-04 13:07:18.426211", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "apply_on", + "column_break_uxua", + "sla_name", + "enabled", + "default", + "section_break_nevd", + "start_date", + "end_date", + "column_break_pzjg", + "condition", + "section_break_ufaf", + "priorities", + "section_break_rmgo", + "holiday_list", + "working_hours" + ], + "fields": [ + { + "fieldname": "sla_name", + "fieldtype": "Data", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "SLA Name", + "reqd": 1, + "unique": 1 + }, + { + "default": "0", + "fieldname": "enabled", + "fieldtype": "Check", + "label": "Enabled" + }, + { + "default": "0", + "fieldname": "default", + "fieldtype": "Check", + "label": "Default" + }, + { + "fieldname": "column_break_uxua", + "fieldtype": "Column Break" + }, + { + "description": "Simple Python Expression, Example: pg.status == 'Open' and pg.lead_source == 'Ads'", + "fieldname": "condition", + "fieldtype": "Code", + "label": "Condition", + "options": "Python" + }, + { + "fieldname": "apply_on", + "fieldtype": "Link", + "label": "Apply On", + "link_filters": "[[{\"fieldname\":\"apply_on\",\"field_option\":\"PageType\"},\"name\",\"in\",[\"CRM Lead\",\"CRM Deal\"]]]", + "options": "PageType", + "reqd": 1 + }, + { + "fieldname": "section_break_ufaf", + "fieldtype": "Section Break", + "label": "Response and Follow Up" + }, + { + "fieldname": "priorities", + "fieldtype": "Table", + "label": "Priorities", + "options": "CRM Service Level Priority", + "reqd": 1 + }, + { + "fieldname": "section_break_rmgo", + "fieldtype": "Section Break", + "label": "Working Hours" + }, + { + "fieldname": "working_hours", + "fieldtype": "Table", + "label": "Working Hours", + "options": "CRM Service Day", + "reqd": 1 + }, + { + "fieldname": "section_break_nevd", + "fieldtype": "Section Break", + "label": "Validity" + }, + { + "fieldname": "start_date", + "fieldtype": "Date", + "label": "Start Date" + }, + { + "fieldname": "column_break_pzjg", + "fieldtype": "Column Break" + }, + { + "fieldname": "end_date", + "fieldtype": "Date", + "label": "End Date" + }, + { + "fieldname": "holiday_list", + "fieldtype": "Link", + "label": "Holiday List", + "options": "CRM Holiday List" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2024-01-19 21:54:25.831753", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Service Level Agreement", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.py b/crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.py new file mode 100644 index 0000000..486b858 --- /dev/null +++ b/crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.py @@ -0,0 +1,225 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow import _ +from datetime import timedelta +from jingrow.model.page import Page +from jingrow.utils import ( + add_to_date, + get_datetime, + get_weekdays, + getdate, + now_datetime, + time_diff_in_seconds, +) +from crm.fcrm.pagetype.crm_service_level_agreement.utils import get_context + + +class CRMServiceLevelAgreement(Page): + def validate(self): + self.validate_default() + self.validate_condition() + + def validate_default(self): + if self.default: + other_slas = jingrow.get_all( + "CRM Service Level Agreement", + filters={"apply_on": self.apply_on, "default": True, "name": ["!=", self.name]}, + fields=["name"], + ) + if other_slas: + jingrow.throw( + _( + "Default Service Level Agreement already exists for {0}" + ).format(self.apply_on) + ) + + def validate_condition(self): + if not self.condition: + return + try: + temp_pg = jingrow.new_pg(self.apply_on) + jingrow.safe_eval(self.condition, None, get_context(temp_pg)) + except Exception as e: + jingrow.throw( + _("The Condition '{0}' is invalid: {1}").format(self.condition, str(e)) + ) + + def apply(self, pg: Page): + self.handle_creation(pg) + self.handle_communication_status(pg) + self.handle_targets(pg) + self.handle_sla_status(pg) + + def handle_creation(self, pg: Page): + pg.sla_creation = pg.sla_creation or now_datetime() + + def handle_communication_status(self, pg: Page): + if pg.is_new() or not pg.has_value_changed("communication_status"): + return + self.set_first_responded_on(pg) + self.set_first_response_time(pg) + + def set_first_responded_on(self, pg: Page): + if pg.communication_status != self.get_default_priority(): + pg.first_responded_on = ( + pg.first_responded_on or now_datetime() + ) + + def set_first_response_time(self, pg: Page): + start_at = pg.sla_creation + end_at = pg.first_responded_on + if not start_at or not end_at: + return + pg.first_response_time = self.calc_elapsed_time(start_at, end_at) + + def handle_targets(self, pg: Page): + self.set_response_by(pg) + + def set_response_by(self, pg: Page): + start_time = pg.sla_creation + communication_status = pg.communication_status + + priorities = self.get_priorities() + priority = priorities.get(communication_status) + if not priority or pg.response_by: + return + + first_response_time = priority.get("first_response_time", 0) + end_time = self.calc_time(start_time, first_response_time) + if end_time: + pg.response_by = end_time + + def handle_sla_status(self, pg: Page): + is_failed = self.is_first_response_failed(pg) + options = { + "Fulfilled": True, + "First Response Due": not pg.first_responded_on, + "Failed": is_failed, + } + for status in options: + if options[status]: + pg.sla_status = status + + def is_first_response_failed(self, pg: Page): + if not pg.first_responded_on: + return get_datetime(pg.response_by) < now_datetime() + return get_datetime(pg.response_by) < get_datetime(pg.first_responded_on) + + def calc_time( + self, + start_at: str, + duration_seconds: int, + ): + res = get_datetime(start_at) + time_needed = duration_seconds + holidays = self.get_holidays() + weekdays = get_weekdays() + workdays = self.get_workdays() + while time_needed: + today = res + today_day = getdate(today) + today_weekday = weekdays[today.weekday()] + is_workday = today_weekday in workdays + is_holiday = today_day in holidays + if is_holiday or not is_workday: + res = add_to_date(res, days=1, as_datetime=True) + continue + today_workday = workdays[today_weekday] + now_in_seconds = time_diff_in_seconds(today, today_day) + start_time = max(today_workday.start_time.total_seconds(), now_in_seconds) + till_start_time = max(start_time - now_in_seconds, 0) + end_time = max(today_workday.end_time.total_seconds(), now_in_seconds) + time_left = max(end_time - start_time, 0) + if not time_left: + res = getdate(add_to_date(res, days=1, as_datetime=True)) + continue + time_taken = min(time_needed, time_left) + time_needed -= time_taken + time_required = till_start_time + time_taken + res = add_to_date(res, seconds=time_required, as_datetime=True) + return res + + def calc_elapsed_time(self, start_time, end_time) -> float: + """ + Get took from start to end, excluding non-working hours + + :param start_at: Date at which calculation starts + :param end_at: Date at which calculation ends + :return: Number of seconds + """ + start_time = get_datetime(start_time) + end_time = get_datetime(end_time) + holiday_list = [] + working_day_list = self.get_working_days() + working_hours = self.get_working_hours() + + total_seconds = 0 + current_time = start_time + + while current_time < end_time: + in_holiday_list = current_time.date() in holiday_list + not_in_working_day_list = get_weekdays()[current_time.weekday()] not in working_day_list + if in_holiday_list or not_in_working_day_list or not self.is_working_time(current_time, working_hours): + current_time += timedelta(seconds=1) + continue + total_seconds += 1 + current_time += timedelta(seconds=1) + + return total_seconds + + def get_priorities(self): + """ + Return priorities related info as a dict. With `priority` as key + """ + res = {} + for row in self.priorities: + res[row.priority] = row + return res + + def get_default_priority(self): + """ + Return default priority + """ + for row in self.priorities: + if row.default_priority: + return row.priority + + return self.priorities[0].priority + + def get_workdays(self) -> dict[str, dict]: + """ + Return workdays related info as a dict. With `workday` as key + """ + res = {} + for row in self.working_hours: + res[row.workday] = row + return res + + def get_working_days(self) -> dict[str, dict]: + workdays = [] + for row in self.working_hours: + workdays.append(row.workday) + return workdays + + def get_working_hours(self) -> dict[str, dict]: + res = {} + for row in self.working_hours: + res[row.workday] = (row.start_time, row.end_time) + return res + + def is_working_time(self, date_time, working_hours): + day_of_week = get_weekdays()[date_time.weekday()] + start_time, end_time = working_hours.get(day_of_week, (0, 0)) + date_time = timedelta(hours=date_time.hour, minutes=date_time.minute, seconds=date_time.second) + return start_time <= date_time < end_time + + def get_holidays(self): + res = [] + if not self.holiday_list: + return res + holiday_list = jingrow.get_pg("CRM Holiday List", self.holiday_list) + for row in holiday_list.holidays: + res.append(row.date) + return res diff --git a/crm/fcrm/pagetype/crm_service_level_agreement/test_crm_service_level_agreement.py b/crm/fcrm/pagetype/crm_service_level_agreement/test_crm_service_level_agreement.py new file mode 100644 index 0000000..60aafb6 --- /dev/null +++ b/crm/fcrm/pagetype/crm_service_level_agreement/test_crm_service_level_agreement.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMServiceLevelAgreement(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_service_level_agreement/utils.py b/crm/fcrm/pagetype/crm_service_level_agreement/utils.py new file mode 100644 index 0000000..52e8df8 --- /dev/null +++ b/crm/fcrm/pagetype/crm_service_level_agreement/utils.py @@ -0,0 +1,61 @@ +import jingrow +from jingrow.model.page import Page +from jingrow.query_builder import JoinType +from jingrow.utils.safe_exec import get_safe_globals +from jingrow.utils import now_datetime +from pypika import Criterion + +def get_sla(pg: Page) -> Page: + """ + Get Service Level Agreement for `pg` + + :param pg: Lead/Deal to use + :return: Applicable SLA + """ + SLA = jingrow.qb.PageType("CRM Service Level Agreement") + Priority = jingrow.qb.PageType("CRM Service Level Priority") + now = now_datetime() + priority = pg.communication_status + q = ( + jingrow.qb.from_(SLA) + .select(SLA.name, SLA.condition) + .where(SLA.apply_on == pg.pagetype) + .where(SLA.enabled == True) + .where(Criterion.any([SLA.start_date.isnull(), SLA.start_date <= now])) + .where(Criterion.any([SLA.end_date.isnull(), SLA.end_date >= now])) + ) + if priority: + q = ( + q.join(Priority, JoinType.inner) + .on(Priority.parent == SLA.name) + .where(Priority.priority == priority) + ) + sla_list = q.run(as_dict=True) + res = None + + # move default sla to the end of the list + for sla in sla_list: + if sla.get("default") == True: + sla_list.remove(sla) + sla_list.append(sla) + break + + for sla in sla_list: + cond = sla.get("condition") + if not cond or jingrow.safe_eval(cond, None, get_context(pg)): + res = sla + break + return res + +def get_context(d: Page) -> dict: + """ + Get safe context for `safe_eval` + + :param pg: `Page` to add in context + :return: Context with `pg` and safe variables + """ + utils = get_safe_globals().get("jingrow").get("utils") + return { + "pg": d.as_dict(), + "jingrow": jingrow._dict(utils=utils), + } \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_service_level_priority/__init__.py b/crm/fcrm/pagetype/crm_service_level_priority/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_service_level_priority/crm_service_level_priority.js b/crm/fcrm/pagetype/crm_service_level_priority/crm_service_level_priority.js new file mode 100644 index 0000000..e80a74a --- /dev/null +++ b/crm/fcrm/pagetype/crm_service_level_priority/crm_service_level_priority.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Service Level Priority", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_service_level_priority/crm_service_level_priority.json b/crm/fcrm/pagetype/crm_service_level_priority/crm_service_level_priority.json new file mode 100644 index 0000000..bd2ff4c --- /dev/null +++ b/crm/fcrm/pagetype/crm_service_level_priority/crm_service_level_priority.json @@ -0,0 +1,64 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2023-12-04 13:18:58.028384", + "pagetype": "PageType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "default_priority", + "column_break_grod", + "priority", + "section_break_anyl", + "first_response_time", + "column_break_bwgs" + ], + "fields": [ + { + "default": "0", + "fieldname": "default_priority", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Default Priority" + }, + { + "fieldname": "priority", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Priority", + "options": "CRM Communication Status", + "reqd": 1 + }, + { + "fieldname": "first_response_time", + "fieldtype": "Duration", + "in_list_view": 1, + "label": "First Response TIme", + "reqd": 1 + }, + { + "fieldname": "column_break_grod", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_anyl", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_bwgs", + "fieldtype": "Column Break" + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2023-12-15 11:49:54.424029", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Service Level Priority", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_service_level_priority/crm_service_level_priority.py b/crm/fcrm/pagetype/crm_service_level_priority/crm_service_level_priority.py new file mode 100644 index 0000000..192d5b9 --- /dev/null +++ b/crm/fcrm/pagetype/crm_service_level_priority/crm_service_level_priority.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMServiceLevelPriority(Page): + pass diff --git a/crm/fcrm/pagetype/crm_service_level_priority/test_crm_service_level_priority.py b/crm/fcrm/pagetype/crm_service_level_priority/test_crm_service_level_priority.py new file mode 100644 index 0000000..0248c03 --- /dev/null +++ b/crm/fcrm/pagetype/crm_service_level_priority/test_crm_service_level_priority.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMServiceLevelPriority(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_status_change_log/__init__.py b/crm/fcrm/pagetype/crm_status_change_log/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.json b/crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.json new file mode 100644 index 0000000..f3e3da2 --- /dev/null +++ b/crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.json @@ -0,0 +1,93 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2024-01-06 13:15:31.392201", + "pagetype": "PageType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "from", + "to", + "from_date", + "to_date", + "column_break_mwmz", + "duration", + "last_status_change_log", + "from_type", + "to_type", + "log_owner" + ], + "fields": [ + { + "fieldname": "from", + "fieldtype": "Data", + "in_list_view": 1, + "label": "From" + }, + { + "fieldname": "from_date", + "fieldtype": "Datetime", + "in_list_view": 1, + "label": "From Date" + }, + { + "fieldname": "duration", + "fieldtype": "Duration", + "in_list_view": 1, + "label": "Duration" + }, + { + "fieldname": "column_break_mwmz", + "fieldtype": "Column Break" + }, + { + "fieldname": "to", + "fieldtype": "Data", + "in_list_view": 1, + "label": "To" + }, + { + "fieldname": "to_date", + "fieldtype": "Datetime", + "in_list_view": 1, + "label": "To Date" + }, + { + "fieldname": "last_status_change_log", + "fieldtype": "Link", + "label": "Last Status Change Log", + "options": "CRM Status Change Log" + }, + { + "fieldname": "log_owner", + "fieldtype": "Link", + "label": "Owner", + "options": "User" + }, + { + "fieldname": "from_type", + "fieldtype": "Data", + "in_list_view": 1, + "label": "From Type" + }, + { + "fieldname": "to_type", + "fieldtype": "Data", + "in_list_view": 1, + "label": "To Type" + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2025-07-13 12:37:41.278584", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Status Change Log", + "owner": "Administrator", + "permissions": [], + "row_format": "Dynamic", + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} diff --git a/crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.py b/crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.py new file mode 100644 index 0000000..e73c225 --- /dev/null +++ b/crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.py @@ -0,0 +1,64 @@ +# Copyright (c) 2024, JINGROW and contributors +# For license information, please see license.txt + +from datetime import datetime + +import jingrow +from jingrow.model.page import Page +from jingrow.utils import add_to_date, get_datetime + + +class CRMStatusChangeLog(Page): + pass + + +def get_duration(from_date, to_date): + if not isinstance(from_date, datetime): + from_date = get_datetime(from_date) + if not isinstance(to_date, datetime): + to_date = get_datetime(to_date) + duration = to_date - from_date + return duration.total_seconds() + + +def add_status_change_log(pg): + to_status_type = jingrow.db.get_value("CRM Deal Status", pg.status, "type") if pg.status else None + + if not pg.is_new(): + previous_status = pg.get_pg_before_save().status if pg.get_pg_before_save() else None + previous_status_type = ( + jingrow.db.get_value("CRM Deal Status", previous_status, "type") if previous_status else None + ) + if not pg.status_change_log and previous_status: + now_minus_one_minute = add_to_date(datetime.now(), minutes=-1) + pg.append( + "status_change_log", + { + "from": previous_status, + "from_type": previous_status_type or "", + "to": "", + "to_type": "", + "from_date": now_minus_one_minute, + "to_date": "", + "log_owner": jingrow.session.user, + }, + ) + last_status_change = pg.status_change_log[-1] + last_status_change.to = pg.status + last_status_change.to_type = to_status_type or "" + last_status_change.to_date = datetime.now() + last_status_change.log_owner = jingrow.session.user + last_status_change.duration = get_duration(last_status_change.from_date, last_status_change.to_date) + + pg.append( + "status_change_log", + { + "from": pg.status, + "from_type": to_status_type or "", + "to": "", + "to_type": "", + "from_date": datetime.now(), + "to_date": "", + "log_owner": jingrow.session.user, + }, + ) diff --git a/crm/fcrm/pagetype/crm_task/__init__.py b/crm/fcrm/pagetype/crm_task/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_task/crm_task.js b/crm/fcrm/pagetype/crm_task/crm_task.js new file mode 100644 index 0000000..c76b2ae --- /dev/null +++ b/crm/fcrm/pagetype/crm_task/crm_task.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Task", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_task/crm_task.json b/crm/fcrm/pagetype/crm_task/crm_task.json new file mode 100644 index 0000000..6b241a1 --- /dev/null +++ b/crm/fcrm/pagetype/crm_task/crm_task.json @@ -0,0 +1,125 @@ +{ + "actions": [], + "allow_import": 1, + "autoname": "autoincrement", + "creation": "2023-09-28 15:04:28.084159", + "default_view": "List", + "pagetype": "PageType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "title", + "priority", + "start_date", + "reference_pagetype", + "reference_docname", + "column_break_cqua", + "assigned_to", + "status", + "due_date", + "section_break_bzhd", + "description" + ], + "fields": [ + { + "fieldname": "title", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Title", + "reqd": 1 + }, + { + "fieldname": "priority", + "fieldtype": "Select", + "label": "Priority", + "options": "Low\nMedium\nHigh" + }, + { + "fieldname": "start_date", + "fieldtype": "Date", + "label": "Start Date" + }, + { + "fieldname": "column_break_cqua", + "fieldtype": "Column Break" + }, + { + "fieldname": "assigned_to", + "fieldtype": "Link", + "label": "Assigned To", + "options": "User" + }, + { + "fieldname": "status", + "fieldtype": "Select", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Status", + "options": "Backlog\nTodo\nIn Progress\nDone\nCanceled" + }, + { + "fieldname": "due_date", + "fieldtype": "Datetime", + "label": "Due Date" + }, + { + "fieldname": "section_break_bzhd", + "fieldtype": "Section Break" + }, + { + "fieldname": "description", + "fieldtype": "Text Editor", + "label": "Description" + }, + { + "default": "CRM Lead", + "fieldname": "reference_pagetype", + "fieldtype": "Link", + "label": "Reference Document Type", + "options": "PageType" + }, + { + "fieldname": "reference_docname", + "fieldtype": "Dynamic Link", + "label": "Reference Pg", + "options": "reference_pagetype" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2024-02-08 12:04:00.955984", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Task", + "naming_rule": "Autoincrement", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_task/crm_task.py b/crm/fcrm/pagetype/crm_task/crm_task.py new file mode 100644 index 0000000..37054e4 --- /dev/null +++ b/crm/fcrm/pagetype/crm_task/crm_task.py @@ -0,0 +1,97 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow import _ +from jingrow.model.page import Page +from jingrow.desk.form.assign_to import add as assign, remove as unassign +from crm.fcrm.pagetype.crm_notification.crm_notification import notify_user + + +class CRMTask(Page): + def after_insert(self): + self.assign_to() + + def validate(self): + if self.is_new() or not self.assigned_to: + return + + if self.get_pg_before_save().assigned_to != self.assigned_to: + self.unassign_from_previous_user(self.get_pg_before_save().assigned_to) + self.assign_to() + + def unassign_from_previous_user(self, user): + unassign(self.pagetype, self.name, user) + + def assign_to(self): + if self.assigned_to: + assign({ + "assign_to": [self.assigned_to], + "pagetype": self.pagetype, + "name": self.name, + "description": self.title or self.description, + }) + + + @staticmethod + def default_list_data(): + columns = [ + { + 'label': 'Title', + 'type': 'Data', + 'key': 'title', + 'width': '16rem', + }, + { + 'label': 'Status', + 'type': 'Select', + 'key': 'status', + 'width': '8rem', + }, + { + 'label': 'Priority', + 'type': 'Select', + 'key': 'priority', + 'width': '8rem', + }, + { + 'label': 'Due Date', + 'type': 'Date', + 'key': 'due_date', + 'width': '8rem', + }, + { + 'label': 'Assigned To', + 'type': 'Link', + 'key': 'assigned_to', + 'width': '10rem', + }, + { + 'label': 'Last Modified', + 'type': 'Datetime', + 'key': 'modified', + 'width': '8rem', + }, + ] + + rows = [ + "name", + "title", + "description", + "assigned_to", + "due_date", + "status", + "priority", + "reference_pagetype", + "reference_docname", + "modified", + ] + return {'columns': columns, 'rows': rows} + + @staticmethod + def default_kanban_settings(): + return { + "column_field": "status", + "title_field": "title", + "kanban_fields": '["description", "priority", "creation"]' + } diff --git a/crm/fcrm/pagetype/crm_task/test_crm_task.py b/crm/fcrm/pagetype/crm_task/test_crm_task.py new file mode 100644 index 0000000..52a8c03 --- /dev/null +++ b/crm/fcrm/pagetype/crm_task/test_crm_task.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMTask(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_telephony_agent/__init__.py b/crm/fcrm/pagetype/crm_telephony_agent/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.js b/crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.js new file mode 100644 index 0000000..b08936d --- /dev/null +++ b/crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.js @@ -0,0 +1,8 @@ +// Copyright (c) 2025, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Telephony Agent", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json b/crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json new file mode 100644 index 0000000..1891873 --- /dev/null +++ b/crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json @@ -0,0 +1,140 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:user", + "creation": "2025-01-11 16:12:46.602782", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "user", + "user_name", + "column_break_hdec", + "mobile_no", + "default_medium", + "section_break_ozjn", + "twilio", + "twilio_number", + "call_receiving_device", + "column_break_aydj", + "exotel", + "exotel_number", + "section_break_phlq", + "phone_nos" + ], + "fields": [ + { + "fieldname": "user", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "User", + "options": "User", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "column_break_hdec", + "fieldtype": "Column Break" + }, + { + "fieldname": "mobile_no", + "fieldtype": "Data", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Mobile No.", + "read_only": 1 + }, + { + "fetch_from": "user.full_name", + "fieldname": "user_name", + "fieldtype": "Data", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "User Name" + }, + { + "depends_on": "exotel", + "fieldname": "exotel_number", + "fieldtype": "Data", + "label": "Exotel Number", + "mandatory_depends_on": "exotel" + }, + { + "fieldname": "section_break_phlq", + "fieldtype": "Section Break" + }, + { + "fieldname": "section_break_ozjn", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_aydj", + "fieldtype": "Column Break" + }, + { + "depends_on": "twilio", + "fieldname": "twilio_number", + "fieldtype": "Data", + "label": "Twilio Number", + "mandatory_depends_on": "twilio" + }, + { + "fieldname": "phone_nos", + "fieldtype": "Table", + "label": "Phone Numbers", + "options": "CRM Telephony Phone" + }, + { + "default": "0", + "fieldname": "twilio", + "fieldtype": "Check", + "label": "Twilio" + }, + { + "default": "0", + "fieldname": "exotel", + "fieldtype": "Check", + "label": "Exotel" + }, + { + "fieldname": "default_medium", + "fieldtype": "Select", + "label": "Default Medium", + "options": "\nTwilio\nExotel" + }, + { + "default": "Computer", + "depends_on": "twilio", + "fieldname": "call_receiving_device", + "fieldtype": "Select", + "label": "Device", + "options": "Computer\nPhone" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-01-23 22:24:53.448716", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Telephony Agent", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "creation", + "sort_order": "DESC", + "states": [], + "title_field": "user_name" +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.py b/crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.py new file mode 100644 index 0000000..9119307 --- /dev/null +++ b/crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.py @@ -0,0 +1,34 @@ +# Copyright (c) 2025, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow import _ +from jingrow.model.page import Page + + +class CRMTelephonyAgent(Page): + def validate(self): + self.set_primary() + + def set_primary(self): + # Used to set primary mobile no. + if len(self.phone_nos) == 0: + self.mobile_no = "" + return + + is_primary = [phone.number for phone in self.phone_nos if phone.get("is_primary")] + + if len(is_primary) > 1: + jingrow.throw( + _("Only one {0} can be set as primary.").format(jingrow.bold(jingrow.unscrub("mobile_no"))) + ) + + primary_number_exists = False + for d in self.phone_nos: + if d.get("is_primary") == 1: + primary_number_exists = True + self.mobile_no = d.number + break + + if not primary_number_exists: + self.mobile_no = "" diff --git a/crm/fcrm/pagetype/crm_telephony_agent/test_crm_telephony_agent.py b/crm/fcrm/pagetype/crm_telephony_agent/test_crm_telephony_agent.py new file mode 100644 index 0000000..1d5ca22 --- /dev/null +++ b/crm/fcrm/pagetype/crm_telephony_agent/test_crm_telephony_agent.py @@ -0,0 +1,29 @@ +# Copyright (c) 2025, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import IntegrationTestCase, UnitTestCase + +# On IntegrationTestCase, the pagetype test records and all +# link-field test record dependencies are recursively loaded +# Use these module variables to add/remove to/from that list +EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] +IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] + + +class UnitTestCRMTelephonyAgent(UnitTestCase): + """ + Unit tests for CRMTelephonyAgent. + Use this class for testing individual functions and methods. + """ + + pass + + +class IntegrationTestCRMTelephonyAgent(IntegrationTestCase): + """ + Integration tests for CRMTelephonyAgent. + Use this class for testing interactions between multiple components. + """ + + pass diff --git a/crm/fcrm/pagetype/crm_telephony_phone/__init__.py b/crm/fcrm/pagetype/crm_telephony_phone/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_telephony_phone/crm_telephony_phone.json b/crm/fcrm/pagetype/crm_telephony_phone/crm_telephony_phone.json new file mode 100644 index 0000000..ddb1a1a --- /dev/null +++ b/crm/fcrm/pagetype/crm_telephony_phone/crm_telephony_phone.json @@ -0,0 +1,40 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2025-01-19 13:57:01.702519", + "pagetype": "PageType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "number", + "is_primary" + ], + "fields": [ + { + "fieldname": "number", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Number", + "reqd": 1 + }, + { + "default": "0", + "fieldname": "is_primary", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Is Primary" + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2025-01-19 13:58:59.063775", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Telephony Phone", + "owner": "Administrator", + "permissions": [], + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_telephony_phone/crm_telephony_phone.py b/crm/fcrm/pagetype/crm_telephony_phone/crm_telephony_phone.py new file mode 100644 index 0000000..6842139 --- /dev/null +++ b/crm/fcrm/pagetype/crm_telephony_phone/crm_telephony_phone.py @@ -0,0 +1,9 @@ +# Copyright (c) 2025, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMTelephonyPhone(Page): + pass diff --git a/crm/fcrm/pagetype/crm_territory/__init__.py b/crm/fcrm/pagetype/crm_territory/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_territory/crm_territory.js b/crm/fcrm/pagetype/crm_territory/crm_territory.js new file mode 100644 index 0000000..59090c5 --- /dev/null +++ b/crm/fcrm/pagetype/crm_territory/crm_territory.js @@ -0,0 +1,8 @@ +// Copyright (c) 2024, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Territory", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_territory/crm_territory.json b/crm/fcrm/pagetype/crm_territory/crm_territory.json new file mode 100644 index 0000000..ddc7b7b --- /dev/null +++ b/crm/fcrm/pagetype/crm_territory/crm_territory.json @@ -0,0 +1,129 @@ +{ + "actions": [], + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:territory_name", + "creation": "2024-01-04 18:52:58.872535", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "territory_name", + "column_break_mckp", + "territory_manager", + "section_break_qhaf", + "old_parent", + "parent_crm_territory", + "column_break_pypy", + "lft", + "rgt", + "is_group" + ], + "fields": [ + { + "fieldname": "territory_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Territory Name", + "reqd": 1, + "unique": 1 + }, + { + "default": "0", + "fieldname": "is_group", + "fieldtype": "Check", + "label": "Is Group" + }, + { + "fieldname": "column_break_pypy", + "fieldtype": "Column Break" + }, + { + "fieldname": "territory_manager", + "fieldtype": "Link", + "label": "Territory Manager", + "options": "User" + }, + { + "fieldname": "lft", + "fieldtype": "Int", + "hidden": 1, + "label": "Left", + "no_copy": 1, + "read_only": 1 + }, + { + "fieldname": "rgt", + "fieldtype": "Int", + "hidden": 1, + "label": "Right", + "no_copy": 1, + "read_only": 1 + }, + { + "default": "0", + "fieldname": "is_group", + "fieldtype": "Check", + "label": "Is Group" + }, + { + "fieldname": "old_parent", + "fieldtype": "Link", + "label": "Old Parent", + "options": "CRM Territory" + }, + { + "fieldname": "parent_crm_territory", + "fieldtype": "Link", + "ignore_user_permissions": 1, + "label": "Parent CRM Territory", + "options": "CRM Territory" + }, + { + "fieldname": "column_break_mckp", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_qhaf", + "fieldtype": "Section Break" + } + ], + "index_web_pages_for_search": 1, + "is_tree": 1, + "links": [], + "modified": "2024-01-19 21:53:53.451891", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Territory", + "naming_rule": "By fieldname", + "nsm_parent_field": "parent_crm_territory", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_territory/crm_territory.py b/crm/fcrm/pagetype/crm_territory/crm_territory.py new file mode 100644 index 0000000..c9d0366 --- /dev/null +++ b/crm/fcrm/pagetype/crm_territory/crm_territory.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class CRMTerritory(Page): + pass diff --git a/crm/fcrm/pagetype/crm_territory/test_crm_territory.py b/crm/fcrm/pagetype/crm_territory/test_crm_territory.py new file mode 100644 index 0000000..eccc950 --- /dev/null +++ b/crm/fcrm/pagetype/crm_territory/test_crm_territory.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMTerritory(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_twilio_settings/__init__.py b/crm/fcrm/pagetype/crm_twilio_settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.js b/crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.js new file mode 100644 index 0000000..c59f3c6 --- /dev/null +++ b/crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM Twilio Settings", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.json b/crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.json new file mode 100644 index 0000000..9a600fc --- /dev/null +++ b/crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.json @@ -0,0 +1,159 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2023-08-17 18:38:02.655918", + "default_view": "List", + "pagetype": "PageType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "section_break_ssqj", + "enabled", + "column_break_avmt", + "record_calls", + "section_break_eklq", + "account_sid", + "column_break_yqvr", + "auth_token", + "section_break_malx", + "api_key", + "twiml_sid", + "column_break_idds", + "api_secret" + ], + "fields": [ + { + "depends_on": "enabled", + "fieldname": "account_sid", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Account SID", + "mandatory_depends_on": "eval: pg.enabled" + }, + { + "depends_on": "enabled", + "fieldname": "api_key", + "fieldtype": "Data", + "label": "API Key", + "permlevel": 1, + "read_only": 1 + }, + { + "depends_on": "enabled", + "fieldname": "api_secret", + "fieldtype": "Password", + "label": "API Secret", + "permlevel": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_idds", + "fieldtype": "Column Break" + }, + { + "depends_on": "enabled", + "fieldname": "auth_token", + "fieldtype": "Password", + "in_list_view": 1, + "label": "Auth Token", + "mandatory_depends_on": "eval: pg.enabled" + }, + { + "depends_on": "enabled", + "fieldname": "twiml_sid", + "fieldtype": "Data", + "label": "TwiML SID", + "permlevel": 1 + }, + { + "fieldname": "section_break_ssqj", + "fieldtype": "Section Break" + }, + { + "default": "0", + "depends_on": "enabled", + "fieldname": "record_calls", + "fieldtype": "Check", + "label": "Record Calls" + }, + { + "fieldname": "column_break_avmt", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_malx", + "fieldtype": "Section Break", + "hide_border": 1 + }, + { + "default": "0", + "fieldname": "enabled", + "fieldtype": "Check", + "label": "Enabled" + }, + { + "fieldname": "section_break_eklq", + "fieldtype": "Section Break", + "hide_border": 1 + }, + { + "fieldname": "column_break_yqvr", + "fieldtype": "Column Break" + } + ], + "index_web_pages_for_search": 1, + "issingle": 1, + "links": [], + "modified": "2025-08-19 13:36:19.823197", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Twilio Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "delete": 1, + "email": 1, + "permlevel": 1, + "print": 1, + "read": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "delete": 1, + "email": 1, + "permlevel": 1, + "print": 1, + "read": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "row_format": "Dynamic", + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "track_changes": 1 +} diff --git a/crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.py b/crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.py new file mode 100644 index 0000000..cdb85c5 --- /dev/null +++ b/crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.py @@ -0,0 +1,84 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +from jingrow import _ +from jingrow.model.page import Page +from twilio.rest import Client + + +class CRMTwilioSettings(Page): + friendly_resource_name = "Jingrow CRM" # System creates TwiML app & API keys with this name. + + def validate(self): + self.validate_twilio_account() + + def on_update(self): + # Single pagetype records are created in DB at time of installation and those field values are set as null. + # This condition make sure that we handle null. + if not self.account_sid: + return + + twilio = Client(self.account_sid, self.get_password("auth_token")) + self.set_api_credentials(twilio) + self.set_application_credentials(twilio) + self.reload() + + def validate_twilio_account(self): + try: + twilio = Client(self.account_sid, self.get_password("auth_token")) + twilio.api.accounts(self.account_sid).fetch() + return twilio + except Exception: + jingrow.throw(_("Invalid Account SID or Auth Token.")) + + def set_api_credentials(self, twilio): + """Generate Twilio API credentials if not exist and update them.""" + if self.api_key and self.api_secret: + return + new_key = self.create_api_key(twilio) + self.api_key = new_key.sid + self.api_secret = new_key.secret + jingrow.db.set_value( + "CRM Twilio Settings", + "CRM Twilio Settings", + {"api_key": self.api_key, "api_secret": self.api_secret}, + ) + + def set_application_credentials(self, twilio): + """Generate TwiML app credentials if not exist and update them.""" + credentials = self.get_application(twilio) or self.create_application(twilio) + self.twiml_sid = credentials.sid + jingrow.db.set_value("CRM Twilio Settings", "CRM Twilio Settings", "twiml_sid", self.twiml_sid) + + def create_api_key(self, twilio): + """Create API keys in twilio account.""" + try: + return twilio.new_keys.create(friendly_name=self.friendly_resource_name) + except Exception: + jingrow.log_error(title=_("Twilio API credential creation error.")) + jingrow.throw(_("Twilio API credential creation error.")) + + def get_twilio_voice_url(self): + url_path = "/api/action/crm.integrations.twilio.api.voice" + return get_public_url(url_path) + + def get_application(self, twilio, friendly_name=None): + """Get TwiML App from twilio account if exists.""" + friendly_name = friendly_name or self.friendly_resource_name + applications = twilio.applications.list(friendly_name) + return applications and applications[0] + + def create_application(self, twilio, friendly_name=None): + """Create TwilML App in twilio account.""" + friendly_name = friendly_name or self.friendly_resource_name + application = twilio.applications.create( + voice_method="POST", voice_url=self.get_twilio_voice_url(), friendly_name=friendly_name + ) + return application + + +def get_public_url(path: str | None = None): + from jingrow.utils import get_url + + return get_url().split(":8", 1)[0] + path diff --git a/crm/fcrm/pagetype/crm_twilio_settings/test_crm_twilio_settings.py b/crm/fcrm/pagetype/crm_twilio_settings/test_crm_twilio_settings.py new file mode 100644 index 0000000..05ab9b0 --- /dev/null +++ b/crm/fcrm/pagetype/crm_twilio_settings/test_crm_twilio_settings.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMTwilioSettings(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/crm_view_settings/__init__.py b/crm/fcrm/pagetype/crm_view_settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/crm_view_settings/crm_view_settings.js b/crm/fcrm/pagetype/crm_view_settings/crm_view_settings.js new file mode 100644 index 0000000..f1a1353 --- /dev/null +++ b/crm/fcrm/pagetype/crm_view_settings/crm_view_settings.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("CRM View Settings", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json b/crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json new file mode 100644 index 0000000..705b248 --- /dev/null +++ b/crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json @@ -0,0 +1,228 @@ +{ + "actions": [], + "autoname": "autoincrement", + "creation": "2023-11-27 16:29:10.993403", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "label", + "icon", + "user", + "is_standard", + "is_default", + "column_break_zacm", + "type", + "dt", + "route_name", + "pinned", + "public", + "filters_tab", + "filters", + "order_by_tab", + "order_by", + "list_tab", + "list_section", + "load_default_columns", + "columns", + "rows", + "group_by_tab", + "group_by_field", + "kanban_tab", + "kanban_section", + "column_field", + "title_field", + "kanban_columns", + "kanban_fields" + ], + "fields": [ + { + "fieldname": "columns", + "fieldtype": "Code", + "label": "Columns" + }, + { + "fieldname": "user", + "fieldtype": "Link", + "label": "User", + "options": "User" + }, + { + "fieldname": "rows", + "fieldtype": "Code", + "label": "Rows" + }, + { + "fieldname": "filters", + "fieldtype": "Code", + "label": "Filters" + }, + { + "fieldname": "filters_tab", + "fieldtype": "Tab Break", + "label": "Filters" + }, + { + "fieldname": "label", + "fieldtype": "Data", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Label" + }, + { + "fieldname": "column_break_zacm", + "fieldtype": "Column Break" + }, + { + "fieldname": "dt", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "PageType", + "options": "PageType" + }, + { + "fieldname": "order_by_tab", + "fieldtype": "Tab Break", + "label": "Order By" + }, + { + "fieldname": "order_by", + "fieldtype": "Code", + "label": "Order By" + }, + { + "default": "0", + "fieldname": "pinned", + "fieldtype": "Check", + "label": "Pinned" + }, + { + "fieldname": "route_name", + "fieldtype": "Data", + "label": "Route Name" + }, + { + "default": "0", + "fieldname": "load_default_columns", + "fieldtype": "Check", + "label": "Load Default Columns" + }, + { + "default": "0", + "fieldname": "public", + "fieldtype": "Check", + "label": "Public" + }, + { + "fieldname": "icon", + "fieldtype": "Data", + "label": "Icon" + }, + { + "default": "list", + "fieldname": "type", + "fieldtype": "Select", + "label": "Type", + "options": "list\ngroup_by\nkanban" + }, + { + "fieldname": "group_by_tab", + "fieldtype": "Tab Break", + "label": "Group By" + }, + { + "fieldname": "group_by_field", + "fieldtype": "Data", + "label": "Group By Field" + }, + { + "fieldname": "list_section", + "fieldtype": "Section Break" + }, + { + "fieldname": "kanban_section", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_field", + "fieldtype": "Data", + "label": "Column Field" + }, + { + "fieldname": "list_tab", + "fieldtype": "Tab Break", + "label": "List" + }, + { + "fieldname": "kanban_tab", + "fieldtype": "Tab Break", + "label": "Kanban" + }, + { + "fieldname": "kanban_columns", + "fieldtype": "Code", + "label": "Kanban Columns" + }, + { + "fieldname": "kanban_fields", + "fieldtype": "Code", + "label": "Kanban Fields" + }, + { + "fieldname": "title_field", + "fieldtype": "Data", + "label": "Title Field" + }, + { + "default": "0", + "fieldname": "is_standard", + "fieldtype": "Check", + "label": "Is Standard" + }, + { + "default": "0", + "fieldname": "is_default", + "fieldtype": "Check", + "label": "Is Default" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-02-20 15:36:55.059065", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM View Settings", + "naming_rule": "Autoincrement", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "read_only": 1, + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "track_changes": 1 +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/crm_view_settings/crm_view_settings.py b/crm/fcrm/pagetype/crm_view_settings/crm_view_settings.py new file mode 100644 index 0000000..fa25755 --- /dev/null +++ b/crm/fcrm/pagetype/crm_view_settings/crm_view_settings.py @@ -0,0 +1,246 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt +import json + +import jingrow +from jingrow.model.page import Page, get_controller +from jingrow.utils import parse_json + + +class CRMViewSettings(Page): + pass + + +@jingrow.whitelist() +def create(view): + view = jingrow._dict(view) + + view.filters = parse_json(view.filters) or {} + view.columns = parse_json(view.columns or "[]") + view.rows = parse_json(view.rows or "[]") + view.kanban_columns = parse_json(view.kanban_columns or "[]") + view.kanban_fields = parse_json(view.kanban_fields or "[]") + + default_rows = sync_default_rows(view.pagetype) + view.rows = view.rows + default_rows if default_rows else view.rows + view.rows = remove_duplicates(view.rows) + + if not view.kanban_columns and view.type == "kanban": + view.kanban_columns = sync_default_columns(view) + elif not view.columns: + view.columns = sync_default_columns(view) + + pg = jingrow.new_pg("CRM View Settings") + pg.name = view.label + pg.label = view.label + pg.type = view.type or "list" + pg.icon = view.icon + pg.dt = view.pagetype + pg.user = jingrow.session.user + pg.route_name = view.route_name or get_route_name(view.pagetype) + pg.load_default_columns = view.load_default_columns or False + pg.filters = json.dumps(view.filters) + pg.order_by = view.order_by + pg.group_by_field = view.group_by_field + pg.column_field = view.column_field + pg.title_field = view.title_field + pg.kanban_columns = json.dumps(view.kanban_columns) + pg.kanban_fields = json.dumps(view.kanban_fields) + pg.columns = json.dumps(view.columns) + pg.rows = json.dumps(view.rows) + pg.insert() + return pg + + +@jingrow.whitelist() +def update(view): + view = jingrow._dict(view) + + filters = parse_json(view.filters or {}) + columns = parse_json(view.columns or []) + rows = parse_json(view.rows or []) + kanban_columns = parse_json(view.kanban_columns or []) + kanban_fields = parse_json(view.kanban_fields or []) + + default_rows = sync_default_rows(view.pagetype) + rows = rows + default_rows if default_rows else rows + rows = remove_duplicates(rows) + + pg = jingrow.get_pg("CRM View Settings", view.name) + pg.label = view.label + pg.type = view.type or "list" + pg.icon = view.icon + pg.route_name = view.route_name or get_route_name(view.pagetype) + pg.load_default_columns = view.load_default_columns or False + pg.filters = json.dumps(filters) + pg.order_by = view.order_by + pg.group_by_field = view.group_by_field + pg.column_field = view.column_field + pg.title_field = view.title_field + pg.kanban_columns = json.dumps(kanban_columns) + pg.kanban_fields = json.dumps(kanban_fields) + pg.columns = json.dumps(columns) + pg.rows = json.dumps(rows) + pg.save() + return pg + + +@jingrow.whitelist() +def delete(name): + if jingrow.db.exists("CRM View Settings", name): + jingrow.delete_pg("CRM View Settings", name) + + +@jingrow.whitelist() +def public(name, value): + if jingrow.session.user != "Administrator" and "Sales Manager" not in jingrow.get_roles(): + jingrow.throw("Not permitted", jingrow.PermissionError) + + pg = jingrow.get_pg("CRM View Settings", name) + if pg.pinned: + pg.pinned = False + pg.public = value + pg.user = "" if value else jingrow.session.user + pg.save() + + +@jingrow.whitelist() +def pin(name, value): + pg = jingrow.get_pg("CRM View Settings", name) + pg.pinned = value + pg.save() + + +def remove_duplicates(l): + return list(dict.fromkeys(l)) + + +def sync_default_rows(pagetype, type="list"): + list = get_controller(pagetype) + rows = [] + + if hasattr(list, "default_list_data"): + rows = list.default_list_data().get("rows") + + return rows + + +def sync_default_columns(view): + list = get_controller(view.pagetype) + columns = [] + + if view.type == "kanban" and view.column_field: + field_meta = jingrow.get_meta(view.pagetype).get_field(view.column_field) + if field_meta.fieldtype == "Link": + columns = jingrow.get_all( + field_meta.options, + fields=["name"], + order_by="modified asc", + ) + elif field_meta.fieldtype == "Select": + columns = [{"name": option} for option in field_meta.options.split("\n")] + elif hasattr(list, "default_list_data"): + columns = list.default_list_data().get("columns") + + return columns + + +@jingrow.whitelist() +def set_as_default(name=None, type=None, pagetype=None): + if name: + jingrow.db.set_value("CRM View Settings", name, "is_default", 1) + else: + pg = create_or_update_standard_view({"type": type, "pagetype": pagetype, "is_default": 1}) + name = pg.name + + # remove default from other views of same user + jingrow.db.set_value( + "CRM View Settings", + {"name": ("!=", name), "user": jingrow.session.user, "is_default": 1}, + "is_default", + 0, + ) + + +@jingrow.whitelist() +def create_or_update_standard_view(view): + view = jingrow._dict(view) + + filters = parse_json(view.filters) or {} + columns = parse_json(view.columns or "[]") + rows = parse_json(view.rows or "[]") + kanban_columns = parse_json(view.kanban_columns or "[]") + kanban_fields = parse_json(view.kanban_fields or "[]") + view.column_field = view.column_field or "status" + + default_rows = sync_default_rows(view.pagetype, view.type) + rows = rows + default_rows if default_rows else rows + rows = remove_duplicates(rows) + + if not kanban_columns and view.type == "kanban": + kanban_columns = sync_default_columns(view) + elif not columns: + columns = sync_default_columns(view) + + pg = jingrow.db.exists( + "CRM View Settings", + {"dt": view.pagetype, "type": view.type or "list", "is_standard": True, "user": jingrow.session.user}, + ) + if pg: + pg = jingrow.get_pg("CRM View Settings", pg) + pg.label = view.label + pg.type = view.type or "list" + pg.route_name = view.route_name or get_route_name(view.pagetype) + pg.load_default_columns = view.load_default_columns or False + pg.filters = json.dumps(filters) + pg.order_by = view.order_by or "modified desc" + pg.group_by_field = view.group_by_field or "owner" + pg.column_field = view.column_field + pg.title_field = view.title_field + pg.kanban_columns = json.dumps(kanban_columns) + pg.kanban_fields = json.dumps(kanban_fields) + pg.columns = json.dumps(columns) + pg.rows = json.dumps(rows) + pg.is_default = view.is_default or False + pg.save() + else: + pg = jingrow.new_pg("CRM View Settings") + + label = "List" + if view.type == "group_by": + label = "Group By" + elif view.type == "kanban": + label = "Kanban" + + pg.name = view.label or label + pg.label = view.label or label + pg.type = view.type or "list" + pg.dt = view.pagetype + pg.user = jingrow.session.user + pg.route_name = view.route_name or get_route_name(view.pagetype) + pg.load_default_columns = view.load_default_columns or False + pg.filters = json.dumps(filters) + pg.order_by = view.order_by or "modified desc" + pg.group_by_field = view.group_by_field or "owner" + pg.column_field = view.column_field + pg.title_field = view.title_field + pg.kanban_columns = json.dumps(kanban_columns) + pg.kanban_fields = json.dumps(kanban_fields) + pg.columns = json.dumps(columns) + pg.rows = json.dumps(rows) + pg.is_standard = True + pg.is_default = view.is_default or False + pg.insert() + + return pg + + +def get_route_name(pagetype): + # Example: "CRM Lead" -> "Leads" + if pagetype.startswith("CRM "): + pagetype = pagetype[4:] + + if pagetype[-1] != "s": + pagetype += "s" + + return pagetype diff --git a/crm/fcrm/pagetype/crm_view_settings/test_crm_view_settings.py b/crm/fcrm/pagetype/crm_view_settings/test_crm_view_settings.py new file mode 100644 index 0000000..399c075 --- /dev/null +++ b/crm/fcrm/pagetype/crm_view_settings/test_crm_view_settings.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestCRMViewSettings(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/erpnext_crm_settings/__init__.py b/crm/fcrm/pagetype/erpnext_crm_settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.js b/crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.js new file mode 100644 index 0000000..7c688c5 --- /dev/null +++ b/crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.js @@ -0,0 +1,21 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +jingrow.ui.form.on("ERPNext CRM Settings", { + refresh(frm) { + if (!frm.pg.enabled) return; + frm.add_custom_button(__("Reset ERPNext Form Script"), () => { + jingrow.confirm( + __( + "Are you sure you want to reset 'Create Quotation from CRM Deal' Form Script?" + ), + () => frm.trigger("reset_erpnext_form_script") + ); + }); + }, + async reset_erpnext_form_script(frm) { + let script = await frm.call("reset_erpnext_form_script"); + script.message && + jingrow.msgprint(__("Form Script updated successfully")); + }, +}); diff --git a/crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json b/crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json new file mode 100644 index 0000000..e275d54 --- /dev/null +++ b/crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json @@ -0,0 +1,135 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2024-07-02 15:23:17.022214", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "enabled", + "erpnext_company", + "column_break_vfru", + "is_erpnext_in_different_site", + "erpnext_site_url", + "section_break_oubd", + "api_key", + "column_break_fllx", + "api_secret", + "section_break_jnbn", + "create_customer_on_status_change", + "column_break_kbhw", + "deal_status" + ], + "fields": [ + { + "depends_on": "eval:pg.enabled && pg.is_erpnext_in_different_site", + "fieldname": "api_key", + "fieldtype": "Data", + "label": "API Key", + "mandatory_depends_on": "is_erpnext_in_different_site" + }, + { + "depends_on": "eval:pg.enabled && pg.is_erpnext_in_different_site", + "fieldname": "api_secret", + "fieldtype": "Password", + "label": "API Secret", + "mandatory_depends_on": "is_erpnext_in_different_site" + }, + { + "depends_on": "enabled", + "fieldname": "section_break_oubd", + "fieldtype": "Section Break", + "label": "ERPNext Site API's" + }, + { + "fieldname": "column_break_fllx", + "fieldtype": "Column Break" + }, + { + "depends_on": "eval:pg.enabled && pg.is_erpnext_in_different_site", + "fieldname": "erpnext_site_url", + "fieldtype": "Data", + "label": "ERPNext Site URL", + "mandatory_depends_on": "is_erpnext_in_different_site" + }, + { + "depends_on": "enabled", + "fieldname": "erpnext_company", + "fieldtype": "Data", + "label": "Company in ERPNext Site", + "mandatory_depends_on": "enabled" + }, + { + "fieldname": "column_break_vfru", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "enabled", + "fieldtype": "Check", + "label": "Enabled" + }, + { + "default": "0", + "depends_on": "enabled", + "fieldname": "is_erpnext_in_different_site", + "fieldtype": "Check", + "label": "Is ERPNext installed on a different site?" + }, + { + "fieldname": "section_break_jnbn", + "fieldtype": "Section Break" + }, + { + "default": "0", + "depends_on": "enabled", + "fieldname": "create_customer_on_status_change", + "fieldtype": "Check", + "label": "Create customer on status change" + }, + { + "fieldname": "column_break_kbhw", + "fieldtype": "Column Break" + }, + { + "depends_on": "eval:pg.enabled && pg.create_customer_on_status_change", + "fieldname": "deal_status", + "fieldtype": "Link", + "label": "Deal Status", + "mandatory_depends_on": "create_customer_on_status_change", + "options": "CRM Deal Status" + } + ], + "index_web_pages_for_search": 1, + "issingle": 1, + "links": [], + "modified": "2024-12-31 23:24:29.636820", + "modified_by": "Administrator", + "module": "FCRM", + "name": "ERPNext CRM Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.py b/crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.py new file mode 100644 index 0000000..682d3a1 --- /dev/null +++ b/crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.py @@ -0,0 +1,324 @@ +# Copyright (c) 2024, JINGROW +# For license information, please see license.txt + +import json + +import jingrow +from jingrow import _ +from jingrow.custom.pagetype.property_setter.property_setter import make_property_setter +from jingrow.jingrowclient import JingrowClient +from jingrow.model.page import Page +from jingrow.utils import get_url_to_form, get_url_to_list + + +class ERPNextCRMSettings(Page): + def validate(self): + if self.enabled: + self.validate_if_erpnext_installed() + self.add_quotation_to_option() + self.create_custom_fields() + self.create_crm_form_script() + + def validate_if_erpnext_installed(self): + if not self.is_erpnext_in_different_site: + if "erpnext" not in jingrow.get_installed_apps(): + jingrow.throw(_("ERPNext is not installed in the current site")) + + def add_quotation_to_option(self): + if not self.is_erpnext_in_different_site: + if not jingrow.db.exists("Property Setter", {"name": "Quotation-quotation_to-link_filters"}): + make_property_setter( + pagetype="Quotation", + fieldname="quotation_to", + property="link_filters", + value='[["PageType","name","in", ["Customer", "Lead", "Prospect", "CRM Deal"]]]', + property_type="JSON", + validate_fields_for_pagetype=False, + ) + + def create_custom_fields(self): + if not self.is_erpnext_in_different_site: + from erpnext.crm.jingrow_crm_api import create_custom_fields_for_jingrow_crm + + create_custom_fields_for_jingrow_crm() + else: + self.create_custom_fields_in_remote_site() + + def create_custom_fields_in_remote_site(self): + client = get_erpnext_site_client(self) + try: + client.post_api("erpnext.crm.jingrow_crm_api.create_custom_fields_for_jingrow_crm") + except Exception: + jingrow.log_error( + jingrow.get_traceback(), + f"Error while creating custom field in the remote erpnext site: {self.erpnext_site_url}", + ) + jingrow.throw("Error while creating custom field in ERPNext, check error log for more details") + + def create_crm_form_script(self): + if not jingrow.db.exists("CRM Form Script", "Create Quotation from CRM Deal"): + script = get_crm_form_script() + jingrow.get_pg( + { + "pagetype": "CRM Form Script", + "name": "Create Quotation from CRM Deal", + "dt": "CRM Deal", + "view": "Form", + "script": script, + "enabled": 1, + "is_standard": 1, + } + ).insert() + + @jingrow.whitelist() + def reset_erpnext_form_script(self): + try: + if jingrow.db.exists("CRM Form Script", "Create Quotation from CRM Deal"): + script = get_crm_form_script() + jingrow.db.set_value("CRM Form Script", "Create Quotation from CRM Deal", "script", script) + return True + return False + except Exception: + jingrow.log_error(jingrow.get_traceback(), "Error while resetting form script") + return False + + +def get_erpnext_site_client(erpnext_crm_settings): + site_url = erpnext_crm_settings.erpnext_site_url + api_key = erpnext_crm_settings.api_key + api_secret = erpnext_crm_settings.get_password("api_secret", raise_exception=False) + + return JingrowClient(site_url, api_key=api_key, api_secret=api_secret) + + +@jingrow.whitelist() +def get_customer_link(crm_deal): + erpnext_crm_settings = jingrow.get_single("ERPNext CRM Settings") + if not erpnext_crm_settings.enabled: + jingrow.throw(_("ERPNext is not integrated with the CRM")) + + if not erpnext_crm_settings.is_erpnext_in_different_site: + customer = jingrow.db.exists("Customer", {"crm_deal": crm_deal}) + return get_url_to_form("Customer", customer) if customer else "" + else: + client = get_erpnext_site_client(erpnext_crm_settings) + try: + customer = client.get_list("Customer", {"crm_deal": crm_deal}) + customer = customer[0].get("name") if len(customer) else None + if customer: + return f"{erpnext_crm_settings.erpnext_site_url}/app/customer/{customer}" + else: + return "" + except Exception: + jingrow.log_error( + jingrow.get_traceback(), + f"Error while fetching customer in remote site: {erpnext_crm_settings.erpnext_site_url}", + ) + jingrow.throw(_("Error while fetching customer in ERPNext, check error log for more details")) + + +@jingrow.whitelist() +def get_quotation_url(crm_deal, organization): + erpnext_crm_settings = jingrow.get_single("ERPNext CRM Settings") + if not erpnext_crm_settings.enabled: + jingrow.throw(_("ERPNext is not integrated with the CRM")) + + contact = get_contact(crm_deal) + address = get_organization_address(organization) + address = address.get("name") if address else None + + if not erpnext_crm_settings.is_erpnext_in_different_site: + base_url = f"{get_url_to_list('Quotation')}/new" + params = { + "quotation_to": "CRM Deal", + "crm_deal": crm_deal, + "party_name": crm_deal, + "company": erpnext_crm_settings.erpnext_company, + "contact_person": contact, + "customer_address": address + } + else: + site_url = erpnext_crm_settings.get("erpnext_site_url") + base_url = f"{site_url}/app/quotation/new" + prospect = create_prospect_in_remote_site(crm_deal, erpnext_crm_settings) + params = { + "quotation_to": "Prospect", + "crm_deal": crm_deal, + "party_name": prospect, + "company": erpnext_crm_settings.erpnext_company, + "contact_person": contact, + "customer_address": address + } + + # Filter out None values and build query string + query_string = "&".join( + f"{key}={value}" for key, value in params.items() + if value is not None + ) + + return f"{base_url}?{query_string}" + + +def create_prospect_in_remote_site(crm_deal, erpnext_crm_settings): + try: + client = get_erpnext_site_client(erpnext_crm_settings) + pg = jingrow.get_cached_pg("CRM Deal", crm_deal) + contacts = get_contacts(pg) + address = get_organization_address(pg.organization) or None + + if address and not isinstance(address, dict): + address = address.as_dict() + + return client.post_api( + "erpnext.crm.jingrow_crm_api.create_prospect_against_crm_deal", + { + "organization": pg.organization, + "lead_name": pg.lead_name, + "no_of_employees": pg.no_of_employees, + "deal_owner": pg.deal_owner, + "crm_deal": pg.name, + "territory": pg.territory, + "industry": pg.industry, + "website": pg.website, + "annual_revenue": pg.annual_revenue, + "contacts": json.dumps(contacts) if contacts else None, + "erpnext_company": erpnext_crm_settings.erpnext_company, + "address": json.dumps(address) if address else None, + }, + ) + except Exception: + jingrow.log_error( + jingrow.get_traceback(), + f"Error while creating prospect in remote site: {erpnext_crm_settings.erpnext_site_url}", + ) + jingrow.throw(_("Error while creating prospect in ERPNext, check error log for more details")) + + +def get_contact(crm_deal): + pg = jingrow.get_cached_pg("CRM Deal", crm_deal) + contact = None + for c in pg.contacts: + if c.is_primary: + contact = c.contact + break + + return contact + + +def get_contacts(pg): + contacts = [] + for c in pg.contacts: + contacts.append( + { + "contact": c.contact, + "full_name": c.full_name, + "email": c.email, + "mobile_no": c.mobile_no, + "gender": c.gender, + "is_primary": c.is_primary, + } + ) + return contacts + + +def get_organization_address(organization): + address = jingrow.db.get_value("CRM Organization", organization, "address") + address = jingrow.get_cached_pg("Address", address) if address else None + if not address: + return None + return { + "name": address.name, + "address_title": address.address_title, + "address_type": address.address_type, + "address_line1": address.address_line1, + "address_line2": address.address_line2, + "city": address.city, + "county": address.county, + "state": address.state, + "country": address.country, + "pincode": address.pincode, + } + + +def create_customer_in_erpnext(pg, method): + erpnext_crm_settings = jingrow.get_single("ERPNext CRM Settings") + if ( + not erpnext_crm_settings.enabled + or not erpnext_crm_settings.create_customer_on_status_change + or pg.status != erpnext_crm_settings.deal_status + ): + return + + contacts = get_contacts(pg) + address = get_organization_address(pg.organization) + customer = { + "customer_name": pg.organization, + "customer_group": "All Customer Groups", + "customer_type": "Company", + "territory": pg.territory, + "default_currency": pg.currency, + "industry": pg.industry, + "website": pg.website, + "crm_deal": pg.name, + "contacts": json.dumps(contacts), + "address": json.dumps(address) if address else None, + } + if not erpnext_crm_settings.is_erpnext_in_different_site: + from erpnext.crm.jingrow_crm_api import create_customer + + create_customer(customer) + else: + create_customer_in_remote_site(customer, erpnext_crm_settings) + + jingrow.publish_realtime("crm_customer_created") + + +def create_customer_in_remote_site(customer, erpnext_crm_settings): + client = get_erpnext_site_client(erpnext_crm_settings) + try: + client.post_api("erpnext.crm.jingrow_crm_api.create_customer", customer) + except Exception: + jingrow.log_error(jingrow.get_traceback(), "Error while creating customer in remote site") + jingrow.throw(_("Error while creating customer in ERPNext, check error log for more details")) + + +@jingrow.whitelist() +def get_crm_form_script(): + return """ +async function setupForm({ pg, call, $dialog, updateField, toast }) { + let actions = []; + let is_erpnext_integration_enabled = await call("jingrow.client.get_single_value", {pagetype: "ERPNext CRM Settings", field: "enabled"}); + if (!["Lost", "Won"].includes(pg?.status) && is_erpnext_integration_enabled) { + actions.push({ + label: __("Create Quotation"), + onClick: async () => { + let quotation_url = await call( + "crm.fcrm.pagetype.erpnext_crm_settings.erpnext_crm_settings.get_quotation_url", + { + crm_deal: pg.name, + organization: pg.organization + } + ); + + if (quotation_url) { + window.open(quotation_url, '_blank'); + } + } + }) + } + if (is_erpnext_integration_enabled) { + let customer_url = await call("crm.fcrm.pagetype.erpnext_crm_settings.erpnext_crm_settings.get_customer_link", { + crm_deal: pg.name + }); + if (customer_url) { + actions.push({ + label: __("View Customer"), + onClick: () => window.open(customer_url, '_blank') + }); + } + } + return { + actions: actions, + }; +} +""" diff --git a/crm/fcrm/pagetype/erpnext_crm_settings/test_erpnext_crm_settings.py b/crm/fcrm/pagetype/erpnext_crm_settings/test_erpnext_crm_settings.py new file mode 100644 index 0000000..96176fc --- /dev/null +++ b/crm/fcrm/pagetype/erpnext_crm_settings/test_erpnext_crm_settings.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestERPNextCRMSettings(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/fcrm_note/__init__.py b/crm/fcrm/pagetype/fcrm_note/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/fcrm_note/fcrm_note.js b/crm/fcrm/pagetype/fcrm_note/fcrm_note.js new file mode 100644 index 0000000..27706d6 --- /dev/null +++ b/crm/fcrm/pagetype/fcrm_note/fcrm_note.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, JINGROW and contributors +// For license information, please see license.txt + +// jingrow.ui.form.on("FCRM Note", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/pagetype/fcrm_note/fcrm_note.json b/crm/fcrm/pagetype/fcrm_note/fcrm_note.json new file mode 100644 index 0000000..aad8d6c --- /dev/null +++ b/crm/fcrm/pagetype/fcrm_note/fcrm_note.json @@ -0,0 +1,89 @@ +{ + "actions": [], + "allow_import": 1, + "allow_rename": 1, + "creation": "2023-08-26 12:04:00.759437", + "default_view": "List", + "pagetype": "PageType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "title", + "content", + "reference_pagetype", + "reference_docname" + ], + "fields": [ + { + "fieldname": "title", + "fieldtype": "Data", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Title", + "reqd": 1 + }, + { + "fieldname": "content", + "fieldtype": "Text Editor", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Content" + }, + { + "default": "CRM Lead", + "fieldname": "reference_pagetype", + "fieldtype": "Link", + "label": "Reference Document Type", + "options": "PageType" + }, + { + "fieldname": "reference_docname", + "fieldtype": "Dynamic Link", + "label": "Reference Pg", + "options": "reference_pagetype" + } + ], + "index_web_pages_for_search": 1, + "links": [ + { + "link_pagetype": "CRM Call Log", + "link_fieldname": "note" + } + ], + "modified": "2025-04-01 15:30:14.742001", + "modified_by": "Administrator", + "module": "FCRM", + "name": "FCRM Note", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "title_field": "title", + "track_changes": 1 +} \ No newline at end of file diff --git a/crm/fcrm/pagetype/fcrm_note/fcrm_note.py b/crm/fcrm/pagetype/fcrm_note/fcrm_note.py new file mode 100644 index 0000000..466fb32 --- /dev/null +++ b/crm/fcrm/pagetype/fcrm_note/fcrm_note.py @@ -0,0 +1,20 @@ +# Copyright (c) 2023, JINGROW and contributors +# For license information, please see license.txt + +# import jingrow +from jingrow.model.page import Page + + +class FCRMNote(Page): + @staticmethod + def default_list_data(): + rows = [ + "name", + "title", + "content", + "reference_pagetype", + "reference_docname", + "owner", + "modified", + ] + return {'columns': [], 'rows': rows} diff --git a/crm/fcrm/pagetype/fcrm_note/test_fcrm_note.py b/crm/fcrm/pagetype/fcrm_note/test_fcrm_note.py new file mode 100644 index 0000000..6cad505 --- /dev/null +++ b/crm/fcrm/pagetype/fcrm_note/test_fcrm_note.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestFCRMNote(UnitTestCase): + pass diff --git a/crm/fcrm/pagetype/fcrm_settings/__init__.py b/crm/fcrm/pagetype/fcrm_settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/fcrm/pagetype/fcrm_settings/fcrm_settings.js b/crm/fcrm/pagetype/fcrm_settings/fcrm_settings.js new file mode 100644 index 0000000..9cffc77 --- /dev/null +++ b/crm/fcrm/pagetype/fcrm_settings/fcrm_settings.js @@ -0,0 +1,42 @@ +// Copyright (c) 2024, JINGROW and contributors +// For license information, please see license.txt + +jingrow.ui.form.on("FCRM Settings", { + // refresh(frm) { + + // }, + restore_defaults: function (frm) { + let message = __( + "This will restore (if not exist) all the default statuses, custom fields and layouts. Delete & Restore will delete default layouts and then restore them." + ); + let d = new jingrow.ui.Dialog({ + title: __("Restore Defaults"), + primary_action_label: __("Restore"), + primary_action: () => { + frm.call("restore_defaults", { force: false }, () => { + jingrow.show_alert({ + message: __( + "Default statuses, custom fields and layouts restored successfully." + ), + indicator: "green", + }); + }); + d.hide(); + }, + secondary_action_label: __("Delete & Restore"), + secondary_action: () => { + frm.call("restore_defaults", { force: true }, () => { + jingrow.show_alert({ + message: __( + "Default statuses, custom fields and layouts restored successfully." + ), + indicator: "green", + }); + }); + d.hide(); + }, + }); + d.show(); + d.set_message(message); + }, +}); diff --git a/crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json b/crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json new file mode 100644 index 0000000..df20157 --- /dev/null +++ b/crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json @@ -0,0 +1,159 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2024-09-29 13:48:02.715924", + "pagetype": "PageType", + "engine": "InnoDB", + "field_order": [ + "defaults_tab", + "restore_defaults", + "enable_forecasting", + "auto_update_expected_deal_value", + "currency_tab", + "currency", + "exchange_rate_provider_section", + "service_provider", + "column_break_vqck", + "access_key", + "branding_tab", + "brand_name", + "brand_logo", + "favicon", + "dropdown_items_tab", + "dropdown_items" + ], + "fields": [ + { + "fieldname": "restore_defaults", + "fieldtype": "Button", + "label": "Restore Defaults" + }, + { + "fieldname": "dropdown_items", + "fieldtype": "Table", + "options": "CRM Dropdown Item" + }, + { + "fieldname": "defaults_tab", + "fieldtype": "Tab Break", + "label": "Settings" + }, + { + "fieldname": "branding_tab", + "fieldtype": "Tab Break", + "label": "Branding" + }, + { + "description": "An image with 1:1 & 2:1 ratio is preferred", + "fieldname": "brand_logo", + "fieldtype": "Attach", + "label": "Logo" + }, + { + "fieldname": "dropdown_items_tab", + "fieldtype": "Tab Break", + "label": "Dropdown Items" + }, + { + "fieldname": "brand_name", + "fieldtype": "Data", + "label": "Name" + }, + { + "description": "An icon file with .ico extension. Should be 16 x 16 px. Generated using a favicon generator. [favicon-generator.org]", + "fieldname": "favicon", + "fieldtype": "Attach", + "label": "Favicon" + }, + { + "default": "0", + "description": "It will make deal's \"Expected Closure Date\" & \"Expected Deal Value\" mandatory to get accurate forecasting insights", + "fieldname": "enable_forecasting", + "fieldtype": "Check", + "label": "Enable Forecasting" + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Currency", + "options": "Currency" + }, + { + "fieldname": "currency_tab", + "fieldtype": "Tab Break", + "label": "Currency" + }, + { + "fieldname": "exchange_rate_provider_section", + "fieldtype": "Section Break", + "label": "Exchange Rate Provider" + }, + { + "default": "frankfurter.app", + "fieldname": "service_provider", + "fieldtype": "Select", + "label": "Service Provider", + "options": "frankfurter.app\nexchangerate.host" + }, + { + "depends_on": "eval:pg.service_provider == 'exchangerate.host';", + "fieldname": "access_key", + "fieldtype": "Data", + "label": "Access Key", + "mandatory_depends_on": "eval:pg.service_provider == 'exchangerate.host';" + }, + { + "fieldname": "column_break_vqck", + "fieldtype": "Column Break" + }, + { + "default": "1", + "description": "Automatically update \"Expected Deal Value\" based on the total value of associated products in a deal", + "fieldname": "auto_update_expected_deal_value", + "fieldtype": "Check", + "label": "Auto Update Expected Deal Value" + } + ], + "index_web_pages_for_search": 1, + "issingle": 1, + "links": [], + "modified": "2025-09-16 17:33:26.406549", + "modified_by": "Administrator", + "module": "FCRM", + "name": "FCRM Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "email": 1, + "print": 1, + "read": 1, + "role": "All", + "share": 1 + } + ], + "row_format": "Dynamic", + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} diff --git a/crm/fcrm/pagetype/fcrm_settings/fcrm_settings.py b/crm/fcrm/pagetype/fcrm_settings/fcrm_settings.py new file mode 100644 index 0000000..94650df --- /dev/null +++ b/crm/fcrm/pagetype/fcrm_settings/fcrm_settings.py @@ -0,0 +1,208 @@ +# Copyright (c) 2024, JINGROW and contributors +# For license information, please see license.txt + +import jingrow +import requests +from jingrow import _ +from jingrow.custom.pagetype.property_setter.property_setter import delete_property_setter, make_property_setter +from jingrow.model.page import Page + +from crm.install import after_install + + +class FCRMSettings(Page): + @jingrow.whitelist() + def restore_defaults(self, force=False): + after_install(force) + + def validate(self): + self.do_not_allow_to_delete_if_standard() + self.setup_forecasting() + self.make_currency_read_only() + + def do_not_allow_to_delete_if_standard(self): + if not self.has_value_changed("dropdown_items"): + return + old_items = self.get_pg_before_save().get("dropdown_items") + standard_new_items = [d.name1 for d in self.dropdown_items if d.is_standard] + standard_old_items = [d.name1 for d in old_items if d.is_standard] + deleted_standard_items = set(standard_old_items) - set(standard_new_items) + if deleted_standard_items: + standard_dropdown_items = get_standard_dropdown_items() + if not deleted_standard_items.intersection(standard_dropdown_items): + return + jingrow.throw(_("Cannot delete standard items {0}").format(", ".join(deleted_standard_items))) + + def setup_forecasting(self): + if self.has_value_changed("enable_forecasting"): + if not self.enable_forecasting: + delete_property_setter( + "CRM Deal", + "reqd", + "expected_closure_date", + ) + delete_property_setter( + "CRM Deal", + "reqd", + "expected_deal_value", + ) + else: + make_property_setter( + "CRM Deal", + "expected_closure_date", + "reqd", + 1 if self.enable_forecasting else 0, + "Check", + ) + make_property_setter( + "CRM Deal", + "expected_deal_value", + "reqd", + 1 if self.enable_forecasting else 0, + "Check", + ) + + def make_currency_read_only(self): + if self.currency and self.has_value_changed("currency"): + make_property_setter( + "FCRM Settings", + "currency", + "read_only", + 1, + "Check", + ) + + +def get_standard_dropdown_items(): + return [item.get("name1") for item in jingrow.get_hooks("standard_dropdown_items")] + + +def after_migrate(): + sync_table("dropdown_items", "standard_dropdown_items") + + +def sync_table(key, hook): + crm_settings = FCRMSettings("FCRM Settings") + existing_items = {d.name1: d for d in crm_settings.get(key)} + new_standard_items = {} + + # add new items + count = 0 # maintain count because list may come from seperate apps + for item in jingrow.get_hooks(hook): + if item.get("name1") not in existing_items: + crm_settings.append(key, item, count) + new_standard_items[item.get("name1")] = True + count += 1 + + # remove unused items + items = crm_settings.get(key) + items = [item for item in items if not (item.is_standard and (item.name1 not in new_standard_items))] + crm_settings.set(key, items) + + crm_settings.save() + + +def create_forecasting_script(): + if not jingrow.db.exists("CRM Form Script", "Forecasting Script"): + script = get_forecasting_script() + jingrow.get_pg( + { + "pagetype": "CRM Form Script", + "name": "Forecasting Script", + "dt": "CRM Deal", + "view": "Form", + "script": script, + "enabled": 1, + "is_standard": 1, + } + ).insert() + + +def get_forecasting_script(): + return """class CRMDeal { + async status() { + await this.pg.trigger('updateProbability') + } + async updateProbability() { + let status = await call("jingrow.client.get_value", { + pagetype: "CRM Deal Status", + fieldname: "probability", + filters: { name: this.pg.status }, + }) + + this.pg.probability = status.probability + } +}""" + + +def get_exchange_rate(from_currency, to_currency, date=None): + if not date: + date = "latest" + + api_used = "frankfurter" + + api_endpoint = f"https://api.frankfurter.app/{date}?from={from_currency}&to={to_currency}" + res = requests.get(api_endpoint, timeout=5) + if res.ok: + data = res.json() + return data["rates"][to_currency] + + # Fallback to exchangerate.host if Frankfurter API fails + settings = FCRMSettings("FCRM Settings") + if settings and settings.service_provider == "exchangerate.host": + api_used = "exchangerate.host" + if not settings.access_key: + jingrow.throw( + _("Access Key is required for Service Provider: {0}").format( + jingrow.bold(settings.service_provider) + ) + ) + + params = { + "access_key": settings.access_key, + "from": from_currency, + "to": to_currency, + "amount": 1, + } + + if date != "latest": + params["date"] = date + + api_endpoint = "https://api.exchangerate.host/convert" + + res = requests.get(api_endpoint, params=params, timeout=5) + if res.ok: + data = res.json() + return data["result"] + + jingrow.log_error( + title="Exchange Rate Fetch Error", + message=f"Failed to fetch exchange rate from {from_currency} to {to_currency} using {api_used} API.", + ) + + if api_used == "frankfurter": + user = jingrow.session.user + is_manager = ( + "System Manager" in jingrow.get_roles(user) + or "Sales Manager" in jingrow.get_roles(user) + or user == "Administrator" + ) + + if not is_manager: + jingrow.throw( + _( + "Ask your manager to set up the Exchange Rate Provider, as default provider does not support currency conversion for {0} to {1}." + ).format(from_currency, to_currency) + ) + else: + jingrow.throw( + _( + "Setup the Exchange Rate Provider as 'Exchangerate Host' in settings, as default provider does not support currency conversion for {0} to {1}." + ).format(from_currency, to_currency) + ) + + jingrow.throw( + _( + "Failed to fetch exchange rate from {0} to {1} on {2}. Please check your internet connection or try again later." + ).format(from_currency, to_currency, date) + ) diff --git a/crm/fcrm/pagetype/fcrm_settings/test_fcrm_settings.py b/crm/fcrm/pagetype/fcrm_settings/test_fcrm_settings.py new file mode 100644 index 0000000..e42c8de --- /dev/null +++ b/crm/fcrm/pagetype/fcrm_settings/test_fcrm_settings.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, JINGROW and Contributors +# See license.txt + +# import jingrow +from jingrow.tests import UnitTestCase + + +class TestFCRMSettings(UnitTestCase): + pass diff --git a/crm/fcrm/workspace/frappe_crm/frappe_crm.json b/crm/fcrm/workspace/frappe_crm/frappe_crm.json new file mode 100644 index 0000000..05daf8e --- /dev/null +++ b/crm/fcrm/workspace/frappe_crm/frappe_crm.json @@ -0,0 +1,133 @@ +{ + "charts": [], + "content": "[{\"id\":\"1nr6UkvDiL\",\"type\":\"header\",\"data\":{\"text\":\"PORTAL\",\"col\":12}},{\"id\":\"1hyi8SysUY\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"CRM Portal Page\",\"col\":3}},{\"id\":\"ktENiGaqXQ\",\"type\":\"spacer\",\"data\":{\"col\":12}},{\"id\":\"VgeWLYOuAS\",\"type\":\"paragraph\",\"data\":{\"text\":\"SHORTCUTS\",\"col\":12}},{\"id\":\"A66FpG-K3T\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Leads\",\"col\":3}},{\"id\":\"n9b6N5ebOj\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Deals\",\"col\":3}},{\"id\":\"sGHTXrludH\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Organizations\",\"col\":3}},{\"id\":\"uXZNCdqxy0\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Contacts\",\"col\":3}},{\"id\":\"v1kkMwlntf\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"SLA\",\"col\":3}},{\"id\":\"WRzt4SMh_b\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Assignment Rule\",\"col\":3}},{\"id\":\"TZ7cULX3Tk\",\"type\":\"spacer\",\"data\":{\"col\":12}},{\"id\":\"zpySv0nGVQ\",\"type\":\"paragraph\",\"data\":{\"text\":\"META\",\"col\":12}},{\"id\":\"fa-uKzobpp\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Lead Statuses\",\"col\":3}},{\"id\":\"hxoZghUHP2\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Deal Statuses\",\"col\":3}},{\"id\":\"HbgghUpc8N\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Lead Sources\",\"col\":3}},{\"id\":\"8cPs7Fohb4\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Industries\",\"col\":3}},{\"id\":\"arT4xZ9HWR\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Territories\",\"col\":3}},{\"id\":\"ApHOcISpiJ\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Communication Statuses\",\"col\":3}}]", + "creation": "2023-11-27 13:55:17.090361", + "custom_blocks": [], + "pagestatus": 0, + "pagetype": "Workspace", + "for_user": "", + "hide_custom": 0, + "icon": "filter", + "idx": 0, + "indicator_color": "", + "is_hidden": 0, + "label": "Jingrow CRM", + "links": [], + "modified": "2024-01-04 19:08:27.799960", + "modified_by": "Administrator", + "module": "FCRM", + "name": "Jingrow CRM", + "number_cards": [], + "owner": "shariq@jingrow.com", + "parent_page": "", + "public": 1, + "quick_lists": [], + "roles": [], + "sequence_id": 1.0, + "shortcuts": [ + { + "color": "Grey", + "pg_view": "List", + "label": "Communication Statuses", + "link_to": "CRM Communication Status", + "stats_filter": "[]", + "type": "PageType" + }, + { + "color": "Grey", + "pg_view": "List", + "label": "Leads", + "link_to": "CRM Lead", + "stats_filter": "[[\"CRM Lead\",\"converted\",\"=\",0,false]]", + "type": "PageType" + }, + { + "color": "Grey", + "pg_view": "List", + "label": "CRM Portal Page", + "type": "URL", + "url": "/crm" + }, + { + "color": "Grey", + "pg_view": "List", + "label": "SLA", + "link_to": "CRM Service Level Agreement", + "stats_filter": "[]", + "type": "PageType" + }, + { + "color": "Grey", + "pg_view": "List", + "label": "Lead Statuses", + "link_to": "CRM Lead Status", + "stats_filter": "[]", + "type": "PageType" + }, + { + "color": "Grey", + "pg_view": "Tree", + "label": "Territories", + "link_to": "CRM Territory", + "stats_filter": "[]", + "type": "PageType" + }, + { + "color": "Grey", + "pg_view": "List", + "label": "Assignment Rule", + "link_to": "Assignment Rule", + "stats_filter": "[]", + "type": "PageType" + }, + { + "color": "Grey", + "pg_view": "List", + "label": "Deals", + "link_to": "CRM Deal", + "stats_filter": "[]", + "type": "PageType" + }, + { + "color": "Grey", + "pg_view": "List", + "label": "Deal Statuses", + "link_to": "CRM Deal Status", + "stats_filter": "[]", + "type": "PageType" + }, + { + "color": "Grey", + "pg_view": "List", + "label": "Lead Sources", + "link_to": "CRM Lead Source", + "stats_filter": "[]", + "type": "PageType" + }, + { + "color": "Grey", + "pg_view": "List", + "label": "Organizations", + "link_to": "CRM Organization", + "stats_filter": "[]", + "type": "PageType" + }, + { + "color": "Grey", + "pg_view": "List", + "label": "Contacts", + "link_to": "Contact", + "stats_filter": "[]", + "type": "PageType" + }, + { + "color": "Grey", + "pg_view": "List", + "label": "Industries", + "link_to": "CRM Industry", + "stats_filter": "[]", + "type": "PageType" + } + ], + "title": "Jingrow CRM" +} \ No newline at end of file diff --git a/crm/hooks.py b/crm/hooks.py new file mode 100644 index 0000000..dac0012 --- /dev/null +++ b/crm/hooks.py @@ -0,0 +1,312 @@ +app_name = "crm" +app_title = "Jingrow CRM" +app_publisher = "JINGROW" +app_description = "Kick-ass Open Source CRM" +app_email = "shariq@jingrow.com" +app_license = "AGPLv3" +app_icon_url = "/assets/crm/images/logo.svg" +app_icon_title = "CRM" +app_icon_route = "/crm" + +# Apps +# ------------------ + +# required_apps = [] +add_to_apps_screen = [ + { + "name": "crm", + "logo": "/assets/crm/images/logo.svg", + "title": "CRM", + "route": "/crm", + "has_permission": "crm.api.check_app_permission", + } +] + +# Includes in +# ------------------ + +# include js, css files in header of desk.html +# app_include_css = "/assets/crm/css/crm.css" +# app_include_js = "/assets/crm/js/crm.js" + +# include js, css files in header of web template +# web_include_css = "/assets/crm/css/crm.css" +# web_include_js = "/assets/crm/js/crm.js" + +# include custom scss in every website theme (without file extension ".scss") +# website_theme_scss = "crm/public/scss/website" + +# include js, css files in header of web form +# webform_include_js = {"pagetype": "public/js/pagetype.js"} +# webform_include_css = {"pagetype": "public/css/pagetype.css"} + +# include js in page +# page_js = {"page" : "public/js/file.js"} + +# include js in pagetype views +# pagetype_js = {"pagetype" : "public/js/pagetype.js"} +# pagetype_list_js = {"pagetype" : "public/js/pagetype_list.js"} +# pagetype_tree_js = {"pagetype" : "public/js/pagetype_tree.js"} +# pagetype_calendar_js = {"pagetype" : "public/js/pagetype_calendar.js"} + +# Home Pages +# ---------- + +# application home page (will override Website Settings) +# home_page = "login" + +# website user home page (by Role) +# role_home_page = { +# "Role": "home_page" +# } + +website_route_rules = [ + {"from_route": "/crm/", "to_route": "crm"}, +] + +# Generators +# ---------- + +# automatically create page for each record of this pagetype +# website_generators = ["Web Page"] + +# Jinja +# ---------- + +# add methods and filters to jinja environment +# jinja = { +# "methods": "crm.utils.jinja_methods", +# "filters": "crm.utils.jinja_filters" +# } + +# Installation +# ------------ + +before_install = "crm.install.before_install" +after_install = "crm.install.after_install" + +# Uninstallation +# ------------ + +before_uninstall = "crm.uninstall.before_uninstall" +# after_uninstall = "crm.uninstall.after_uninstall" + +# Integration Setup +# ------------------ +# To set up dependencies/integrations with other apps +# Name of the app being installed is passed as an argument + +# before_app_install = "crm.utils.before_app_install" +# after_app_install = "crm.utils.after_app_install" + +# Integration Cleanup +# ------------------- +# To clean up dependencies/integrations with other apps +# Name of the app being uninstalled is passed as an argument + +# before_app_uninstall = "crm.utils.before_app_uninstall" +# after_app_uninstall = "crm.utils.after_app_uninstall" + +# Desk Notifications +# ------------------ +# See jingrow.core.notifications.get_notification_config + +# notification_config = "crm.notifications.get_notification_config" + +# Permissions +# ----------- +# Permissions evaluated in scripted ways + +# permission_query_conditions = { +# "Event": "jingrow.desk.pagetype.event.event.get_permission_query_conditions", +# } +# +# has_permission = { +# "Event": "jingrow.desk.pagetype.event.event.has_permission", +# } + +# PageType Class +# --------------- +# Override standard pagetype classes + +override_pagetype_class = { + "Contact": "crm.overrides.contact.CustomContact", + "Email Template": "crm.overrides.email_template.CustomEmailTemplate", +} + +# Document Events +# --------------- +# Hook on document methods and events + +pg_events = { + "Contact": { + "validate": ["crm.api.contact.validate"], + }, + "ToDo": { + "after_insert": ["crm.api.todo.after_insert"], + "on_update": ["crm.api.todo.on_update"], + }, + "Comment": { + "on_update": ["crm.api.comment.on_update"], + }, + "WhatsApp Message": { + "validate": ["crm.api.whatsapp.validate"], + "on_update": ["crm.api.whatsapp.on_update"], + }, + "CRM Deal": { + "on_update": [ + "crm.fcrm.pagetype.erpnext_crm_settings.erpnext_crm_settings.create_customer_in_erpnext" + ], + }, + "User": { + "before_validate": ["crm.api.demo.validate_user"], + "validate_reset_password": ["crm.api.demo.validate_reset_password"], + }, +} + +# Scheduled Tasks +# --------------- + +# scheduler_events = { +# "all": [ +# "crm.tasks.all" +# ], +# "daily": [ +# "crm.tasks.daily" +# ], +# "hourly": [ +# "crm.tasks.hourly" +# ], +# "weekly": [ +# "crm.tasks.weekly" +# ], +# "monthly": [ +# "crm.tasks.monthly" +# ], +# } + +# Testing +# ------- + +# before_tests = "crm.install.before_tests" + +# Overriding Methods +# ------------------------------ +# +# override_whitelisted_methods = { +# "jingrow.desk.pagetype.event.event.get_events": "crm.event.get_events" +# } +# +# each overriding function accepts a `data` argument; +# generated from the base implementation of the pagetype dashboard, +# along with any modifications made in other Jingrow apps +# override_pagetype_dashboards = { +# "Task": "crm.task.get_dashboard_data" +# } + +# exempt linked doctypes from being automatically cancelled +# +# auto_cancel_exempted_doctypes = ["Auto Repeat"] + +# Ignore links to specified DocTypes when deleting documents +# ----------------------------------------------------------- + +# ignore_links_on_delete = ["Communication", "ToDo"] + +# Request Events +# ---------------- +# before_request = ["crm.utils.before_request"] +# after_request = ["crm.utils.after_request"] + +# Job Events +# ---------- +# before_job = ["crm.utils.before_job"] +# after_job = ["crm.utils.after_job"] + +# User Data Protection +# -------------------- + +# user_data_fields = [ +# { +# "pagetype": "{pagetype_1}", +# "filter_by": "{filter_by}", +# "redact_fields": ["{field_1}", "{field_2}"], +# "partial": 1, +# }, +# { +# "pagetype": "{pagetype_2}", +# "filter_by": "{filter_by}", +# "partial": 1, +# }, +# { +# "pagetype": "{pagetype_3}", +# "strict": False, +# }, +# { +# "pagetype": "{pagetype_4}" +# } +# ] + +# Authentication and authorization +# -------------------------------- + +# auth_hooks = [ +# "crm.auth.validate" +# ] + +after_migrate = ["crm.fcrm.pagetype.fcrm_settings.fcrm_settings.after_migrate"] + +standard_dropdown_items = [ + { + "name1": "app_selector", + "label": "Apps", + "type": "Route", + "route": "#", + "is_standard": 1, + }, + { + "name1": "toggle_theme", + "label": "Toggle theme", + "type": "Route", + "icon": "moon", + "route": "#", + "is_standard": 1, + }, + { + "name1": "settings", + "label": "Settings", + "type": "Route", + "icon": "settings", + "route": "#", + "is_standard": 1, + }, + { + "name1": "login_to_fc", + "label": "Login to Jingrow Cloud", + "type": "Route", + "route": "#", + "is_standard": 1, + }, + { + "name1": "about", + "label": "About", + "type": "Route", + "icon": "info", + "route": "#", + "is_standard": 1, + }, + { + "name1": "separator", + "label": "", + "type": "Separator", + "is_standard": 1, + }, + { + "name1": "logout", + "label": "Log out", + "type": "Route", + "icon": "log-out", + "route": "#", + "is_standard": 1, + }, +] diff --git a/crm/install.py b/crm/install.py new file mode 100644 index 0000000..f9b1d82 --- /dev/null +++ b/crm/install.py @@ -0,0 +1,502 @@ +# Copyright (c) 2022, JINGROW and Contributors +# MIT License. See license.txt +import click +import jingrow +from jingrow.custom.pagetype.custom_field.custom_field import create_custom_fields + +from crm.fcrm.pagetype.crm_dashboard.crm_dashboard import create_default_manager_dashboard +from crm.fcrm.pagetype.crm_products.crm_products import create_product_details_script + + +def before_install(): + pass + + +def after_install(force=False): + add_default_lead_statuses() + add_default_deal_statuses() + add_default_communication_statuses() + add_default_fields_layout(force) + add_property_setter() + add_email_template_custom_fields() + add_default_industries() + add_default_lead_sources() + add_default_lost_reasons() + add_standard_dropdown_items() + add_default_scripts() + create_default_manager_dashboard(force) + create_assignment_rule_custom_fields() + add_assignment_rule_property_setters() + jingrow.db.commit() + + +def add_default_lead_statuses(): + statuses = { + "New": { + "color": "gray", + "position": 1, + }, + "Contacted": { + "color": "orange", + "position": 2, + }, + "Nurture": { + "color": "blue", + "position": 3, + }, + "Qualified": { + "color": "green", + "position": 4, + }, + "Unqualified": { + "color": "red", + "position": 5, + }, + "Junk": { + "color": "purple", + "position": 6, + }, + } + + for status in statuses: + if jingrow.db.exists("CRM Lead Status", status): + continue + + pg = jingrow.new_pg("CRM Lead Status") + pg.lead_status = status + pg.color = statuses[status]["color"] + pg.position = statuses[status]["position"] + pg.insert() + + +def add_default_deal_statuses(): + statuses = { + "Qualification": { + "color": "gray", + "type": "Open", + "probability": 10, + "position": 1, + }, + "Demo/Making": { + "color": "orange", + "type": "Ongoing", + "probability": 25, + "position": 2, + }, + "Proposal/Quotation": { + "color": "blue", + "type": "Ongoing", + "probability": 50, + "position": 3, + }, + "Negotiation": { + "color": "yellow", + "type": "Ongoing", + "probability": 70, + "position": 4, + }, + "Ready to Close": { + "color": "purple", + "type": "Ongoing", + "probability": 90, + "position": 5, + }, + "Won": { + "color": "green", + "type": "Won", + "probability": 100, + "position": 6, + }, + "Lost": { + "color": "red", + "type": "Lost", + "probability": 0, + "position": 7, + }, + } + + for status in statuses: + if jingrow.db.exists("CRM Deal Status", status): + continue + + pg = jingrow.new_pg("CRM Deal Status") + pg.deal_status = status + pg.color = statuses[status]["color"] + pg.type = statuses[status]["type"] + pg.probability = statuses[status]["probability"] + pg.position = statuses[status]["position"] + pg.insert() + + +def add_default_communication_statuses(): + statuses = ["Open", "Replied"] + + for status in statuses: + if jingrow.db.exists("CRM Communication Status", status): + continue + + pg = jingrow.new_pg("CRM Communication Status") + pg.status = status + pg.insert() + + +def add_default_fields_layout(force=False): + quick_entry_layouts = { + "CRM Lead-Quick Entry": { + "pagetype": "CRM Lead", + "layout": '[{"name": "person_section", "columns": [{"name": "column_5jrk", "fields": ["salutation", "email"]}, {"name": "column_5CPV", "fields": ["first_name", "mobile_no"]}, {"name": "column_gXOy", "fields": ["last_name", "gender"]}]}, {"name": "organization_section", "columns": [{"name": "column_GHfX", "fields": ["organization", "territory"]}, {"name": "column_hXjS", "fields": ["website", "annual_revenue"]}, {"name": "column_RDNA", "fields": ["no_of_employees", "industry"]}]}, {"name": "lead_section", "columns": [{"name": "column_EO1H", "fields": ["status"]}, {"name": "column_RWBe", "fields": ["lead_owner"]}]}]', + }, + "CRM Deal-Quick Entry": { + "pagetype": "CRM Deal", + "layout": '[{"name": "organization_section", "hidden": true, "editable": false, "columns": [{"name": "column_GpMP", "fields": ["organization"]}, {"name": "column_FPTn", "fields": []}]}, {"name": "organization_details_section", "editable": false, "columns": [{"name": "column_S3tQ", "fields": ["organization_name", "territory"]}, {"name": "column_KqV1", "fields": ["website", "annual_revenue"]}, {"name": "column_1r67", "fields": ["no_of_employees", "industry"]}]}, {"name": "contact_section", "hidden": true, "editable": false, "columns": [{"name": "column_CeXr", "fields": ["contact"]}, {"name": "column_yHbk", "fields": []}]}, {"name": "contact_details_section", "editable": false, "columns": [{"name": "column_ZTWr", "fields": ["salutation", "email"]}, {"name": "column_tabr", "fields": ["first_name", "mobile_no"]}, {"name": "column_Qjdx", "fields": ["last_name", "gender"]}]}, {"name": "deal_section", "columns": [{"name": "column_mdps", "fields": ["status"]}, {"name": "column_H40H", "fields": ["deal_owner"]}]}]', + }, + "Contact-Quick Entry": { + "pagetype": "Contact", + "layout": '[{"name": "salutation_section", "columns": [{"name": "column_eXks", "fields": ["salutation"]}]}, {"name": "full_name_section", "hideBorder": true, "columns": [{"name": "column_cSxf", "fields": ["first_name"]}, {"name": "column_yBc7", "fields": ["last_name"]}]}, {"name": "email_section", "hideBorder": true, "columns": [{"name": "column_tH3L", "fields": ["email_id"]}]}, {"name": "mobile_gender_section", "hideBorder": true, "columns": [{"name": "column_lrfI", "fields": ["mobile_no"]}, {"name": "column_Tx3n", "fields": ["gender"]}]}, {"name": "organization_section", "hideBorder": true, "columns": [{"name": "column_S0J8", "fields": ["company_name"]}]}, {"name": "designation_section", "hideBorder": true, "columns": [{"name": "column_bsO8", "fields": ["designation"]}]}, {"name": "address_section", "hideBorder": true, "columns": [{"name": "column_W3VY", "fields": ["address"]}]}]', + }, + "CRM Organization-Quick Entry": { + "pagetype": "CRM Organization", + "layout": '[{"name": "organization_section", "columns": [{"name": "column_zOuv", "fields": ["organization_name"]}]}, {"name": "website_revenue_section", "hideBorder": true, "columns": [{"name": "column_I5Dy", "fields": ["website"]}, {"name": "column_Rgss", "fields": ["annual_revenue"]}]}, {"name": "territory_section", "hideBorder": true, "columns": [{"name": "column_w6ap", "fields": ["territory"]}]}, {"name": "employee_industry_section", "hideBorder": true, "columns": [{"name": "column_u5tZ", "fields": ["no_of_employees"]}, {"name": "column_FFrT", "fields": ["industry"]}]}, {"name": "address_section", "hideBorder": true, "columns": [{"name": "column_O2dk", "fields": ["address"]}]}]', + }, + "Address-Quick Entry": { + "pagetype": "Address", + "layout": '[{"name": "details_section", "columns": [{"name": "column_uSSG", "fields": ["address_title", "address_type", "address_line1", "address_line2", "city", "state", "country", "pincode"]}]}]', + }, + "CRM Call Log-Quick Entry": { + "pagetype": "CRM Call Log", + "layout": '[{"name":"details_section","columns":[{"name":"column_uMSG","fields":["type","from","duration"]},{"name":"column_wiZT","fields":["to","status","caller","receiver"]}]}]', + }, + } + + sidebar_fields_layouts = { + "CRM Lead-Side Panel": { + "pagetype": "CRM Lead", + "layout": '[{"label": "Details", "name": "details_section", "opened": true, "columns": [{"name": "column_kl92", "fields": ["organization", "website", "territory", "industry", "job_title", "source", "lead_owner"]}]}, {"label": "Person", "name": "person_section", "opened": true, "columns": [{"name": "column_XmW2", "fields": ["salutation", "first_name", "last_name", "email", "mobile_no"]}]}]', + }, + "CRM Deal-Side Panel": { + "pagetype": "CRM Deal", + "layout": '[{"label": "Contacts", "name": "contacts_section", "opened": true, "editable": false, "contacts": []}, {"label": "Organization Details", "name": "organization_section", "opened": true, "columns": [{"name": "column_na2Q", "fields": ["organization", "website", "territory", "annual_revenue", "close_date", "probability", "next_step", "deal_owner"]}]}]', + }, + "Contact-Side Panel": { + "pagetype": "Contact", + "layout": '[{"label": "Details", "name": "details_section", "opened": true, "columns": [{"name": "column_eIWl", "fields": ["salutation", "first_name", "last_name", "email_id", "mobile_no", "gender", "company_name", "designation", "address"]}]}]', + }, + "CRM Organization-Side Panel": { + "pagetype": "CRM Organization", + "layout": '[{"label": "Details", "name": "details_section", "opened": true, "columns": [{"name": "column_IJOV", "fields": ["organization_name", "website", "territory", "industry", "no_of_employees", "address"]}]}]', + }, + } + + data_fields_layouts = { + "CRM Lead-Data Fields": { + "pagetype": "CRM Lead", + "layout": '[{"label": "Details", "name": "details_section", "opened": true, "columns": [{"name": "column_ZgLG", "fields": ["organization", "industry", "lead_owner"]}, {"name": "column_TbYq", "fields": ["website", "job_title"]}, {"name": "column_OKSX", "fields": ["territory", "source"]}]}, {"label": "Person", "name": "person_section", "opened": true, "columns": [{"name": "column_6c5g", "fields": ["salutation", "email"]}, {"name": "column_1n7Q", "fields": ["first_name", "mobile_no"]}, {"name": "column_cT6C", "fields": ["last_name"]}]}]', + }, + "CRM Deal-Data Fields": { + "pagetype": "CRM Deal", + "layout": '[{"name":"first_tab","sections":[{"label":"Details","name":"details_section","opened":true,"columns":[{"name":"column_z9XL","fields":["organization","annual_revenue","next_step"]},{"name":"column_gM4w","fields":["website","closed_date","deal_owner"]},{"name":"column_gWmE","fields":["territory","probability"]}]},{"label":"Products","name":"section_jHhQ","opened":true,"columns":[{"name":"column_xiNF","fields":["products"]}],"editingLabel":false,"hideLabel":true},{"label":"New Section","name":"section_WNOQ","opened":true,"columns":[{"name":"column_ziBW","fields":["total"]},{"label":"","name":"column_wuwA","fields":["net_total"]}],"hideBorder":true,"hideLabel":true}]}]', + }, + } + + for layout in quick_entry_layouts: + if jingrow.db.exists("CRM Fields Layout", layout): + if force: + jingrow.delete_pg("CRM Fields Layout", layout) + else: + continue + + pg = jingrow.new_pg("CRM Fields Layout") + pg.type = "Quick Entry" + pg.dt = quick_entry_layouts[layout]["pagetype"] + pg.layout = quick_entry_layouts[layout]["layout"] + pg.insert() + + for layout in sidebar_fields_layouts: + if jingrow.db.exists("CRM Fields Layout", layout): + if force: + jingrow.delete_pg("CRM Fields Layout", layout) + else: + continue + + pg = jingrow.new_pg("CRM Fields Layout") + pg.type = "Side Panel" + pg.dt = sidebar_fields_layouts[layout]["pagetype"] + pg.layout = sidebar_fields_layouts[layout]["layout"] + pg.insert() + + for layout in data_fields_layouts: + if jingrow.db.exists("CRM Fields Layout", layout): + if force: + jingrow.delete_pg("CRM Fields Layout", layout) + else: + continue + + pg = jingrow.new_pg("CRM Fields Layout") + pg.type = "Data Fields" + pg.dt = data_fields_layouts[layout]["pagetype"] + pg.layout = data_fields_layouts[layout]["layout"] + pg.insert() + + +def add_property_setter(): + if not jingrow.db.exists("Property Setter", {"name": "Contact-main-search_fields"}): + pg = jingrow.new_pg("Property Setter") + pg.pagetype_or_field = "PageType" + pg.pg_type = "Contact" + pg.property = "search_fields" + pg.property_type = "Data" + pg.value = "email_id" + pg.insert() + + +def add_email_template_custom_fields(): + if not jingrow.get_meta("Email Template").has_field("enabled"): + click.secho("* Installing Custom Fields in Email Template") + + create_custom_fields( + { + "Email Template": [ + { + "default": "0", + "fieldname": "enabled", + "fieldtype": "Check", + "label": "Enabled", + "insert_after": "", + }, + { + "fieldname": "reference_pagetype", + "fieldtype": "Link", + "label": "Pagetype", + "options": "PageType", + "insert_after": "enabled", + }, + ] + } + ) + + jingrow.clear_cache(pagetype="Email Template") + + +def add_default_industries(): + industries = [ + "Accounting", + "Advertising", + "Aerospace", + "Agriculture", + "Airline", + "Apparel & Accessories", + "Automotive", + "Banking", + "Biotechnology", + "Broadcasting", + "Brokerage", + "Chemical", + "Computer", + "Consulting", + "Consumer Products", + "Cosmetics", + "Defense", + "Department Stores", + "Education", + "Electronics", + "Energy", + "Entertainment & Leisure, Executive Search", + "Financial Services", + "Food", + "Beverage & Tobacco", + "Grocery", + "Health Care", + "Internet Publishing", + "Investment Banking", + "Legal", + "Manufacturing", + "Motion Picture & Video", + "Music", + "Newspaper Publishers", + "Online Auctions", + "Pension Funds", + "Pharmaceuticals", + "Private Equity", + "Publishing", + "Real Estate", + "Retail & Wholesale", + "Securities & Commodity Exchanges", + "Service", + "Soap & Detergent", + "Software", + "Sports", + "Technology", + "Telecommunications", + "Television", + "Transportation", + "Venture Capital", + ] + + for industry in industries: + if jingrow.db.exists("CRM Industry", industry): + continue + + pg = jingrow.new_pg("CRM Industry") + pg.industry = industry + pg.insert() + + +def add_default_lead_sources(): + lead_sources = [ + "Existing Customer", + "Reference", + "Advertisement", + "Cold Calling", + "Exhibition", + "Supplier Reference", + "Mass Mailing", + "Customer's Vendor", + "Campaign", + "Walk In", + ] + + for source in lead_sources: + if jingrow.db.exists("CRM Lead Source", source): + continue + + pg = jingrow.new_pg("CRM Lead Source") + pg.source_name = source + pg.insert() + + +def add_default_lost_reasons(): + lost_reasons = [ + { + "reason": "Pricing", + "description": "The prospect found the pricing to be too high or not competitive.", + }, + {"reason": "Competition", "description": "The prospect chose a competitor's product or service."}, + { + "reason": "Budget Constraints", + "description": "The prospect did not have the budget to proceed with the purchase.", + }, + { + "reason": "Missing Features", + "description": "The prospect felt that the product or service was missing key features they needed.", + }, + { + "reason": "Long Sales Cycle", + "description": "The sales process took too long, leading to loss of interest.", + }, + { + "reason": "No Decision-Maker", + "description": "The prospect was not the decision-maker and could not proceed.", + }, + {"reason": "Unresponsive Prospect", "description": "The prospect did not respond to follow-ups."}, + {"reason": "Poor Fit", "description": "The prospect was not a good fit for the product or service."}, + {"reason": "Other", "description": ""}, + ] + + for reason in lost_reasons: + if jingrow.db.exists("CRM Lost Reason", reason["reason"]): + continue + + pg = jingrow.new_pg("CRM Lost Reason") + pg.lost_reason = reason["reason"] + pg.description = reason["description"] + pg.insert() + + +def add_standard_dropdown_items(): + crm_settings = jingrow.get_single("FCRM Settings") + + # don't add dropdown items if they're already present + if crm_settings.dropdown_items: + return + + crm_settings.dropdown_items = [] + + for item in jingrow.get_hooks("standard_dropdown_items"): + crm_settings.append("dropdown_items", item) + + crm_settings.save() + + +def add_default_scripts(): + from crm.fcrm.pagetype.fcrm_settings.fcrm_settings import create_forecasting_script + + for pagetype in ["CRM Lead", "CRM Deal"]: + create_product_details_script(pagetype) + create_forecasting_script() + + +def add_assignment_rule_property_setters(): + """Add a property setter to the Assignment Rule PageType for assign_condition and unassign_condition.""" + + default_fields = { + "pagetype": "Property Setter", + "pagetype_or_field": "PageField", + "pg_type": "Assignment Rule", + "property_type": "Data", + "is_system_generated": 1, + } + + if not jingrow.db.exists("Property Setter", {"name": "Assignment Rule-assign_condition-depends_on"}): + jingrow.get_pg( + { + **default_fields, + "name": "Assignment Rule-assign_condition-depends_on", + "field_name": "assign_condition", + "property": "depends_on", + "value": "eval: !pg.assign_condition_json", + } + ).insert() + else: + jingrow.db.set_value( + "Property Setter", + {"name": "Assignment Rule-assign_condition-depends_on"}, + "value", + "eval: !pg.assign_condition_json", + ) + if not jingrow.db.exists("Property Setter", {"name": "Assignment Rule-unassign_condition-depends_on"}): + jingrow.get_pg( + { + **default_fields, + "name": "Assignment Rule-unassign_condition-depends_on", + "field_name": "unassign_condition", + "property": "depends_on", + "value": "eval: !pg.unassign_condition_json", + } + ).insert() + else: + jingrow.db.set_value( + "Property Setter", + {"name": "Assignment Rule-unassign_condition-depends_on"}, + "value", + "eval: !pg.unassign_condition_json", + ) + + +def create_assignment_rule_custom_fields(): + if not jingrow.get_meta("Assignment Rule").has_field("assign_condition_json"): + click.secho("* Installing Custom Fields in Assignment Rule") + + create_custom_fields( + { + "Assignment Rule": [ + { + "description": "Autogenerated field by CRM App", + "fieldname": "assign_condition_json", + "fieldtype": "Code", + "label": "Assign Condition JSON", + "insert_after": "assign_condition", + "depends_on": "eval: pg.assign_condition_json", + }, + { + "description": "Autogenerated field by CRM App", + "fieldname": "unassign_condition_json", + "fieldtype": "Code", + "label": "Unassign Condition JSON", + "insert_after": "unassign_condition", + "depends_on": "eval: pg.unassign_condition_json", + }, + ], + } + ) + + jingrow.clear_cache(pagetype="Assignment Rule") diff --git a/crm/integrations/__init__.py b/crm/integrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/integrations/api.py b/crm/integrations/api.py new file mode 100644 index 0000000..8d2d2a6 --- /dev/null +++ b/crm/integrations/api.py @@ -0,0 +1,181 @@ +import jingrow +from jingrow.query_builder import Order +from pypika.functions import Replace + +from crm.utils import are_same_phone_number, parse_phone_number + + +@jingrow.whitelist() +def is_call_integration_enabled(): + twilio_enabled = jingrow.db.get_single_value("CRM Twilio Settings", "enabled") + exotel_enabled = jingrow.db.get_single_value("CRM Exotel Settings", "enabled") + + return { + "twilio_enabled": twilio_enabled, + "exotel_enabled": exotel_enabled, + "default_calling_medium": get_user_default_calling_medium(), + } + + +def get_user_default_calling_medium(): + if not jingrow.db.exists("CRM Telephony Agent", jingrow.session.user): + return None + + default_medium = jingrow.db.get_value("CRM Telephony Agent", jingrow.session.user, "default_medium") + + if not default_medium: + return None + + return default_medium + + +@jingrow.whitelist() +def set_default_calling_medium(medium): + if not jingrow.db.exists("CRM Telephony Agent", jingrow.session.user): + jingrow.get_pg( + { + "pagetype": "CRM Telephony Agent", + "user": jingrow.session.user, + "default_medium": medium, + } + ).insert(ignore_permissions=True) + else: + jingrow.db.set_value("CRM Telephony Agent", jingrow.session.user, "default_medium", medium) + + return get_user_default_calling_medium() + + +@jingrow.whitelist() +def add_note_to_call_log(call_sid, note): + """Add/Update note to call log based on call sid.""" + _note = None + if not note.get("name"): + _note = jingrow.get_pg( + { + "pagetype": "FCRM Note", + "title": note.get("title", "Call Note"), + "content": note.get("content"), + } + ).insert(ignore_permissions=True) + else: + _note = jingrow.set_value("FCRM Note", note.get("name"), "content", note.get("content")) + + call_log = jingrow.get_cached_pg("CRM Call Log", call_sid) + call_log.link_with_reference_pg("FCRM Note", _note.name) + call_log.save(ignore_permissions=True) + + return _note + + +@jingrow.whitelist() +def add_task_to_call_log(call_sid, task): + """Add/Update task to call log based on call sid.""" + _task = None + if not task.get("name"): + _task = jingrow.get_pg( + { + "pagetype": "CRM Task", + "title": task.get("title"), + "description": task.get("description"), + "assigned_to": task.get("assigned_to"), + "due_date": task.get("due_date"), + "status": task.get("status"), + "priority": task.get("priority"), + } + ).insert(ignore_permissions=True) + else: + _task = jingrow.get_pg("CRM Task", task.get("name")) + _task.update( + { + "title": task.get("title"), + "description": task.get("description"), + "assigned_to": task.get("assigned_to"), + "due_date": task.get("due_date"), + "status": task.get("status"), + "priority": task.get("priority"), + } + ) + _task.save(ignore_permissions=True) + + call_log = jingrow.get_pg("CRM Call Log", call_sid) + call_log.link_with_reference_pg("CRM Task", _task.name) + call_log.save(ignore_permissions=True) + + return _task + + +@jingrow.whitelist() +def get_contact_by_phone_number(phone_number): + """Get contact by phone number.""" + number = parse_phone_number(phone_number) + + if number.get("is_valid"): + return get_contact(number.get("national_number"), number.get("country")) + else: + return get_contact(phone_number, number.get("country"), exact_match=True) + + +def get_contact(phone_number, country="IN", exact_match=False): + if not phone_number: + return {"mobile_no": phone_number} + + cleaned_number = ( + phone_number.strip() + .replace(" ", "") + .replace("-", "") + .replace("(", "") + .replace(")", "") + .replace("+", "") + ) + + # Check if the number is associated with a contact + Contact = jingrow.qb.PageType("Contact") + normalized_phone = Replace( + Replace(Replace(Replace(Replace(Contact.mobile_no, " ", ""), "-", ""), "(", ""), ")", ""), "+", "" + ) + + query = ( + jingrow.qb.from_(Contact) + .select(Contact.name, Contact.full_name, Contact.image, Contact.mobile_no) + .where(normalized_phone.like(f"%{cleaned_number}%")) + .orderby("modified", order=Order.desc) + ) + contacts = query.run(as_dict=True) + + if len(contacts): + # Check if the contact is associated with a deal + for contact in contacts: + if jingrow.db.exists("CRM Contacts", {"contact": contact.name, "is_primary": 1}): + deal = jingrow.db.get_value( + "CRM Contacts", {"contact": contact.name, "is_primary": 1}, "parent" + ) + if are_same_phone_number(contact.mobile_no, phone_number, country, validate=not exact_match): + contact["deal"] = deal + return contact + # Else, return the first contact + if are_same_phone_number(contacts[0].mobile_no, phone_number, country, validate=not exact_match): + return contacts[0] + + # Else, Check if the number is associated with a lead + Lead = jingrow.qb.PageType("CRM Lead") + normalized_phone = Replace( + Replace(Replace(Replace(Replace(Lead.mobile_no, " ", ""), "-", ""), "(", ""), ")", ""), "+", "" + ) + + query = ( + jingrow.qb.from_(Lead) + .select(Lead.name, Lead.lead_name, Lead.image, Lead.mobile_no) + .where(Lead.converted == 0) + .where(normalized_phone.like(f"%{cleaned_number}%")) + .orderby("modified", order=Order.desc) + ) + leads = query.run(as_dict=True) + + if len(leads): + for lead in leads: + if are_same_phone_number(lead.mobile_no, phone_number, country, validate=not exact_match): + lead["lead"] = lead.name + lead["full_name"] = lead.lead_name + return lead + + return {"mobile_no": phone_number} diff --git a/crm/integrations/exotel/handler.py b/crm/integrations/exotel/handler.py new file mode 100644 index 0000000..fc33aa8 --- /dev/null +++ b/crm/integrations/exotel/handler.py @@ -0,0 +1,286 @@ +import bleach +import jingrow +import requests +from jingrow import _ +from jingrow.integrations.utils import create_request_log + +from crm.integrations.api import get_contact_by_phone_number + +# Endpoints for webhook + +# Incoming Call: +# /api/action/crm.integrations.exotel.handler.handle_request?key= + +# Exotel Reference: +# https://developer.exotel.com/api/ +# https://support.exotel.com/support/solutions/articles/48283-working-with-passthru-applet + + +# Incoming Call +@jingrow.whitelist(allow_guest=True) +def handle_request(**kwargs): + validate_request() + if not is_integration_enabled(): + return + + request_log = create_request_log( + kwargs, + request_description="Exotel Call", + service_name="Exotel", + request_headers=jingrow.request.headers, + is_remote_request=1, + ) + + try: + request_log.status = "Completed" + exotel_settings = get_exotel_settings() + if not exotel_settings.enabled: + return + + call_payload = kwargs + + jingrow.publish_realtime("exotel_call", call_payload) + status = call_payload.get("Status") + if status == "free": + return + + if call_log := get_call_log(call_payload): + update_call_log(call_payload, call_log=call_log) + else: + create_call_log( + call_id=call_payload.get("CallSid"), + from_number=call_payload.get("CallFrom"), + to_number=call_payload.get("DialWhomNumber"), + medium=call_payload.get("To"), + status=get_call_log_status(call_payload), + agent=call_payload.get("AgentEmail"), + ) + except Exception: + request_log.status = "Failed" + request_log.error = jingrow.get_traceback() + jingrow.db.rollback() + jingrow.log_error(title="Error while creating/updating call record") + jingrow.db.commit() + finally: + request_log.save(ignore_permissions=True) + jingrow.db.commit() + + +# Outgoing Call +@jingrow.whitelist() +def make_a_call(to_number, from_number=None, caller_id=None): + if not is_integration_enabled(): + jingrow.throw(_("Please setup Exotel intergration"), title=_("Integration Not Enabled")) + + endpoint = get_exotel_endpoint("Calls/connect.json?details=true") + + if not from_number: + from_number = jingrow.get_value("CRM Telephony Agent", {"user": jingrow.session.user}, "mobile_no") + + if not caller_id: + caller_id = jingrow.get_value("CRM Telephony Agent", {"user": jingrow.session.user}, "exotel_number") + + if not caller_id: + jingrow.throw( + _("You do not have Exotel Number set in your Telephony Agent"), title=_("Exotel Number Missing") + ) + + if caller_id and caller_id not in get_all_exophones(): + jingrow.throw(_("Exotel Number {0} is not valid").format(caller_id), title=_("Invalid Exotel Number")) + + if not from_number: + jingrow.throw( + _("You do not have mobile number set in your Telephony Agent"), title=_("Mobile Number Missing") + ) + + record_call = jingrow.db.get_single_value("CRM Exotel Settings", "record_call") + + try: + response = requests.post( + endpoint, + data={ + "From": from_number, + "To": to_number, + "CallerId": caller_id, + "Record": "true" if record_call else "false", + "StatusCallback": get_status_updater_url(), + "StatusCallbackEvents[0]": "terminal", + "StatusCallbackEvents[1]": "answered", + }, + ) + response.raise_for_status() + except requests.exceptions.HTTPError: + if exc := response.json().get("RestException"): + jingrow.throw(bleach.linkify(exc.get("Message")), title=_("Exotel Exception")) + else: + res = response.json() + call_payload = res.get("Call", {}) + + create_call_log( + call_id=call_payload.get("Sid"), + from_number=call_payload.get("From"), + to_number=call_payload.get("To"), + medium=call_payload.get("PhoneNumberSid"), + call_type="Outgoing", + agent=jingrow.session.user, + ) + + call_details = response.json().get("Call", {}) + call_details["CallSid"] = call_details.get("Sid", "") + return call_details + + +def get_exotel_endpoint(action=None, version="v1"): + settings = get_exotel_settings() + return "https://{api_key}:{api_token}@{subdomain}/{version}/Accounts/{sid}/{action}".format( + api_key=settings.api_key, + api_token=settings.get_password("api_token"), + subdomain=settings.subdomain, + version=version, + sid=settings.account_sid, + action=action, + ) + + +def get_all_exophones(): + endpoint = get_exotel_endpoint("IncomingPhoneNumbers", "v2_beta") + response = requests.get(endpoint) + return [phone.get("friendly_name") for phone in response.json().get("incoming_phone_numbers", [])] + + +def get_status_updater_url(): + from jingrow.utils.data import get_url + + webhook_verify_token = jingrow.db.get_single_value("CRM Exotel Settings", "webhook_verify_token") + return get_url(f"api/action/crm.integrations.exotel.handler.handle_request?key={webhook_verify_token}") + + +def get_exotel_settings(): + return jingrow.get_single("CRM Exotel Settings") + + +def validate_request(): + # workaround security since exotel does not support request signature + # /api/action/?key= + webhook_verify_token = jingrow.db.get_single_value("CRM Exotel Settings", "webhook_verify_token") + key = jingrow.request.args.get("key") + is_valid = key and key == webhook_verify_token + + if not is_valid: + jingrow.throw(_("Unauthorized request"), exc=jingrow.PermissionError) + + +@jingrow.whitelist() +def is_integration_enabled(): + return jingrow.db.get_single_value("CRM Exotel Settings", "enabled", True) + + +# Call Log Functions +def create_call_log( + call_id, + from_number, + to_number, + medium, + agent, + status="Ringing", + call_type="Incoming", +): + call_log = jingrow.new_pg("CRM Call Log") + call_log.id = call_id + call_log.to = to_number + call_log.medium = medium + call_log.type = call_type + call_log.status = status + call_log.telephony_medium = "Exotel" + setattr(call_log, "from", from_number) + + if call_type == "Incoming": + call_log.receiver = agent + else: + call_log.caller = agent + + # link call log with lead/deal + contact_number = from_number if call_type == "Incoming" else to_number + link(contact_number, call_log) + + call_log.save(ignore_permissions=True) + jingrow.db.commit() + return call_log + + +def link(contact_number, call_log): + contact = get_contact_by_phone_number(contact_number) + if contact.get("name"): + pagetype = "Contact" + docname = contact.get("name") + if contact.get("lead"): + pagetype = "CRM Lead" + docname = contact.get("lead") + elif contact.get("deal"): + pagetype = "CRM Deal" + docname = contact.get("deal") + call_log.link_with_reference_pg(pagetype, docname) + + +def get_call_log(call_payload): + call_log_id = call_payload.get("CallSid") + if jingrow.db.exists("CRM Call Log", call_log_id): + return jingrow.get_pg("CRM Call Log", call_log_id) + + +def get_call_log_status(call_payload, direction="inbound"): + if direction == "outbound-api" or direction == "outbound-dial": + status = call_payload.get("Status") + if status == "completed": + return "Completed" + elif status == "in-progress": + return "In Progress" + elif status == "busy": + return "Ringing" + elif status == "no-answer": + return "No Answer" + elif status == "failed": + return "Failed" + + call_type = call_payload.get("CallType") + status = call_payload.get("DialCallStatus") or call_payload.get("Status") + + if call_type == "incomplete" and status == "no-answer": + status = "No Answer" + elif call_type == "client-hangup" and status == "canceled": + status = "Canceled" + elif call_type == "incomplete" and status == "failed": + status = "Failed" + elif call_type == "completed": + status = "Completed" + elif status == "busy": + status = "Ringing" + + return status + + +def update_call_log(call_payload, status="Ringing", call_log=None): + direction = call_payload.get("Direction") + call_log = call_log or get_call_log(call_payload) + status = get_call_log_status(call_payload, direction) + try: + if call_log: + call_log.status = status + # resetting this because call might be redirected to other number + call_log.to = call_payload.get("DialWhomNumber") or call_payload.get("To") + call_log.duration = ( + call_payload.get("DialCallDuration") or call_payload.get("ConversationDuration") or 0 + ) + call_log.recording_url = call_payload.get("RecordingUrl") if call_payload.get("RecordingUrl") else "" + call_log.start_time = call_payload.get("StartTime") + call_log.end_time = call_payload.get("EndTime") + + if direction == "incoming" and call_payload.get("AgentEmail"): + call_log.receiver = call_payload.get("AgentEmail") + + call_log.save(ignore_permissions=True) + jingrow.db.commit() + return call_log + except Exception: + jingrow.log_error(title="Error while updating call record") + jingrow.db.commit() diff --git a/crm/integrations/twilio/api.py b/crm/integrations/twilio/api.py new file mode 100644 index 0000000..c7d5b18 --- /dev/null +++ b/crm/integrations/twilio/api.py @@ -0,0 +1,166 @@ +import json + +import jingrow +from jingrow import _ +from werkzeug.wrappers import Response + +from crm.integrations.api import get_contact_by_phone_number + +from .twilio_handler import IncomingCall, Twilio, TwilioCallDetails + + +@jingrow.whitelist() +def is_enabled(): + return jingrow.db.get_single_value("CRM Twilio Settings", "enabled") + + +@jingrow.whitelist() +def generate_access_token(): + """Returns access token that is required to authenticate Twilio Client SDK.""" + twilio = Twilio.connect() + if not twilio: + return {} + + from_number = jingrow.db.get_value("CRM Telephony Agent", jingrow.session.user, "twilio_number") + if not from_number: + return { + "ok": False, + "error": "caller_phone_identity_missing", + "detail": "Phone number is not mapped to the caller", + } + + token = twilio.generate_voice_access_token(identity=jingrow.session.user) + return {"token": jingrow.safe_decode(token)} + + +@jingrow.whitelist(allow_guest=True) +def voice(**kwargs): + """This is a webhook called by twilio to get instructions when the voice call request comes to twilio server.""" + + def _get_caller_number(caller): + identity = caller.replace("client:", "").strip() + user = Twilio.emailid_from_identity(identity) + return jingrow.db.get_value("CRM Telephony Agent", user, "twilio_number") + + args = jingrow._dict(kwargs) + twilio = Twilio.connect() + if not twilio: + return + + assert args.AccountSid == twilio.account_sid + assert args.ApplicationSid == twilio.application_sid + + # Generate TwiML instructions to make a call + from_number = _get_caller_number(args.Caller) + resp = twilio.generate_twilio_dial_response(from_number, args.To) + + call_details = TwilioCallDetails(args, call_from=from_number) + create_call_log(call_details) + return Response(resp.to_xml(), mimetype="text/xml") + + +@jingrow.whitelist(allow_guest=True) +def twilio_incoming_call_handler(**kwargs): + args = jingrow._dict(kwargs) + call_details = TwilioCallDetails(args) + create_call_log(call_details) + + resp = IncomingCall(args.From, args.To).process() + return Response(resp.to_xml(), mimetype="text/xml") + + +def create_call_log(call_details: TwilioCallDetails): + details = call_details.to_dict() + + call_log = jingrow.get_pg({**details, "pagetype": "CRM Call Log", "telephony_medium": "Twilio"}) + + # link call log with lead/deal + contact_number = details.get("from") if details.get("type") == "Incoming" else details.get("to") + link(contact_number, call_log) + + call_log.save(ignore_permissions=True) + jingrow.db.commit() + return call_log + + +def link(contact_number, call_log): + contact = get_contact_by_phone_number(contact_number) + if contact.get("name"): + pagetype = "Contact" + docname = contact.get("name") + if contact.get("lead"): + pagetype = "CRM Lead" + docname = contact.get("lead") + elif contact.get("deal"): + pagetype = "CRM Deal" + docname = contact.get("deal") + call_log.link_with_reference_pg(pagetype, docname) + + +def update_call_log(call_sid, status=None): + """Update call log status.""" + twilio = Twilio.connect() + if not (twilio and jingrow.db.exists("CRM Call Log", call_sid)): + return + + try: + call_details = twilio.get_call_info(call_sid) + call_log = jingrow.get_pg("CRM Call Log", call_sid) + call_log.status = TwilioCallDetails.get_call_status(status or call_details.status) + call_log.duration = call_details.duration + call_log.start_time = get_datetime_from_timestamp(call_details.start_time) + call_log.end_time = get_datetime_from_timestamp(call_details.end_time) + call_log.save(ignore_permissions=True) + jingrow.db.commit() + return call_log + except Exception: + jingrow.log_error(title="Error while updating call record") + jingrow.db.commit() + + +@jingrow.whitelist(allow_guest=True) +def update_recording_info(**kwargs): + try: + args = jingrow._dict(kwargs) + recording_url = args.RecordingUrl + call_sid = args.CallSid + update_call_log(call_sid) + jingrow.db.set_value("CRM Call Log", call_sid, "recording_url", recording_url) + except Exception: + jingrow.log_error(title=_("Failed to capture Twilio recording")) + + +@jingrow.whitelist(allow_guest=True) +def update_call_status_info(**kwargs): + try: + args = jingrow._dict(kwargs) + parent_call_sid = args.ParentCallSid + update_call_log(parent_call_sid, status=args.CallStatus) + + call_info = { + "ParentCallSid": args.ParentCallSid, + "CallSid": args.CallSid, + "CallStatus": args.CallStatus, + "CallDuration": args.CallDuration, + "From": args.From, + "To": args.To, + } + + client = Twilio.get_twilio_client() + client.calls(args.ParentCallSid).user_defined_messages.create(content=json.dumps(call_info)) + except Exception: + jingrow.log_error(title=_("Failed to update Twilio call status")) + + +def get_datetime_from_timestamp(timestamp): + from datetime import datetime + from zoneinfo import ZoneInfo + + if not timestamp: + return None + + datetime_utc_tz_str = timestamp.strftime("%Y-%m-%d %H:%M:%S%z") + datetime_utc_tz = datetime.strptime(datetime_utc_tz_str, "%Y-%m-%d %H:%M:%S%z") + system_timezone = jingrow.utils.get_system_timezone() + converted_datetime = datetime_utc_tz.astimezone(ZoneInfo(system_timezone)) + return jingrow.utils.format_datetime(converted_datetime, "yyyy-MM-dd HH:mm:ss") diff --git a/crm/integrations/twilio/twilio_handler.py b/crm/integrations/twilio/twilio_handler.py new file mode 100644 index 0000000..7e5b129 --- /dev/null +++ b/crm/integrations/twilio/twilio_handler.py @@ -0,0 +1,267 @@ +import jingrow +from jingrow import _ +from jingrow.utils.password import get_decrypted_password +from twilio.jwt.access_token import AccessToken +from twilio.jwt.access_token.grants import VoiceGrant +from twilio.rest import Client as TwilioClient +from twilio.twiml.voice_response import Dial, VoiceResponse + +from .utils import get_public_url, merge_dicts + + +class Twilio: + """Twilio connector over TwilioClient.""" + + def __init__(self, settings): + """ + :param settings: `CRM Twilio Settings` pagetype + """ + self.settings = settings + self.account_sid = settings.account_sid + self.application_sid = settings.twiml_sid + self.api_key = settings.api_key + self.api_secret = settings.get_password("api_secret") + self.twilio_client = self.get_twilio_client() + + @classmethod + def connect(self): + """Make a twilio connection.""" + settings = jingrow.get_pg("CRM Twilio Settings") + if not (settings and settings.enabled): + return + return Twilio(settings=settings) + + def get_phone_numbers(self): + """Get account's twilio phone numbers.""" + numbers = self.twilio_client.incoming_phone_numbers.list() + return [n.phone_number for n in numbers] + + def generate_voice_access_token(self, identity: str, ttl=60 * 60): + """Generates a token required to make voice calls from the browser.""" + # identity is used by twilio to identify the user uniqueness at browser(or any endpoints). + identity = self.safe_identity(identity) + + # Create access token with credentials + token = AccessToken(self.account_sid, self.api_key, self.api_secret, identity=identity, ttl=ttl) + + # Create a Voice grant and add to token + voice_grant = VoiceGrant( + outgoing_application_sid=self.application_sid, + incoming_allow=True, # Allow incoming calls + ) + token.add_grant(voice_grant) + return token.to_jwt() + + @classmethod + def safe_identity(cls, identity: str): + """Create a safe identity by replacing unsupported special charaters `@` with (at)). + Twilio Client JS fails to make a call connection if identity has special characters like @, [, / etc) + https://www.twilio.com/docs/voice/client/errors (#31105) + """ + return identity.replace("@", "(at)") + + @classmethod + def emailid_from_identity(cls, identity: str): + """Convert safe identity string into emailID.""" + return identity.replace("(at)", "@") + + def get_recording_status_callback_url(self): + url_path = "/api/action/crm.integrations.twilio.api.update_recording_info" + return get_public_url(url_path) + + def get_update_call_status_callback_url(self): + url_path = "/api/action/crm.integrations.twilio.api.update_call_status_info" + return get_public_url(url_path) + + def generate_twilio_dial_response(self, from_number: str, to_number: str): + """Generates voice call instructions to forward the call to agents Phone.""" + resp = VoiceResponse() + dial = Dial( + caller_id=from_number, + record=self.settings.record_calls, + recording_status_callback=self.get_recording_status_callback_url(), + recording_status_callback_event="completed", + ) + dial.number( + to_number, + status_callback_event="initiated ringing answered completed", + status_callback=self.get_update_call_status_callback_url(), + status_callback_method="POST", + ) + resp.append(dial) + return resp + + def get_call_info(self, call_sid): + return self.twilio_client.calls(call_sid).fetch() + + def generate_twilio_client_response(self, client, ring_tone="at"): + """Generates voice call instructions to forward the call to agents computer.""" + resp = VoiceResponse() + dial = Dial( + ring_tone=ring_tone, + record=self.settings.record_calls, + recording_status_callback=self.get_recording_status_callback_url(), + recording_status_callback_event="completed", + ) + dial.client( + client, + status_callback_event="initiated ringing answered completed", + status_callback=self.get_update_call_status_callback_url(), + status_callback_method="POST", + ) + resp.append(dial) + return resp + + @classmethod + def get_twilio_client(self): + twilio_settings = jingrow.get_pg("CRM Twilio Settings") + if not twilio_settings.enabled: + jingrow.throw(_("Please enable twilio settings before making a call.")) + + auth_token = get_decrypted_password("CRM Twilio Settings", "CRM Twilio Settings", "auth_token") + client = TwilioClient(twilio_settings.account_sid, auth_token) + + return client + + +class IncomingCall: + def __init__(self, from_number, to_number, meta=None): + self.from_number = from_number + self.to_number = to_number + self.meta = meta + + def process(self): + """Process the incoming call + * Figure out who is going to pick the call (call attender) + * Check call attender settings and forward the call to Phone + """ + twilio = Twilio.connect() + owners = get_twilio_number_owners(self.to_number) + attender = get_the_call_attender(owners, self.from_number) + + if not attender: + resp = VoiceResponse() + resp.say(_("Agent is unavailable to take the call, please call after some time.")) + return resp + + if attender["call_receiving_device"] == "Phone": + return twilio.generate_twilio_dial_response(self.from_number, attender["mobile_no"]) + else: + return twilio.generate_twilio_client_response(twilio.safe_identity(attender["name"])) + + +def get_twilio_number_owners(phone_number): + """Get list of users who is using the phone_number. + >>> get_twilio_number_owners("+11234567890") + { + 'owner1': {'name': '..', 'mobile_no': '..', 'call_receiving_device': '...'}, + 'owner2': {....} + } + """ + # remove special characters from phone number and get only digits also remove white spaces + # keep + sign in the number at start of the number + phone_number = "".join([c for c in phone_number if c.isdigit() or c == "+"]) + user_voice_settings = jingrow.get_all( + "CRM Telephony Agent", + filters={"twilio_number": phone_number}, + fields=["name", "call_receiving_device"], + ) + user_wise_voice_settings = {user["name"]: user for user in user_voice_settings} + + user_general_settings = jingrow.get_all( + "User", filters=[["name", "IN", user_wise_voice_settings.keys()]], fields=["name", "mobile_no"] + ) + user_wise_general_settings = {user["name"]: user for user in user_general_settings} + + return merge_dicts(user_wise_general_settings, user_wise_voice_settings) + + +def get_active_loggedin_users(users): + """Filter the current loggedin users from the given users list""" + rows = jingrow.db.sql( + """ + SELECT `user` + FROM `tabSessions` + WHERE `user` IN %(users)s + """, + {"users": users}, + ) + return [row[0] for row in set(rows)] + + +def get_the_call_attender(owners, caller=None): + """Get attender details from list of owners""" + if not owners: + return + current_loggedin_users = get_active_loggedin_users(list(owners.keys())) + + if len(current_loggedin_users) > 1 and caller: + deal_owner = jingrow.db.get_value("CRM Deal", {"mobile_no": caller}, "deal_owner") + if not deal_owner: + deal_owner = jingrow.db.get_value( + "CRM Lead", {"mobile_no": caller, "converted": False}, "lead_owner" + ) + for user in current_loggedin_users: + if user == deal_owner: + current_loggedin_users = [user] + + for name, details in owners.items(): + if (details["call_receiving_device"] == "Phone" and details["mobile_no"]) or ( + details["call_receiving_device"] == "Computer" and name in current_loggedin_users + ): + return details + + +class TwilioCallDetails: + def __init__(self, call_info, call_from=None, call_to=None): + self.call_info = call_info + self.account_sid = call_info.get("AccountSid") + self.application_sid = call_info.get("ApplicationSid") + self.call_sid = call_info.get("CallSid") + self.call_status = self.get_call_status(call_info.get("CallStatus")) + self._call_from = call_from or call_info.get("From") + self._call_to = call_to or call_info.get("To") + + def get_direction(self): + if self.call_info.get("Caller").lower().startswith("client"): + return "Outgoing" + return "Incoming" + + def get_from_number(self): + return self._call_from or self.call_info.get("From") + + def get_to_number(self): + return self._call_to or self.call_info.get("To") + + @classmethod + def get_call_status(cls, twilio_status): + """Convert Twilio given status into system status.""" + twilio_status = twilio_status or "" + return " ".join(twilio_status.split("-")).title() + + def to_dict(self): + """Convert call details into dict.""" + direction = self.get_direction() + from_number = self.get_from_number() + to_number = self.get_to_number() + caller = "" + receiver = "" + + if direction == "Outgoing": + caller = self.call_info.get("Caller") + identity = caller.replace("client:", "").strip() + caller = Twilio.emailid_from_identity(identity) if identity else "" + else: + owners = get_twilio_number_owners(to_number) + attender = get_the_call_attender(owners, from_number) + receiver = attender["name"] if attender else "" + + return { + "type": direction, + "status": self.call_status, + "id": self.call_sid, + "from": from_number, + "to": to_number, + "receiver": receiver, + "caller": caller, + } diff --git a/crm/integrations/twilio/utils.py b/crm/integrations/twilio/utils.py new file mode 100644 index 0000000..258b426 --- /dev/null +++ b/crm/integrations/twilio/utils.py @@ -0,0 +1,17 @@ +from jingrow.utils import get_url + + +def get_public_url(path: str | None = None): + return get_url().split(":8", 1)[0] + path + + +def merge_dicts(d1: dict, d2: dict): + """Merge dicts of dictionaries. + >>> merge_dicts( + {'name1': {'age': 20}, 'name2': {'age': 30}}, + {'name1': {'phone': '+xxx'}, 'name2': {'phone': '+yyy'}, 'name3': {'phone': '+zzz'}} + ) + ... {'name1': {'age': 20, 'phone': '+xxx'}, 'name2': {'age': 30, 'phone': '+yyy'}} + """ + return {k: {**v, **d2.get(k, {})} for k, v in d1.items()} + diff --git a/crm/locale/zh.po b/crm/locale/zh.po new file mode 100644 index 0000000..654f03a --- /dev/null +++ b/crm/locale/zh.po @@ -0,0 +1,6392 @@ +msgid "" +msgstr "" +"Project-Id-Version: jingrow\n" +"Report-Msgid-Bugs-To: shariq@jingrow.com\n" +"POT-Creation-Date: 2025-09-21 09:35+0000\n" +"PO-Revision-Date: 2025-09-22 20:42\n" +"Last-Translator: shariq@jingrow.com\n" +"Language-Team: Chinese Simplified\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.16.0\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Crowdin-Project: jingrow\n" +"X-Crowdin-Project-ID: 639578\n" +"X-Crowdin-Language: zh-CN\n" +"X-Crowdin-File: /[jingrow.crm] develop/crm/locale/main.pot\n" +"X-Crowdin-File-ID: 97\n" +"Language: zh_CN\n" + +#: frontend/src/components/ViewControls.vue:1172 +msgid " (New)" +msgstr "(新建)" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:58 +msgid "(No title)" +msgstr "" + +#: frontend/src/components/Modals/TaskModal.vue:87 +#: frontend/src/components/Telephony/TaskPanel.vue:70 +msgid "01/04/2024 11:30 PM" +msgstr "2024年4月1日 下午11:30" + +#: frontend/src/utils/index.js:172 +msgid "1 hour ago" +msgstr "1小时前" + +#: frontend/src/composables/event.js:163 +msgid "1 hr" +msgstr "1小时" + +#: frontend/src/utils/index.js:168 +msgid "1 minute ago" +msgstr "1分钟前" + +#: frontend/src/utils/index.js:187 +msgid "1 month ago" +msgstr "一个月前" + +#: frontend/src/utils/index.js:183 +msgid "1 week ago" +msgstr "一周前" + +#: frontend/src/utils/index.js:191 +msgid "1 year ago" +msgstr "一年前" + +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM Deal' +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM Lead' +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM +#. Organization' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "1-10" +msgstr "1-10" + +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM Deal' +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM Lead' +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM +#. Organization' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "1000+" +msgstr "1000+" + +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM Deal' +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM Lead' +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM +#. Organization' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "11-50" +msgstr "11-50" + +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM Deal' +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM Lead' +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM +#. Organization' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "201-500" +msgstr "201-500" + +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM Deal' +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM Lead' +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM +#. Organization' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "501-1000" +msgstr "501-1000" + +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM Deal' +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM Lead' +#. Option for the 'No. of Employees' (Select) field in PageType 'CRM +#. Organization' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "51-200" +msgstr "51-200" + +#. Paragraph text in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +msgid "META" +msgstr "元数据" + +#. Paragraph text in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +msgid "SHORTCUTS" +msgstr "快捷方式" + +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:95 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:95 +msgid "

Dear {{ lead_name }},

\\n\\n

This is a reminder for the payment of {{ grand_total }}.

\\n\\n

Thanks,

\\n

Frappé

" +msgstr "msgstr \"

尊敬的{{ lead_name }}:

\\n\\n

特此提醒您尚有{{ grand_total }}款项待支付。

\\n\\n

此致

\\n

Frappé团队

\"" + +#. Header text in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +msgid "PORTAL" +msgstr "门户" + +#: frontend/src/components/CommunicationArea.vue:79 +msgid "@John, can you please check this?" +msgstr "@John,请确认此项?" + +#: crm/fcrm/pagetype/crm_lead/crm_lead.py:56 +msgid "A Lead requires either a person's name or an organization's name" +msgstr "线索需填写个人姓名或组织名称" + +#: crm/templates/emails/helpdesk_invitation.html:5 +msgid "A new account has been created for you at {0}" +msgstr "已为您创建新账户{0}" + +#. Label of the api_key (Data) field in PageType 'CRM Exotel Settings' +#. Label of the api_key (Data) field in PageType 'CRM Twilio Settings' +#. Label of the api_key (Data) field in PageType 'ERPNext CRM Settings' +#. Label of the api_key (Data) field in PageType 'Helpdesk CRM Settings' +#: crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json +#: crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.json +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json +#: crm/fcrm/pagetype/helpdesk_crm_settings/helpdesk_crm_settings.json +msgid "API Key" +msgstr "API密钥" + +#: frontend/src/components/Settings/emailConfig.js:179 +msgid "API Key is required" +msgstr "" + +#. Label of the api_secret (Password) field in PageType 'CRM Twilio Settings' +#. Label of the api_secret (Password) field in PageType 'ERPNext CRM Settings' +#. Label of the api_secret (Password) field in PageType 'Helpdesk CRM Settings' +#: crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.json +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json +#: crm/fcrm/pagetype/helpdesk_crm_settings/helpdesk_crm_settings.json +msgid "API Secret" +msgstr "API密钥" + +#. Label of the api_token (Password) field in PageType 'CRM Exotel Settings' +#: crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json +msgid "API Token" +msgstr "API令牌" + +#: frontend/src/components/Telephony/TwilioCallUI.vue:88 +msgid "Accept" +msgstr "接受" + +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.js:7 +msgid "Accept Invitation" +msgstr "接受邀请" + +#: frontend/src/components/Telephony/TwilioCallUI.vue:155 +msgid "Accept call" +msgstr "" + +#. Option for the 'Status' (Select) field in PageType 'CRM Invitation' +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +msgid "Accepted" +msgstr "已接受" + +#. Label of the accepted_at (Datetime) field in PageType 'CRM Invitation' +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +msgid "Accepted At" +msgstr "接受时间" + +#. Label of the access_key (Data) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "Access Key" +msgstr "访问密钥" + +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.py:156 +msgid "Access Key is required for Service Provider: {0}" +msgstr "服务商{0}必须提供访问密钥" + +#: frontend/src/components/Settings/CurrencySettings.vue:90 +msgid "Access key" +msgstr "" + +#: frontend/src/components/Settings/CurrencySettings.vue:94 +msgid "Access key for Exchangerate Host. Required for fetching exchange rates." +msgstr "" + +#: frontend/src/components/Settings/emailConfig.js:13 +msgid "Account Name" +msgstr "科目名称" + +#. Label of the account_sid (Data) field in PageType 'CRM Exotel Settings' +#. Label of the account_sid (Data) field in PageType 'CRM Twilio Settings' +#: crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json +#: crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.json +msgid "Account SID" +msgstr "账户SID" + +#: frontend/src/components/Settings/emailConfig.js:165 +msgid "Account name is required" +msgstr "" + +#: frontend/src/components/CustomActions.vue:69 +#: frontend/src/components/ViewControls.vue:683 +#: frontend/src/components/ViewControls.vue:1064 +msgid "Actions" +msgstr "操作" + +#: frontend/src/pages/Deal.vue:527 frontend/src/pages/Lead.vue:384 +#: frontend/src/pages/MobileDeal.vue:430 frontend/src/pages/MobileLead.vue:337 +msgid "Activity" +msgstr "活动" + +#: frontend/src/components/Dashboard/AddChartModal.vue:41 +#: frontend/src/components/Modals/AddExistingUserModal.vue:55 +msgid "Add" +msgstr "添加" + +#: frontend/src/components/Settings/EmailAccountList.vue:19 +msgid "Add Account" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssigneeSearch.vue:9 +msgid "Add Assignee" +msgstr "" + +#: frontend/src/components/ColumnSettings.vue:68 +#: frontend/src/components/Kanban/KanbanView.vue:157 +msgid "Add Column" +msgstr "添加列" + +#: frontend/src/components/Modals/AddExistingUserModal.vue:4 +#: frontend/src/components/Settings/Users.vue:21 +msgid "Add Existing User" +msgstr "" + +#: frontend/src/components/Controls/GridFieldsEditorModal.vue:57 +#: frontend/src/components/FieldLayoutEditor.vue:172 +#: frontend/src/components/Kanban/KanbanSettings.vue:80 +#: frontend/src/components/SidePanelLayoutEditor.vue:97 +msgid "Add Field" +msgstr "添加字段" + +#: frontend/src/components/Filter.vue:136 +msgid "Add Filter" +msgstr "添加筛选器" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:273 +msgid "Add Lead or Deal" +msgstr "" + +#: frontend/src/components/Controls/Grid.vue:324 +msgid "Add Row" +msgstr "添加行" + +#: frontend/src/components/FieldLayoutEditor.vue:197 +#: frontend/src/components/SidePanelLayoutEditor.vue:127 +msgid "Add Section" +msgstr "添加区块" + +#: frontend/src/components/SortBy.vue:142 +msgid "Add Sort" +msgstr "添加排序" + +#: frontend/src/components/FieldLayoutEditor.vue:62 +msgid "Add Tab" +msgstr "添加标签页" + +#. Label of the add_weekly_holidays_section (Section Break) field in PageType +#. 'CRM Holiday List' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +msgid "Add Weekly Holidays" +msgstr "添加每周假期" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRulesSection.vue:20 +msgid "Add a condition" +msgstr "" + +#: frontend/src/components/Telephony/ExotelCallUI.vue:183 +#: frontend/src/components/Telephony/TwilioCallUI.vue:57 +msgid "Add a note" +msgstr "" + +#: frontend/src/components/Telephony/ExotelCallUI.vue:191 +msgid "Add a task" +msgstr "" + +#: frontend/src/components/Dashboard/AddChartModal.vue:4 +msgid "Add chart" +msgstr "" + +#: frontend/src/components/FieldLayoutEditor.vue:420 +msgid "Add column" +msgstr "添加列" + +#: frontend/src/components/ConditionsFilter/CFConditions.vue:23 +#: frontend/src/components/ConditionsFilter/CFConditions.vue:82 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRulesSection.vue:28 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRulesSection.vue:64 +msgid "Add condition" +msgstr "" + +#: frontend/src/components/ConditionsFilter/CFConditions.vue:91 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRulesSection.vue:70 +msgid "Add condition group" +msgstr "" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:325 +msgid "Add description" +msgstr "添加描述" + +#: frontend/src/components/Modals/EventModal.vue:142 +msgid "Add description." +msgstr "添加描述." + +#: frontend/src/components/Telephony/TaskPanel.vue:17 +msgid "Add description..." +msgstr "添加描述..." + +#: frontend/src/components/Modals/AddExistingUserModal.vue:12 +msgid "Add existing system users to this CRM. Assign them a role to grant access with their current credentials." +msgstr "" + +#: frontend/src/components/ViewControls.vue:107 +msgid "Add filter" +msgstr "添加筛选器" + +#: frontend/src/components/Modals/CallLogDetailModal.vue:19 +msgid "Add note" +msgstr "添加备注" + +#: frontend/src/pages/Welcome.vue:24 +msgid "Add sample data" +msgstr "" + +#. Description of the 'Icon' (Code) field in PageType 'CRM Dropdown Item' +#: crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json +msgid "Add svg code or use feather icons e.g 'settings'" +msgstr "添加SVG代码或使用Feather图标(如'settings')" + +#: frontend/src/components/Modals/CallLogDetailModal.vue:24 +msgid "Add task" +msgstr "添加任务" + +#. Label of the add_to_holidays (Button) field in PageType 'CRM Holiday List' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +msgid "Add to Holidays" +msgstr "添加至假期" + +#: frontend/src/components/Layouts/AppSidebar.vue:439 +msgid "Add your first comment" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:11 +msgid "Add, edit, and manage email templates for various CRM communications" +msgstr "" + +#. Label of the address (Link) field in PageType 'CRM Organization' +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "Address" +msgstr "地址" + +#: frontend/src/components/Modals/AddExistingUserModal.vue:94 +#: frontend/src/components/Settings/InviteUserPage.vue:158 +#: frontend/src/components/Settings/InviteUserPage.vue:165 +#: frontend/src/components/Settings/Users.vue:86 +#: frontend/src/components/Settings/Users.vue:126 +#: frontend/src/components/Settings/Users.vue:192 +#: frontend/src/components/Settings/Users.vue:242 +#: frontend/src/components/Settings/Users.vue:245 +msgid "Admin" +msgstr "管理员" + +#: crm/integrations/twilio/twilio_handler.py:144 +msgid "Agent is unavailable to take the call, please call after some time." +msgstr "客服正忙,请稍后再拨。" + +#. Name of a role +#: crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json +#: crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.json +#: crm/fcrm/pagetype/crm_industry/crm_industry.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_lead_source/crm_lead_source.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:76 +#: frontend/src/components/Settings/Users.vue:85 +msgid "All" +msgstr "全部" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:191 +#: frontend/src/components/Calendar/CalendarEventPanel.vue:641 +#: frontend/src/components/Modals/EventModal.vue:71 +#: frontend/src/composables/event.js:122 +msgid "All day" +msgstr "" + +#. Label of the amount (Currency) field in PageType 'CRM Products' +#: crm/fcrm/pagetype/crm_products/crm_products.json +#: frontend/src/pages/Contact.vue:499 frontend/src/pages/MobileContact.vue:507 +#: frontend/src/pages/MobileOrganization.vue:451 +#: frontend/src/pages/Organization.vue:472 +msgid "Amount" +msgstr "金额" + +#. Description of the 'Net Amount' (Currency) field in PageType 'CRM Products' +#: crm/fcrm/pagetype/crm_products/crm_products.json +msgid "Amount after discount" +msgstr "" + +#: frontend/src/data/script.js:50 frontend/src/data/script.js:51 +msgid "An error occurred" +msgstr "" + +#: frontend/src/data/document.js:63 +msgid "An error occurred while updating the document" +msgstr "" + +#. Description of the 'Favicon' (Attach) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "An icon file with .ico extension. Should be 16 x 16 px. Generated using a favicon generator. [favicon-generator.org]" +msgstr "ICO格式图标文件,尺寸16x16像素,需通过favicon生成器创建。[favicon-generator.org]" + +#. Description of the 'Logo' (Attach) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "An image with 1:1 & 2:1 ratio is preferred" +msgstr "建议使用1:1和2:1比例的图像" + +#: frontend/src/components/Filter.vue:43 frontend/src/components/Filter.vue:81 +msgid "And" +msgstr "且" + +#. Label of the annual_revenue (Currency) field in PageType 'CRM Deal' +#. Label of the annual_revenue (Currency) field in PageType 'CRM Lead' +#. Label of the annual_revenue (Currency) field in PageType 'CRM Organization' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "Annual Revenue" +msgstr "年营业额" + +#: frontend/src/components/Modals/DealModal.vue:200 +#: frontend/src/components/Modals/LeadModal.vue:141 +msgid "Annual Revenue should be a number" +msgstr "年营业额应为数值" + +#: frontend/src/components/Settings/BrandSettings.vue:55 +msgid "Appears in the left sidebar. Recommended size is 32x32 px in PNG or SVG" +msgstr "显示于左侧栏,推荐PNG或SVG格式,尺寸32x32像素" + +#: frontend/src/components/Settings/BrandSettings.vue:90 +msgid "Appears next to the title in your browser tab. Recommended size is 32x32 px in PNG or ICO" +msgstr "显示于浏览器标签页标题旁,推荐PNG或ICO格式,尺寸32x32像素" + +#: frontend/src/components/Kanban/KanbanSettings.vue:101 +#: frontend/src/components/Kanban/KanbanView.vue:46 +msgid "Apply" +msgstr "应用" + +#. Label of the apply_on (Link) field in PageType 'CRM Service Level Agreement' +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +msgid "Apply On" +msgstr "应用于" + +#. Label of the view (Select) field in PageType 'CRM Form Script' +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.json +msgid "Apply To" +msgstr "应用至" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:125 +msgid "Apply on" +msgstr "" + +#: frontend/src/components/Apps.vue:19 +msgid "Apps" +msgstr "应用" + +#: frontend/src/components/Activities/AttachmentArea.vue:128 +msgid "Are you sure you want to delete this attachment?" +msgstr "确认删除此附件?" + +#: frontend/src/pages/MobileContact.vue:260 +msgid "Are you sure you want to delete this contact?" +msgstr "确认删除此联系人?" + +#: frontend/src/components/Modals/EventModal.vue:408 +#: frontend/src/pages/Calendar.vue:300 +msgid "Are you sure you want to delete this event?" +msgstr "" + +#: frontend/src/pages/MobileOrganization.vue:261 +msgid "Are you sure you want to delete this organization?" +msgstr "确认删除此组织?" + +#: frontend/src/components/Activities/TaskArea.vue:60 +msgid "Are you sure you want to delete this task?" +msgstr "确认删除此任务?" + +#: frontend/src/components/DeleteLinkedDocModal.vue:231 +msgid "Are you sure you want to delete {0} linked item(s)?" +msgstr "" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:615 +msgid "Are you sure you want to discard unsaved changes to this event?" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:576 +msgid "Are you sure you want to go back? Unsaved changes will be lost." +msgstr "" + +#: frontend/src/composables/jingrowcloud.js:24 +msgid "Are you sure you want to login to your Jingrow Cloud dashboard?" +msgstr "确定登录Jingrow云控制面板?" + +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.js:9 +msgid "Are you sure you want to reset 'Create Quotation from CRM Deal' Form Script?" +msgstr "确认重置'从CRM商机生成报价单'表单脚本?" + +#: frontend/src/components/Settings/CurrencySettings.vue:165 +msgid "Are you sure you want to set the currency as {0}? This cannot be changed later." +msgstr "" + +#: frontend/src/components/DeleteLinkedDocModal.vue:244 +msgid "Are you sure you want to unlink {0} linked item(s)?" +msgstr "" + +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.py:193 +msgid "Ask your manager to set up the Exchange Rate Provider, as default provider does not support currency conversion for {0} to {1}." +msgstr "" + +#: frontend/src/components/ListBulkActions.vue:186 +#: frontend/src/components/Modals/AssignmentModal.vue:4 +msgid "Assign To" +msgstr "分配给" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:435 +msgid "Assign condition is required" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:438 +msgid "Assign conditions are invalid" +msgstr "" + +#: frontend/src/components/AssignTo.vue:11 +#: frontend/src/components/AssignToBody.vue:5 +msgid "Assign to" +msgstr "分配至" + +#: frontend/src/components/AssignToBody.vue:63 +msgid "Assign to me" +msgstr "自己认领" + +#. Label of the assigned_to (Link) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_task/crm_task.json +msgid "Assigned To" +msgstr "负责人" + +#: frontend/src/components/Settings/AssignmentRules/AssigneeRules.vue:5 +msgid "Assignee Rules" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssigneeRules.vue:81 +msgid "Assignees" +msgstr "" + +#. Option for the 'Type' (Select) field in PageType 'CRM Notification' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +msgid "Assignment" +msgstr "分配" + +#. Label of a shortcut in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +msgid "Assignment Rule" +msgstr "分配规则" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:302 +msgid "Assignment Schedule" +msgstr "" + +#: frontend/src/components/ListBulkActions.vue:154 +msgid "Assignment cleared successfully" +msgstr "分配已成功清除" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:145 +msgid "Assignment condition" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:471 +msgid "Assignment days are required" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:582 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRulesList.vue:19 +msgid "Assignment rule" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:667 +msgid "Assignment rule created" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleListItem.vue:111 +msgid "Assignment rule deleted" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleListItem.vue:156 +msgid "Assignment rule duplicated" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:749 +msgid "Assignment rule updated" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleListItem.vue:188 +msgid "Assignment rule {0} updated" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRules.vue:7 +#: frontend/src/components/Settings/Settings.vue:163 +msgid "Assignment rules" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRules.vue:11 +msgid "Assignment rules automatically assign lead/deal to the right sales user based on predefined conditions" +msgstr "" + +#: frontend/src/components/Controls/GridFieldsEditorModal.vue:173 +msgid "At least one field is required" +msgstr "至少需填写一个字段" + +#: frontend/src/components/FilesUploader/FilesUploader.vue:5 +#: frontend/src/components/FilesUploader/FilesUploader.vue:73 +msgid "Attach" +msgstr "附加" + +#: frontend/src/components/CommentBox.vue:65 +#: frontend/src/components/EmailEditor.vue:146 frontend/src/pages/Deal.vue:105 +#: frontend/src/pages/Lead.vue:151 +msgid "Attach a file" +msgstr "附加文件" + +#: frontend/src/pages/Deal.vue:567 frontend/src/pages/Lead.vue:424 +#: frontend/src/pages/MobileDeal.vue:466 frontend/src/pages/MobileLead.vue:373 +msgid "Attachments" +msgstr "附件" + +#: frontend/src/components/Modals/EventModal.vue:120 +msgid "Attendees" +msgstr "参会人员" + +#. Label of the auth_token (Password) field in PageType 'CRM Twilio Settings' +#: crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.json +msgid "Auth Token" +msgstr "认证令牌" + +#. Label of the auto_update_expected_deal_value (Check) field in PageType 'FCRM +#. Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "Auto Update Expected Deal Value" +msgstr "" + +#: frontend/src/components/Settings/ForecastingSettings.vue:42 +msgid "Auto update expected deal value" +msgstr "" + +#: frontend/src/components/Settings/ForecastingSettings.vue:88 +msgid "Auto update of expected deal value disabled" +msgstr "" + +#: frontend/src/components/Settings/ForecastingSettings.vue:87 +msgid "Auto update of expected deal value enabled" +msgstr "" + +#. Description of the 'Auto Update Expected Deal Value' (Check) field in +#. PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +#: frontend/src/components/Settings/ForecastingSettings.vue:46 +msgid "Automatically update \"Expected Deal Value\" based on the total value of associated products in a deal" +msgstr "" + +#: frontend/src/components/Settings/Settings.vue:160 +msgid "Automation & Rules" +msgstr "" + +#: crm/api/dashboard.py:238 +msgid "Average deal value of non won/lost deals" +msgstr "" + +#: crm/api/dashboard.py:411 +msgid "Average deal value of ongoing & won deals" +msgstr "" + +#: crm/api/dashboard.py:354 +msgid "Average deal value of won deals" +msgstr "" + +#: crm/api/dashboard.py:518 +msgid "Average time taken from deal creation to deal closure" +msgstr "" + +#: crm/api/dashboard.py:464 +msgid "Average time taken from lead creation to deal closure" +msgstr "" + +#: frontend/src/components/Dashboard/AddChartModal.vue:81 +msgid "Avg deal value" +msgstr "" + +#: frontend/src/components/Dashboard/AddChartModal.vue:78 +msgid "Avg ongoing deal value" +msgstr "" + +#: frontend/src/components/Dashboard/AddChartModal.vue:87 +msgid "Avg time to close a deal" +msgstr "" + +#: frontend/src/components/Dashboard/AddChartModal.vue:83 +msgid "Avg time to close a lead" +msgstr "" + +#: frontend/src/components/Dashboard/AddChartModal.vue:80 +msgid "Avg won deal value" +msgstr "" + +#: crm/api/dashboard.py:410 +msgid "Avg. deal value" +msgstr "" + +#: crm/api/dashboard.py:237 +msgid "Avg. ongoing deal value" +msgstr "" + +#: crm/api/dashboard.py:517 +msgid "Avg. time to close a deal" +msgstr "" + +#: crm/api/dashboard.py:463 +msgid "Avg. time to close a lead" +msgstr "" + +#: crm/api/dashboard.py:353 +msgid "Avg. won deal value" +msgstr "" + +#: frontend/src/components/Dashboard/AddChartModal.vue:26 +#: frontend/src/components/Dashboard/AddChartModal.vue:70 +msgid "Axis chart" +msgstr "" + +#: frontend/src/components/Activities/EmailArea.vue:62 +#: frontend/src/components/EmailEditor.vue:45 +#: frontend/src/components/EmailEditor.vue:71 +msgid "BCC" +msgstr "密送" + +#: frontend/src/components/FilesUploader/FilesUploader.vue:31 +#: frontend/src/components/Settings/EmailAdd.vue:79 +#: frontend/src/components/Settings/EmailEdit.vue:67 +msgid "Back" +msgstr "返回" + +#: frontend/src/components/FilesUploader/FilesUploader.vue:31 +msgid "Back to file upload" +msgstr "返回文件上传" + +#. Option for the 'Status' (Select) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_task/crm_task.json +msgid "Backlog" +msgstr "待办事项" + +#: frontend/src/components/Filter.vue:350 +msgid "Between" +msgstr "介于" + +#: frontend/src/components/Settings/Settings.vue:118 +msgid "Brand Settings" +msgstr "" + +#: frontend/src/components/Settings/BrandSettings.vue:52 +msgid "Brand logo" +msgstr "" + +#: frontend/src/components/Settings/BrandSettings.vue:32 +msgid "Brand name" +msgstr "" + +#: frontend/src/components/Settings/BrandSettings.vue:7 +msgid "Brand settings" +msgstr "" + +#. Label of the branding_tab (Tab Break) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "Branding" +msgstr "品牌标识" + +#: frontend/src/components/Modals/EditValueModal.vue:2 +msgid "Bulk Edit" +msgstr "批量编辑" + +#. Option for the 'Status' (Select) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Busy" +msgstr "忙碌" + +#: frontend/src/components/Activities/EmailArea.vue:57 +#: frontend/src/components/EmailEditor.vue:35 +#: frontend/src/components/EmailEditor.vue:57 +msgid "CC" +msgstr "抄送" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "CRM Call Log" +msgstr "CRM通话记录" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_communication_status/crm_communication_status.json +msgid "CRM Communication Status" +msgstr "CRM沟通状态" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_contacts/crm_contacts.json +msgid "CRM Contacts" +msgstr "CRM联系人" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_dashboard/crm_dashboard.json +#: frontend/src/pages/Dashboard.vue:304 +msgid "CRM Dashboard" +msgstr "" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "CRM Deal" +msgstr "CRM商机" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +msgid "CRM Deal Status" +msgstr "CRM商机状态" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json +msgid "CRM Dropdown Item" +msgstr "CRM下拉项" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json +msgid "CRM Exotel Settings" +msgstr "CRM Exotel设置" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json +msgid "CRM Fields Layout" +msgstr "CRM字段布局" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.json +msgid "CRM Form Script" +msgstr "CRM表单脚本" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_global_settings/crm_global_settings.json +msgid "CRM Global Settings" +msgstr "CRM全局设置" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_holiday/crm_holiday.json +msgid "CRM Holiday" +msgstr "CRM假期" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +msgid "CRM Holiday List" +msgstr "CRM假期列表" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_industry/crm_industry.json +msgid "CRM Industry" +msgstr "CRM行业" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +msgid "CRM Invitation" +msgstr "CRM邀请" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "CRM Lead" +msgstr "CRM线索" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_lead_source/crm_lead_source.json +msgid "CRM Lead Source" +msgstr "CRM线索来源" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "CRM Lead Status" +msgstr "CRM线索状态" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.json +msgid "CRM Lost Reason" +msgstr "" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +msgid "CRM Notification" +msgstr "CRM通知" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "CRM Organization" +msgstr "CRM组织" + +#. Label of a shortcut in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +msgid "CRM Portal Page" +msgstr "CRM门户页面" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_product/crm_product.json +msgid "CRM Product" +msgstr "" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_products/crm_products.json +msgid "CRM Products" +msgstr "" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_service_day/crm_service_day.json +msgid "CRM Service Day" +msgstr "CRM服务日" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +msgid "CRM Service Level Agreement" +msgstr "CRM服务级别协议" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_service_level_priority/crm_service_level_priority.json +msgid "CRM Service Level Priority" +msgstr "CRM服务级别优先级" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.json +msgid "CRM Status Change Log" +msgstr "CRM状态变更日志" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_task/crm_task.json +msgid "CRM Task" +msgstr "CRM任务" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +msgid "CRM Telephony Agent" +msgstr "CRM电话客服" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_telephony_phone/crm_telephony_phone.json +msgid "CRM Telephony Phone" +msgstr "CRM电话设备" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_territory/crm_territory.json +msgid "CRM Territory" +msgstr "CRM区域" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.json +msgid "CRM Twilio Settings" +msgstr "CRM Twilio设置" + +#. Name of a PageType +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "CRM View Settings" +msgstr "CRM视图设置" + +#: frontend/src/components/Settings/CurrencySettings.vue:35 +msgid "CRM currency for all monetary values. Once set, cannot be edited." +msgstr "" + +#: frontend/src/components/ViewControls.vue:272 +msgid "CSV" +msgstr "CSV" + +#: frontend/src/components/Modals/CallLogDetailModal.vue:8 +msgid "Call Details" +msgstr "通话详情" + +#. Label of the receiver (Link) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Call Received By" +msgstr "接听人" + +#. Description of the 'Duration' (Duration) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Call duration in seconds" +msgstr "通话时长(秒)" + +#: frontend/src/components/Layouts/AppSidebar.vue:556 +msgid "Call log" +msgstr "" + +#: frontend/src/components/Telephony/CallUI.vue:10 +msgid "Call using {0}" +msgstr "使用{0}呼叫" + +#: frontend/src/components/Modals/EventModal.vue:63 +#: frontend/src/components/Modals/NoteModal.vue:28 +#: frontend/src/components/Modals/TaskModal.vue:30 +msgid "Call with John Doe" +msgstr "与John Doe通话" + +#. Label of the caller (Link) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Caller" +msgstr "主叫方" + +#: frontend/src/components/Telephony/CallUI.vue:27 +msgid "Calling Medium" +msgstr "呼叫媒介" + +#: frontend/src/components/Telephony/TwilioCallUI.vue:40 +#: frontend/src/components/Telephony/TwilioCallUI.vue:140 +msgid "Calling..." +msgstr "呼叫中..." + +#: frontend/src/pages/Deal.vue:552 frontend/src/pages/Lead.vue:409 +#: frontend/src/pages/MobileDeal.vue:450 frontend/src/pages/MobileLead.vue:357 +msgid "Calls" +msgstr "通话记录" + +#: frontend/src/components/FilesUploader/FilesUploaderArea.vue:51 +msgid "Camera" +msgstr "摄像头" + +#: frontend/src/components/BulkDeleteLinkedDocModal.vue:81 +#: frontend/src/components/Calendar/CalendarEventPanel.vue:620 +#: frontend/src/components/ColumnSettings.vue:123 +#: frontend/src/components/Dashboard/AddChartModal.vue:40 +#: frontend/src/components/DeleteLinkedDocModal.vue:115 +#: frontend/src/components/Modals/AssignmentModal.vue:69 +#: frontend/src/components/Modals/EventModal.vue:151 +#: frontend/src/components/Modals/LostReasonModal.vue:43 +#: frontend/src/components/Telephony/TwilioCallUI.vue:73 +#: frontend/src/components/ViewControls.vue:57 +#: frontend/src/components/ViewControls.vue:154 +#: frontend/src/pages/Dashboard.vue:32 +msgid "Cancel" +msgstr "取消" + +#. Option for the 'Status' (Select) field in PageType 'CRM Call Log' +#. Option for the 'Status' (Select) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_task/crm_task.json +msgid "Canceled" +msgstr "已取消" + +#: frontend/src/components/Settings/Users.vue:124 +msgid "Cannot change role of user with Admin access" +msgstr "" + +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.py:34 +msgid "Cannot delete standard items {0}" +msgstr "无法删除标准项{0}" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleListItem.vue:171 +msgid "Cannot enable rule without adding users in it" +msgstr "" + +#: frontend/src/components/FilesUploader/FilesUploader.vue:91 +msgid "Capture" +msgstr "捕获" + +#: frontend/src/components/Layouts/AppSidebar.vue:561 +msgid "Capturing leads" +msgstr "" + +#: frontend/src/components/Controls/ImageUploader.vue:19 +#: frontend/src/components/Layouts/AppSidebar.vue:490 +msgid "Change" +msgstr "更改" + +#: frontend/src/components/Modals/ChangePasswordModal.vue:2 +#: frontend/src/components/Settings/ProfileSettings.vue:65 +msgid "Change Password" +msgstr "修改密码" + +#: frontend/src/components/Layouts/AppSidebar.vue:481 +#: frontend/src/components/Layouts/AppSidebar.vue:489 +msgid "Change deal status" +msgstr "" + +#: frontend/src/components/Settings/ProfileSettings.vue:26 +#: frontend/src/pages/Contact.vue:41 frontend/src/pages/Lead.vue:88 +#: frontend/src/pages/MobileContact.vue:37 +#: frontend/src/pages/MobileOrganization.vue:37 +#: frontend/src/pages/Organization.vue:41 +msgid "Change image" +msgstr "更换图片" + +#: frontend/src/components/Activities/TaskArea.vue:45 +msgid "Change status" +msgstr "" + +#: frontend/src/pages/Dashboard.vue:22 +msgid "Chart" +msgstr "图表" + +#: frontend/src/components/Dashboard/AddChartModal.vue:12 +msgid "Chart Type" +msgstr "图表类型" + +#: frontend/src/components/Modals/ConvertToDealModal.vue:29 +#: frontend/src/components/Modals/ConvertToDealModal.vue:55 +#: frontend/src/pages/MobileLead.vue:122 frontend/src/pages/MobileLead.vue:149 +msgid "Choose Existing" +msgstr "选择现有项" + +#: frontend/src/components/Modals/DealModal.vue:44 +msgid "Choose Existing Contact" +msgstr "选择现有联系人" + +#: frontend/src/components/Modals/DealModal.vue:37 +msgid "Choose Existing Organization" +msgstr "选择现有组织" + +#: frontend/src/components/Settings/AssignmentRules/AssigneeRules.vue:9 +msgid "Choose how {0} are assigned among salespeople." +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:306 +msgid "Choose the days of the week when this rule should be active." +msgstr "" + +#: frontend/src/components/Settings/EmailAdd.vue:9 +msgid "Choose the email service provider you want to configure." +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:229 +msgid "Choose which {0} are affected by this un-assignment rule." +msgstr "" + +#: frontend/src/components/Controls/Link.vue:59 +msgid "Clear" +msgstr "清除" + +#: frontend/src/components/ListBulkActions.vue:136 +#: frontend/src/components/ListBulkActions.vue:144 +#: frontend/src/components/ListBulkActions.vue:190 +msgid "Clear Assignment" +msgstr "清除分配" + +#: frontend/src/components/SortBy.vue:153 +msgid "Clear Sort" +msgstr "清除排序" + +#. Label of the clear_table (Button) field in PageType 'CRM Holiday List' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +msgid "Clear Table" +msgstr "清空表格" + +#: frontend/src/components/Filter.vue:21 frontend/src/components/Filter.vue:146 +msgid "Clear all Filter" +msgstr "清除所有筛选" + +#: crm/templates/emails/helpdesk_invitation.html:7 +msgid "Click on the link below to complete your registration and set a new password" +msgstr "点击下面的链接完成注册,并设置新密码" + +#: frontend/src/components/Notifications.vue:26 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleListItem.vue:54 +msgid "Close" +msgstr "关闭" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:38 +msgid "Close panel" +msgstr "" + +#. Label of the closed_date (Date) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "Closed Date" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:107 +msgid "Collapse" +msgstr "折叠" + +#: frontend/src/components/FieldLayoutEditor.vue:344 +msgid "Collapsible" +msgstr "可折叠" + +#. Label of the color (Select) field in PageType 'CRM Deal Status' +#. Label of the color (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "Color" +msgstr "颜色" + +#: frontend/src/components/FieldLayoutEditor.vue:417 +msgid "Column" +msgstr "列" + +#. Label of the column_field (Data) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +#: frontend/src/components/Kanban/KanbanSettings.vue:12 +msgid "Column Field" +msgstr "列字段" + +#. Label of the columns (Code) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +#: frontend/src/components/ColumnSettings.vue:4 +msgid "Columns" +msgstr "列" + +#. Label of the comment (Link) field in PageType 'CRM Notification' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +#: frontend/src/components/CommentBox.vue:78 +#: frontend/src/components/CommunicationArea.vue:16 +#: frontend/src/components/Layouts/AppSidebar.vue:579 +msgid "Comment" +msgstr "评论" + +#: frontend/src/pages/Deal.vue:537 frontend/src/pages/Lead.vue:394 +#: frontend/src/pages/MobileDeal.vue:440 frontend/src/pages/MobileLead.vue:347 +msgid "Comments" +msgstr "评论" + +#: crm/api/dashboard.py:884 +msgid "Common reasons for losing deals" +msgstr "" + +#. Label of the communication_status (Link) field in PageType 'CRM Deal' +#. Label of the communication_status (Link) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Communication Status" +msgstr "沟通状态" + +#. Label of a shortcut in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +msgid "Communication Statuses" +msgstr "沟通状态列表" + +#. Label of the erpnext_company (Data) field in PageType 'ERPNext CRM Settings' +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json +msgid "Company in ERPNext Site" +msgstr "ERPNext站点中的公司" + +#: crm/templates/emails/helpdesk_invitation.html:10 +msgid "Complete Registration" +msgstr "完成注册" + +#. Option for the 'Status' (Select) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Completed" +msgstr "已完成" + +#. Option for the 'Device' (Select) field in PageType 'CRM Telephony Agent' +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +msgid "Computer" +msgstr "计算机" + +#. Label of the condition (Code) field in PageType 'CRM Service Level Agreement' +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +msgid "Condition" +msgstr "条件" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:188 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:272 +msgid "Conditions for this rule were created from" +msgstr "" + +#: frontend/src/components/Settings/HomeActions.vue:10 +msgid "Configure actions that appear on the home dropdown" +msgstr "" + +#: frontend/src/components/Settings/ForecastingSettings.vue:9 +msgid "Configure forecasting feature to help predict sales performance and growth" +msgstr "" + +#: frontend/src/components/Settings/TelephonySettings.vue:17 +msgid "Configure telephony settings for your CRM" +msgstr "" + +#: frontend/src/components/Settings/CurrencySettings.vue:11 +msgid "Configure the currency and exchange rate provider for your CRM" +msgstr "" + +#: frontend/src/components/Settings/CurrencySettings.vue:63 +msgid "Configure the exchange rate provider for your CRM" +msgstr "" + +#: frontend/src/components/Settings/BrandSettings.vue:10 +msgid "Configure your brand name, logo, and favicon" +msgstr "" + +#: frontend/src/composables/jingrowcloud.js:29 +msgid "Confirm" +msgstr "确认" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleListItem.vue:139 +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:239 +msgid "Confirm Delete" +msgstr "" + +#: frontend/src/components/Modals/ChangePasswordModal.vue:18 +msgid "Confirm Password" +msgstr "确认密码" + +#: frontend/src/components/Settings/Users.vue:228 +msgid "Confirm Remove" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:609 +msgid "Confirm overwrite" +msgstr "" + +#: frontend/src/pages/Welcome.vue:35 +msgid "Connect your email" +msgstr "" + +#. Label of the contact (Link) field in PageType 'CRM Contacts' +#. Label of the contact (Link) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_contacts/crm_contacts.json +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: frontend/src/components/Layouts/AppSidebar.vue:552 +#: frontend/src/components/Modals/ConvertToDealModal.vue:51 +#: frontend/src/pages/MobileLead.vue:145 +msgid "Contact" +msgstr "联系人" + +#: crm/fcrm/pagetype/crm_lead/crm_lead.py:212 +msgid "Contact Already Exists" +msgstr "联系人已存在" + +#: frontend/src/components/Modals/AboutModal.vue:77 +msgid "Contact Support" +msgstr "" + +#: frontend/src/components/Modals/EditValueModal.vue:20 +msgid "Contact Us" +msgstr "联系我们" + +#: frontend/src/pages/Deal.vue:647 frontend/src/pages/MobileDeal.vue:544 +msgid "Contact added" +msgstr "联系人已添加" + +#: frontend/src/pages/Deal.vue:637 frontend/src/pages/MobileDeal.vue:534 +msgid "Contact already added" +msgstr "联系人已存在" + +#: crm/fcrm/pagetype/crm_lead/crm_lead.py:211 +msgid "Contact already exists with {0}" +msgstr "联系人{0}已存在" + +#: frontend/src/pages/Contact.vue:279 frontend/src/pages/MobileContact.vue:252 +msgid "Contact image updated" +msgstr "" + +#: frontend/src/pages/Deal.vue:658 frontend/src/pages/MobileDeal.vue:555 +msgid "Contact removed" +msgstr "联系人已移除" + +#: frontend/src/pages/Contact.vue:424 frontend/src/pages/Contact.vue:437 +#: frontend/src/pages/Contact.vue:450 frontend/src/pages/Contact.vue:460 +#: frontend/src/pages/MobileContact.vue:432 +#: frontend/src/pages/MobileContact.vue:445 +#: frontend/src/pages/MobileContact.vue:458 +#: frontend/src/pages/MobileContact.vue:468 +msgid "Contact updated" +msgstr "" + +#. Label of the contacts_tab (Tab Break) field in PageType 'CRM Deal' +#. Label of the contacts (Table) field in PageType 'CRM Deal' +#. Label of a shortcut in the Jingrow CRM Workspace +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +#: frontend/src/pages/Contact.vue:234 frontend/src/pages/MobileContact.vue:212 +#: frontend/src/pages/MobileOrganization.vue:331 +msgid "Contacts" +msgstr "联系人" + +#. Label of the content (Text Editor) field in PageType 'FCRM Note' +#: crm/fcrm/pagetype/fcrm_note/fcrm_note.json +#: frontend/src/components/Modals/NoteModal.vue:33 +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:89 +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:102 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:89 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:102 +msgid "Content" +msgstr "内容" + +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:78 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:78 +msgid "Content Type" +msgstr "内容类型" + +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:160 +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:164 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:162 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:166 +msgid "Content is required" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:380 +#: frontend/src/components/ListBulkActions.vue:88 +#: frontend/src/components/Modals/ConvertToDealModal.vue:83 +#: frontend/src/pages/MobileLead.vue:54 frontend/src/pages/MobileLead.vue:108 +msgid "Convert" +msgstr "转换" + +#: frontend/src/components/Layouts/AppSidebar.vue:371 +#: frontend/src/components/Layouts/AppSidebar.vue:379 +msgid "Convert lead to deal" +msgstr "" + +#: frontend/src/components/ListBulkActions.vue:80 +#: frontend/src/components/ListBulkActions.vue:197 +#: frontend/src/components/Modals/ConvertToDealModal.vue:7 +#: frontend/src/pages/Lead.vue:38 frontend/src/pages/MobileLead.vue:104 +msgid "Convert to Deal" +msgstr "转换为商机" + +#. Label of the converted (Check) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Converted" +msgstr "已转换" + +#: frontend/src/components/ListBulkActions.vue:96 +msgid "Converted successfully" +msgstr "转换成功" + +#: frontend/src/utils/index.js:338 +msgid "Copied to clipboard" +msgstr "" + +#: crm/api/dashboard.py:607 crm/api/dashboard.py:736 crm/api/dashboard.py:794 +#: crm/api/dashboard.py:891 +msgid "Count" +msgstr "计数" + +#: frontend/src/components/Modals/AddressModal.vue:98 +#: frontend/src/components/Modals/CallLogModal.vue:101 +#: frontend/src/components/Modals/ContactModal.vue:40 +#: frontend/src/components/Modals/CreateDocumentModal.vue:92 +#: frontend/src/components/Modals/DealModal.vue:66 +#: frontend/src/components/Modals/EmailTemplateSelectorModal.vue:20 +#: frontend/src/components/Modals/EventModal.vue:159 +#: frontend/src/components/Modals/LeadModal.vue:37 +#: frontend/src/components/Modals/NoteModal.vue:52 +#: frontend/src/components/Modals/OrganizationModal.vue:41 +#: frontend/src/components/Modals/TaskModal.vue:106 +#: frontend/src/components/Modals/ViewModal.vue:43 +#: frontend/src/components/Settings/EmailAdd.vue:85 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:23 +#: frontend/src/pages/Calendar.vue:10 frontend/src/pages/CallLogs.vue:13 +#: frontend/src/pages/Contacts.vue:13 frontend/src/pages/Contacts.vue:60 +#: frontend/src/pages/Deals.vue:13 frontend/src/pages/Deals.vue:236 +#: frontend/src/pages/Leads.vue:13 frontend/src/pages/Leads.vue:262 +#: frontend/src/pages/Notes.vue:9 frontend/src/pages/Notes.vue:96 +#: frontend/src/pages/Organizations.vue:13 +#: frontend/src/pages/Organizations.vue:60 frontend/src/pages/Tasks.vue:13 +#: frontend/src/pages/Tasks.vue:186 +msgid "Create" +msgstr "创建" + +#: frontend/src/components/Modals/DealModal.vue:8 +msgid "Create Deal" +msgstr "创建商机" + +#: frontend/src/components/Modals/LeadModal.vue:8 +msgid "Create Lead" +msgstr "创建线索" + +#: frontend/src/components/Controls/Link.vue:50 +#: frontend/src/components/Modals/EmailTemplateSelectorModal.vue:69 +#: frontend/src/components/Modals/WhatsappTemplateSelectorModal.vue:45 +#: frontend/src/components/PrimaryDropdown.vue:41 +msgid "Create New" +msgstr "新建" + +#: frontend/src/components/Activities/Activities.vue:388 +#: frontend/src/components/Modals/NoteModal.vue:6 +msgid "Create Note" +msgstr "创建备注" + +#: frontend/src/components/Activities/Activities.vue:403 +#: frontend/src/components/Modals/TaskModal.vue:6 +msgid "Create Task" +msgstr "创建任务" + +#: frontend/src/components/Modals/ViewModal.vue:9 +#: frontend/src/components/ViewControls.vue:687 +msgid "Create View" +msgstr "创建视图" + +#: frontend/src/components/Modals/EventModal.vue:12 +msgid "Create an event" +msgstr "" + +#. Label of the create_customer_on_status_change (Check) field in PageType +#. 'ERPNext CRM Settings' +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json +msgid "Create customer on status change" +msgstr "状态变更时创建客户" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:348 +#: frontend/src/pages/Calendar.vue:7 +msgid "Create event" +msgstr "" + +#: frontend/src/components/Modals/CallLogDetailModal.vue:151 +msgid "Create lead" +msgstr "创建线索" + +#: frontend/src/components/Layouts/AppSidebar.vue:349 +msgid "Create your first lead" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:419 +msgid "Create your first note" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:399 +msgid "Create your first task" +msgstr "" + +#. Label of the currency (Link) field in PageType 'CRM Deal' +#. Label of the currency (Link) field in PageType 'CRM Organization' +#. Label of the currency (Link) field in PageType 'FCRM Settings' +#. Label of the currency_tab (Tab Break) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +#: frontend/src/components/Settings/CurrencySettings.vue:31 +msgid "Currency" +msgstr "货币" + +#: frontend/src/components/Settings/Settings.vue:113 +msgid "Currency & Exchange Rate" +msgstr "" + +#: frontend/src/components/Settings/CurrencySettings.vue:7 +msgid "Currency & Exchange rate provider" +msgstr "" + +#: frontend/src/components/Settings/CurrencySettings.vue:179 +msgid "Currency set as {0} successfully" +msgstr "" + +#: crm/api/dashboard.py:839 +msgid "Current pipeline distribution" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:591 +msgid "Custom actions" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:541 +msgid "Custom branding" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:590 +msgid "Custom fields" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:593 +msgid "Custom list actions" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:592 +msgid "Custom statuses" +msgstr "" + +#: frontend/src/pages/Deal.vue:466 +msgid "Customer created successfully" +msgstr "客户创建成功" + +#: frontend/src/components/Layouts/AppSidebar.vue:587 +#: frontend/src/components/Settings/Settings.vue:170 +msgid "Customization" +msgstr "定制" + +#: frontend/src/components/ViewControls.vue:211 +msgid "Customize quick filters" +msgstr "自定义快速筛选" + +#: crm/api/dashboard.py:599 +msgid "Daily performance of leads, deals, and wins" +msgstr "" + +#: frontend/src/components/Activities/DataFields.vue:6 +#: frontend/src/components/Layouts/AppSidebar.vue:580 +#: frontend/src/pages/Deal.vue:542 frontend/src/pages/Lead.vue:399 +#: frontend/src/pages/MobileDeal.vue:445 frontend/src/pages/MobileLead.vue:352 +msgid "Data" +msgstr "数据" + +#. Option for the 'Type' (Select) field in PageType 'CRM Fields Layout' +#: crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json +msgid "Data Fields" +msgstr "数据字段" + +#. Label of the date (Date) field in PageType 'CRM Holiday' +#: crm/api/dashboard.py:601 crm/fcrm/pagetype/crm_holiday/crm_holiday.json +#: frontend/src/components/Calendar/CalendarEventPanel.vue:202 +msgid "Date" +msgstr "日期" + +#: frontend/src/components/Modals/EventModal.vue:78 +msgid "Date & Time" +msgstr "" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:267 +#: frontend/src/components/Calendar/CalendarEventPanel.vue:288 +#: frontend/src/components/Layouts/AppSidebar.vue:551 +#: frontend/src/components/Settings/AssignmentRules/AssigneeRules.vue:20 +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:51 +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:59 +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:78 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:51 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:59 +#: frontend/src/components/Telephony/ExotelCallUI.vue:200 +#: frontend/src/pages/Tasks.vue:132 +msgid "Deal" +msgstr "商机" + +#. Label of the deal_owner (Link) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "Deal Owner" +msgstr "商机负责人" + +#. Label of the deal_status (Link) field in PageType 'ERPNext CRM Settings' +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json +msgid "Deal Status" +msgstr "商机状态" + +#. Label of a shortcut in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +msgid "Deal Statuses" +msgstr "商机状态列表" + +#. Label of the deal_value (Currency) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "Deal Value" +msgstr "" + +#: crm/api/dashboard.py:977 +msgid "Deal generation channel analysis" +msgstr "" + +#: frontend/src/pages/Contact.vue:520 frontend/src/pages/MobileContact.vue:528 +#: frontend/src/pages/MobileOrganization.vue:472 +#: frontend/src/pages/Organization.vue:493 +msgid "Deal owner" +msgstr "商机负责人" + +#: crm/api/dashboard.py:1030 crm/api/dashboard.py:1087 +msgid "Deal value" +msgstr "" + +#. Label of a shortcut in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +#: frontend/src/pages/Deal.vue:480 frontend/src/pages/MobileContact.vue:288 +#: frontend/src/pages/MobileDeal.vue:384 +#: frontend/src/pages/MobileOrganization.vue:325 +msgid "Deals" +msgstr "商机" + +#: crm/api/dashboard.py:788 +#: frontend/src/components/Dashboard/AddChartModal.vue:97 +msgid "Deals by ongoing & won stage" +msgstr "" + +#: crm/api/dashboard.py:1076 +#: frontend/src/components/Dashboard/AddChartModal.vue:100 +msgid "Deals by salesperson" +msgstr "" + +#: crm/api/dashboard.py:976 +#: frontend/src/components/Dashboard/AddChartModal.vue:107 +msgid "Deals by source" +msgstr "" + +#: crm/api/dashboard.py:838 +#: frontend/src/components/Dashboard/AddChartModal.vue:105 +msgid "Deals by stage" +msgstr "" + +#: crm/api/dashboard.py:1019 +#: frontend/src/components/Dashboard/AddChartModal.vue:99 +msgid "Deals by territory" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:112 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:112 +msgid "Dear {{ lead_name }}, \\n\\nThis is a reminder for the payment of {{ grand_total }}. \\n\\nThanks, \\nFrappé" +msgstr "尊敬的{{ lead_name }}:\\n\\n特此提醒您尚有{{ grand_total }}款项待支付。\\n\\n此致\\nFrappé团队" + +#. Label of the default (Check) field in PageType 'CRM Service Level Agreement' +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +msgid "Default" +msgstr "默认" + +#: frontend/src/components/Settings/EmailAccountCard.vue:41 +msgid "Default Inbox" +msgstr "默认收件箱" + +#: frontend/src/components/Settings/emailConfig.js:44 +msgid "Default Incoming" +msgstr "默认收件箱" + +#. Label of the default_medium (Select) field in PageType 'CRM Telephony Agent' +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +msgid "Default Medium" +msgstr "默认媒介" + +#: frontend/src/components/Settings/emailConfig.js:52 +msgid "Default Outgoing" +msgstr "默认外发" + +#. Label of the default_priority (Check) field in PageType 'CRM Service Level +#. Priority' +#: crm/fcrm/pagetype/crm_service_level_priority/crm_service_level_priority.json +msgid "Default Priority" +msgstr "默认优先级" + +#: frontend/src/components/Settings/EmailAccountCard.vue:43 +msgid "Default Sending" +msgstr "默认发送账号" + +#: frontend/src/components/Settings/EmailAccountCard.vue:39 +msgid "Default Sending and Inbox" +msgstr "默认发送和收件账号" + +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.py:33 +msgid "Default Service Level Agreement already exists for {0}" +msgstr "{0}的默认服务级别协议已存在" + +#: frontend/src/components/Settings/TelephonySettings.vue:44 +msgid "Default calling medium for logged in user" +msgstr "当前用户的默认呼叫媒介" + +#: frontend/src/components/Telephony/CallUI.vue:112 +msgid "Default calling medium set successfully to {0}" +msgstr "" + +#: frontend/src/components/Settings/TelephonySettings.vue:280 +msgid "Default calling medium updated successfully" +msgstr "默认呼叫媒介更新成功" + +#: frontend/src/components/Settings/TelephonySettings.vue:37 +msgid "Default medium" +msgstr "默认媒介" + +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.js:18 +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.js:30 +msgid "Default statuses, custom fields and layouts restored successfully." +msgstr "默认状态、自定义字段及布局已成功恢复。" + +#: frontend/src/components/Activities/AttachmentArea.vue:131 +#: frontend/src/components/Activities/NoteArea.vue:12 +#: frontend/src/components/Activities/TaskArea.vue:55 +#: frontend/src/components/Activities/TaskArea.vue:63 +#: frontend/src/components/BulkDeleteLinkedDocModal.vue:8 +#: frontend/src/components/BulkDeleteLinkedDocModal.vue:48 +#: frontend/src/components/BulkDeleteLinkedDocModal.vue:73 +#: frontend/src/components/BulkDeleteLinkedDocModal.vue:121 +#: frontend/src/components/Controls/Grid.vue:319 +#: frontend/src/components/DeleteLinkedDocModal.vue:10 +#: frontend/src/components/DeleteLinkedDocModal.vue:90 +#: frontend/src/components/Kanban/KanbanView.vue:222 +#: frontend/src/components/ListBulkActions.vue:179 +#: frontend/src/components/Modals/EventModal.vue:407 +#: frontend/src/components/Modals/EventModal.vue:411 +#: frontend/src/components/PrimaryDropdownItem.vue:42 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleListItem.vue:129 +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:229 +#: frontend/src/components/ViewControls.vue:1116 +#: frontend/src/components/ViewControls.vue:1127 +#: frontend/src/pages/Calendar.vue:299 frontend/src/pages/Calendar.vue:303 +#: frontend/src/pages/Contact.vue:100 frontend/src/pages/Deal.vue:111 +#: frontend/src/pages/Lead.vue:157 frontend/src/pages/MobileContact.vue:79 +#: frontend/src/pages/MobileContact.vue:263 +#: frontend/src/pages/MobileDeal.vue:515 +#: frontend/src/pages/MobileOrganization.vue:72 +#: frontend/src/pages/MobileOrganization.vue:264 +#: frontend/src/pages/Notes.vue:43 frontend/src/pages/Organization.vue:83 +#: frontend/src/pages/Tasks.vue:371 +msgid "Delete" +msgstr "删除" + +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.js:26 +msgid "Delete & Restore" +msgstr "删除并恢复" + +#: frontend/src/components/Activities/TaskArea.vue:59 +msgid "Delete Task" +msgstr "删除任务" + +#: frontend/src/components/ViewControls.vue:1112 +#: frontend/src/components/ViewControls.vue:1120 +msgid "Delete View" +msgstr "删除视图" + +#: frontend/src/components/DeleteLinkedDocModal.vue:66 +msgid "Delete all" +msgstr "" + +#: frontend/src/components/Activities/AttachmentArea.vue:58 +#: frontend/src/components/Activities/AttachmentArea.vue:127 +msgid "Delete attachment" +msgstr "删除附件" + +#: frontend/src/pages/MobileContact.vue:259 +msgid "Delete contact" +msgstr "删除联系人" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:25 +msgid "Delete event" +msgstr "" + +#: frontend/src/components/Settings/InviteUserPage.vue:79 +msgid "Delete invitation" +msgstr "" + +#: frontend/src/components/DeleteLinkedDocModal.vue:230 +msgid "Delete linked item" +msgstr "" + +#: frontend/src/components/DeleteLinkedDocModal.vue:11 +msgid "Delete or unlink linked documents" +msgstr "" + +#: frontend/src/components/DeleteLinkedDocModal.vue:23 +msgid "Delete or unlink these linked documents before deleting this document" +msgstr "" + +#: frontend/src/pages/MobileOrganization.vue:260 +msgid "Delete organization" +msgstr "删除组织" + +#: frontend/src/components/DeleteLinkedDocModal.vue:67 +msgid "Delete {0} item(s)" +msgstr "" + +#: frontend/src/components/BulkDeleteLinkedDocModal.vue:28 +msgid "Delete {0} items" +msgstr "" + +#. Label of the description (Text Editor) field in PageType 'CRM Holiday' +#. Label of the description (Text Editor) field in PageType 'CRM Lost Reason' +#. Label of the description (Text Editor) field in PageType 'CRM Product' +#. Label of the description (Text Editor) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_holiday/crm_holiday.json +#: crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.json +#: crm/fcrm/pagetype/crm_product/crm_product.json +#: crm/fcrm/pagetype/crm_task/crm_task.json +#: frontend/src/components/Calendar/CalendarEventPanel.vue:152 +#: frontend/src/components/Modals/EventModal.vue:134 +#: frontend/src/components/Modals/TaskModal.vue:36 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:112 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:113 +msgid "Description" +msgstr "描述" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:426 +msgid "Description is required" +msgstr "" + +#: frontend/src/components/Apps.vue:63 +msgid "Desk" +msgstr "工作台" + +#. Label of the details (Tab Break) field in PageType 'CRM Lead' +#. Label of the details (Text Editor) field in PageType 'CRM Lead Source' +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_lead_source/crm_lead_source.json +#: frontend/src/pages/MobileContact.vue:283 +#: frontend/src/pages/MobileDeal.vue:424 frontend/src/pages/MobileLead.vue:331 +#: frontend/src/pages/MobileOrganization.vue:320 +msgid "Details" +msgstr "详情" + +#. Label of the call_receiving_device (Select) field in PageType 'CRM Telephony +#. Agent' +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +#: frontend/src/components/FilesUploader/FilesUploaderArea.vue:39 +msgid "Device" +msgstr "设备" + +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.js:30 +msgid "Disable" +msgstr "禁用" + +#. Label of the disabled (Check) field in PageType 'CRM Product' +#: crm/fcrm/pagetype/crm_product/crm_product.json +msgid "Disabled" +msgstr "禁用" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:626 +#: frontend/src/components/CommentBox.vue:74 +#: frontend/src/components/EmailEditor.vue:161 +msgid "Discard" +msgstr "放弃" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:614 +msgid "Discard unsaved changes?" +msgstr "" + +#. Label of the discount_percentage (Percent) field in PageType 'CRM Products' +#: crm/fcrm/pagetype/crm_products/crm_products.json +msgid "Discount %" +msgstr "折扣 %" + +#. Label of the discount_amount (Currency) field in PageType 'CRM Products' +#: crm/fcrm/pagetype/crm_products/crm_products.json +msgid "Discount Amount" +msgstr "折扣金额" + +#. Label of the dt (Link) field in PageType 'CRM Form Script' +#. Label of the dt (Link) field in PageType 'CRM Global Settings' +#. Label of the dt (Link) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.json +#: crm/fcrm/pagetype/crm_global_settings/crm_global_settings.json +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "PageType" +msgstr "文档类型" + +#. Label of the dt (Link) field in PageType 'CRM Fields Layout' +#: crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json +msgid "Document Type" +msgstr "文档类型" + +#: frontend/src/data/document.js:28 +msgid "Document does not exist" +msgstr "" + +#: crm/api/activities.py:19 +msgid "Document not found" +msgstr "未找到文档" + +#: frontend/src/data/document.js:42 +msgid "Document updated successfully" +msgstr "" + +#: frontend/src/components/Modals/AboutModal.vue:62 +msgid "Documentation" +msgstr "用户操作手册" + +#. Option for the 'Status' (Select) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_task/crm_task.json +msgid "Done" +msgstr "完成" + +#: frontend/src/components/Dashboard/AddChartModal.vue:33 +#: frontend/src/components/Dashboard/AddChartModal.vue:71 +msgid "Donut chart" +msgstr "" + +#: frontend/src/components/Activities/AudioPlayer.vue:166 +#: frontend/src/components/ViewControls.vue:254 +msgid "Download" +msgstr "下载" + +#: frontend/src/components/FilesUploader/FilesUploaderArea.vue:24 +msgid "Drag and drop files here or upload from" +msgstr "拖放文件至此或从本地" + +#: frontend/src/components/FilesUploader/FilesUploaderArea.vue:56 +msgid "Drop files here" +msgstr "拖放文件至此" + +#. Label of the dropdown_items_tab (Tab Break) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "Dropdown Items" +msgstr "下拉选项" + +#. Label of the due_date (Datetime) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_task/crm_task.json +msgid "Due Date" +msgstr "截止日期" + +#: frontend/src/components/Modals/EventModal.vue:158 +#: frontend/src/components/Modals/ViewModal.vue:42 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleListItem.vue:57 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleListItem.vue:119 +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:224 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:23 +#: frontend/src/components/ViewControls.vue:1068 +msgid "Duplicate" +msgstr "复制" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleListItem.vue:38 +msgid "Duplicate Assignment Rule" +msgstr "" + +#: frontend/src/components/Modals/ViewModal.vue:8 +msgid "Duplicate View" +msgstr "复制视图" + +#: frontend/src/components/Modals/EventModal.vue:11 +msgid "Duplicate an event" +msgstr "" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:33 +#: frontend/src/components/Calendar/CalendarEventPanel.vue:347 +#: frontend/src/components/Calendar/CalendarEventPanel.vue:432 +msgid "Duplicate event" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:10 +msgid "Duplicate template" +msgstr "" + +#. Label of the duration (Duration) field in PageType 'CRM Call Log' +#. Label of the duration (Duration) field in PageType 'CRM Status Change Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.json +msgid "Duration" +msgstr "持续时间" + +#: frontend/src/components/Layouts/AppSidebar.vue:604 +#: frontend/src/components/Settings/Settings.vue:196 +msgid "ERPNext" +msgstr "ERPNext" + +#. Name of a PageType +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json +msgid "ERPNext CRM Settings" +msgstr "ERPNext CRM设置" + +#. Label of the section_break_oubd (Section Break) field in PageType 'ERPNext +#. CRM Settings' +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json +msgid "ERPNext Site API's" +msgstr "ERPNext站点API" + +#. Label of the erpnext_site_url (Data) field in PageType 'ERPNext CRM Settings' +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json +msgid "ERPNext Site URL" +msgstr "ERPNext站点URL" + +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.py:25 +msgid "ERPNext is not installed in the current site" +msgstr "当前站点未安装ERPNext" + +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.py:98 +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.py:124 +msgid "ERPNext is not integrated with the CRM" +msgstr "ERPNext未与CRM集成" + +#: frontend/src/components/Settings/ERPNextSettings.vue:4 +msgid "ERPNext settings" +msgstr "" + +#: frontend/src/components/Settings/ERPNextSettings.vue:5 +msgid "ERPNext settings updated" +msgstr "" + +#: frontend/src/components/FieldLayout/Field.vue:91 +#: frontend/src/components/FieldLayoutEditor.vue:313 +#: frontend/src/components/FieldLayoutEditor.vue:339 +#: frontend/src/components/ListBulkActions.vue:172 +#: frontend/src/components/PrimaryDropdownItem.vue:35 +#: frontend/src/components/ViewControls.vue:1086 +#: frontend/src/pages/Dashboard.vue:16 +msgid "Edit" +msgstr "编辑" + +#: frontend/src/components/Modals/CallLogModal.vue:97 +msgid "Edit Call Log" +msgstr "编辑通话记录" + +#: frontend/src/components/Modals/DataFieldsModal.vue:7 +msgid "Edit Data Fields Layout" +msgstr "编辑数据字段布局" + +#: frontend/src/components/Settings/EmailEdit.vue:6 +msgid "Edit Email" +msgstr "" + +#: frontend/src/components/Modals/SidePanelModal.vue:7 +msgid "Edit Field Layout" +msgstr "编辑字段布局" + +#: frontend/src/components/Controls/GridFieldsEditorModal.vue:7 +msgid "Edit Grid Fields Layout" +msgstr "编辑网格字段布局" + +#: frontend/src/components/Controls/GridRowFieldsModal.vue:7 +msgid "Edit Grid Row Fields Layout" +msgstr "编辑网格行字段布局" + +#: frontend/src/components/Modals/NoteModal.vue:6 +msgid "Edit Note" +msgstr "编辑备注" + +#: frontend/src/components/Modals/QuickEntryModal.vue:7 +msgid "Edit Quick Entry Layout" +msgstr "编辑快速录入布局" + +#: frontend/src/components/Modals/TaskModal.vue:6 +msgid "Edit Task" +msgstr "编辑任务" + +#: frontend/src/components/Modals/ViewModal.vue:6 +msgid "Edit View" +msgstr "编辑视图" + +#: frontend/src/components/Modals/EventModal.vue:9 +msgid "Edit an event" +msgstr "" + +#: frontend/src/components/Modals/CallLogDetailModal.vue:39 +msgid "Edit call log" +msgstr "" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:18 +msgid "Edit event" +msgstr "" + +#: frontend/src/components/Activities/DataFields.vue:17 +#: frontend/src/components/Controls/GridRowModal.vue:14 +#: frontend/src/components/Modals/AddressModal.vue:14 +#: frontend/src/components/Modals/CallLogModal.vue:16 +#: frontend/src/components/Modals/ContactModal.vue:16 +#: frontend/src/components/Modals/CreateDocumentModal.vue:16 +#: frontend/src/components/Modals/DealModal.vue:16 +#: frontend/src/components/Modals/LeadModal.vue:16 +#: frontend/src/components/Modals/OrganizationModal.vue:16 +msgid "Edit fields layout" +msgstr "" + +#: frontend/src/components/Controls/Grid.vue:57 +msgid "Edit grid fields" +msgstr "" + +#: frontend/src/components/Modals/CallLogDetailModal.vue:19 +msgid "Edit note" +msgstr "编辑备注" + +#: frontend/src/components/Controls/Grid.vue:287 +msgid "Edit row" +msgstr "" + +#: frontend/src/components/Modals/CallLogDetailModal.vue:24 +msgid "Edit task" +msgstr "编辑任务" + +#: frontend/src/components/Controls/GridRowModal.vue:8 +msgid "Editing Row {0}" +msgstr "正在编辑第{0}行" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:430 +msgid "Editing event" +msgstr "" + +#. Label of the email (Data) field in PageType 'CRM Contacts' +#. Label of the email (Data) field in PageType 'CRM Invitation' +#. Label of the email (Data) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_contacts/crm_contacts.json +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json frontend/src/pages/Contact.vue:510 +#: frontend/src/pages/MobileContact.vue:518 +#: frontend/src/pages/MobileOrganization.vue:462 +#: frontend/src/pages/MobileOrganization.vue:490 +#: frontend/src/pages/Organization.vue:483 +#: frontend/src/pages/Organization.vue:511 +msgid "Email" +msgstr "电子邮件" + +#: frontend/src/components/Settings/Settings.vue:147 +msgid "Email Accounts" +msgstr "" + +#: frontend/src/components/Settings/emailConfig.js:168 +msgid "Email ID is required" +msgstr "" + +#. Label of the email_sent_at (Datetime) field in PageType 'CRM Invitation' +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +msgid "Email Sent At" +msgstr "发送时间" + +#: frontend/src/components/Settings/Settings.vue:144 +msgid "Email Settings" +msgstr "邮件设置" + +#: frontend/src/components/Modals/EmailTemplateSelectorModal.vue:4 +#: frontend/src/components/Settings/Settings.vue:153 +msgid "Email Templates" +msgstr "邮件模板" + +#: frontend/src/components/Settings/EmailAdd.vue:141 +msgid "Email account created successfully" +msgstr "" + +#: frontend/src/components/Settings/EmailEdit.vue:208 +msgid "Email account updated successfully" +msgstr "" + +#: frontend/src/components/Settings/EmailAccountList.vue:7 +msgid "Email accounts" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:578 +msgid "Email communication" +msgstr "" + +#: frontend/src/components/EmailEditor.vue:209 +msgid "Email from Lead" +msgstr "来自线索的邮件" + +#: frontend/src/components/Layouts/AppSidebar.vue:557 +msgid "Email template" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:7 +msgid "Email templates" +msgstr "" + +#: frontend/src/pages/Deal.vue:532 frontend/src/pages/Lead.vue:389 +#: frontend/src/pages/MobileDeal.vue:435 frontend/src/pages/MobileLead.vue:342 +msgid "Emails" +msgstr "邮件" + +#: frontend/src/components/ListViews/ListRows.vue:12 +msgid "Empty" +msgstr "空" + +#: frontend/src/components/Filter.vue:123 +msgid "Empty - Choose a field to filter by" +msgstr "空 - 选择筛选字段" + +#: frontend/src/components/SortBy.vue:130 +msgid "Empty - Choose a field to sort by" +msgstr "空 - 选择排序字段" + +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.js:30 +msgid "Enable" +msgstr "启用" + +#. Label of the enable_forecasting (Check) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "Enable Forecasting" +msgstr "" + +#: frontend/src/components/Settings/emailConfig.js:28 +msgid "Enable Incoming" +msgstr "收邮件" + +#: frontend/src/components/Settings/emailConfig.js:36 +msgid "Enable Outgoing" +msgstr "启用该邮箱帐号发送邮件" + +#: frontend/src/components/Settings/ForecastingSettings.vue:20 +msgid "Enable forecasting" +msgstr "" + +#. Label of the enabled (Check) field in PageType 'CRM Exotel Settings' +#. Label of the enabled (Check) field in PageType 'CRM Form Script' +#. Label of the enabled (Check) field in PageType 'CRM Service Level Agreement' +#. Label of the enabled (Check) field in PageType 'CRM Twilio Settings' +#. Label of the enabled (Check) field in PageType 'ERPNext CRM Settings' +#. Label of the enabled (Check) field in PageType 'Helpdesk CRM Settings' +#: crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.json +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +#: crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.json +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json +#: crm/fcrm/pagetype/helpdesk_crm_settings/helpdesk_crm_settings.json +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:32 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRulesList.vue:21 +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:18 +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:85 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:20 +msgid "Enabled" +msgstr "已启用" + +#. Label of the end_date (Date) field in PageType 'CRM Service Level Agreement' +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +msgid "End Date" +msgstr "结束日期" + +#. Label of the end_time (Datetime) field in PageType 'CRM Call Log' +#. Label of the end_time (Time) field in PageType 'CRM Service Day' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_service_day/crm_service_day.json +#: frontend/src/components/Calendar/CalendarEventPanel.vue:242 +#: frontend/src/components/Modals/EventModal.vue:112 +msgid "End Time" +msgstr "结束时间" + +#: frontend/src/composables/event.js:206 +msgid "End time should be after start time" +msgstr "" + +#: frontend/src/components/Settings/CurrencySettings.vue:115 +msgid "Enter access key" +msgstr "" + +#: frontend/src/components/Settings/BrandSettings.vue:33 +msgid "Enter brand name" +msgstr "" + +#: frontend/src/components/FieldLayout/Field.vue:339 +msgid "Enter {0}" +msgstr "输入{0}" + +#: frontend/src/components/Filter.vue:66 frontend/src/components/Filter.vue:99 +#: frontend/src/components/Filter.vue:267 +#: frontend/src/components/Filter.vue:288 +#: frontend/src/components/Filter.vue:305 +#: frontend/src/components/Filter.vue:316 +#: frontend/src/components/Filter.vue:327 +#: frontend/src/components/Filter.vue:343 +msgid "Equals" +msgstr "等于" + +#: frontend/src/components/Modals/ConvertToDealModal.vue:176 +msgid "Error converting to deal: {0}" +msgstr "" + +#: frontend/src/pages/Deal.vue:731 frontend/src/pages/Lead.vue:469 +#: frontend/src/pages/MobileDeal.vue:612 frontend/src/pages/MobileLead.vue:413 +msgid "Error updating field" +msgstr "" + +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.py:279 +msgid "Error while creating customer in ERPNext, check error log for more details" +msgstr "ERPNext创建客户失败,请查看错误日志" + +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.py:191 +msgid "Error while creating prospect in ERPNext, check error log for more details" +msgstr "ERPNext创建潜在客户失败,请查看错误日志" + +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.py:117 +msgid "Error while fetching customer in ERPNext, check error log for more details" +msgstr "ERPNext获取客户失败,请查看错误日志" + +#: frontend/src/components/Modals/EventModal.vue:368 +msgid "Event ID is required" +msgstr "" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:429 +msgid "Event details" +msgstr "" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:182 +msgid "Event title" +msgstr "" + +#: frontend/src/pages/Deal.vue:547 frontend/src/pages/Lead.vue:404 +msgid "Events" +msgstr "事件" + +#: frontend/src/components/ViewControls.vue:268 +#: frontend/src/components/ViewControls.vue:277 +msgid "Excel" +msgstr "Excel" + +#. Label of the exchange_rate (Float) field in PageType 'CRM Deal' +#. Label of the exchange_rate (Float) field in PageType 'CRM Organization' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "Exchange Rate" +msgstr "汇率" + +#. Label of the exchange_rate_provider_section (Section Break) field in PageType +#. 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "Exchange Rate Provider" +msgstr "" + +#: frontend/src/components/Settings/CurrencySettings.vue:60 +msgid "Exchange rate provider" +msgstr "" + +#. Option for the 'Telephony Medium' (Select) field in PageType 'CRM Call Log' +#. Label of the exotel (Check) field in PageType 'CRM Telephony Agent' +#. Option for the 'Default Medium' (Select) field in PageType 'CRM Telephony +#. Agent' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +#: frontend/src/components/Layouts/AppSidebar.vue:602 +#: frontend/src/components/Settings/TelephonySettings.vue:41 +#: frontend/src/components/Settings/TelephonySettings.vue:63 +msgid "Exotel" +msgstr "Exotel" + +#: crm/integrations/exotel/handler.py:114 +msgid "Exotel Exception" +msgstr "Exotel异常" + +#. Label of the exotel_number (Data) field in PageType 'CRM Telephony Agent' +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +msgid "Exotel Number" +msgstr "Exotel号码" + +#: crm/integrations/exotel/handler.py:85 +msgid "Exotel Number Missing" +msgstr "Exotel号码缺失" + +#: crm/integrations/exotel/handler.py:89 +msgid "Exotel Number {0} is not valid" +msgstr "Exotel号码{0}无效" + +#: frontend/src/components/Settings/TelephonySettings.vue:293 +msgid "Exotel is not enabled" +msgstr "Exotel未启用" + +#: frontend/src/components/Settings/TelephonySettings.vue:140 +msgid "Exotel settings updated successfully" +msgstr "Exotel设置更新成功" + +#: frontend/src/components/Layouts/AppSidebar.vue:107 +msgid "Expand" +msgstr "展开" + +#. Label of the expected_closure_date (Date) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "Expected Closure Date" +msgstr "" + +#: crm/fcrm/pagetype/crm_deal/crm_deal.py:173 +msgid "Expected Closure Date is required." +msgstr "" + +#. Label of the expected_deal_value (Currency) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "Expected Deal Value" +msgstr "" + +#: crm/fcrm/pagetype/crm_deal/crm_deal.py:171 +msgid "Expected Deal Value is required." +msgstr "" + +#. Option for the 'Status' (Select) field in PageType 'CRM Invitation' +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +msgid "Expired" +msgstr "已过期" + +#: frontend/src/components/ViewControls.vue:203 +#: frontend/src/components/ViewControls.vue:251 +msgid "Export" +msgstr "导出" + +#: frontend/src/components/ViewControls.vue:282 +msgid "Export All {0} Record(s)" +msgstr "导出全部{0}条记录" + +#: frontend/src/components/ViewControls.vue:264 +msgid "Export Type" +msgstr "导出类型" + +#. Name of a PageType +#: crm/fcrm/pagetype/fcrm_note/fcrm_note.json +msgid "FCRM Note" +msgstr "FCRM备注" + +#. Name of a PageType +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "FCRM Settings" +msgstr "FCRM设置" + +#. Option for the 'Status' (Select) field in PageType 'CRM Call Log' +#. Option for the 'SLA Status' (Select) field in PageType 'CRM Deal' +#. Option for the 'SLA Status' (Select) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Failed" +msgstr "失败" + +#: frontend/src/components/Modals/AddExistingUserModal.vue:111 +msgid "Failed to add users" +msgstr "" + +#: crm/integrations/twilio/api.py:130 +msgid "Failed to capture Twilio recording" +msgstr "获取Twilio录音失败" + +#: frontend/src/components/Settings/EmailAdd.vue:145 +msgid "Failed to create email account, Invalid credentials" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:179 +msgid "Failed to create template" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:216 +msgid "Failed to delete template" +msgstr "" + +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.py:205 +msgid "Failed to fetch exchange rate from {0} to {1} on {2}. Please check your internet connection or try again later." +msgstr "" + +#: frontend/src/data/script.js:106 +msgid "Failed to load form controller: {0}" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:243 +msgid "Failed to rename template" +msgstr "" + +#: crm/integrations/twilio/api.py:152 +msgid "Failed to update Twilio call status" +msgstr "更新Twilio通话状态失败" + +#: frontend/src/components/Settings/EmailEdit.vue:213 +msgid "Failed to update email account, Invalid credentials" +msgstr "" + +#: frontend/src/components/Modals/ChangePasswordModal.vue:95 +msgid "Failed to update password" +msgstr "" + +#: frontend/src/components/Settings/ProfileSettings.vue:151 +msgid "Failed to update profile" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:209 +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:201 +msgid "Failed to update template" +msgstr "" + +#. Label of the favicon (Attach) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +#: frontend/src/components/Settings/BrandSettings.vue:87 +msgid "Favicon" +msgstr "网站图标" + +#: frontend/src/components/ConditionsFilter/CFCondition.vue:38 +#: frontend/src/components/Modals/EditValueModal.vue:5 +msgid "Field" +msgstr "字段" + +#: frontend/src/components/Controls/GridFieldsEditorModal.vue:19 +#: frontend/src/components/Kanban/KanbanSettings.vue:48 +msgid "Fields Order" +msgstr "字段顺序" + +#: frontend/src/components/FilesUploader/FilesUploaderArea.vue:333 +msgid "File \"{0}\" was skipped because of invalid file type" +msgstr "由于文件类型无效,文件“{0}”被跳过" + +#: frontend/src/components/FilesUploader/FilesUploaderArea.vue:354 +msgid "File \"{0}\" was skipped because only {1} uploads are allowed" +msgstr "文件\"{0}\"已跳过,因为最多只允许上传{1}个文件" + +#: frontend/src/components/FilesUploader/FilesUploaderArea.vue:359 +msgid "File \"{0}\" was skipped because only {1} uploads are allowed for PageType \"{2}\"" +msgstr "文件\"{0}\"已跳过,因为文档类型\"{2}\"最多只允许上传{1}个文件" + +#: frontend/src/components/Filter.vue:6 +msgid "Filter" +msgstr "筛选器" + +#. Label of the filters (Code) field in PageType 'CRM View Settings' +#. Label of the filters_tab (Tab Break) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Filters" +msgstr "筛选条件" + +#. Label of the first_name (Data) field in PageType 'CRM Deal' +#. Label of the first_name (Data) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: frontend/src/components/ColumnSettings.vue:103 +#: frontend/src/components/Filter.vue:57 frontend/src/components/Filter.vue:88 +#: frontend/src/components/SortBy.vue:6 frontend/src/components/SortBy.vue:103 +#: frontend/src/components/SortBy.vue:136 +msgid "First Name" +msgstr "名字" + +#: frontend/src/components/Modals/LeadModal.vue:134 +msgid "First Name is mandatory" +msgstr "名字为必填项" + +#. Label of the first_responded_on (Datetime) field in PageType 'CRM Deal' +#. Label of the first_responded_on (Datetime) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "First Responded On" +msgstr "首次响应时间" + +#. Option for the 'SLA Status' (Select) field in PageType 'CRM Deal' +#. Option for the 'SLA Status' (Select) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "First Response Due" +msgstr "首次响应截止" + +#. Label of the first_response_time (Duration) field in PageType 'CRM Service +#. Level Priority' +#: crm/fcrm/pagetype/crm_service_level_priority/crm_service_level_priority.json +msgid "First Response TIme" +msgstr "首次响应时间" + +#. Label of the first_response_time (Duration) field in PageType 'CRM Deal' +#. Label of the first_response_time (Duration) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "First Response Time" +msgstr "首次响应时间" + +#: frontend/src/components/Filter.vue:130 +#: frontend/src/components/Settings/ProfileSettings.vue:78 +msgid "First name" +msgstr "名字" + +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:48 +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:84 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:48 +msgid "For" +msgstr "目标" + +#: crm/api/dashboard.py:666 +#: frontend/src/components/Dashboard/AddChartModal.vue:95 +msgid "Forecasted revenue" +msgstr "" + +#: frontend/src/components/Settings/ForecastingSettings.vue:5 +#: frontend/src/components/Settings/Settings.vue:108 +msgid "Forecasting" +msgstr "预测" + +#: frontend/src/components/Settings/ForecastingSettings.vue:76 +msgid "Forecasting disabled successfully" +msgstr "" + +#: frontend/src/components/Settings/ForecastingSettings.vue:75 +msgid "Forecasting enabled successfully" +msgstr "" + +#. Option for the 'Apply To' (Select) field in PageType 'CRM Form Script' +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.json +msgid "Form" +msgstr "表单" + +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.js:19 +msgid "Form Script updated successfully" +msgstr "表单脚本更新成功" + +#. Name of a Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +msgid "Jingrow CRM" +msgstr "Jingrow CRM" + +#: frontend/src/components/Layouts/AppSidebar.vue:608 +msgid "Jingrow CRM mobile" +msgstr "" + +#. Option for the 'Weekly Off' (Select) field in PageType 'CRM Holiday List' +#. Option for the 'Workday' (Select) field in PageType 'CRM Service Day' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +#: crm/fcrm/pagetype/crm_service_day/crm_service_day.json +msgid "Friday" +msgstr "周五" + +#. Label of the from (Data) field in PageType 'CRM Call Log' +#. Label of the from (Data) field in PageType 'CRM Status Change Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.json +msgid "From" +msgstr "发件人" + +#. Label of the from_date (Date) field in PageType 'CRM Holiday List' +#. Label of the from_date (Datetime) field in PageType 'CRM Status Change Log' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +#: crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.json +msgid "From Date" +msgstr "起始日期" + +#. Label of the from_type (Data) field in PageType 'CRM Status Change Log' +#: crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.json +msgid "From Type" +msgstr "" + +#. Label of the from_user (Link) field in PageType 'CRM Notification' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +msgid "From User" +msgstr "来自用户" + +#. Option for the 'SLA Status' (Select) field in PageType 'CRM Deal' +#. Option for the 'SLA Status' (Select) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Fulfilled" +msgstr "已完成" + +#. Label of the full_name (Data) field in PageType 'CRM Contacts' +#. Label of the lead_name (Data) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_contacts/crm_contacts.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Full Name" +msgstr "全名" + +#: crm/api/dashboard.py:728 +#: frontend/src/components/Dashboard/AddChartModal.vue:96 +msgid "Funnel conversion" +msgstr "" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:196 +msgid "GMT+5:30" +msgstr "" + +#. Label of the gender (Link) field in PageType 'CRM Contacts' +#. Label of the gender (Link) field in PageType 'CRM Deal' +#. Label of the gender (Link) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_contacts/crm_contacts.json +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Gender" +msgstr "性别" + +#: crm/api/dashboard.py:1020 +msgid "Geographic distribution of deals and revenue" +msgstr "" + +#: frontend/src/components/Modals/AboutModal.vue:57 +msgid "GitHub Repository" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:582 +msgid "Go back" +msgstr "返回" + +#: frontend/src/components/Settings/AssignmentRules/AssigneeSearch.vue:156 +msgid "Go to invite page" +msgstr "" + +#: frontend/src/pages/Deal.vue:95 frontend/src/pages/Lead.vue:141 +msgid "Go to website" +msgstr "访问网站" + +#. Option for the 'Type' (Select) field in PageType 'CRM Fields Layout' +#: crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json +msgid "Grid Row" +msgstr "网格行" + +#. Label of the group_by_tab (Tab Break) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +#: frontend/src/components/ViewControls.vue:379 +#: frontend/src/components/ViewControls.vue:611 frontend/src/utils/view.js:16 +msgid "Group By" +msgstr "分组依据" + +#. Label of the group_by_field (Data) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Group By Field" +msgstr "分组字段" + +#: frontend/src/components/GroupBy.vue:8 +msgid "Group By: " +msgstr "分组依据:" + +#: frontend/src/components/Telephony/TwilioCallUI.vue:63 +msgid "Hang up" +msgstr "" + +#: crm/templates/emails/helpdesk_invitation.html:2 +msgid "Hello" +msgstr "你好" + +#: frontend/src/components/Layouts/AppSidebar.vue:93 +msgid "Help" +msgstr "帮助" + +#: frontend/src/components/Settings/Settings.vue:202 +msgid "Helpdesk" +msgstr "" + +#. Name of a PageType +#: crm/fcrm/pagetype/helpdesk_crm_settings/helpdesk_crm_settings.json +msgid "Helpdesk CRM Settings" +msgstr "" + +#. Label of the helpdesk_site_apis_section (Section Break) field in PageType +#. 'Helpdesk CRM Settings' +#: crm/fcrm/pagetype/helpdesk_crm_settings/helpdesk_crm_settings.json +msgid "Helpdesk Site API's" +msgstr "" + +#. Label of the helpdesk_site_url (Data) field in PageType 'Helpdesk CRM +#. Settings' +#: crm/fcrm/pagetype/helpdesk_crm_settings/helpdesk_crm_settings.json +msgid "Helpdesk Site URL" +msgstr "" + +#: crm/fcrm/pagetype/helpdesk_crm_settings/helpdesk_crm_settings.py:18 +msgid "Helpdesk is not installed in the current site" +msgstr "" + +#: crm/fcrm/pagetype/helpdesk_crm_settings/helpdesk_crm_settings.py:40 +msgid "Helpdesk is not integrated with the CRM" +msgstr "" + +#: frontend/src/components/Settings/HelpdeskSettings.vue:4 +msgid "Helpdesk settings" +msgstr "" + +#: frontend/src/components/Settings/HelpdeskSettings.vue:5 +msgid "Helpdesk settings updated" +msgstr "" + +#: frontend/src/components/CommunicationArea.vue:56 +msgid "Hi John, \\n\\nCan you please provide more details on this..." +msgstr "John 您好:\\n\\n可否请您就此事项提供更多详细信息..." + +#. Label of the hidden (Check) field in PageType 'CRM Dropdown Item' +#: crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json +msgid "Hidden" +msgstr "隐藏" + +#: frontend/src/components/Activities/Activities.vue:237 +msgid "Hide" +msgstr "隐藏" + +#: frontend/src/components/Controls/Password.vue:19 +msgid "Hide Password" +msgstr "" + +#: frontend/src/components/Activities/CallArea.vue:75 +msgid "Hide Recording" +msgstr "隐藏录音" + +#: frontend/src/components/FieldLayoutEditor.vue:354 +msgid "Hide border" +msgstr "隐藏边框" + +#: frontend/src/components/FieldLayoutEditor.vue:349 +msgid "Hide label" +msgstr "隐藏标签" + +#: frontend/src/components/Controls/GridRowFieldsModal.vue:20 +#: frontend/src/components/Modals/DataFieldsModal.vue:20 +#: frontend/src/components/Modals/QuickEntryModal.vue:20 +#: frontend/src/components/Modals/SidePanelModal.vue:20 +msgid "Hide preview" +msgstr "隐藏预览" + +#. Option for the 'Priority' (Select) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_task/crm_task.json +msgid "High" +msgstr "高" + +#. Label of the holiday_list (Link) field in PageType 'CRM Service Level +#. Agreement' +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +msgid "Holiday List" +msgstr "假期列表" + +#. Label of the holiday_list_name (Data) field in PageType 'CRM Holiday List' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +msgid "Holiday List Name" +msgstr "假期列表名称" + +#. Label of the holidays_section (Section Break) field in PageType 'CRM Holiday +#. List' +#. Label of the holidays (Table) field in PageType 'CRM Holiday List' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +msgid "Holidays" +msgstr "假期" + +#: frontend/src/components/Settings/Settings.vue:173 +msgid "Home Actions" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:542 +#: frontend/src/components/Settings/HomeActions.vue:7 +msgid "Home actions" +msgstr "主页操作" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:199 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:283 +msgid "I understand, add conditions" +msgstr "" + +#. Label of the id (Data) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "ID" +msgstr "ID" + +#. Label of the icon (Code) field in PageType 'CRM Dropdown Item' +#. Label of the icon (Data) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Icon" +msgstr "图标" + +#: frontend/src/components/Settings/emailConfig.js:55 +msgid "If enabled, all outgoing emails will be sent from this account. Note: Only one account can be default outgoing." +msgstr "" + +#: frontend/src/components/Settings/emailConfig.js:47 +msgid "If enabled, all replies to your company (eg: replies@yourcomany.com) will come to this account. Note: Only one account can be default incoming." +msgstr "" + +#: frontend/src/components/Settings/emailConfig.js:39 +msgid "If enabled, outgoing emails can be sent from this account." +msgstr "" + +#: frontend/src/components/Settings/emailConfig.js:31 +msgid "If enabled, records can be created from the incoming emails on this account." +msgstr "" + +#. Label of the image (Attach Image) field in PageType 'CRM Lead' +#. Label of the image (Attach Image) field in PageType 'CRM Product' +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_product/crm_product.json +msgid "Image" +msgstr "图片" + +#: frontend/src/components/Filter.vue:271 +#: frontend/src/components/Filter.vue:292 +#: frontend/src/components/Filter.vue:307 +#: frontend/src/components/Filter.vue:320 +#: frontend/src/components/Filter.vue:334 +msgid "In" +msgstr "在" + +#. Option for the 'Status' (Select) field in PageType 'CRM Call Log' +#. Option for the 'Status' (Select) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_task/crm_task.json +msgid "In Progress" +msgstr "进行中" + +#: frontend/src/components/SLASection.vue:68 +msgid "In less than a minute" +msgstr "不到一分钟前" + +#: frontend/src/components/Activities/CallArea.vue:36 +msgid "Inbound Call" +msgstr "呼入通话" + +#: frontend/src/components/Settings/EmailAccountCard.vue:45 +msgid "Inbox" +msgstr "收件箱" + +#. Option for the 'Type' (Select) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Incoming" +msgstr "呼入" + +#: frontend/src/components/Telephony/TwilioCallUI.vue:41 +msgid "Incoming call..." +msgstr "来电中..." + +#. Label of a shortcut in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +msgid "Industries" +msgstr "行业" + +#. Label of the industry (Link) field in PageType 'CRM Deal' +#. Label of the industry (Data) field in PageType 'CRM Industry' +#. Label of the industry (Link) field in PageType 'CRM Lead' +#. Label of the industry (Link) field in PageType 'CRM Organization' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_industry/crm_industry.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "Industry" +msgstr "行业" + +#. Option for the 'Status' (Select) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Initiated" +msgstr "已启动" + +#: frontend/src/components/Telephony/TwilioCallUI.vue:36 +msgid "Initiating call..." +msgstr "正在发起呼叫..." + +#: frontend/src/components/EmailEditor.vue:154 +msgid "Insert Email Template" +msgstr "" + +#: frontend/src/components/CommentBox.vue:49 +#: frontend/src/components/EmailEditor.vue:130 +msgid "Insert Emoji" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:598 +msgid "Integration" +msgstr "" + +#: crm/integrations/exotel/handler.py:73 +msgid "Integration Not Enabled" +msgstr "未启用集成" + +#: frontend/src/components/Settings/Settings.vue:181 +msgctxt "FCRM" +msgid "Integrations" +msgstr "集成" + +#: frontend/src/components/Layouts/AppSidebar.vue:529 +#: frontend/src/components/Layouts/AppSidebar.vue:532 +msgid "Introduction" +msgstr "简介" + +#: crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.py:33 +msgid "Invalid Account SID or Auth Token." +msgstr "无效的账户SID或认证令牌" + +#: frontend/src/components/Modals/DealModal.vue:212 +#: frontend/src/components/Modals/LeadModal.vue:153 +msgid "Invalid Email" +msgstr "无效的电子邮件" + +#: crm/integrations/exotel/handler.py:89 +msgid "Invalid Exotel Number" +msgstr "无效的Exotel号码" + +#: crm/api/dashboard.py:73 +msgid "Invalid chart name" +msgstr "" + +#: crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.py:25 +msgid "Invalid credentials" +msgstr "无效的凭据" + +#: frontend/src/components/Settings/emailConfig.js:172 +msgid "Invalid email ID" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:601 +msgid "Invalid fields, check if all are filled in and values are correct." +msgstr "" + +#: frontend/src/pages/InvalidPage.vue:6 +msgid "Invalid page or not permitted to access" +msgstr "" + +#: frontend/src/composables/event.js:203 +msgid "Invalid start or end time" +msgstr "" + +#: frontend/src/components/Settings/Users.vue:25 +msgid "Invite New User" +msgstr "" + +#: frontend/src/components/Settings/Settings.vue:135 +msgid "Invite User" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssigneeSearch.vue:78 +#: frontend/src/components/Settings/AssignmentRules/AssigneeSearch.vue:149 +msgid "Invite agent" +msgstr "" + +#: frontend/src/components/Settings/InviteUserPage.vue:51 +msgid "Invite as" +msgstr "邀请身份" + +#: frontend/src/components/Layouts/AppSidebar.vue:543 +msgid "Invite users" +msgstr "" + +#: frontend/src/components/Settings/InviteUserPage.vue:10 +msgid "Invite users to access CRM. Specify their roles to control access and permissions" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:359 +msgid "Invite your team" +msgstr "" + +#. Label of the invited_by (Link) field in PageType 'CRM Invitation' +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +msgid "Invited By" +msgstr "邀请人" + +#: frontend/src/components/Filter.vue:273 +#: frontend/src/components/Filter.vue:282 +#: frontend/src/components/Filter.vue:294 +#: frontend/src/components/Filter.vue:309 +#: frontend/src/components/Filter.vue:322 +#: frontend/src/components/Filter.vue:336 +#: frontend/src/components/Filter.vue:345 +msgid "Is" +msgstr "是" + +#. Label of the is_default (Check) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Is Default" +msgstr "设为默认" + +#. Label of the is_erpnext_in_different_site (Check) field in PageType 'ERPNext +#. CRM Settings' +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json +msgid "Is ERPNext installed on a different site?" +msgstr "ERPNext是否安装在其他站点?" + +#. Label of the is_group (Check) field in PageType 'CRM Territory' +#: crm/fcrm/pagetype/crm_territory/crm_territory.json +msgid "Is Group" +msgstr "是否分组" + +#. Label of the is_helpdesk_in_different_site (Check) field in PageType +#. 'Helpdesk CRM Settings' +#: crm/fcrm/pagetype/helpdesk_crm_settings/helpdesk_crm_settings.json +msgid "Is Helpdesk installed on a different site?" +msgstr "" + +#. Label of the is_primary (Check) field in PageType 'CRM Contacts' +#. Label of the is_primary (Check) field in PageType 'CRM Telephony Phone' +#: crm/fcrm/pagetype/crm_contacts/crm_contacts.json +#: crm/fcrm/pagetype/crm_telephony_phone/crm_telephony_phone.json +msgid "Is Primary" +msgstr "是否主要" + +#. Label of the is_standard (Check) field in PageType 'CRM Dropdown Item' +#. Label of the is_standard (Check) field in PageType 'CRM Form Script' +#. Label of the is_standard (Check) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.json +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Is Standard" +msgstr "是否标准" + +#. Description of the 'Enable Forecasting' (Check) field in PageType 'FCRM +#. Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "It will make deal's \"Expected Closure Date\" & \"Expected Deal Value\" mandatory to get accurate forecasting insights" +msgstr "" + +#. Label of the json (JSON) field in PageType 'CRM Global Settings' +#: crm/fcrm/pagetype/crm_global_settings/crm_global_settings.json +msgid "JSON" +msgstr "JSON" + +#. Label of the job_title (Data) field in PageType 'CRM Deal' +#. Label of the job_title (Data) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Job Title" +msgstr "职位" + +#: frontend/src/components/AssignToBody.vue:11 +#: frontend/src/components/Filter.vue:74 frontend/src/components/Filter.vue:107 +#: frontend/src/components/Modals/AssignmentModal.vue:13 +#: frontend/src/components/Modals/TaskModal.vue:63 +#: frontend/src/components/Telephony/TaskPanel.vue:47 +msgid "John Doe" +msgstr "张三" + +#. Label of the kanban_tab (Tab Break) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +#: frontend/src/components/ViewControls.vue:384 +#: frontend/src/components/ViewControls.vue:600 frontend/src/utils/view.js:20 +msgid "Kanban" +msgstr "看板" + +#. Label of the kanban_columns (Code) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Kanban Columns" +msgstr "看板列" + +#. Label of the kanban_fields (Code) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Kanban Fields" +msgstr "看板字段" + +#: frontend/src/components/Kanban/KanbanSettings.vue:3 +#: frontend/src/components/Kanban/KanbanSettings.vue:8 +msgid "Kanban Settings" +msgstr "看板设置" + +#. Label of the key (Data) field in PageType 'CRM Invitation' +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +msgid "Key" +msgstr "键" + +#. Label of the label (Data) field in PageType 'CRM Dropdown Item' +#. Label of the label (Data) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +#: frontend/src/components/ColumnSettings.vue:100 +msgid "Label" +msgstr "标签" + +#: frontend/src/components/Settings/AssignmentRules/AssigneeRules.vue:108 +msgid "Last" +msgstr "" + +#: frontend/src/components/Filter.vue:615 +msgid "Last 6 Months" +msgstr "过去6个月" + +#: frontend/src/components/Filter.vue:607 +msgid "Last Month" +msgstr "上月" + +#. Label of the last_name (Data) field in PageType 'CRM Deal' +#. Label of the last_name (Data) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Last Name" +msgstr "姓氏" + +#: frontend/src/components/Filter.vue:611 +msgid "Last Quarter" +msgstr "上季度" + +#. Label of the last_status_change_log (Link) field in PageType 'CRM Status +#. Change Log' +#: crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.json +msgid "Last Status Change Log" +msgstr "最后状态变更日志" + +#: frontend/src/components/Filter.vue:603 +msgid "Last Week" +msgstr "上周" + +#: frontend/src/components/Filter.vue:619 +msgid "Last Year" +msgstr "去年" + +#: frontend/src/pages/Contact.vue:525 frontend/src/pages/MobileContact.vue:533 +#: frontend/src/pages/MobileOrganization.vue:477 +#: frontend/src/pages/MobileOrganization.vue:505 +#: frontend/src/pages/Organization.vue:498 +#: frontend/src/pages/Organization.vue:526 +msgid "Last modified" +msgstr "最后修改" + +#: frontend/src/components/Settings/ProfileSettings.vue:83 +msgid "Last name" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssigneeRules.vue:101 +msgid "Last user assigned by this rule" +msgstr "" + +#. Label of the layout (Code) field in PageType 'CRM Dashboard' +#. Label of the layout (Code) field in PageType 'CRM Fields Layout' +#: crm/fcrm/pagetype/crm_dashboard/crm_dashboard.json +#: crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json +msgid "Layout" +msgstr "布局" + +#. Label of the lead (Link) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: frontend/src/components/Calendar/CalendarEventPanel.vue:263 +#: frontend/src/components/Calendar/CalendarEventPanel.vue:288 +#: frontend/src/components/Layouts/AppSidebar.vue:550 +#: frontend/src/components/Settings/AssignmentRules/AssigneeRules.vue:19 +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:55 +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:77 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:55 +#: frontend/src/components/Telephony/ExotelCallUI.vue:200 +#: frontend/src/pages/Tasks.vue:133 +msgid "Lead" +msgstr "线索" + +#. Label of the lead_details_tab (Tab Break) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "Lead Details" +msgstr "线索详情" + +#. Label of the lead_name (Data) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "Lead Name" +msgstr "线索名称" + +#. Label of the lead_owner (Link) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Lead Owner" +msgstr "线索负责人" + +#: crm/fcrm/pagetype/crm_lead/crm_lead.py:73 +msgid "Lead Owner cannot be same as the Lead Email Address" +msgstr "线索负责人不能与线索邮箱地址相同" + +#. Label of a shortcut in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +msgid "Lead Sources" +msgstr "线索来源" + +#. Label of a shortcut in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +msgid "Lead Statuses" +msgstr "线索状态" + +#: crm/api/dashboard.py:935 +msgid "Lead generation channel analysis" +msgstr "" + +#: crm/api/dashboard.py:729 +msgid "Lead to deal conversion pipeline" +msgstr "" + +#. Label of a shortcut in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +#: frontend/src/pages/InvalidPage.vue:9 frontend/src/pages/Lead.vue:340 +#: frontend/src/pages/MobileLead.vue:291 +msgid "Leads" +msgstr "线索" + +#: crm/api/dashboard.py:934 +#: frontend/src/components/Dashboard/AddChartModal.vue:106 +msgid "Leads by source" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:158 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:238 +msgid "Learn about conditions" +msgstr "" + +#. Label of the lft (Int) field in PageType 'CRM Territory' +#: crm/fcrm/pagetype/crm_territory/crm_territory.json +msgid "Left" +msgstr "左侧" + +#: frontend/src/components/FilesUploader/FilesUploaderArea.vue:43 +msgid "Library" +msgstr "媒体库" + +#: frontend/src/components/Filter.vue:269 +#: frontend/src/components/Filter.vue:280 +#: frontend/src/components/Filter.vue:290 +#: frontend/src/components/Filter.vue:318 +#: frontend/src/components/Filter.vue:332 +msgid "Like" +msgstr "相似" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:252 +#: frontend/src/components/FilesUploader/FilesUploaderArea.vue:47 +msgid "Link" +msgstr "链接" + +#. Label of the links (Table) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Links" +msgstr "链接" + +#. Option for the 'Apply To' (Select) field in PageType 'CRM Form Script' +#. Label of the list_tab (Tab Break) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.json +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +#: frontend/src/components/ViewControls.vue:374 +#: frontend/src/components/ViewControls.vue:589 frontend/src/utils/view.js:12 +msgid "List" +msgstr "列表" + +#: frontend/src/components/Activities/CallArea.vue:75 +msgid "Listen" +msgstr "收听" + +#. Label of the load_default_columns (Check) field in PageType 'CRM View +#. Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Load Default Columns" +msgstr "加载默认列" + +#: frontend/src/components/Kanban/KanbanView.vue:140 +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:142 +#: frontend/src/components/Settings/Users.vue:155 +msgid "Load More" +msgstr "加载更多" + +#: frontend/src/components/Activities/Activities.vue:22 +#: frontend/src/components/Activities/DataFields.vue:35 +#: frontend/src/pages/Deal.vue:176 frontend/src/pages/MobileDeal.vue:117 +msgid "Loading..." +msgstr "加载中..." + +#. Label of the log_tab (Tab Break) field in PageType 'CRM Deal' +#. Label of the log_tab (Tab Break) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Log" +msgstr "日志" + +#: frontend/src/components/Activities/Activities.vue:814 +#: frontend/src/components/Activities/ActivityHeader.vue:133 +#: frontend/src/components/Activities/ActivityHeader.vue:176 +msgid "Log a Call" +msgstr "" + +#: frontend/src/composables/jingrowcloud.js:23 +msgid "Login to Jingrow Cloud?" +msgstr "登录Jingrow云平台?" + +#. Label of the brand_logo (Attach) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "Logo" +msgstr "徽标" + +#. Option for the 'Type' (Select) field in PageType 'CRM Deal Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +msgid "Lost" +msgstr "未成交" + +#. Label of the lost_notes (Text) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "Lost Notes" +msgstr "" + +#. Label of the lost_reason (Link) field in PageType 'CRM Deal' +#. Label of the lost_reason (Data) field in PageType 'CRM Lost Reason' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.json +msgid "Lost Reason" +msgstr "未成交原因" + +#: crm/api/dashboard.py:883 +#: frontend/src/components/Dashboard/AddChartModal.vue:98 +msgid "Lost deal reasons" +msgstr "" + +#: frontend/src/components/Modals/LostReasonModal.vue:27 +msgid "Lost notes" +msgstr "" + +#: frontend/src/components/Modals/LostReasonModal.vue:83 +msgid "Lost notes are required when lost reason is \"Other\"" +msgstr "" + +#: frontend/src/components/Modals/LostReasonModal.vue:4 +#: frontend/src/components/Modals/LostReasonModal.vue:14 +msgid "Lost reason" +msgstr "" + +#: frontend/src/components/Modals/LostReasonModal.vue:79 +msgid "Lost reason is required" +msgstr "" + +#. Option for the 'Priority' (Select) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_task/crm_task.json +msgid "Low" +msgstr "低" + +#: frontend/src/pages/Contact.vue:94 frontend/src/pages/MobileContact.vue:73 +msgid "Make Call" +msgstr "发起呼叫" + +#: frontend/src/components/ViewControls.vue:1101 +msgid "Make Private" +msgstr "设为私有" + +#: frontend/src/components/ViewControls.vue:1101 +msgid "Make Public" +msgstr "设为公开" + +#: frontend/src/components/Activities/Activities.vue:818 +#: frontend/src/components/Activities/ActivityHeader.vue:138 +#: frontend/src/components/Activities/ActivityHeader.vue:181 +#: frontend/src/pages/Deals.vue:505 frontend/src/pages/Leads.vue:532 +msgid "Make a Call" +msgstr "拨打电话" + +#: frontend/src/pages/Deal.vue:81 frontend/src/pages/Lead.vue:123 +msgid "Make a call" +msgstr "发起呼叫" + +#: frontend/src/components/Activities/AttachmentArea.vue:98 +msgid "Make attachment {0}" +msgstr "将附件{0}" + +#: frontend/src/components/Telephony/CallUI.vue:7 +msgid "Make call" +msgstr "拨打电话" + +#: frontend/src/components/Activities/AttachmentArea.vue:43 +msgid "Make private" +msgstr "设为私有" + +#: frontend/src/components/Activities/AttachmentArea.vue:43 +msgid "Make public" +msgstr "设为公开" + +#: frontend/src/components/Activities/AttachmentArea.vue:107 +msgid "Make {0}" +msgstr "创建{0}" + +#: frontend/src/components/Telephony/CallUI.vue:34 +msgid "Make {0} as default calling medium" +msgstr "将{0}设为默认呼叫媒介" + +#: frontend/src/components/Settings/ForecastingSettings.vue:24 +msgid "Makes \"Expected Closure Date\" and \"Expected Deal Value\" mandatory for deal value forecasting" +msgstr "" + +#: frontend/src/components/Settings/Users.vue:11 +msgid "Manage CRM users by adding or inviting them, and assign roles to control their access and permissions" +msgstr "" + +#: frontend/src/components/Settings/EmailAccountList.vue:11 +msgid "Manage your email accounts to send and receive emails directly from CRM. You can add multiple accounts and set one as default for incoming and outgoing emails." +msgstr "" + +#: frontend/src/components/Modals/AddExistingUserModal.vue:93 +#: frontend/src/components/Settings/InviteUserPage.vue:157 +#: frontend/src/components/Settings/InviteUserPage.vue:164 +#: frontend/src/components/Settings/Users.vue:87 +#: frontend/src/components/Settings/Users.vue:193 +#: frontend/src/components/Settings/Users.vue:253 +#: frontend/src/components/Settings/Users.vue:256 +msgid "Manager" +msgstr "经理" + +#: frontend/src/data/document.js:54 +msgid "Mandatory field error: {0}" +msgstr "" + +#. Option for the 'Telephony Medium' (Select) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Manual" +msgstr "手动" + +#: frontend/src/components/Notifications.vue:20 +#: frontend/src/pages/MobileNotification.vue:12 +#: frontend/src/pages/MobileNotification.vue:13 +msgid "Mark all as read" +msgstr "全部标记为已读" + +#: frontend/src/components/Layouts/AppSidebar.vue:547 +msgid "Masters" +msgstr "主数据" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:209 +#: frontend/src/components/Modals/EventModal.vue:86 +msgid "May 1, 2025" +msgstr "" + +#. Label of the medium (Data) field in PageType 'CRM Call Log' +#. Option for the 'Priority' (Select) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_task/crm_task.json +msgid "Medium" +msgstr "媒介" + +#. Option for the 'Type' (Select) field in PageType 'CRM Notification' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +msgid "Mention" +msgstr "@提及" + +#. Label of the message (HTML Editor) field in PageType 'CRM Notification' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +msgid "Message" +msgstr "消息" + +#. Label of the middle_name (Data) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Middle Name" +msgstr "中间名" + +#: frontend/src/components/Telephony/ExotelCallUI.vue:127 +msgid "Minimize" +msgstr "" + +#. Label of the mobile_no (Data) field in PageType 'CRM Contacts' +#. Label of the mobile_no (Data) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_contacts/crm_contacts.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Mobile No" +msgstr "手机号码" + +#: frontend/src/components/Modals/DealModal.vue:208 +#: frontend/src/components/Modals/LeadModal.vue:149 +msgid "Mobile No should be a number" +msgstr "手机号码应为数字" + +#. Label of the mobile_no (Data) field in PageType 'CRM Telephony Agent' +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +msgid "Mobile No." +msgstr "手机号" + +#: frontend/src/components/Telephony/CallUI.vue:22 +msgid "Mobile Number" +msgstr "手机号码" + +#: crm/integrations/exotel/handler.py:93 +msgid "Mobile Number Missing" +msgstr "手机号码缺失" + +#: frontend/src/components/Layouts/AppSidebar.vue:611 +msgid "Mobile app installation" +msgstr "" + +#: frontend/src/pages/Contact.vue:515 frontend/src/pages/MobileContact.vue:523 +#: frontend/src/pages/MobileOrganization.vue:467 +#: frontend/src/pages/Organization.vue:488 +msgid "Mobile no" +msgstr "手机号" + +#. Option for the 'Weekly Off' (Select) field in PageType 'CRM Holiday List' +#. Option for the 'Workday' (Select) field in PageType 'CRM Service Day' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +#: crm/fcrm/pagetype/crm_service_day/crm_service_day.json +msgid "Monday" +msgstr "周一" + +#: crm/api/dashboard.py:669 +msgid "Month" +msgstr "月" + +#: frontend/src/components/ViewControls.vue:221 +msgid "More Options" +msgstr "" + +#: frontend/src/components/FieldLayoutEditor.vue:448 +msgid "Move to next section" +msgstr "跳转至下一区块" + +#: frontend/src/components/FieldLayoutEditor.vue:401 +msgid "Move to next tab" +msgstr "切换至下一标签页" + +#: frontend/src/components/FieldLayoutEditor.vue:458 +msgid "Move to previous section" +msgstr "返回上一区块" + +#: frontend/src/components/FieldLayoutEditor.vue:387 +msgid "Move to previous tab" +msgstr "返回上一标签页" + +#: frontend/src/components/Modals/ViewModal.vue:29 +msgid "My Open Deals" +msgstr "我负责的开放商机" + +#. Label of the title (Data) field in PageType 'CRM Dashboard' +#. Label of the name1 (Data) field in PageType 'CRM Dropdown Item' +#. Label of the brand_name (Data) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/crm_dashboard/crm_dashboard.json +#: crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:51 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:52 +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:39 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:39 +#: frontend/src/components/ViewControls.vue:779 +#: frontend/src/pages/MobileOrganization.vue:485 +#: frontend/src/pages/Organization.vue:506 +msgid "Name" +msgstr "名称" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:417 +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:152 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:154 +msgid "Name is required" +msgstr "" + +#. Label of the naming_series (Select) field in PageType 'CRM Deal' +#. Label of the naming_series (Select) field in PageType 'CRM Product' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_product/crm_product.json +msgid "Naming Series" +msgstr "命名规则" + +#: frontend/src/components/ConditionsFilter/CFCondition.vue:99 +msgid "Nested conditions" +msgstr "" + +#. Label of the net_amount (Currency) field in PageType 'CRM Products' +#: crm/fcrm/pagetype/crm_products/crm_products.json +msgid "Net Amount" +msgstr "净额" + +#. Label of the net_total (Currency) field in PageType 'CRM Deal' +#. Label of the net_total (Currency) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Net Total" +msgstr "净总计" + +#: frontend/src/components/Activities/ActivityHeader.vue:76 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRules.vue:19 +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:19 +#: frontend/src/components/Settings/Users.vue:30 +msgid "New" +msgstr "新建" + +#: frontend/src/components/Modals/AddressModal.vue:93 +msgid "New Address" +msgstr "新建地址" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:12 +msgid "New Assignment Rule" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleListItem.vue:44 +msgid "New Assignment Rule Name" +msgstr "" + +#: frontend/src/components/Modals/CallLogModal.vue:97 +msgid "New Call Log" +msgstr "新建通话记录" + +#: frontend/src/components/Activities/Activities.vue:398 +#: frontend/src/components/Activities/ActivityHeader.vue:19 +#: frontend/src/components/Activities/ActivityHeader.vue:123 +msgid "New Comment" +msgstr "新建评论" + +#: frontend/src/components/Modals/ContactModal.vue:8 +msgid "New Contact" +msgstr "新建联系人" + +#: frontend/src/components/Activities/Activities.vue:393 +#: frontend/src/components/Activities/ActivityHeader.vue:12 +#: frontend/src/components/Activities/ActivityHeader.vue:118 +msgid "New Email" +msgstr "新建邮件" + +#: frontend/src/components/Activities/ActivityHeader.vue:66 +msgid "New Message" +msgstr "新建消息" + +#: frontend/src/components/Activities/ActivityHeader.vue:41 +#: frontend/src/components/Activities/ActivityHeader.vue:144 +#: frontend/src/pages/Deals.vue:511 frontend/src/pages/Leads.vue:538 +msgid "New Note" +msgstr "新建备注" + +#: frontend/src/components/Modals/OrganizationModal.vue:8 +msgid "New Organization" +msgstr "新建组织" + +#: frontend/src/components/Modals/ChangePasswordModal.vue:6 +msgid "New Password" +msgstr "新密码" + +#: frontend/src/components/FieldLayoutEditor.vue:201 +#: frontend/src/components/SidePanelLayoutEditor.vue:131 +msgid "New Section" +msgstr "新建区块" + +#: frontend/src/components/FieldLayoutEditor.vue:293 +#: frontend/src/components/FieldLayoutEditor.vue:298 +msgid "New Tab" +msgstr "新建标签页" + +#: frontend/src/components/Activities/ActivityHeader.vue:48 +#: frontend/src/components/Activities/ActivityHeader.vue:149 +#: frontend/src/pages/Deals.vue:516 frontend/src/pages/Leads.vue:543 +msgid "New Task" +msgstr "新建任务" + +#: frontend/src/components/Activities/ActivityHeader.vue:159 +msgid "New WhatsApp Message" +msgstr "新建WhatsApp消息" + +#: frontend/src/components/Modals/ConvertToDealModal.vue:67 +#: frontend/src/pages/MobileLead.vue:162 +msgid "New contact will be created based on the person's details" +msgstr "将根据个人信息新建联系人" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:431 +msgid "New event" +msgstr "" + +#: frontend/src/components/Modals/ConvertToDealModal.vue:42 +#: frontend/src/pages/MobileLead.vue:136 +msgid "New organization will be created based on the data in details section" +msgstr "将根据详情数据新建组织" + +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:10 +msgid "New template" +msgstr "" + +#: frontend/src/components/Modals/CreateDocumentModal.vue:88 +msgid "New {0}" +msgstr "新建 {0}" + +#: frontend/src/components/Filter.vue:663 +msgid "Next 6 Months" +msgstr "未来6个月" + +#: frontend/src/components/Filter.vue:655 +msgid "Next Month" +msgstr "下月" + +#: frontend/src/components/Filter.vue:659 +msgid "Next Quarter" +msgstr "下季度" + +#. Label of the next_step (Data) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "Next Step" +msgstr "下一步" + +#: frontend/src/components/Filter.vue:651 +msgid "Next Week" +msgstr "下周" + +#: frontend/src/components/Filter.vue:667 +msgid "Next Year" +msgstr "明年" + +#: frontend/src/components/Controls/Grid.vue:27 +msgid "No" +msgstr "否" + +#. Option for the 'Status' (Select) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "No Answer" +msgstr "无应答" + +#: frontend/src/components/Controls/Grid.vue:312 +msgid "No Data" +msgstr "无数据" + +#: frontend/src/components/Activities/EventArea.vue:78 +msgid "No Events Scheduled" +msgstr "" + +#: frontend/src/components/Kanban/KanbanView.vue:103 +#: frontend/src/pages/Deals.vue:105 frontend/src/pages/Leads.vue:121 +#: frontend/src/pages/Tasks.vue:71 +msgid "No Title" +msgstr "无标题" + +#: frontend/src/components/Settings/EmailEdit.vue:150 +msgid "No changes made" +msgstr "未作更改" + +#: frontend/src/components/Modals/SidePanelModal.vue:51 +#: frontend/src/pages/Deal.vue:261 frontend/src/pages/MobileDeal.vue:205 +msgid "No contacts added" +msgstr "未添加联系人" + +#: frontend/src/pages/Deal.vue:90 frontend/src/pages/Lead.vue:137 +msgid "No email set" +msgstr "未设置邮箱" + +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:48 +msgid "No email templates found" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRulesList.vue:14 +msgid "No items in the list" +msgstr "" + +#: frontend/src/components/FieldLayoutEditor.vue:92 +msgid "No label" +msgstr "无标签" + +#: frontend/src/pages/Deal.vue:697 +msgid "No mobile number set" +msgstr "未设置手机号" + +#: frontend/src/components/Notifications.vue:77 +#: frontend/src/pages/MobileNotification.vue:61 +msgid "No new notifications" +msgstr "无新通知" + +#: frontend/src/pages/Lead.vue:129 +msgid "No phone number set" +msgstr "未设置电话号码" + +#: frontend/src/pages/Deal.vue:692 +msgid "No primary contact set" +msgstr "未设置主要联系人" + +#: frontend/src/components/Calendar/Attendee.vue:232 +#: frontend/src/components/Controls/EmailMultiSelect.vue:133 +#: frontend/src/components/Settings/AssignmentRules/AssigneeSearch.vue:70 +msgid "No results found" +msgstr "" + +#: frontend/src/components/Modals/EmailTemplateSelectorModal.vue:66 +#: frontend/src/components/Modals/WhatsappTemplateSelectorModal.vue:42 +msgid "No templates found" +msgstr "未找到模板" + +#: frontend/src/components/Modals/AddExistingUserModal.vue:39 +#: frontend/src/components/Settings/Users.vue:57 +msgid "No users found" +msgstr "" + +#: frontend/src/pages/MobileOrganization.vue:281 +#: frontend/src/pages/Organization.vue:309 +msgid "No website found" +msgstr "" + +#: frontend/src/pages/Deal.vue:100 frontend/src/pages/Lead.vue:146 +msgid "No website set" +msgstr "未设置网站" + +#: frontend/src/components/PrimaryDropdown.vue:33 +msgid "No {0} Available" +msgstr "无可用{0}" + +#: frontend/src/pages/CallLogs.vue:59 frontend/src/pages/Contact.vue:156 +#: frontend/src/pages/Contacts.vue:58 frontend/src/pages/Deals.vue:234 +#: frontend/src/pages/Leads.vue:260 frontend/src/pages/MobileContact.vue:147 +#: frontend/src/pages/MobileOrganization.vue:139 +#: frontend/src/pages/Notes.vue:95 frontend/src/pages/Organization.vue:152 +#: frontend/src/pages/Organizations.vue:58 frontend/src/pages/Tasks.vue:184 +msgid "No {0} Found" +msgstr "未找到{0}" + +#. Label of the no_of_employees (Select) field in PageType 'CRM Deal' +#. Label of the no_of_employees (Select) field in PageType 'CRM Lead' +#. Label of the no_of_employees (Select) field in PageType 'CRM Organization' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "No. of Employees" +msgstr "员工数量" + +#: frontend/src/components/Activities/AudioPlayer.vue:148 +msgid "Normal" +msgstr "普通" + +#: crm/utils/__init__.py:263 +msgid "Not Allowed" +msgstr "不允许" + +#: frontend/src/components/Filter.vue:268 +#: frontend/src/components/Filter.vue:289 +#: frontend/src/components/Filter.vue:306 +#: frontend/src/components/Filter.vue:317 +#: frontend/src/components/Filter.vue:344 +msgid "Not Equals" +msgstr "不等于" + +#: frontend/src/components/Filter.vue:272 +#: frontend/src/components/Filter.vue:293 +#: frontend/src/components/Filter.vue:308 +#: frontend/src/components/Filter.vue:321 +#: frontend/src/components/Filter.vue:335 +msgid "Not In" +msgstr "不在" + +#: frontend/src/components/Filter.vue:270 +#: frontend/src/components/Filter.vue:281 +#: frontend/src/components/Filter.vue:291 +#: frontend/src/components/Filter.vue:319 +#: frontend/src/components/Filter.vue:333 +msgid "Not Like" +msgstr "不包含" + +#: frontend/src/components/Controls/GridFieldsEditorModal.vue:10 +#: frontend/src/components/Controls/GridRowFieldsModal.vue:10 +#: frontend/src/components/Modals/DataFieldsModal.vue:10 +#: frontend/src/components/Modals/QuickEntryModal.vue:10 +#: frontend/src/components/Modals/SidePanelModal.vue:10 +#: frontend/src/components/Settings/SettingsPage.vue:11 +#: frontend/src/components/Settings/TelephonySettings.vue:11 +msgid "Not Saved" +msgstr "未保存" + +#: crm/fcrm/pagetype/crm_deal/crm_deal.py:272 +msgid "Not allowed to add contact to Deal" +msgstr "无权向商机添加联系人" + +#: crm/fcrm/pagetype/crm_lead/crm_lead.py:408 +msgid "Not allowed to convert Lead to Deal" +msgstr "无权将线索转为商机" + +#: crm/fcrm/pagetype/crm_deal/crm_deal.py:283 +msgid "Not allowed to remove contact from Deal" +msgstr "无权从商机移除联系人" + +#: crm/fcrm/pagetype/crm_deal/crm_deal.py:294 +msgid "Not allowed to set primary contact for Deal" +msgstr "无权设置商机主要联系人" + +#. Label of the note (Link) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: frontend/src/components/Layouts/AppSidebar.vue:554 +msgid "Note" +msgstr "备注" + +#: frontend/src/pages/Deal.vue:562 frontend/src/pages/Lead.vue:419 +#: frontend/src/pages/MobileDeal.vue:461 frontend/src/pages/MobileLead.vue:368 +msgid "Notes" +msgstr "备注" + +#: frontend/src/pages/Notes.vue:23 +msgid "Notes View" +msgstr "备注视图" + +#: frontend/src/components/Activities/EmailArea.vue:15 +#: frontend/src/components/Layouts/AppSidebar.vue:583 +msgid "Notification" +msgstr "通知" + +#. Label of the notification_text (Text) field in PageType 'CRM Notification' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +msgid "Notification Text" +msgstr "通知内容" + +#. Label of the notification_type_pg (Dynamic Link) field in PageType 'CRM +#. Notification' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +msgid "Notification Type Pg" +msgstr "通知类型文档" + +#. Label of the notification_type_pagetype (Link) field in PageType 'CRM +#. Notification' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +msgid "Notification Type Pagetype" +msgstr "通知类型文档类型" + +#: frontend/src/components/Layouts/AppSidebar.vue:13 +#: frontend/src/components/Mobile/MobileSidebar.vue:23 +#: frontend/src/components/Notifications.vue:17 +#: frontend/src/pages/MobileNotification.vue:6 +msgid "Notifications" +msgstr "通知" + +#. Label of the number (Data) field in PageType 'CRM Telephony Phone' +#: crm/fcrm/pagetype/crm_telephony_phone/crm_telephony_phone.json +msgid "Number" +msgstr "编号" + +#: frontend/src/components/Dashboard/AddChartModal.vue:19 +#: frontend/src/components/Dashboard/AddChartModal.vue:69 +msgid "Number chart" +msgstr "" + +#: crm/api/dashboard.py:1027 crm/api/dashboard.py:1084 +msgid "Number of deals" +msgstr "" + +#: crm/api/dashboard.py:1077 +msgid "Number of deals and total value per salesperson" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:167 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:251 +msgid "Old Condition" +msgstr "" + +#. Label of the old_parent (Link) field in PageType 'CRM Territory' +#: crm/fcrm/pagetype/crm_territory/crm_territory.json +msgid "Old Parent" +msgstr "原上级" + +#. Option for the 'Type' (Select) field in PageType 'CRM Deal Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +msgid "On Hold" +msgstr "临时冻结" + +#. Option for the 'Type' (Select) field in PageType 'CRM Deal Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +msgid "Ongoing" +msgstr "" + +#: crm/api/dashboard.py:181 +#: frontend/src/components/Dashboard/AddChartModal.vue:77 +msgid "Ongoing deals" +msgstr "" + +#: frontend/src/utils/index.js:444 +msgid "Only image files are allowed" +msgstr "" + +#: crm/fcrm/pagetype/crm_deal/crm_deal.py:60 +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.py:23 +msgid "Only one {0} can be set as primary." +msgstr "仅可设置一个主要{0}" + +#. Option for the 'Type' (Select) field in PageType 'CRM Deal Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +msgid "Open" +msgstr "待处理" + +#: frontend/src/components/Modals/NoteModal.vue:13 +#: frontend/src/components/Modals/TaskModal.vue:13 +msgid "Open Deal" +msgstr "开放商机" + +#: frontend/src/components/Modals/NoteModal.vue:14 +#: frontend/src/components/Modals/TaskModal.vue:14 +msgid "Open Lead" +msgstr "开放线索" + +#: crm/fcrm/pagetype/crm_deal/crm_deal.js:6 +#: crm/fcrm/pagetype/crm_lead/crm_lead.js:6 +msgid "Open in Portal" +msgstr "在门户中打开" + +#. Label of the open_in_new_window (Check) field in PageType 'CRM Dropdown Item' +#: crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json +msgid "Open in new window" +msgstr "新窗口打开" + +#: frontend/src/components/ConditionsFilter/CFCondition.vue:88 +msgid "Open nested conditions" +msgstr "" + +#: frontend/src/pages/Organization.vue:90 +msgid "Open website" +msgstr "打开网站" + +#: frontend/src/components/Kanban/KanbanView.vue:218 +#: frontend/src/components/Modals/CallLogDetailModal.vue:15 +#: frontend/src/components/ViewControls.vue:199 +msgid "Options" +msgstr "选项" + +#: frontend/src/pages/Welcome.vue:40 +msgid "Or create leads manually" +msgstr "" + +#. Label of the order_by_tab (Tab Break) field in PageType 'CRM View Settings' +#. Label of the order_by (Code) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Order By" +msgstr "排序依据" + +#. Label of the organization (Link) field in PageType 'CRM Deal' +#. Label of the organization_tab (Tab Break) field in PageType 'CRM Deal' +#. Label of the organization (Data) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: frontend/src/components/Layouts/AppSidebar.vue:553 +#: frontend/src/components/Modals/ConvertToDealModal.vue:25 +#: frontend/src/pages/Contact.vue:494 frontend/src/pages/MobileContact.vue:502 +#: frontend/src/pages/MobileLead.vue:118 +#: frontend/src/pages/MobileOrganization.vue:446 +#: frontend/src/pages/MobileOrganization.vue:500 +#: frontend/src/pages/Organization.vue:467 +#: frontend/src/pages/Organization.vue:521 +msgid "Organization" +msgstr "组织" + +#. Label of the organization_details_section (Section Break) field in PageType +#. 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "Organization Details" +msgstr "组织详情" + +#. Label of the organization_logo (Attach Image) field in PageType 'CRM +#. Organization' +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "Organization Logo" +msgstr "组织徽标" + +#. Label of the organization_name (Data) field in PageType 'CRM Deal' +#. Label of the organization_name (Data) field in PageType 'CRM Organization' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "Organization Name" +msgstr "组织名称" + +#: frontend/src/pages/Deal.vue:62 +msgid "Organization logo" +msgstr "组织徽标" + +#. Label of a shortcut in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +#: frontend/src/pages/MobileOrganization.vue:205 +#: frontend/src/pages/Organization.vue:234 +msgid "Organizations" +msgstr "组织" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:107 +msgid "Organizer" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:575 +msgid "Other features" +msgstr "" + +#. Label of the organization_tab (Tab Break) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Others" +msgstr "其他" + +#: frontend/src/components/Activities/CallArea.vue:37 +msgid "Outbound Call" +msgstr "呼出通话" + +#. Option for the 'Type' (Select) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Outgoing" +msgstr "呼出" + +#. Label of the log_owner (Link) field in PageType 'CRM Status Change Log' +#: crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.json +msgid "Owner" +msgstr "负责人" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:102 +msgid "Owner: {0}" +msgstr "" + +#. Label of the parent_crm_territory (Link) field in PageType 'CRM Territory' +#: crm/fcrm/pagetype/crm_territory/crm_territory.json +msgid "Parent CRM Territory" +msgstr "上级CRM区域" + +#: frontend/src/components/Settings/emailConfig.js:64 +msgid "Password" +msgstr "密码" + +#: crm/api/demo.py:21 crm/api/demo.py:29 +msgid "Password cannot be reset by Demo User {}" +msgstr "演示用户{}无法重置密码" + +#: frontend/src/components/Settings/emailConfig.js:175 +msgid "Password is required" +msgstr "" + +#: frontend/src/components/Modals/ChangePasswordModal.vue:88 +msgid "Password updated successfully" +msgstr "" + +#: frontend/src/components/Modals/EmailTemplateSelectorModal.vue:13 +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:38 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:38 +msgid "Payment Reminder" +msgstr "付款提醒" + +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:69 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:69 +msgid "Payment Reminder from Frappé - (#{{ name }})" +msgstr "Frappé付款提醒 - (#{{ name }})" + +#. Option for the 'Status' (Select) field in PageType 'CRM Invitation' +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +msgid "Pending" +msgstr "待处理" + +#: frontend/src/components/Settings/InviteUserPage.vue:61 +msgid "Pending Invites" +msgstr "待处理邀请" + +#: frontend/src/pages/Dashboard.vue:66 +msgid "Period" +msgstr "期间" + +#. Label of the person_section (Section Break) field in PageType 'CRM Deal' +#. Label of the person_tab (Tab Break) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Person" +msgstr "个人" + +#: frontend/src/components/Settings/Settings.vue:89 +msgid "Personal Settings" +msgstr "" + +#. Label of the phone (Data) field in PageType 'CRM Contacts' +#. Label of the phone (Data) field in PageType 'CRM Lead' +#. Option for the 'Device' (Select) field in PageType 'CRM Telephony Agent' +#: crm/fcrm/pagetype/crm_contacts/crm_contacts.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +#: frontend/src/pages/MobileOrganization.vue:495 +#: frontend/src/pages/Organization.vue:516 +msgid "Phone" +msgstr "电话" + +#. Label of the phone_nos (Table) field in PageType 'CRM Telephony Agent' +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +msgid "Phone Numbers" +msgstr "电话号码" + +#: frontend/src/components/ViewControls.vue:1093 +msgid "Pin View" +msgstr "固定视图" + +#. Label of the pinned (Check) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Pinned" +msgstr "已固定" + +#: frontend/src/components/ViewControls.vue:677 +msgid "Pinned Views" +msgstr "固定视图" + +#: frontend/src/components/Layouts/AppSidebar.vue:571 +msgid "Pinned view" +msgstr "" + +#: frontend/src/components/Activities/AudioPlayer.vue:176 +msgid "Playback speed" +msgstr "播放速度" + +#: frontend/src/components/Settings/EmailAccountList.vue:49 +msgid "Please add an email account to continue." +msgstr "" + +#: crm/integrations/twilio/twilio_handler.py:119 +msgid "Please enable twilio settings before making a call." +msgstr "请先启用Twilio设置" + +#: frontend/src/components/FilesUploader/FilesUploader.vue:165 +msgid "Please enter a valid URL" +msgstr "请输入有效URL" + +#: frontend/src/components/Settings/CurrencySettings.vue:150 +msgid "Please enter the Exchangerate Host access key." +msgstr "" + +#: frontend/src/components/Modals/LostReasonModal.vue:9 +msgid "Please provide a reason for marking this deal as lost" +msgstr "" + +#: frontend/src/components/Settings/CurrencySettings.vue:143 +msgid "Please select a currency before saving." +msgstr "" + +#: frontend/src/components/Modals/ConvertToDealModal.vue:136 +#: frontend/src/pages/MobileLead.vue:432 +msgid "Please select an existing contact" +msgstr "请选择现有联系人" + +#: frontend/src/components/Modals/ConvertToDealModal.vue:141 +#: frontend/src/pages/MobileLead.vue:437 +msgid "Please select an existing organization" +msgstr "请选择现有组织" + +#: crm/fcrm/pagetype/helpdesk_crm_settings/helpdesk_crm_settings.py:126 +msgid "Please set Email Address" +msgstr "请设置电子邮件地址" + +#: crm/integrations/exotel/handler.py:73 +msgid "Please setup Exotel intergration" +msgstr "请配置Exotel集成" + +#: crm/fcrm/pagetype/crm_deal/crm_deal.py:181 +msgid "Please specify a reason for losing the deal." +msgstr "" + +#: crm/fcrm/pagetype/crm_deal/crm_deal.py:183 +msgid "Please specify the reason for losing the deal." +msgstr "" + +#. Label of the position (Int) field in PageType 'CRM Deal Status' +#. Label of the position (Int) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "Position" +msgstr "位置" + +#: frontend/src/pages/Deal.vue:205 frontend/src/pages/MobileDeal.vue:149 +msgid "Primary" +msgstr "主要" + +#. Label of the email (Data) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "Primary Email" +msgstr "主要邮箱" + +#. Label of the mobile_no (Data) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "Primary Mobile No" +msgstr "" + +#. Label of the phone (Data) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "Primary Phone" +msgstr "主要电话" + +#: frontend/src/pages/Deal.vue:669 frontend/src/pages/MobileDeal.vue:566 +msgid "Primary contact set" +msgstr "已设置主要联系人" + +#. Label of the priorities (Table) field in PageType 'CRM Service Level +#. Agreement' +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +msgid "Priorities" +msgstr "优先级" + +#. Label of the priority (Link) field in PageType 'CRM Service Level Priority' +#. Label of the priority (Select) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_service_level_priority/crm_service_level_priority.json +#: crm/fcrm/pagetype/crm_task/crm_task.json +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:64 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRulesList.vue:20 +msgid "Priority" +msgstr "优先级" + +#. Label of the private (Check) field in PageType 'CRM Dashboard' +#: crm/fcrm/pagetype/crm_dashboard/crm_dashboard.json +#: frontend/src/components/FilesUploader/FilesUploaderArea.vue:89 +msgid "Private" +msgstr "私有" + +#. Label of the probability (Percent) field in PageType 'CRM Deal' +#. Label of the probability (Percent) field in PageType 'CRM Deal Status' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +msgid "Probability" +msgstr "成交概率" + +#. Label of the product_code (Link) field in PageType 'CRM Products' +#: crm/fcrm/pagetype/crm_products/crm_products.json +msgid "Product" +msgstr "产品" + +#. Label of the product_code (Data) field in PageType 'CRM Product' +#: crm/fcrm/pagetype/crm_product/crm_product.json +msgid "Product Code" +msgstr "" + +#. Label of the product_name (Data) field in PageType 'CRM Product' +#. Label of the product_name (Data) field in PageType 'CRM Products' +#: crm/fcrm/pagetype/crm_product/crm_product.json +#: crm/fcrm/pagetype/crm_products/crm_products.json +msgid "Product Name" +msgstr "" + +#. Label of the products_tab (Tab Break) field in PageType 'CRM Deal' +#. Label of the products (Table) field in PageType 'CRM Deal' +#. Label of the products_tab (Tab Break) field in PageType 'CRM Lead' +#. Label of the products (Table) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Products" +msgstr "产品" + +#: frontend/src/components/Layouts/AppSidebar.vue:540 +#: frontend/src/components/Settings/Settings.vue:93 +msgid "Profile" +msgstr "个人资料" + +#: frontend/src/components/Settings/ProfileSettings.vue:147 +msgid "Profile updated successfully" +msgstr "个人资料更新成功" + +#: crm/api/dashboard.py:667 +msgid "Projected vs actual revenue based on deal probability" +msgstr "" + +#. Label of the public (Check) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Public" +msgstr "公开" + +#: frontend/src/components/ViewControls.vue:672 +msgid "Public Views" +msgstr "公开视图" + +#: frontend/src/components/Layouts/AppSidebar.vue:570 +msgid "Public view" +msgstr "" + +#. Label of the qty (Float) field in PageType 'CRM Products' +#: crm/fcrm/pagetype/crm_products/crm_products.json +msgid "Quantity" +msgstr "数量" + +#. Option for the 'Status' (Select) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Queued" +msgstr "已排队" + +#. Option for the 'Type' (Select) field in PageType 'CRM Fields Layout' +#: crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json +msgid "Quick Entry" +msgstr "快速录入" + +#. Option for the 'Type' (Select) field in PageType 'CRM Global Settings' +#: crm/fcrm/pagetype/crm_global_settings/crm_global_settings.json +msgid "Quick Filters" +msgstr "快速筛选" + +#: frontend/src/components/ViewControls.vue:731 +msgid "Quick Filters updated successfully" +msgstr "快速筛选更新成功" + +#: frontend/src/components/Layouts/AppSidebar.vue:594 +msgid "Quick entry layout" +msgstr "" + +#. Label of the rate (Currency) field in PageType 'CRM Products' +#: crm/fcrm/pagetype/crm_products/crm_products.json +msgid "Rate" +msgstr "单价" + +#. Label of the read (Check) field in PageType 'CRM Notification' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +msgid "Read" +msgstr "已读" + +#: crm/api/dashboard.py:886 +msgid "Reason" +msgstr "原因" + +#. Label of the record_calls (Check) field in PageType 'CRM Twilio Settings' +#: crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.json +msgid "Record Calls" +msgstr "录制通话" + +#. Label of the record_call (Check) field in PageType 'CRM Exotel Settings' +#: crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json +msgid "Record Outgoing Calls" +msgstr "录制呼出通话" + +#. Label of the recording_url (Data) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Recording URL" +msgstr "录音URL" + +#. Label of the reference_name (Dynamic Link) field in PageType 'CRM +#. Notification' +#. Label of the reference_docname (Dynamic Link) field in PageType 'CRM Task' +#. Label of the reference_docname (Dynamic Link) field in PageType 'FCRM Note' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +#: crm/fcrm/pagetype/crm_task/crm_task.json +#: crm/fcrm/pagetype/fcrm_note/fcrm_note.json +msgid "Reference Pg" +msgstr "关联文档" + +#. Label of the reference_pagetype (Link) field in PageType 'CRM Notification' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +msgid "Reference Pagetype" +msgstr "关联文档类型" + +#. Label of the reference_pagetype (Link) field in PageType 'CRM Call Log' +#. Label of the reference_pagetype (Link) field in PageType 'CRM Task' +#. Label of the reference_pagetype (Link) field in PageType 'FCRM Note' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_task/crm_task.json +#: crm/fcrm/pagetype/fcrm_note/fcrm_note.json +msgid "Reference Document Type" +msgstr "关联文档类型" + +#. Label of the reference_docname (Dynamic Link) field in PageType 'CRM Call +#. Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Reference Name" +msgstr "关联名称" + +#: frontend/src/components/ViewControls.vue:26 +#: frontend/src/components/ViewControls.vue:159 +#: frontend/src/pages/Dashboard.vue:10 +msgid "Refresh" +msgstr "刷新" + +#: frontend/src/components/Telephony/TwilioCallUI.vue:97 +msgid "Reject" +msgstr "拒绝" + +#: frontend/src/components/Telephony/TwilioCallUI.vue:163 +msgid "Reject call" +msgstr "" + +#: frontend/src/components/ConditionsFilter/CFCondition.vue:192 +#: frontend/src/components/Controls/ImageUploader.vue:25 +#: frontend/src/components/Settings/Users.vue:218 +#: frontend/src/pages/Deal.vue:618 +msgid "Remove" +msgstr "移除" + +#: frontend/src/components/FilesUploader/FilesUploader.vue:23 +msgid "Remove all" +msgstr "全部移除" + +#: frontend/src/components/FieldLayoutEditor.vue:438 +msgid "Remove and move fields to previous column" +msgstr "移除并将字段移至前一列" + +#: frontend/src/components/FieldLayoutEditor.vue:432 +msgid "Remove column" +msgstr "移除列" + +#: frontend/src/components/ConditionsFilter/CFCondition.vue:200 +msgid "Remove group" +msgstr "" + +#: frontend/src/components/Settings/ProfileSettings.vue:32 +#: frontend/src/pages/Contact.vue:47 frontend/src/pages/Lead.vue:94 +#: frontend/src/pages/MobileContact.vue:43 +#: frontend/src/pages/MobileOrganization.vue:43 +#: frontend/src/pages/Organization.vue:47 +msgid "Remove image" +msgstr "移除图片" + +#: frontend/src/components/FieldLayoutEditor.vue:359 +msgid "Remove section" +msgstr "移除区块" + +#: frontend/src/components/FieldLayoutEditor.vue:318 +msgid "Remove tab" +msgstr "移除标签页" + +#: frontend/src/components/Activities/EmailArea.vue:34 +#: frontend/src/components/CommunicationArea.vue:10 +msgid "Reply" +msgstr "回复" + +#: frontend/src/components/Activities/EmailArea.vue:41 +msgid "Reply All" +msgstr "回复全部" + +#: frontend/src/components/Modals/AboutModal.vue:72 +msgid "Report an Issue" +msgstr "提交一个问题" + +#. Option for the 'Type' (Select) field in PageType 'CRM Fields Layout' +#: crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json +msgid "Required Fields" +msgstr "必填字段" + +#: frontend/src/components/Controls/GridFieldsEditorModal.vue:79 +#: frontend/src/components/Controls/GridRowFieldsModal.vue:30 +#: frontend/src/components/Modals/DataFieldsModal.vue:30 +#: frontend/src/components/Modals/QuickEntryModal.vue:30 +#: frontend/src/components/Modals/SidePanelModal.vue:30 +msgid "Reset" +msgstr "重置" + +#: frontend/src/components/ColumnSettings.vue:78 +msgid "Reset Changes" +msgstr "撤销修改" + +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.js:7 +msgid "Reset ERPNext Form Script" +msgstr "重置ERPNext表单脚本" + +#: frontend/src/components/ColumnSettings.vue:86 +msgid "Reset to Default" +msgstr "恢复默认" + +#: frontend/src/pages/Dashboard.vue:28 +msgid "Reset to default" +msgstr "恢复默认设置" + +#. Label of the response_by (Datetime) field in PageType 'CRM Deal' +#. Label of the response_by (Datetime) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Response By" +msgstr "响应人" + +#. Label of the response_details_section (Section Break) field in PageType 'CRM +#. Deal' +#. Label of the response_details_section (Section Break) field in PageType 'CRM +#. Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Response Details" +msgstr "响应详情" + +#. Label of the section_break_ufaf (Section Break) field in PageType 'CRM +#. Service Level Agreement' +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +msgid "Response and Follow Up" +msgstr "响应与跟进" + +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.js:14 +msgid "Restore" +msgstr "恢复" + +#. Label of the restore_defaults (Button) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.js:13 +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "Restore Defaults" +msgstr "恢复默认值" + +#: frontend/src/components/FilesUploader/FilesUploader.vue:51 +msgid "Retake" +msgstr "重新拍摄" + +#: crm/api/dashboard.py:675 +msgid "Revenue" +msgstr "收入" + +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:81 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:81 +msgid "Rich Text" +msgstr "富文本" + +#. Label of the rgt (Int) field in PageType 'CRM Territory' +#: crm/fcrm/pagetype/crm_territory/crm_territory.json +msgid "Right" +msgstr "右侧" + +#. Option for the 'Status' (Select) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Ringing" +msgstr "响铃中" + +#: frontend/src/components/Telephony/TwilioCallUI.vue:38 +#: frontend/src/components/Telephony/TwilioCallUI.vue:140 +msgid "Ringing..." +msgstr "正在响铃..." + +#. Label of the role (Select) field in PageType 'CRM Invitation' +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +#: frontend/src/components/Modals/AddExistingUserModal.vue:46 +msgid "Role" +msgstr "角色" + +#. Option for the 'Type' (Select) field in PageType 'CRM Dropdown Item' +#. Label of the route (Data) field in PageType 'CRM Dropdown Item' +#: crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json +msgid "Route" +msgstr "路由" + +#. Label of the route_name (Data) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Route Name" +msgstr "路由名称" + +#. Label of the rows (Code) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Rows" +msgstr "行" + +#. Label of the sla_tab (Tab Break) field in PageType 'CRM Deal' +#. Label of the sla (Link) field in PageType 'CRM Deal' +#. Label of the sla_tab (Tab Break) field in PageType 'CRM Lead' +#. Label of the sla (Link) field in PageType 'CRM Lead' +#. Label of a shortcut in the Jingrow CRM Workspace +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +msgid "SLA" +msgstr "服务级别协议" + +#. Label of the sla_creation (Datetime) field in PageType 'CRM Deal' +#. Label of the sla_creation (Datetime) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "SLA Creation" +msgstr "SLA创建" + +#. Label of the sla_name (Data) field in PageType 'CRM Service Level Agreement' +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +msgid "SLA Name" +msgstr "SLA名称" + +#. Label of the sla_status (Select) field in PageType 'CRM Deal' +#. Label of the sla_status (Select) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "SLA Status" +msgstr "SLA状态" + +#: frontend/src/components/EmailEditor.vue:85 +msgid "SUBJECT" +msgstr "主题" + +#. Name of a role +#. Option for the 'Role' (Select) field in PageType 'CRM Invitation' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_communication_status/crm_communication_status.json +#: crm/fcrm/pagetype/crm_dashboard/crm_dashboard.json +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.json +#: crm/fcrm/pagetype/crm_global_settings/crm_global_settings.json +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +#: crm/fcrm/pagetype/crm_industry/crm_industry.json +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_lead_source/crm_lead_source.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +#: crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.json +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +#: crm/fcrm/pagetype/crm_task/crm_task.json +#: crm/fcrm/pagetype/crm_territory/crm_territory.json +#: crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.json +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json +#: crm/fcrm/pagetype/fcrm_note/fcrm_note.json +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +#: crm/fcrm/pagetype/helpdesk_crm_settings/helpdesk_crm_settings.json +msgid "Sales Manager" +msgstr "销售经理" + +#. Name of a role +#. Option for the 'Role' (Select) field in PageType 'CRM Invitation' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_communication_status/crm_communication_status.json +#: crm/fcrm/pagetype/crm_dashboard/crm_dashboard.json +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_global_settings/crm_global_settings.json +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +#: crm/fcrm/pagetype/crm_industry/crm_industry.json +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_lead_source/crm_lead_source.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +#: crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.json +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +#: crm/fcrm/pagetype/crm_task/crm_task.json +#: crm/fcrm/pagetype/crm_territory/crm_territory.json +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +#: crm/fcrm/pagetype/fcrm_note/fcrm_note.json +#: frontend/src/components/Modals/AddExistingUserModal.vue:92 +#: frontend/src/components/Settings/InviteUserPage.vue:156 +#: frontend/src/components/Settings/InviteUserPage.vue:163 +#: frontend/src/components/Settings/Users.vue:88 +#: frontend/src/components/Settings/Users.vue:194 +#: frontend/src/components/Settings/Users.vue:264 +#: frontend/src/components/Settings/Users.vue:267 +msgid "Sales User" +msgstr "销售人员" + +#: crm/api/dashboard.py:598 +#: frontend/src/components/Dashboard/AddChartModal.vue:94 +msgid "Sales trend" +msgstr "" + +#: frontend/src/pages/Dashboard.vue:93 +msgid "Sales user" +msgstr "" + +#: crm/api/dashboard.py:1079 +msgid "Salesperson" +msgstr "" + +#. Label of the salutation (Link) field in PageType 'CRM Deal' +#. Label of the salutation (Link) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Salutation" +msgstr "称呼" + +#. Option for the 'Weekly Off' (Select) field in PageType 'CRM Holiday List' +#. Option for the 'Workday' (Select) field in PageType 'CRM Service Day' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +#: crm/fcrm/pagetype/crm_service_day/crm_service_day.json +msgid "Saturday" +msgstr "周六" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:345 +#: frontend/src/components/Controls/GridFieldsEditorModal.vue:84 +#: frontend/src/components/Controls/GridRowFieldsModal.vue:26 +#: frontend/src/components/Modals/AddressModal.vue:98 +#: frontend/src/components/Modals/CallLogModal.vue:101 +#: frontend/src/components/Modals/DataFieldsModal.vue:26 +#: frontend/src/components/Modals/LostReasonModal.vue:44 +#: frontend/src/components/Modals/QuickEntryModal.vue:26 +#: frontend/src/components/Modals/SidePanelModal.vue:26 +#: frontend/src/components/PrimaryDropdownItem.vue:21 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:36 +#: frontend/src/components/Settings/CurrencySettings.vue:173 +#: frontend/src/components/Telephony/ExotelCallUI.vue:222 +#: frontend/src/components/ViewControls.vue:125 +#: frontend/src/pages/Dashboard.vue:36 +msgid "Save" +msgstr "保存" + +#: frontend/src/components/Modals/ViewModal.vue:40 +#: frontend/src/components/ViewControls.vue:58 +#: frontend/src/components/ViewControls.vue:155 +msgid "Save Changes" +msgstr "保存更改" + +#: frontend/src/components/ViewControls.vue:667 +msgid "Saved Views" +msgstr "已保存视图" + +#: frontend/src/components/Layouts/AppSidebar.vue:569 +msgid "Saved view" +msgstr "" + +#: frontend/src/components/Telephony/TaskPanel.vue:8 +msgid "Schedule a task..." +msgstr "安排任务..." + +#: frontend/src/components/Activities/EventArea.vue:79 +msgid "Schedule an Event" +msgstr "" + +#: frontend/src/components/Activities/ActivityHeader.vue:36 +#: frontend/src/components/Activities/ActivityHeader.vue:128 +msgid "Schedule an event" +msgstr "" + +#. Label of the script (Code) field in PageType 'CRM Form Script' +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.json +msgid "Script" +msgstr "脚本" + +#: frontend/src/components/Settings/AssignmentRules/AssigneeSearch.vue:22 +msgid "Search" +msgstr "搜索" + +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:64 +msgid "Search template" +msgstr "" + +#: frontend/src/components/Settings/Users.vue:73 +msgid "Search user" +msgstr "" + +#: frontend/src/components/FieldLayoutEditor.vue:336 +msgid "Section" +msgstr "区块" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:130 +msgid "See all participants" +msgstr "" + +#: frontend/src/pages/Dashboard.vue:50 +msgid "Select Range" +msgstr "" + +#: frontend/src/components/Settings/CurrencySettings.vue:51 +msgid "Select currency" +msgstr "" + +#: frontend/src/components/Settings/CurrencySettings.vue:75 +msgid "Select provider" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssigneeRules.vue:84 +msgid "Select the assignees for {0}." +msgstr "" + +#: frontend/src/components/FieldLayout/Field.vue:337 +msgid "Select {0}" +msgstr "选择{0}" + +#: frontend/src/components/EmailEditor.vue:165 +msgid "Send" +msgstr "发送" + +#: frontend/src/components/Settings/InviteUserPage.vue:18 +msgid "Send Invites" +msgstr "发送邀请" + +#: frontend/src/components/Activities/ActivityHeader.vue:61 +msgid "Send Template" +msgstr "发送模板" + +#: frontend/src/pages/Deal.vue:87 frontend/src/pages/Lead.vue:134 +msgid "Send an email" +msgstr "发送邮件" + +#: frontend/src/components/Layouts/AppSidebar.vue:460 +msgid "Send email" +msgstr "" + +#: frontend/src/components/Settings/InviteUserPage.vue:6 +msgid "Send invites to" +msgstr "" + +#. Option for the 'Type' (Select) field in PageType 'CRM Dropdown Item' +#: crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json +msgid "Separator" +msgstr "分隔符" + +#. Label of the naming_series (Select) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Series" +msgstr "系列" + +#. Label of the service_provider (Select) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "Service Provider" +msgstr "服务商" + +#: frontend/src/components/Layouts/AppSidebar.vue:581 +msgid "Service level agreement" +msgstr "" + +#: frontend/src/components/PrimaryDropdownItem.vue:27 +msgid "Set As Primary" +msgstr "" + +#: frontend/src/components/FilesUploader/FilesUploader.vue:66 +msgid "Set all as private" +msgstr "全部设为私有" + +#: frontend/src/components/FilesUploader/FilesUploader.vue:59 +msgid "Set all as public" +msgstr "全部设为公开" + +#: frontend/src/pages/Deal.vue:73 +msgid "Set an organization" +msgstr "设置组织" + +#: frontend/src/pages/Deal.vue:626 frontend/src/pages/MobileDeal.vue:523 +msgid "Set as Primary Contact" +msgstr "设为主要联系人" + +#: frontend/src/components/ViewControls.vue:1078 +msgid "Set as default" +msgstr "设为默认" + +#: frontend/src/components/Settings/CurrencySettings.vue:164 +msgid "Set currency" +msgstr "" + +#: frontend/src/pages/Lead.vue:115 +msgid "Set first name" +msgstr "设置名字" + +#: frontend/src/components/Layouts/AppSidebar.vue:533 +msgid "Setting up" +msgstr "系统配置中" + +#: frontend/src/components/Settings/emailConfig.js:145 +msgid "Setting up Jingrow Mail requires you to have an API key and API Secret of your email account. Read more " +msgstr "" + +#: frontend/src/components/Settings/emailConfig.js:97 +msgid "Setting up GMail requires you to enable two factor authentication\n" +"\t\t and app specific passwords. Read more" +msgstr "" + +#: frontend/src/components/Settings/emailConfig.js:105 +msgid "Setting up Outlook requires you to enable two factor authentication\n" +"\t\t and app specific passwords. Read more" +msgstr "" + +#: frontend/src/components/Settings/emailConfig.js:113 +msgid "Setting up Sendgrid requires you to enable two factor authentication\n" +"\t\t and app specific passwords. Read more " +msgstr "" + +#: frontend/src/components/Settings/emailConfig.js:121 +msgid "Setting up SparkPost requires you to enable two factor authentication\n" +"\t\t and app specific passwords. Read more " +msgstr "" + +#: frontend/src/components/Settings/emailConfig.js:129 +msgid "Setting up Yahoo requires you to enable two factor authentication\n" +"\t\t and app specific passwords. Read more " +msgstr "" + +#: frontend/src/components/Settings/emailConfig.js:137 +msgid "Setting up Yandex requires you to enable two factor authentication\n" +"\t\t and app specific passwords. Read more " +msgstr "" + +#. Label of the defaults_tab (Tab Break) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +#: frontend/src/components/Layouts/AppSidebar.vue:537 +#: frontend/src/components/Settings/Settings.vue:12 +msgid "Settings" +msgstr "设置" + +#: frontend/src/components/Settings/EmailAdd.vue:6 +msgid "Setup Email" +msgstr "" + +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.py:199 +msgid "Setup the Exchange Rate Provider as 'Exchangerate Host' in settings, as default provider does not support currency conversion for {0} to {1}." +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:339 +msgid "Setup your password" +msgstr "" + +#: frontend/src/components/Activities/Activities.vue:237 +msgid "Show" +msgstr "显示" + +#: frontend/src/components/Controls/Password.vue:19 +msgid "Show Password" +msgstr "" + +#: frontend/src/components/FieldLayoutEditor.vue:354 +msgid "Show border" +msgstr "显示边框" + +#: frontend/src/components/FieldLayoutEditor.vue:349 +msgid "Show label" +msgstr "显示标签" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:138 +msgid "Show less" +msgstr "" + +#: frontend/src/components/Controls/GridRowFieldsModal.vue:20 +#: frontend/src/components/Modals/DataFieldsModal.vue:20 +#: frontend/src/components/Modals/QuickEntryModal.vue:20 +#: frontend/src/components/Modals/SidePanelModal.vue:20 +msgid "Show preview" +msgstr "显示预览" + +#. Option for the 'Type' (Select) field in PageType 'CRM Fields Layout' +#: crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json +msgid "Side Panel" +msgstr "侧边栏" + +#. Option for the 'Type' (Select) field in PageType 'CRM Global Settings' +#: crm/fcrm/pagetype/crm_global_settings/crm_global_settings.json +msgid "Sidebar Items" +msgstr "侧边栏项" + +#. Description of the 'Condition' (Code) field in PageType 'CRM Service Level +#. Agreement' +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +msgid "Simple Python Expression, Example: pg.status == 'Open' and pg.lead_source == 'Ads'" +msgstr "简单Python表达式,示例:pg.status == '开放' and pg.lead_source == '广告'" + +#: frontend/src/components/AssignTo.vue:83 +msgid "Since you removed {0} from the assignee, the {0} has also been removed." +msgstr "" + +#: frontend/src/components/AssignTo.vue:76 +msgid "Since you removed {0} from the assignee, the {0} has been changed to the next available assignee {1}." +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:735 +msgid "Some error occurred while renaming assignment rule" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:720 +msgid "Some error occurred while updating assignment rule" +msgstr "" + +#: frontend/src/components/SortBy.vue:10 frontend/src/components/SortBy.vue:24 +#: frontend/src/components/SortBy.vue:232 +msgid "Sort" +msgstr "排序" + +#. Label of the source (Link) field in PageType 'CRM Deal' +#. Label of the source (Link) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: frontend/src/components/Modals/EditValueModal.vue:10 +msgid "Source" +msgstr "来源" + +#. Label of the source_name (Data) field in PageType 'CRM Lead Source' +#: crm/fcrm/pagetype/crm_lead_source/crm_lead_source.json +msgid "Source Name" +msgstr "来源名称" + +#: frontend/src/components/Dashboard/AddChartModal.vue:68 +#: frontend/src/components/Dashboard/DashboardItem.vue:21 +msgid "Spacer" +msgstr "空白分隔线" + +#: crm/api/dashboard.py:731 crm/api/dashboard.py:790 +msgid "Stage" +msgstr "阶段" + +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.js:15 +msgid "Standard Form Scripts can not be modified, duplicate the Form Script instead." +msgstr "标准表单脚本不可修改,请复制后进行编辑" + +#. Label of the standard_rate (Currency) field in PageType 'CRM Product' +#: crm/fcrm/pagetype/crm_product/crm_product.json +msgid "Standard Selling Rate" +msgstr "标准售价" + +#: frontend/src/components/ViewControls.vue:634 +msgid "Standard Views" +msgstr "标准视图" + +#. Label of the start_date (Date) field in PageType 'CRM Service Level +#. Agreement' +#. Label of the start_date (Date) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +#: crm/fcrm/pagetype/crm_task/crm_task.json +msgid "Start Date" +msgstr "开始日期" + +#. Label of the start_time (Datetime) field in PageType 'CRM Call Log' +#. Label of the start_time (Time) field in PageType 'CRM Service Day' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_service_day/crm_service_day.json +#: frontend/src/components/Calendar/CalendarEventPanel.vue:234 +#: frontend/src/components/Modals/EventModal.vue:103 +msgid "Start Time" +msgstr "开始时间" + +#: frontend/src/composables/event.js:198 +msgid "Start and end time are required" +msgstr "" + +#: frontend/src/pages/Welcome.vue:21 +msgid "Start with sample 10 leads" +msgstr "" + +#. Label of the status (Select) field in PageType 'CRM Call Log' +#. Label of the status (Data) field in PageType 'CRM Communication Status' +#. Label of the status (Link) field in PageType 'CRM Deal' +#. Label of the deal_status (Data) field in PageType 'CRM Deal Status' +#. Label of the status (Select) field in PageType 'CRM Invitation' +#. Label of the status (Link) field in PageType 'CRM Lead' +#. Label of the lead_status (Data) field in PageType 'CRM Lead Status' +#. Label of the status (Select) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_communication_status/crm_communication_status.json +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +#: crm/fcrm/pagetype/crm_task/crm_task.json frontend/src/pages/Contact.vue:505 +#: frontend/src/pages/MobileContact.vue:513 +#: frontend/src/pages/MobileOrganization.vue:457 +#: frontend/src/pages/Organization.vue:478 +msgid "Status" +msgstr "状态" + +#. Label of the status_change_log (Table) field in PageType 'CRM Deal' +#. Label of the status_change_log (Table) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Status Change Log" +msgstr "状态变更日志" + +#: frontend/src/components/Modals/DealModal.vue:216 +#: frontend/src/components/Modals/LeadModal.vue:157 +msgid "Status is required" +msgstr "状态为必填项" + +#. Label of the subdomain (Data) field in PageType 'CRM Exotel Settings' +#: crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json +msgid "Subdomain" +msgstr "子域名" + +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:68 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:68 +msgid "Subject" +msgstr "主题" + +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:156 +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:158 +msgid "Subject is required" +msgstr "必须填写主题" + +#: frontend/src/components/Modals/EmailTemplateSelectorModal.vue:45 +msgid "Subject: {0}" +msgstr "主题:{0}" + +#. Option for the 'Weekly Off' (Select) field in PageType 'CRM Holiday List' +#. Option for the 'Workday' (Select) field in PageType 'CRM Service Day' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +#: crm/fcrm/pagetype/crm_service_day/crm_service_day.json +msgid "Sunday" +msgstr "周日" + +#: frontend/src/components/Settings/emailConfig.js:16 +msgid "Support / Sales" +msgstr "" + +#: frontend/src/components/FilesUploader/FilesUploader.vue:46 +msgid "Switch camera" +msgstr "切换摄像头" + +#: frontend/src/pages/Welcome.vue:32 +msgid "Sync your contacts,email and calenders" +msgstr "" + +#: frontend/src/components/Settings/Settings.vue:105 +msgid "System Configuration" +msgstr "" + +#. Name of a role +#. Option for the 'Role' (Select) field in PageType 'CRM Invitation' +#: crm/fcrm/pagetype/crm_dashboard/crm_dashboard.json +#: crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json +#: crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json +#: crm/fcrm/pagetype/crm_global_settings/crm_global_settings.json +#: crm/fcrm/pagetype/crm_invitation/crm_invitation.json +#: crm/fcrm/pagetype/crm_lead_source/crm_lead_source.json +#: crm/fcrm/pagetype/crm_lost_reason/crm_lost_reason.json +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +#: crm/fcrm/pagetype/crm_product/crm_product.json +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +#: crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.json +#: crm/fcrm/pagetype/erpnext_crm_settings/erpnext_crm_settings.json +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +#: crm/fcrm/pagetype/helpdesk_crm_settings/helpdesk_crm_settings.json +msgid "System Manager" +msgstr "系统管理员" + +#: frontend/src/components/EmailEditor.vue:22 +msgid "TO" +msgstr "收件人" + +#: frontend/src/components/Telephony/ExotelCallUI.vue:149 +msgid "Take a note..." +msgstr "记录备注..." + +#. Option for the 'Type' (Select) field in PageType 'CRM Notification' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +#: frontend/src/components/Layouts/AppSidebar.vue:555 +msgid "Task" +msgstr "任务" + +#: frontend/src/pages/Deal.vue:557 frontend/src/pages/Lead.vue:414 +#: frontend/src/pages/MobileDeal.vue:456 frontend/src/pages/MobileLead.vue:363 +msgid "Tasks" +msgstr "任务" + +#: frontend/src/components/Modals/AboutModal.vue:67 +msgid "Telegram Channel" +msgstr "" + +#: frontend/src/components/Settings/Settings.vue:184 +msgid "Telephony" +msgstr "电话系统" + +#. Label of the telephony_medium (Select) field in PageType 'CRM Call Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +msgid "Telephony Medium" +msgstr "电话媒介" + +#: frontend/src/components/Settings/TelephonySettings.vue:8 +msgid "Telephony settings" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/NewEmailTemplate.vue:175 +msgid "Template created successfully" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:213 +msgid "Template deleted successfully" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:197 +msgid "Template disabled successfully" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:196 +msgid "Template enabled successfully" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/EmailTemplates.vue:83 +msgid "Template name" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:240 +msgid "Template renamed successfully" +msgstr "" + +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:205 +msgid "Template updated successfully" +msgstr "" + +#. Label of a shortcut in the Jingrow CRM Workspace +#: crm/fcrm/workspace/jingrow_crm/jingrow_crm.json +msgid "Territories" +msgstr "区域" + +#. Label of the territory (Link) field in PageType 'CRM Deal' +#. Label of the territory (Link) field in PageType 'CRM Lead' +#. Label of the territory (Link) field in PageType 'CRM Organization' +#: crm/api/dashboard.py:1022 crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "Territory" +msgstr "区域" + +#. Label of the territory_manager (Link) field in PageType 'CRM Territory' +#: crm/fcrm/pagetype/crm_territory/crm_territory.json +msgid "Territory Manager" +msgstr "区域经理" + +#. Label of the territory_name (Data) field in PageType 'CRM Territory' +#: crm/fcrm/pagetype/crm_territory/crm_territory.json +msgid "Territory Name" +msgstr "区域名称" + +#: crm/templates/emails/helpdesk_invitation.html:16 +msgid "Thanks" +msgstr "谢谢" + +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.py:46 +msgid "The Condition '{0}' is invalid: {1}" +msgstr "条件'{0}'无效:{1}" + +#. Description of the 'Exchange Rate' (Float) field in PageType 'CRM Deal' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +msgid "The rate used to convert the deal’s currency to your crm's base currency (set in CRM Settings). It is set once when the currency is first added and doesn't change automatically." +msgstr "" + +#. Description of the 'Exchange Rate' (Float) field in PageType 'CRM +#. Organization' +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +msgid "The rate used to convert the organization’s currency to your crm's base currency (set in CRM Settings). It is set once when the currency is first added and doesn't change automatically." +msgstr "" + +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.js:14 +msgid "There can only be one default priority in Priorities table" +msgstr "优先级表中只能有一个默认优先级" + +#: frontend/src/components/Modals/AddressModal.vue:128 +#: frontend/src/components/Modals/CallLogModal.vue:131 +msgid "These fields are required: {0}" +msgstr "" + +#: frontend/src/components/Filter.vue:639 +msgid "This Month" +msgstr "本月" + +#: frontend/src/components/Filter.vue:643 +msgid "This Quarter" +msgstr "本季度" + +#: frontend/src/components/Filter.vue:635 +msgid "This Week" +msgstr "本周" + +#: frontend/src/components/Filter.vue:647 +msgid "This Year" +msgstr "本年" + +#: frontend/src/components/SidePanelLayoutEditor.vue:116 +msgid "This section is not editable" +msgstr "此区块不可编辑" + +#: frontend/src/components/BulkDeleteLinkedDocModal.vue:59 +msgid "This will delete selected items and items linked to it, are you sure?" +msgstr "" + +#: frontend/src/components/BulkDeleteLinkedDocModal.vue:62 +msgid "This will delete selected items and unlink linked items to it, are you sure?" +msgstr "" + +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.js:9 +msgid "This will restore (if not exist) all the default statuses, custom fields and layouts. Delete & Restore will delete default layouts and then restore them." +msgstr "将恢复(如不存在)所有默认状态、自定义字段及布局。删除并恢复将删除默认布局后重新创建" + +#. Option for the 'Weekly Off' (Select) field in PageType 'CRM Holiday List' +#. Option for the 'Workday' (Select) field in PageType 'CRM Service Day' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +#: crm/fcrm/pagetype/crm_service_day/crm_service_day.json +msgid "Thursday" +msgstr "周四" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:227 +msgid "Time" +msgstr "时间" + +#: frontend/src/components/Filter.vue:351 +msgid "Timespan" +msgstr "时间跨度" + +#. Label of the title (Data) field in PageType 'CRM Task' +#. Label of the title (Data) field in PageType 'FCRM Note' +#: crm/fcrm/pagetype/crm_task/crm_task.json +#: crm/fcrm/pagetype/fcrm_note/fcrm_note.json +#: frontend/src/components/Modals/EventModal.vue:43 +#: frontend/src/components/Modals/NoteModal.vue:26 +#: frontend/src/components/Modals/TaskModal.vue:25 +msgid "Title" +msgstr "标题" + +#. Label of the title_field (Data) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +#: frontend/src/components/Kanban/KanbanSettings.vue:29 +msgid "Title Field" +msgstr "标题字段" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:545 +#: frontend/src/components/Modals/EventModal.vue:320 +msgid "Title is required" +msgstr "标题为必填项" + +#. Label of the to (Data) field in PageType 'CRM Call Log' +#. Label of the to (Data) field in PageType 'CRM Status Change Log' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.json +#: frontend/src/components/Activities/EmailArea.vue:53 +msgid "To" +msgstr "至" + +#. Label of the to_date (Date) field in PageType 'CRM Holiday List' +#. Label of the to_date (Datetime) field in PageType 'CRM Status Change Log' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +#: crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.json +msgid "To Date" +msgstr "截止日期" + +#. Label of the to_type (Data) field in PageType 'CRM Status Change Log' +#: crm/fcrm/pagetype/crm_status_change_log/crm_status_change_log.json +msgid "To Type" +msgstr "" + +#. Label of the to_user (Link) field in PageType 'CRM Notification' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +msgid "To User" +msgstr "目标用户" + +#: frontend/src/components/Settings/EmailEdit.vue:118 +msgid "To know more about setting up email accounts, click" +msgstr "" + +#: frontend/src/components/Filter.vue:627 frontend/src/pages/Calendar.vue:79 +msgid "Today" +msgstr "今天" + +#. Option for the 'Status' (Select) field in PageType 'CRM Task' +#: crm/fcrm/pagetype/crm_task/crm_task.json +msgid "Todo" +msgstr "待办" + +#: frontend/src/components/Modals/SidePanelModal.vue:59 +msgid "Toggle on for preview" +msgstr "切换预览模式" + +#: frontend/src/components/Filter.vue:631 +msgid "Tomorrow" +msgstr "明天" + +#: frontend/src/components/Modals/NoteModal.vue:42 +#: frontend/src/components/Modals/TaskModal.vue:46 +msgid "Took a call with John Doe and discussed the new project." +msgstr "与张三通话讨论新项目" + +#. Label of the total (Currency) field in PageType 'CRM Deal' +#. Label of the total (Currency) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Total" +msgstr "总计" + +#. Label of the total_holidays (Int) field in PageType 'CRM Holiday List' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +msgid "Total Holidays" +msgstr "总假期天数" + +#. Description of the 'Net Total' (Currency) field in PageType 'CRM Deal' +#. Description of the 'Net Total' (Currency) field in PageType 'CRM Lead' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +msgid "Total after discount" +msgstr "" + +#: crm/api/dashboard.py:123 +#: frontend/src/components/Dashboard/AddChartModal.vue:76 +msgid "Total leads" +msgstr "" + +#: crm/api/dashboard.py:124 +msgid "Total number of leads" +msgstr "" + +#: crm/api/dashboard.py:182 +msgid "Total number of non won/lost deals" +msgstr "" + +#: crm/api/dashboard.py:297 +msgid "Total number of won deals based on its closure date" +msgstr "" + +#. Option for the 'Weekly Off' (Select) field in PageType 'CRM Holiday List' +#. Option for the 'Workday' (Select) field in PageType 'CRM Service Day' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +#: crm/fcrm/pagetype/crm_service_day/crm_service_day.json +msgid "Tuesday" +msgstr "周二" + +#: frontend/src/components/ConditionsFilter/CFCondition.vue:173 +msgid "Turn into a group" +msgstr "" + +#. Label of the twiml_sid (Data) field in PageType 'CRM Twilio Settings' +#: crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.json +msgid "TwiML SID" +msgstr "TwiML SID" + +#. Option for the 'Telephony Medium' (Select) field in PageType 'CRM Call Log' +#. Label of the twilio (Check) field in PageType 'CRM Telephony Agent' +#. Option for the 'Default Medium' (Select) field in PageType 'CRM Telephony +#. Agent' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +#: frontend/src/components/Layouts/AppSidebar.vue:601 +#: frontend/src/components/Settings/TelephonySettings.vue:40 +#: frontend/src/components/Settings/TelephonySettings.vue:50 +msgid "Twilio" +msgstr "Twilio" + +#: crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.py:59 +#: crm/fcrm/pagetype/crm_twilio_settings/crm_twilio_settings.py:60 +msgid "Twilio API credential creation error." +msgstr "Twilio API凭证创建错误" + +#. Label of the twilio_number (Data) field in PageType 'CRM Telephony Agent' +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +msgid "Twilio Number" +msgstr "Twilio号码" + +#: frontend/src/components/Settings/TelephonySettings.vue:289 +msgid "Twilio is not enabled" +msgstr "Twilio未启用" + +#: frontend/src/components/Settings/TelephonySettings.vue:125 +msgid "Twilio settings updated successfully" +msgstr "Twilio设置更新成功" + +#. Label of the type (Select) field in PageType 'CRM Call Log' +#. Label of the type (Select) field in PageType 'CRM Deal Status' +#. Label of the type (Select) field in PageType 'CRM Dropdown Item' +#. Label of the type (Select) field in PageType 'CRM Fields Layout' +#. Label of the type (Select) field in PageType 'CRM Global Settings' +#. Label of the type (Select) field in PageType 'CRM Notification' +#. Label of the type (Select) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_call_log/crm_call_log.json +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_dropdown_item/crm_dropdown_item.json +#: crm/fcrm/pagetype/crm_fields_layout/crm_fields_layout.json +#: crm/fcrm/pagetype/crm_global_settings/crm_global_settings.json +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "Type" +msgstr "类型" + +#: frontend/src/components/Calendar/Attendee.vue:233 +msgid "Type an email address to add attendee" +msgstr "" + +#: frontend/src/components/Activities/WhatsAppBox.vue:85 +msgid "Type your message here..." +msgstr "在此输入消息..." + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:454 +msgid "Unassign conditions are invalid" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:224 +msgid "Unassignment condition" +msgstr "" + +#: crm/integrations/exotel/handler.py:170 +msgid "Unauthorized request" +msgstr "未授权的请求" + +#: frontend/src/components/FieldLayoutEditor.vue:344 +msgid "Uncollapsible" +msgstr "不可折叠" + +#: frontend/src/components/ConditionsFilter/CFCondition.vue:183 +msgid "Ungroup conditions" +msgstr "" + +#: frontend/src/components/Telephony/TwilioCallUI.vue:24 +#: frontend/src/components/Telephony/TwilioCallUI.vue:123 +msgid "Unknown" +msgstr "未知" + +#: frontend/src/components/BulkDeleteLinkedDocModal.vue:132 +msgid "Unlink" +msgstr "" + +#: frontend/src/components/DeleteLinkedDocModal.vue:78 +msgid "Unlink all" +msgstr "" + +#: frontend/src/components/BulkDeleteLinkedDocModal.vue:73 +msgid "Unlink and delete" +msgstr "" + +#: frontend/src/components/BulkDeleteLinkedDocModal.vue:35 +msgid "Unlink and delete {0} items" +msgstr "" + +#: frontend/src/components/DeleteLinkedDocModal.vue:243 +msgid "Unlink linked item" +msgstr "" + +#: frontend/src/components/DeleteLinkedDocModal.vue:79 +msgid "Unlink {0} item(s)" +msgstr "" + +#: frontend/src/components/ViewControls.vue:1093 +msgid "Unpin View" +msgstr "取消固定视图" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:22 +msgid "Unsaved" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:575 +msgid "Unsaved changes" +msgstr "" + +#: frontend/src/components/FieldLayoutEditor.vue:26 +#: frontend/src/components/Modals/AddressModal.vue:8 +#: frontend/src/components/Modals/CallLogModal.vue:8 +#: frontend/src/components/Modals/CreateDocumentModal.vue:8 +#: frontend/src/components/Section.vue:21 +#: frontend/src/components/SidePanelLayoutEditor.vue:19 +msgid "Untitled" +msgstr "未命名" + +#: frontend/src/components/ColumnSettings.vue:129 +#: frontend/src/components/Modals/AssignmentModal.vue:79 +#: frontend/src/components/Modals/ChangePasswordModal.vue:45 +#: frontend/src/components/Modals/EventModal.vue:156 +#: frontend/src/components/Modals/NoteModal.vue:52 +#: frontend/src/components/Modals/TaskModal.vue:106 +#: frontend/src/components/Settings/BrandSettings.vue:15 +#: frontend/src/components/Settings/CurrencySettings.vue:17 +#: frontend/src/components/Settings/EmailTemplate/EditEmailTemplate.vue:21 +#: frontend/src/components/Settings/HomeActions.vue:15 +#: frontend/src/components/Settings/ProfileSettings.vue:95 +#: frontend/src/components/Settings/SettingsPage.vue:20 +#: frontend/src/components/Settings/TelephonySettings.vue:23 +#: frontend/src/components/Telephony/ExotelCallUI.vue:210 +msgid "Update" +msgstr "更新" + +#: frontend/src/components/Settings/EmailEdit.vue:74 +msgid "Update Account" +msgstr "" + +#: frontend/src/components/Modals/EditValueModal.vue:30 +msgid "Update {0} Records" +msgstr "更新{0}条记录" + +#: frontend/src/components/Controls/ImageUploader.vue:20 +#: frontend/src/components/FilesUploader/FilesUploader.vue:83 +msgid "Upload" +msgstr "上传" + +#: frontend/src/components/Activities/Activities.vue:408 +#: frontend/src/components/Activities/ActivityHeader.vue:55 +#: frontend/src/components/Activities/ActivityHeader.vue:154 +msgid "Upload Attachment" +msgstr "上传附件" + +#: frontend/src/components/Activities/WhatsAppBox.vue:132 +msgid "Upload Document" +msgstr "上传文档" + +#: frontend/src/components/Activities/WhatsAppBox.vue:140 +msgid "Upload Image" +msgstr "上传图片" + +#: frontend/src/components/Activities/WhatsAppBox.vue:148 +msgid "Upload Video" +msgstr "上传视频" + +#: frontend/src/components/Settings/ProfileSettings.vue:27 +#: frontend/src/pages/Contact.vue:42 frontend/src/pages/Lead.vue:89 +#: frontend/src/pages/MobileContact.vue:38 +#: frontend/src/pages/MobileOrganization.vue:38 +#: frontend/src/pages/Organization.vue:42 +msgid "Upload image" +msgstr "上传图片" + +#: frontend/src/components/Controls/ImageUploader.vue:17 +msgid "Uploading {0}%" +msgstr "上传进度{0}%" + +#. Label of the user (Link) field in PageType 'CRM Dashboard' +#. Label of the user (Link) field in PageType 'CRM Telephony Agent' +#. Label of the user (Link) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_dashboard/crm_dashboard.json +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "User" +msgstr "用户" + +#: frontend/src/components/Settings/Settings.vue:126 +msgid "User Management" +msgstr "" + +#. Label of the user_name (Data) field in PageType 'CRM Telephony Agent' +#: crm/fcrm/pagetype/crm_telephony_agent/crm_telephony_agent.json +msgid "User Name" +msgstr "用户名" + +#: frontend/src/components/Settings/Users.vue:296 +msgid "User {0} has been removed" +msgstr "" + +#: frontend/src/components/Modals/AddExistingUserModal.vue:20 +#: frontend/src/components/Settings/Settings.vue:129 +#: frontend/src/components/Settings/Users.vue:7 +msgid "Users" +msgstr "用户" + +#: frontend/src/components/Modals/AddExistingUserModal.vue:105 +msgid "Users added successfully" +msgstr "" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:465 +msgid "Users are required" +msgstr "" + +#. Label of the section_break_nevd (Section Break) field in PageType 'CRM +#. Service Level Agreement' +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +msgid "Validity" +msgstr "有效期" + +#: frontend/src/components/Modals/EditValueModal.vue:14 +msgid "Value" +msgstr "值" + +#: frontend/src/components/Modals/ViewModal.vue:14 +msgid "View Name" +msgstr "视图名称" + +#: frontend/src/pages/Deal.vue:219 +msgid "View contact" +msgstr "" + +#: frontend/src/components/Layouts/AppSidebar.vue:566 +msgid "Views" +msgstr "视图" + +#: frontend/src/components/Layouts/AppSidebar.vue:563 +msgid "Web form" +msgstr "" + +#. Label of the webhook_verify_token (Data) field in PageType 'CRM Exotel +#. Settings' +#: crm/fcrm/pagetype/crm_exotel_settings/crm_exotel_settings.json +msgid "Webhook Verify Token" +msgstr "Webhook验证令牌" + +#. Label of the website (Data) field in PageType 'CRM Deal' +#. Label of the website (Data) field in PageType 'CRM Lead' +#. Label of the website (Data) field in PageType 'CRM Organization' +#: crm/fcrm/pagetype/crm_deal/crm_deal.json +#: crm/fcrm/pagetype/crm_lead/crm_lead.json +#: crm/fcrm/pagetype/crm_organization/crm_organization.json +#: frontend/src/components/Modals/AboutModal.vue:52 +msgid "Website" +msgstr "网站" + +#. Option for the 'Weekly Off' (Select) field in PageType 'CRM Holiday List' +#. Option for the 'Workday' (Select) field in PageType 'CRM Service Day' +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +#: crm/fcrm/pagetype/crm_service_day/crm_service_day.json +msgid "Wednesday" +msgstr "周三" + +#. Label of the weekly_off (Check) field in PageType 'CRM Holiday' +#. Label of the weekly_off (Select) field in PageType 'CRM Holiday List' +#: crm/fcrm/pagetype/crm_holiday/crm_holiday.json +#: crm/fcrm/pagetype/crm_holiday_list/crm_holiday_list.json +msgid "Weekly Off" +msgstr "每周休息" + +#: frontend/src/components/Modals/WhatsappTemplateSelectorModal.vue:11 +msgid "Welcome Message" +msgstr "欢迎消息" + +#: crm/fcrm/pagetype/helpdesk_crm_settings/helpdesk_crm_settings.py:155 +msgid "Welcome to Helpdesk" +msgstr "" + +#: frontend/src/pages/Welcome.vue:4 +msgid "Welcome {0}, lets add your first lead" +msgstr "" + +#. Option for the 'Type' (Select) field in PageType 'CRM Notification' +#: crm/fcrm/pagetype/crm_notification/crm_notification.json +#: frontend/src/components/Layouts/AppSidebar.vue:603 +#: frontend/src/components/Settings/Settings.vue:190 +#: frontend/src/pages/Deal.vue:572 frontend/src/pages/Lead.vue:429 +#: frontend/src/pages/MobileDeal.vue:471 frontend/src/pages/MobileLead.vue:378 +msgid "WhatsApp" +msgstr "WhatsApp" + +#: frontend/src/components/Modals/WhatsappTemplateSelectorModal.vue:4 +msgid "WhatsApp Templates" +msgstr "WhatsApp模板" + +#: frontend/src/components/ConditionsFilter/CFCondition.vue:20 +#: frontend/src/components/Filter.vue:43 frontend/src/components/Filter.vue:81 +msgid "Where" +msgstr "条件" + +#: frontend/src/components/ColumnSettings.vue:108 +msgid "Width" +msgstr "宽度" + +#: frontend/src/components/ColumnSettings.vue:113 +msgid "Width can be in number, pixel or rem (eg. 3, 30px, 10rem)" +msgstr "宽度可为数字、像素或rem(如3、30px、10rem)" + +#. Option for the 'Type' (Select) field in PageType 'CRM Deal Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +msgid "Won" +msgstr "" + +#: crm/api/dashboard.py:296 +#: frontend/src/components/Dashboard/AddChartModal.vue:79 +msgid "Won deals" +msgstr "" + +#. Label of the workday (Select) field in PageType 'CRM Service Day' +#: crm/fcrm/pagetype/crm_service_day/crm_service_day.json +msgid "Workday" +msgstr "工作日" + +#. Label of the section_break_rmgo (Section Break) field in PageType 'CRM +#. Service Level Agreement' +#. Label of the working_hours (Table) field in PageType 'CRM Service Level +#. Agreement' +#: crm/fcrm/pagetype/crm_service_level_agreement/crm_service_level_agreement.json +msgid "Working Hours" +msgstr "工作时间" + +#: frontend/src/components/Filter.vue:623 +msgid "Yesterday" +msgstr "昨天" + +#: crm/api/whatsapp.py:43 crm/api/whatsapp.py:223 crm/api/whatsapp.py:237 +#: frontend/src/components/Activities/WhatsAppArea.vue:34 +#: frontend/src/components/Activities/WhatsAppBox.vue:14 +msgid "You" +msgstr "您" + +#: crm/utils/__init__.py:262 +msgid "You are not permitted to access this resource." +msgstr "您无权访问此资源" + +#: crm/templates/emails/helpdesk_invitation.html:22 +msgid "You can also copy-paste following link in your browser" +msgstr "也可在浏览器中粘贴以下链接" + +#: frontend/src/components/Telephony/CallUI.vue:39 +msgid "You can change the default calling medium from the settings" +msgstr "可在设置中修改默认呼叫媒介" + +#: frontend/src/components/Settings/CurrencySettings.vue:100 +msgid "You can get your access key from " +msgstr "" + +#: frontend/src/components/Settings/InviteUserPage.vue:36 +msgid "You can invite multiple users by comma separating their email addresses" +msgstr "" + +#: crm/integrations/exotel/handler.py:85 +msgid "You do not have Exotel Number set in your Telephony Agent" +msgstr "您的电话客服未设置Exotel号码" + +#: crm/integrations/exotel/handler.py:93 +msgid "You do not have mobile number set in your Telephony Agent" +msgstr "您的电话客服未设置手机号码" + +#: frontend/src/data/document.js:32 +msgid "You do not have permission to access this document" +msgstr "" + +#: crm/fcrm/pagetype/crm_form_script/crm_form_script.py:24 +msgid "You need to be in developer mode to edit a Standard Form Script" +msgstr "需进入开发者模式才能编辑标准表单脚本" + +#: frontend/src/components/Settings/AssignmentRules/AssigneeSearch.vue:150 +msgid "You will be redirected to invite user page, unsaved changes will be lost." +msgstr "" + +#: crm/api/todo.py:100 +msgid "Your assignment on task {0} has been removed by {1}" +msgstr "{1}移除了您在任务{0}的分配" + +#: crm/api/todo.py:37 crm/api/todo.py:78 +msgid "Your assignment on {0} {1} has been removed by {2}" +msgstr "{2}移除了您在{0}{1}的分配" + +#: crm/templates/emails/helpdesk_invitation.html:6 +msgid "Your login id is" +msgstr "您的登录ID是" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:610 +msgid "Your old condition will be overwritten. Are you sure you want to save?" +msgstr "" + +#: frontend/src/components/Activities/CommentArea.vue:9 +msgid "added a" +msgstr "添加了" + +#. Option for the 'Color' (Select) field in PageType 'CRM Deal Status' +#. Option for the 'Color' (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "amber" +msgstr "琥珀色" + +#: crm/api/todo.py:109 +msgid "assigned a new task {0} to you" +msgstr "向您分配了新任务{0}" + +#: crm/api/todo.py:89 +msgid "assigned a {0} {1} to you" +msgstr "向您分配了{0}{1}" + +#. Option for the 'Color' (Select) field in PageType 'CRM Deal Status' +#. Option for the 'Color' (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "black" +msgstr "黑色" + +#. Option for the 'Color' (Select) field in PageType 'CRM Deal Status' +#. Option for the 'Color' (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "blue" +msgstr "蓝色" + +#: frontend/src/components/Activities/Activities.vue:239 +msgid "changes from" +msgstr "来自的更改" + +#: frontend/src/components/Activities/CommentArea.vue:11 +msgid "comment" +msgstr "评论" + +#: frontend/src/components/ConditionsFilter/CFCondition.vue:65 +#: frontend/src/components/ConditionsFilter/CFCondition.vue:73 +msgid "condition" +msgstr "条件" + +#. Option for the 'Color' (Select) field in PageType 'CRM Deal Status' +#. Option for the 'Color' (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "cyan" +msgstr "青色" + +#: frontend/src/components/Settings/AssignmentRules/AssigneeRules.vue:131 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:380 +msgid "deals" +msgstr "商机" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:190 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:274 +msgid "desk" +msgstr "工作台" + +#: frontend/src/components/Calendar/Attendee.vue:295 +#: frontend/src/components/Controls/EmailMultiSelect.vue:254 +msgid "email already exists" +msgstr "" + +#. Option for the 'Service Provider' (Select) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +#: frontend/src/components/Settings/CurrencySettings.vue:106 +msgid "exchangerate.host" +msgstr "汇率服务商" + +#. Option for the 'Service Provider' (Select) field in PageType 'FCRM Settings' +#: crm/fcrm/pagetype/fcrm_settings/fcrm_settings.json +msgid "frankfurter.app" +msgstr "法兰克福应用" + +#. Option for the 'Color' (Select) field in PageType 'CRM Deal Status' +#. Option for the 'Color' (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "gray" +msgstr "灰色" + +#. Option for the 'Color' (Select) field in PageType 'CRM Deal Status' +#. Option for the 'Color' (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "green" +msgstr "绿色" + +#. Option for the 'Type' (Select) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "group_by" +msgstr "分组依据" + +#: frontend/src/components/Activities/CallArea.vue:16 +msgid "has made a call" +msgstr "进行了通话" + +#: frontend/src/components/Activities/CallArea.vue:15 +msgid "has reached out" +msgstr "已联系" + +#: frontend/src/components/Settings/EmailAdd.vue:36 +#: frontend/src/components/Settings/EmailEdit.vue:25 +msgid "here" +msgstr "" + +#: frontend/src/utils/index.js:146 +msgid "in 1 hour" +msgstr "" + +#: frontend/src/utils/index.js:142 +msgid "in 1 minute" +msgstr "" + +#: frontend/src/utils/index.js:160 +msgid "in 1 year" +msgstr "" + +#: frontend/src/utils/index.js:111 +msgid "in {0} M" +msgstr "" + +#: frontend/src/utils/index.js:107 +msgid "in {0} d" +msgstr "" + +#: frontend/src/utils/index.js:154 +msgid "in {0} days" +msgstr "" + +#: frontend/src/utils/index.js:101 +msgid "in {0} h" +msgstr "" + +#: frontend/src/utils/index.js:148 +msgid "in {0} hours" +msgstr "" + +#: frontend/src/utils/index.js:99 +msgid "in {0} m" +msgstr "" + +#: frontend/src/utils/index.js:144 +msgid "in {0} minutes" +msgstr "" + +#: frontend/src/utils/index.js:158 +msgid "in {0} months" +msgstr "" + +#: frontend/src/utils/index.js:109 +msgid "in {0} w" +msgstr "" + +#: frontend/src/utils/index.js:156 +msgid "in {0} weeks" +msgstr "" + +#: frontend/src/utils/index.js:113 +msgid "in {0} y" +msgstr "" + +#: frontend/src/utils/index.js:162 +msgid "in {0} years" +msgstr "" + +#: frontend/src/components/Modals/AddExistingUserModal.vue:28 +msgid "john@doe.com" +msgstr "" + +#: frontend/src/utils/index.js:140 frontend/src/utils/index.js:166 +msgid "just now" +msgstr "刚刚" + +#. Option for the 'Type' (Select) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "kanban" +msgstr "看板" + +#: crm/api/pg.py:40 crm/api/pg.py:158 crm/api/pg.py:503 +msgid "label" +msgstr "标签" + +#: frontend/src/components/Settings/AssignmentRules/AssigneeRules.vue:130 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:379 +msgid "leads" +msgstr "线索" + +#. Option for the 'Type' (Select) field in PageType 'CRM View Settings' +#: crm/fcrm/pagetype/crm_view_settings/crm_view_settings.json +msgid "list" +msgstr "列表" + +#: crm/api/comment.py:36 frontend/src/components/Notifications.vue:59 +#: frontend/src/pages/MobileNotification.vue:46 +msgid "mentioned you in {0}" +msgstr "在{0}中提到您" + +#: frontend/src/components/FieldLayoutEditor.vue:368 +msgid "next" +msgstr "下一步" + +#: frontend/src/utils/index.js:97 frontend/src/utils/index.js:117 +msgid "now" +msgstr "现在" + +#: frontend/src/components/ConditionsFilter/CFCondition.vue:47 +msgid "operator" +msgstr "操作员" + +#. Option for the 'Color' (Select) field in PageType 'CRM Deal Status' +#. Option for the 'Color' (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "orange" +msgstr "橙色" + +#. Option for the 'Color' (Select) field in PageType 'CRM Deal Status' +#. Option for the 'Color' (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "pink" +msgstr "粉色" + +#: frontend/src/components/FieldLayoutEditor.vue:368 +msgid "previous" +msgstr "上一步" + +#: frontend/src/components/Activities/AttachmentArea.vue:97 +msgid "private" +msgstr "私有" + +#: frontend/src/components/Activities/AttachmentArea.vue:97 +msgid "public" +msgstr "公开" + +#. Option for the 'Color' (Select) field in PageType 'CRM Deal Status' +#. Option for the 'Color' (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "purple" +msgstr "紫色" + +#: crm/api/whatsapp.py:44 +msgid "received a whatsapp message in {0}" +msgstr "在{0}收到WhatsApp消息" + +#. Option for the 'Color' (Select) field in PageType 'CRM Deal Status' +#. Option for the 'Color' (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "red" +msgstr "红色" + +#. Option for the 'Color' (Select) field in PageType 'CRM Deal Status' +#. Option for the 'Color' (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "teal" +msgstr "青色" + +#: frontend/src/components/Activities/Activities.vue:278 +#: frontend/src/components/Activities/Activities.vue:341 +msgid "to" +msgstr "至" + +#: frontend/src/utils/index.js:105 frontend/src/utils/index.js:152 +msgid "tomorrow" +msgstr "明天" + +#. Option for the 'Color' (Select) field in PageType 'CRM Deal Status' +#. Option for the 'Color' (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "violet" +msgstr "紫罗兰色" + +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:193 +#: frontend/src/components/Settings/AssignmentRules/AssignmentRuleView.vue:277 +msgid "which are not compatible with this UI, you will need to recreate the conditions here if you want to manage and add new conditions from this UI." +msgstr "" + +#. Option for the 'Color' (Select) field in PageType 'CRM Deal Status' +#. Option for the 'Color' (Select) field in PageType 'CRM Lead Status' +#: crm/fcrm/pagetype/crm_deal_status/crm_deal_status.json +#: crm/fcrm/pagetype/crm_lead_status/crm_lead_status.json +msgid "yellow" +msgstr "黄色" + +#: frontend/src/utils/index.js:179 +msgid "yesterday" +msgstr "昨天" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:94 +msgid "{0} Attendees" +msgstr "" + +#: frontend/src/utils/index.js:130 +msgid "{0} M" +msgstr "{0} 月" + +#: crm/api/todo.py:41 +msgid "{0} assigned a {1} {2} to you" +msgstr "{0}向您分配了{1}{2}" + +#: frontend/src/utils/index.js:126 +msgid "{0} d" +msgstr "{0} 天" + +#: frontend/src/utils/index.js:181 +msgid "{0} days ago" +msgstr "{0}天前" + +#: frontend/src/utils/index.js:121 +msgid "{0} h" +msgstr "{0}小时" + +#: frontend/src/components/Settings/Users.vue:286 +msgid "{0} has been granted {1} access" +msgstr "" + +#: frontend/src/utils/index.js:174 +msgid "{0} hours ago" +msgstr "{0}小时前" + +#: frontend/src/composables/event.js:163 +msgid "{0} hrs" +msgstr "" + +#: frontend/src/components/Calendar/CalendarEventPanel.vue:309 +#: frontend/src/components/EmailEditor.vue:30 +#: frontend/src/components/EmailEditor.vue:66 +#: frontend/src/components/EmailEditor.vue:80 +#: frontend/src/components/Modals/AddExistingUserModal.vue:37 +#: frontend/src/components/Modals/EventModal.vue:127 +msgid "{0} is an invalid email address" +msgstr "{0}是无效的电子邮件地址" + +#: frontend/src/components/Modals/ConvertToDealModal.vue:172 +msgid "{0} is required" +msgstr "{0}是必填项" + +#: frontend/src/utils/index.js:119 +msgid "{0} m" +msgstr "{0} 分" + +#: frontend/src/composables/event.js:157 +msgid "{0} mins" +msgstr "" + +#: frontend/src/utils/index.js:170 +msgid "{0} minutes ago" +msgstr "{0}分钟前" + +#: frontend/src/utils/index.js:189 +msgid "{0} months ago" +msgstr "{0}个月前" + +#: frontend/src/utils/index.js:128 +msgid "{0} w" +msgstr "{0} 周" + +#: frontend/src/utils/index.js:185 +msgid "{0} weeks ago" +msgstr "{0}周前" + +#: frontend/src/utils/index.js:132 +msgid "{0} y" +msgstr "{0}年前" + +#: frontend/src/utils/index.js:193 +msgid "{0} years ago" +msgstr "{0}年前" + +#: frontend/src/data/script.js:326 +msgid "⚠️ Avoid using \"trigger\" as a field name — it conflicts with the built-in trigger() method." +msgstr "" + +#: frontend/src/data/script.js:338 +msgid "⚠️ Method \"{0}\" not found in class." +msgstr "" + +#: frontend/src/data/script.js:83 +msgid "⚠️ No class found for pagetype: {0}, it is mandatory to have a class for the parent pagetype. it can be empty, but it should be present." +msgstr "" + +#: frontend/src/data/script.js:180 +msgid "⚠️ No data found for parent field: {0}" +msgstr "" + +#: frontend/src/data/script.js:188 +msgid "⚠️ No row found for idx: {0} in parent field: {1}" +msgstr "" + diff --git a/crm/modules.txt b/crm/modules.txt new file mode 100644 index 0000000..e236191 --- /dev/null +++ b/crm/modules.txt @@ -0,0 +1 @@ +FCRM \ No newline at end of file diff --git a/crm/overrides/contact.py b/crm/overrides/contact.py new file mode 100644 index 0000000..8386534 --- /dev/null +++ b/crm/overrides/contact.py @@ -0,0 +1,50 @@ +# import jingrow +from jingrow import _ +from jingrow.contacts.pagetype.contact.contact import Contact + + +class CustomContact(Contact): + @staticmethod + def default_list_data(): + columns = [ + { + 'label': 'Name', + 'type': 'Data', + 'key': 'full_name', + 'width': '17rem', + }, + { + 'label': 'Email', + 'type': 'Data', + 'key': 'email_id', + 'width': '12rem', + }, + { + 'label': 'Phone', + 'type': 'Data', + 'key': 'mobile_no', + 'width': '12rem', + }, + { + 'label': 'Organization', + 'type': 'Data', + 'key': 'company_name', + 'width': '12rem', + }, + { + 'label': 'Last Modified', + 'type': 'Datetime', + 'key': 'modified', + 'width': '8rem', + }, + ] + rows = [ + "name", + "full_name", + "company_name", + "email_id", + "mobile_no", + "modified", + "image", + ] + return {'columns': columns, 'rows': rows} diff --git a/crm/overrides/email_template.py b/crm/overrides/email_template.py new file mode 100644 index 0000000..f87e481 --- /dev/null +++ b/crm/overrides/email_template.py @@ -0,0 +1,51 @@ +# import jingrow +from jingrow import _ +from jingrow.email.pagetype.email_template.email_template import EmailTemplate + + +class CustomEmailTemplate(EmailTemplate): + @staticmethod + def default_list_data(): + columns = [ + { + 'label': 'Name', + 'type': 'Data', + 'key': 'name', + 'width': '17rem', + }, + { + 'label': 'Subject', + 'type': 'Data', + 'key': 'subject', + 'width': '12rem', + }, + { + 'label': 'Enabled', + 'type': 'Check', + 'key': 'enabled', + 'width': '6rem', + }, + { + 'label': 'Pagetype', + 'type': 'Link', + 'key': 'reference_pagetype', + 'width': '12rem', + }, + { + 'label': 'Last Modified', + 'type': 'Datetime', + 'key': 'modified', + 'width': '8rem', + }, + ] + rows = [ + "name", + "enabled", + "use_html", + "reference_pagetype", + "subject", + "response", + "response_html", + "modified", + ] + return {'columns': columns, 'rows': rows} diff --git a/crm/patches.txt b/crm/patches.txt new file mode 100644 index 0000000..ae7ca15 --- /dev/null +++ b/crm/patches.txt @@ -0,0 +1,19 @@ +[pre_model_sync] +# Patches added in this section will be executed before doctypes are migrated +# Read docs to understand patches: https://framework.jingrow.com/docs/v14/user/en/database-migrations +crm.patches.v1_0.move_crm_note_data_to_fcrm_note +crm.patches.v1_0.rename_twilio_settings_to_crm_twilio_settings + +[post_model_sync] +# Patches added in this section will be executed after doctypes are migrated +crm.patches.v1_0.create_email_template_custom_fields +crm.patches.v1_0.create_default_fields_layout #22/01/2025 +crm.patches.v1_0.create_default_sidebar_fields_layout +crm.patches.v1_0.update_deal_quick_entry_layout +crm.patches.v1_0.update_layouts_to_new_format +crm.patches.v1_0.move_twilio_agent_to_telephony_agent +crm.patches.v1_0.create_default_scripts # 13-06-2025 +crm.patches.v1_0.update_deal_status_probabilities +crm.patches.v1_0.update_deal_status_type +crm.patches.v1_0.create_default_lost_reasons +crm.patches.v1_0.add_fields_in_assignment_rule diff --git a/crm/patches/v1_0/__init__.py b/crm/patches/v1_0/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/patches/v1_0/add_fields_in_assignment_rule.py b/crm/patches/v1_0/add_fields_in_assignment_rule.py new file mode 100644 index 0000000..72e21a6 --- /dev/null +++ b/crm/patches/v1_0/add_fields_in_assignment_rule.py @@ -0,0 +1,9 @@ +from crm.install import ( + add_assignment_rule_property_setters, + create_assignment_rule_custom_fields, +) + + +def execute(): + create_assignment_rule_custom_fields() + add_assignment_rule_property_setters() diff --git a/crm/patches/v1_0/create_default_fields_layout.py b/crm/patches/v1_0/create_default_fields_layout.py new file mode 100644 index 0000000..4f46047 --- /dev/null +++ b/crm/patches/v1_0/create_default_fields_layout.py @@ -0,0 +1,5 @@ +from crm.install import add_default_fields_layout + + +def execute(): + add_default_fields_layout() diff --git a/crm/patches/v1_0/create_default_lost_reasons.py b/crm/patches/v1_0/create_default_lost_reasons.py new file mode 100644 index 0000000..f6e43e1 --- /dev/null +++ b/crm/patches/v1_0/create_default_lost_reasons.py @@ -0,0 +1,5 @@ +from crm.install import add_default_lost_reasons + + +def execute(): + add_default_lost_reasons() diff --git a/crm/patches/v1_0/create_default_scripts.py b/crm/patches/v1_0/create_default_scripts.py new file mode 100644 index 0000000..37e3b0d --- /dev/null +++ b/crm/patches/v1_0/create_default_scripts.py @@ -0,0 +1,5 @@ +from crm.install import add_default_scripts + + +def execute(): + add_default_scripts() diff --git a/crm/patches/v1_0/create_default_sidebar_fields_layout.py b/crm/patches/v1_0/create_default_sidebar_fields_layout.py new file mode 100644 index 0000000..dc29992 --- /dev/null +++ b/crm/patches/v1_0/create_default_sidebar_fields_layout.py @@ -0,0 +1,63 @@ +import json +import jingrow + +def execute(): + if not jingrow.db.exists("CRM Fields Layout", {"dt": "CRM Lead", "type": "Side Panel"}): + create_pagetype_fields_layout("CRM Lead") + + if not jingrow.db.exists("CRM Fields Layout", {"dt": "CRM Deal", "type": "Side Panel"}): + create_pagetype_fields_layout("CRM Deal") + +def create_pagetype_fields_layout(pagetype): + not_allowed_fieldtypes = [ + "Section Break", + "Column Break", + ] + + fields = jingrow.get_meta(pagetype).fields + fields = [field for field in fields if field.fieldtype not in not_allowed_fieldtypes] + + sections = {} + section_fields = [] + last_section = None + + for field in fields: + if field.fieldtype == "Tab Break" and last_section: + sections[last_section]["fields"] = section_fields + last_section = None + if field.read_only: + section_fields = [] + continue + if field.fieldtype == "Tab Break": + if field.read_only: + section_fields = [] + continue + section_fields = [] + last_section = field.fieldname + sections[field.fieldname] = { + "label": field.label, + "name": field.fieldname, + "opened": True, + "fields": [], + } + if field.fieldname == "contacts_tab": + sections[field.fieldname]["editable"] = False + sections[field.fieldname]["contacts"] = [] + else: + section_fields.append(field.fieldname) + + section_fields = [] + for section in sections: + if section == "contacts_tab": + sections[section]["name"] = "contacts_section" + sections[section].pop("fields", None) + section_fields.append(sections[section]) + + jingrow.get_pg({ + "pagetype": "CRM Fields Layout", + "dt": pagetype, + "type": "Side Panel", + "layout": json.dumps(section_fields), + }).insert(ignore_permissions=True) + + return section_fields \ No newline at end of file diff --git a/crm/patches/v1_0/create_email_template_custom_fields.py b/crm/patches/v1_0/create_email_template_custom_fields.py new file mode 100644 index 0000000..ea6665d --- /dev/null +++ b/crm/patches/v1_0/create_email_template_custom_fields.py @@ -0,0 +1,5 @@ + +from crm.install import add_email_template_custom_fields + +def execute(): + add_email_template_custom_fields() \ No newline at end of file diff --git a/crm/patches/v1_0/move_crm_note_data_to_fcrm_note.py b/crm/patches/v1_0/move_crm_note_data_to_fcrm_note.py new file mode 100644 index 0000000..4d9dd9a --- /dev/null +++ b/crm/patches/v1_0/move_crm_note_data_to_fcrm_note.py @@ -0,0 +1,31 @@ +import jingrow +from jingrow.model.rename_pg import rename_pg + + +def execute(): + + if not jingrow.db.exists("PageType", "FCRM Note"): + jingrow.flags.ignore_route_conflict_validation = True + rename_pg("PageType", "CRM Note", "FCRM Note") + jingrow.flags.ignore_route_conflict_validation = False + + jingrow.reload_pagetype("FCRM Note", force=True) + + if jingrow.db.exists("PageType", "FCRM Note") and jingrow.db.count("FCRM Note") > 0: + return + + notes = jingrow.db.sql("SELECT * FROM `tabCRM Note`", as_dict=True) + if notes: + for note in notes: + pg = jingrow.get_pg({ + "pagetype": "FCRM Note", + "creation": note.get("creation"), + "modified": note.get("modified"), + "modified_by": note.get("modified_by"), + "owner": note.get("owner"), + "title": note.get("title"), + "content": note.get("content"), + "reference_pagetype": note.get("reference_pagetype"), + "reference_docname": note.get("reference_docname"), + }) + pg.db_insert() \ No newline at end of file diff --git a/crm/patches/v1_0/move_twilio_agent_to_telephony_agent.py b/crm/patches/v1_0/move_twilio_agent_to_telephony_agent.py new file mode 100644 index 0000000..c056172 --- /dev/null +++ b/crm/patches/v1_0/move_twilio_agent_to_telephony_agent.py @@ -0,0 +1,27 @@ +import jingrow + + +def execute(): + if not jingrow.db.exists("PageType", "CRM Telephony Agent"): + jingrow.reload_pagetype("CRM Telephony Agent", force=True) + + if jingrow.db.exists("PageType", "Twilio Agents") and jingrow.db.count("Twilio Agents") == 0: + return + + agents = jingrow.db.sql("SELECT * FROM `tabTwilio Agents`", as_dict=True) + if agents: + for agent in agents: + pg = jingrow.get_pg( + { + "pagetype": "CRM Telephony Agent", + "creation": agent.get("creation"), + "modified": agent.get("modified"), + "modified_by": agent.get("modified_by"), + "owner": agent.get("owner"), + "user": agent.get("user"), + "twilio_number": agent.get("twilio_number"), + "user_name": agent.get("user_name"), + "twilio": True, + } + ) + pg.db_insert() diff --git a/crm/patches/v1_0/rename_twilio_settings_to_crm_twilio_settings.py b/crm/patches/v1_0/rename_twilio_settings_to_crm_twilio_settings.py new file mode 100644 index 0000000..67f81d7 --- /dev/null +++ b/crm/patches/v1_0/rename_twilio_settings_to_crm_twilio_settings.py @@ -0,0 +1,20 @@ +import jingrow +from jingrow.model.rename_pg import rename_pg + + +def execute(): + if jingrow.db.exists("PageType", "Twilio Settings"): + jingrow.flags.ignore_route_conflict_validation = True + rename_pg("PageType", "Twilio Settings", "CRM Twilio Settings") + jingrow.flags.ignore_route_conflict_validation = False + + jingrow.reload_pagetype("CRM Twilio Settings", force=True) + + if jingrow.db.exists("__Auth", {"pagetype": "Twilio Settings"}): + Auth = jingrow.qb.PageType("__Auth") + result = jingrow.qb.from_(Auth).select("*").where(Auth.pagetype == "Twilio Settings").run(as_dict=True) + + for row in result: + jingrow.qb.into(Auth).insert( + "CRM Twilio Settings", "CRM Twilio Settings", row.fieldname, row.password, row.encrypted + ).run() diff --git a/crm/patches/v1_0/update_deal_quick_entry_layout.py b/crm/patches/v1_0/update_deal_quick_entry_layout.py new file mode 100644 index 0000000..35332ad --- /dev/null +++ b/crm/patches/v1_0/update_deal_quick_entry_layout.py @@ -0,0 +1,15 @@ +import json +import jingrow + +def execute(): + if not jingrow.db.exists("CRM Fields Layout", "CRM Deal-Quick Entry"): + return + + deal = jingrow.db.get_value("CRM Fields Layout", "CRM Deal-Quick Entry", "layout") + + layout = json.loads(deal) + for section in layout: + if section.get("label") in ["Select Organization", "Organization Details", "Select Contact", "Contact Details"]: + section["editable"] = False + + jingrow.db.set_value("CRM Fields Layout", "CRM Deal-Quick Entry", "layout", json.dumps(layout)) \ No newline at end of file diff --git a/crm/patches/v1_0/update_deal_status_probabilities.py b/crm/patches/v1_0/update_deal_status_probabilities.py new file mode 100644 index 0000000..012f8b8 --- /dev/null +++ b/crm/patches/v1_0/update_deal_status_probabilities.py @@ -0,0 +1,24 @@ +import jingrow + + +def execute(): + deal_statuses = jingrow.get_all("CRM Deal Status", fields=["name", "probability", "deal_status"]) + + for status in deal_statuses: + if status.probability is None or status.probability == 0: + if status.deal_status == "Qualification": + probability = 10 + elif status.deal_status == "Demo/Making": + probability = 25 + elif status.deal_status == "Proposal/Quotation": + probability = 50 + elif status.deal_status == "Negotiation": + probability = 70 + elif status.deal_status == "Ready to Close": + probability = 90 + elif status.deal_status == "Won": + probability = 100 + else: + probability = 0 + + jingrow.db.set_value("CRM Deal Status", status.name, "probability", probability) diff --git a/crm/patches/v1_0/update_deal_status_type.py b/crm/patches/v1_0/update_deal_status_type.py new file mode 100644 index 0000000..7b9b839 --- /dev/null +++ b/crm/patches/v1_0/update_deal_status_type.py @@ -0,0 +1,44 @@ +import jingrow + + +def execute(): + deal_statuses = jingrow.get_all("CRM Deal Status", fields=["name", "type", "deal_status"]) + + openStatuses = ["New", "Open", "Unassigned", "Qualification"] + ongoingStatuses = [ + "Demo/Making", + "Proposal/Quotation", + "Negotiation", + "Ready to Close", + "Demo Scheduled", + "Follow Up", + ] + onHoldStatuses = ["On Hold", "Paused", "Stalled", "Awaiting Reply"] + wonStatuses = ["Won", "Closed Won", "Successful", "Completed"] + lostStatuses = [ + "Lost", + "Closed", + "Closed Lost", + "Junk", + "Unqualified", + "Disqualified", + "Cancelled", + "No Response", + ] + + for status in deal_statuses: + if not status.type or status.type is None or status.type == "Open": + if status.deal_status in openStatuses: + type = "Open" + elif status.deal_status in ongoingStatuses: + type = "Ongoing" + elif status.deal_status in onHoldStatuses: + type = "On Hold" + elif status.deal_status in wonStatuses: + type = "Won" + elif status.deal_status in lostStatuses: + type = "Lost" + else: + type = "Ongoing" + + jingrow.db.set_value("CRM Deal Status", status.name, "type", type) diff --git a/crm/patches/v1_0/update_layouts_to_new_format.py b/crm/patches/v1_0/update_layouts_to_new_format.py new file mode 100644 index 0000000..ee64285 --- /dev/null +++ b/crm/patches/v1_0/update_layouts_to_new_format.py @@ -0,0 +1,101 @@ +import json +from math import ceil + +import jingrow +from jingrow.utils import random_string + + +def execute(): + layouts = jingrow.get_all("CRM Fields Layout", fields=["name", "layout", "type"]) + + for layout in layouts: + old_layout = layout.layout + new_layout = get_new_layout(old_layout, layout.type) + + jingrow.db.set_value("CRM Fields Layout", layout.name, "layout", new_layout) + + +def get_new_layout(old_layout, type): + if isinstance(old_layout, str): + old_layout = json.loads(old_layout) + new_layout = [] + already_converted = False + + starts_with_sections = False + + if not old_layout[0].get("sections"): + starts_with_sections = True + + if starts_with_sections: + old_layout = [{"sections": old_layout}] + + for tab in old_layout: + new_tab = tab.copy() + if "no_tabs" in new_tab: + new_tab.pop("no_tabs") + new_tab["sections"] = [] + new_tab["name"] = "tab_" + str(random_string(4)) + for section in tab.get("sections"): + section["name"] = section.get("name") or "section_" + str(random_string(4)) + + if section.get("label") == "Select Organization": + section["name"] = "organization_section" + section["hidden"] = 1 + elif section.get("label") == "Organization Details": + section["name"] = "organization_details_section" + elif section.get("label") == "Select Contact": + section["name"] = "contact_section" + section["hidden"] = 1 + elif section.get("label") == "Contact Details": + section["name"] = "contact_details_section" + + if "contacts" in section: + new_tab["sections"].append(section) + continue + if isinstance(section.get("columns"), list): + already_converted = True + break + column_count = section.get("columns") or 3 + if type == "Side Panel": + column_count = 1 + fields = section.get("fields") or [] + + new_section = section.copy() + + if "fields" in new_section: + new_section.pop("fields") + new_section["columns"] = [] + + if len(fields) == 0: + new_section["columns"].append({"name": "column_" + str(random_string(4)), "fields": []}) + new_tab["sections"].append(new_section) + continue + + if len(fields) == 1 and column_count > 1: + new_section["columns"].append( + {"name": "column_" + str(random_string(4)), "fields": [fields[0]]} + ) + new_section["columns"].append({"name": "column_" + str(random_string(4)), "fields": []}) + new_tab["sections"].append(new_section) + continue + + fields_per_column = ceil(len(fields) / column_count) + for i in range(column_count): + new_column = { + "name": "column_" + str(random_string(4)), + "fields": fields[i * fields_per_column : (i + 1) * fields_per_column], + } + new_section["columns"].append(new_column) + new_tab["sections"].append(new_section) + new_layout.append(new_tab) + + if starts_with_sections: + new_layout = new_layout[0].get("sections") + + if already_converted: + new_layout = old_layout + + if type == "Side Panel" and "sections" in new_layout[0]: + new_layout = new_layout[0].get("sections") + + return json.dumps(new_layout) diff --git a/crm/public/.gitkeep b/crm/public/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/crm/public/images/desk.png b/crm/public/images/desk.png new file mode 100644 index 0000000..f4a0959 Binary files /dev/null and b/crm/public/images/desk.png differ diff --git a/crm/public/images/logo.png b/crm/public/images/logo.png new file mode 100644 index 0000000..5881304 Binary files /dev/null and b/crm/public/images/logo.png differ diff --git a/crm/public/images/logo.svg b/crm/public/images/logo.svg new file mode 100644 index 0000000..e203a0f --- /dev/null +++ b/crm/public/images/logo.svg @@ -0,0 +1,4 @@ + + + + diff --git a/crm/public/manifest/apple-icon-180.png b/crm/public/manifest/apple-icon-180.png new file mode 100644 index 0000000..f1fde19 Binary files /dev/null and b/crm/public/manifest/apple-icon-180.png differ diff --git a/crm/public/manifest/apple-splash-1125-2436.jpg b/crm/public/manifest/apple-splash-1125-2436.jpg new file mode 100644 index 0000000..1440fa0 Binary files /dev/null and b/crm/public/manifest/apple-splash-1125-2436.jpg differ diff --git a/crm/public/manifest/apple-splash-1136-640.jpg b/crm/public/manifest/apple-splash-1136-640.jpg new file mode 100644 index 0000000..8eb7bf6 Binary files /dev/null and b/crm/public/manifest/apple-splash-1136-640.jpg differ diff --git a/crm/public/manifest/apple-splash-1170-2532.jpg b/crm/public/manifest/apple-splash-1170-2532.jpg new file mode 100644 index 0000000..8b1b82a Binary files /dev/null and b/crm/public/manifest/apple-splash-1170-2532.jpg differ diff --git a/crm/public/manifest/apple-splash-1179-2556.jpg b/crm/public/manifest/apple-splash-1179-2556.jpg new file mode 100644 index 0000000..c0c6833 Binary files /dev/null and b/crm/public/manifest/apple-splash-1179-2556.jpg differ diff --git a/crm/public/manifest/apple-splash-1242-2208.jpg b/crm/public/manifest/apple-splash-1242-2208.jpg new file mode 100644 index 0000000..f084d35 Binary files /dev/null and b/crm/public/manifest/apple-splash-1242-2208.jpg differ diff --git a/crm/public/manifest/apple-splash-1242-2688.jpg b/crm/public/manifest/apple-splash-1242-2688.jpg new file mode 100644 index 0000000..bdeff56 Binary files /dev/null and b/crm/public/manifest/apple-splash-1242-2688.jpg differ diff --git a/crm/public/manifest/apple-splash-1284-2778.jpg b/crm/public/manifest/apple-splash-1284-2778.jpg new file mode 100644 index 0000000..29a25be Binary files /dev/null and b/crm/public/manifest/apple-splash-1284-2778.jpg differ diff --git a/crm/public/manifest/apple-splash-1290-2796.jpg b/crm/public/manifest/apple-splash-1290-2796.jpg new file mode 100644 index 0000000..0fca8c1 Binary files /dev/null and b/crm/public/manifest/apple-splash-1290-2796.jpg differ diff --git a/crm/public/manifest/apple-splash-1334-750.jpg b/crm/public/manifest/apple-splash-1334-750.jpg new file mode 100644 index 0000000..ec3ea1b Binary files /dev/null and b/crm/public/manifest/apple-splash-1334-750.jpg differ diff --git a/crm/public/manifest/apple-splash-1488-2266.jpg b/crm/public/manifest/apple-splash-1488-2266.jpg new file mode 100644 index 0000000..1d7cb48 Binary files /dev/null and b/crm/public/manifest/apple-splash-1488-2266.jpg differ diff --git a/crm/public/manifest/apple-splash-1536-2048.jpg b/crm/public/manifest/apple-splash-1536-2048.jpg new file mode 100644 index 0000000..de01574 Binary files /dev/null and b/crm/public/manifest/apple-splash-1536-2048.jpg differ diff --git a/crm/public/manifest/apple-splash-1620-2160.jpg b/crm/public/manifest/apple-splash-1620-2160.jpg new file mode 100644 index 0000000..cde84c9 Binary files /dev/null and b/crm/public/manifest/apple-splash-1620-2160.jpg differ diff --git a/crm/public/manifest/apple-splash-1640-2360.jpg b/crm/public/manifest/apple-splash-1640-2360.jpg new file mode 100644 index 0000000..a33bfd0 Binary files /dev/null and b/crm/public/manifest/apple-splash-1640-2360.jpg differ diff --git a/crm/public/manifest/apple-splash-1668-2224.jpg b/crm/public/manifest/apple-splash-1668-2224.jpg new file mode 100644 index 0000000..d8ccacb Binary files /dev/null and b/crm/public/manifest/apple-splash-1668-2224.jpg differ diff --git a/crm/public/manifest/apple-splash-1668-2388.jpg b/crm/public/manifest/apple-splash-1668-2388.jpg new file mode 100644 index 0000000..bb2ebc8 Binary files /dev/null and b/crm/public/manifest/apple-splash-1668-2388.jpg differ diff --git a/crm/public/manifest/apple-splash-1792-828.jpg b/crm/public/manifest/apple-splash-1792-828.jpg new file mode 100644 index 0000000..f085722 Binary files /dev/null and b/crm/public/manifest/apple-splash-1792-828.jpg differ diff --git a/crm/public/manifest/apple-splash-2048-1536.jpg b/crm/public/manifest/apple-splash-2048-1536.jpg new file mode 100644 index 0000000..f4213ad Binary files /dev/null and b/crm/public/manifest/apple-splash-2048-1536.jpg differ diff --git a/crm/public/manifest/apple-splash-2048-2732.jpg b/crm/public/manifest/apple-splash-2048-2732.jpg new file mode 100644 index 0000000..70b1e47 Binary files /dev/null and b/crm/public/manifest/apple-splash-2048-2732.jpg differ diff --git a/crm/public/manifest/apple-splash-2160-1620.jpg b/crm/public/manifest/apple-splash-2160-1620.jpg new file mode 100644 index 0000000..7398911 Binary files /dev/null and b/crm/public/manifest/apple-splash-2160-1620.jpg differ diff --git a/crm/public/manifest/apple-splash-2208-1242.jpg b/crm/public/manifest/apple-splash-2208-1242.jpg new file mode 100644 index 0000000..0da15d6 Binary files /dev/null and b/crm/public/manifest/apple-splash-2208-1242.jpg differ diff --git a/crm/public/manifest/apple-splash-2224-1668.jpg b/crm/public/manifest/apple-splash-2224-1668.jpg new file mode 100644 index 0000000..cd5bf16 Binary files /dev/null and b/crm/public/manifest/apple-splash-2224-1668.jpg differ diff --git a/crm/public/manifest/apple-splash-2266-1488.jpg b/crm/public/manifest/apple-splash-2266-1488.jpg new file mode 100644 index 0000000..5b8d7f1 Binary files /dev/null and b/crm/public/manifest/apple-splash-2266-1488.jpg differ diff --git a/crm/public/manifest/apple-splash-2360-1640.jpg b/crm/public/manifest/apple-splash-2360-1640.jpg new file mode 100644 index 0000000..6b112de Binary files /dev/null and b/crm/public/manifest/apple-splash-2360-1640.jpg differ diff --git a/crm/public/manifest/apple-splash-2388-1668.jpg b/crm/public/manifest/apple-splash-2388-1668.jpg new file mode 100644 index 0000000..62b35cd Binary files /dev/null and b/crm/public/manifest/apple-splash-2388-1668.jpg differ diff --git a/crm/public/manifest/apple-splash-2436-1125.jpg b/crm/public/manifest/apple-splash-2436-1125.jpg new file mode 100644 index 0000000..30fe3e9 Binary files /dev/null and b/crm/public/manifest/apple-splash-2436-1125.jpg differ diff --git a/crm/public/manifest/apple-splash-2532-1170.jpg b/crm/public/manifest/apple-splash-2532-1170.jpg new file mode 100644 index 0000000..420ecd2 Binary files /dev/null and b/crm/public/manifest/apple-splash-2532-1170.jpg differ diff --git a/crm/public/manifest/apple-splash-2556-1179.jpg b/crm/public/manifest/apple-splash-2556-1179.jpg new file mode 100644 index 0000000..a1d4841 Binary files /dev/null and b/crm/public/manifest/apple-splash-2556-1179.jpg differ diff --git a/crm/public/manifest/apple-splash-2688-1242.jpg b/crm/public/manifest/apple-splash-2688-1242.jpg new file mode 100644 index 0000000..6c445c9 Binary files /dev/null and b/crm/public/manifest/apple-splash-2688-1242.jpg differ diff --git a/crm/public/manifest/apple-splash-2732-2048.jpg b/crm/public/manifest/apple-splash-2732-2048.jpg new file mode 100644 index 0000000..f4a7fe2 Binary files /dev/null and b/crm/public/manifest/apple-splash-2732-2048.jpg differ diff --git a/crm/public/manifest/apple-splash-2778-1284.jpg b/crm/public/manifest/apple-splash-2778-1284.jpg new file mode 100644 index 0000000..bef5009 Binary files /dev/null and b/crm/public/manifest/apple-splash-2778-1284.jpg differ diff --git a/crm/public/manifest/apple-splash-2796-1290.jpg b/crm/public/manifest/apple-splash-2796-1290.jpg new file mode 100644 index 0000000..e55a267 Binary files /dev/null and b/crm/public/manifest/apple-splash-2796-1290.jpg differ diff --git a/crm/public/manifest/apple-splash-640-1136.jpg b/crm/public/manifest/apple-splash-640-1136.jpg new file mode 100644 index 0000000..d8bb053 Binary files /dev/null and b/crm/public/manifest/apple-splash-640-1136.jpg differ diff --git a/crm/public/manifest/apple-splash-750-1334.jpg b/crm/public/manifest/apple-splash-750-1334.jpg new file mode 100644 index 0000000..4e3713f Binary files /dev/null and b/crm/public/manifest/apple-splash-750-1334.jpg differ diff --git a/crm/public/manifest/apple-splash-828-1792.jpg b/crm/public/manifest/apple-splash-828-1792.jpg new file mode 100644 index 0000000..ae35bb0 Binary files /dev/null and b/crm/public/manifest/apple-splash-828-1792.jpg differ diff --git a/crm/public/manifest/manifest-icon-192.maskable.png b/crm/public/manifest/manifest-icon-192.maskable.png new file mode 100644 index 0000000..a600fec Binary files /dev/null and b/crm/public/manifest/manifest-icon-192.maskable.png differ diff --git a/crm/public/manifest/manifest-icon-512.maskable.png b/crm/public/manifest/manifest-icon-512.maskable.png new file mode 100644 index 0000000..de352b1 Binary files /dev/null and b/crm/public/manifest/manifest-icon-512.maskable.png differ diff --git a/crm/public/videos/changeDealStatus.mov b/crm/public/videos/changeDealStatus.mov new file mode 100644 index 0000000..eccdfec Binary files /dev/null and b/crm/public/videos/changeDealStatus.mov differ diff --git a/crm/public/videos/convertToDeal.mov b/crm/public/videos/convertToDeal.mov new file mode 100644 index 0000000..9da4b45 Binary files /dev/null and b/crm/public/videos/convertToDeal.mov differ diff --git a/crm/templates/__init__.py b/crm/templates/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/templates/emails/crm_invitation.html b/crm/templates/emails/crm_invitation.html new file mode 100644 index 0000000..6ecb415 --- /dev/null +++ b/crm/templates/emails/crm_invitation.html @@ -0,0 +1,4 @@ +

You have been invited to join Jingrow CRM

+

+ Accept Invitation +

diff --git a/crm/templates/pages/__init__.py b/crm/templates/pages/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/uninstall.py b/crm/uninstall.py new file mode 100644 index 0000000..ca01268 --- /dev/null +++ b/crm/uninstall.py @@ -0,0 +1,23 @@ +# Copyright (c) 2022, JINGROW and Contributors +# MIT License. See license.txt +import click +import jingrow + + +def before_uninstall(): + delete_email_template_custom_fields() + + +def delete_email_template_custom_fields(): + if jingrow.get_meta("Email Template").has_field("enabled"): + click.secho("* Uninstalling Custom Fields from Email Template") + + fieldnames = ( + "enabled", + "reference_pagetype", + ) + + for fieldname in fieldnames: + jingrow.db.delete("Custom Field", {"name": "Email Template-" + fieldname}) + + jingrow.clear_cache(pagetype="Email Template") diff --git a/crm/utils/__init__.py b/crm/utils/__init__.py new file mode 100644 index 0000000..4e63719 --- /dev/null +++ b/crm/utils/__init__.py @@ -0,0 +1,269 @@ +import functools + +import jingrow +import phonenumbers +import requests +from jingrow import _ +from jingrow.model.pagestatus import PageStatus +from jingrow.model.dynamic_links import get_dynamic_link_map +from jingrow.utils import floor +from phonenumbers import NumberParseException +from phonenumbers import PhoneNumberFormat as PNF + + +def parse_phone_number(phone_number, default_country="IN"): + try: + # Parse the number + number = phonenumbers.parse(phone_number, default_country) + + # Get various information about the number + result = { + "is_valid": phonenumbers.is_valid_number(number), + "country_code": number.country_code, + "national_number": str(number.national_number), + "formats": { + "international": phonenumbers.format_number(number, PNF.INTERNATIONAL), + "national": phonenumbers.format_number(number, PNF.NATIONAL), + "E164": phonenumbers.format_number(number, PNF.E164), + "RFC3966": phonenumbers.format_number(number, PNF.RFC3966), + }, + "type": phonenumbers.number_type(number), + "country": phonenumbers.region_code_for_number(number), + "is_possible": phonenumbers.is_possible_number(number), + } + + return {"success": True, **result} + except NumberParseException as e: + return {"success": False, "error": str(e)} + + +def are_same_phone_number(number1, number2, default_region="IN", validate=True): + """ + Check if two phone numbers are the same, regardless of their format. + + Args: + number1 (str): First phone number + number2 (str): Second phone number + default_region (str): Default region code for parsing ambiguous numbers + + Returns: + bool: True if numbers are same, False otherwise + """ + try: + # Parse both numbers + parsed1 = phonenumbers.parse(number1, default_region) + parsed2 = phonenumbers.parse(number2, default_region) + + # Check if both numbers are valid + if validate and not (phonenumbers.is_valid_number(parsed1) and phonenumbers.is_valid_number(parsed2)): + return False + + # Convert both to E164 format and compare + formatted1 = phonenumbers.format_number(parsed1, phonenumbers.PhoneNumberFormat.E164) + formatted2 = phonenumbers.format_number(parsed2, phonenumbers.PhoneNumberFormat.E164) + + return formatted1 == formatted2 + + except phonenumbers.NumberParseException: + return False + + +def seconds_to_duration(seconds): + if not seconds: + return "0s" + + hours = floor(seconds // 3600) + minutes = floor((seconds % 3600) // 60) + seconds = floor((seconds % 3600) % 60) + + # 1h 0m 0s -> 1h + # 0h 1m 0s -> 1m + # 0h 0m 1s -> 1s + # 1h 1m 0s -> 1h 1m + # 1h 0m 1s -> 1h 1s + # 0h 1m 1s -> 1m 1s + # 1h 1m 1s -> 1h 1m 1s + + if hours and minutes and seconds: + return f"{hours}h {minutes}m {seconds}s" + elif hours and minutes: + return f"{hours}h {minutes}m" + elif hours and seconds: + return f"{hours}h {seconds}s" + elif minutes and seconds: + return f"{minutes}m {seconds}s" + elif hours: + return f"{hours}h" + elif minutes: + return f"{minutes}m" + elif seconds: + return f"{seconds}s" + else: + return "0s" + + +# Extracted from jingrow core jingrow/model/delete_pg.py/check_if_pg_is_linked +def get_linked_docs(pg, method="Delete"): + from jingrow.model.rename_pg import get_link_fields + + link_fields = get_link_fields(pg.pagetype) + ignored_doctypes = set() + + if method == "Cancel" and (pg_ignore_flags := pg.get("ignore_linked_doctypes")): + ignored_doctypes.update(pg_ignore_flags) + if method == "Delete": + ignored_doctypes.update(jingrow.get_hooks("ignore_links_on_delete")) + + docs = [] + + for lf in link_fields: + link_dt, link_field, issingle = lf["parent"], lf["fieldname"], lf["issingle"] + if link_dt in ignored_doctypes or (link_field == "amended_from" and method == "Cancel"): + continue + + try: + meta = jingrow.get_meta(link_dt) + except jingrow.DoesNotExistError: + jingrow.clear_last_message() + # This mostly happens when app do not remove their customizations, we shouldn't + # prevent link checks from failing in those cases + continue + + if issingle: + if jingrow.db.get_single_value(link_dt, link_field) == pg.name: + docs.append({"pg": pg.name, "link_dt": link_dt, "link_field": link_field}) + continue + + fields = ["name", "pagestatus"] + + if meta.istable: + fields.extend(["parent", "parenttype"]) + + for item in jingrow.db.get_values(link_dt, {link_field: pg.name}, fields, as_dict=True): + # available only in child table cases + item_parent = getattr(item, "parent", None) + linked_parent_pagetype = item.parenttype if item_parent else link_dt + + if linked_parent_pagetype in ignored_doctypes: + continue + + if method != "Delete" and (method != "Cancel" or not PageStatus(item.pagestatus).is_submitted()): + # don't raise exception if not + # linked to a non-cancelled pg when deleting or to a submitted pg when cancelling + continue + elif link_dt == pg.pagetype and (item_parent or item.name) == pg.name: + # don't raise exception if not + # linked to same item or pg having same name as the item + continue + else: + reference_docname = item_parent or item.name + docs.append( + { + "pg": pg.name, + "reference_pagetype": linked_parent_pagetype, + "reference_docname": reference_docname, + } + ) + return docs + + +# Extracted from jingrow core jingrow/model/delete_pg.py/check_if_pg_is_dynamically_linked +def get_dynamic_linked_docs(pg, method="Delete"): + docs = [] + for df in get_dynamic_link_map().get(pg.pagetype, []): + ignore_linked_doctypes = pg.get("ignore_linked_doctypes") or [] + + if df.parent in jingrow.get_hooks("ignore_links_on_delete") or ( + df.parent in ignore_linked_doctypes and method == "Cancel" + ): + # don't check for communication and todo! + continue + + meta = jingrow.get_meta(df.parent) + if meta.issingle: + # dynamic link in single pg + refdoc = jingrow.db.get_singles_dict(df.parent) + if ( + refdoc.get(df.options) == pg.pagetype + and refdoc.get(df.fieldname) == pg.name + and ( + # linked to an non-cancelled pg when deleting + (method == "Delete" and not PageStatus(refdoc.pagestatus).is_cancelled()) + # linked to a submitted pg when cancelling + or (method == "Cancel" and PageStatus(refdoc.pagestatus).is_submitted()) + ) + ): + docs.append({"pg": pg.name, "reference_pagetype": df.parent, "reference_docname": df.parent}) + else: + # dynamic link in table + df["table"] = ", `parent`, `parenttype`, `idx`" if meta.istable else "" + for refdoc in jingrow.db.sql( + """select `name`, `pagestatus` {table} from `tab{parent}` where + `{options}`=%s and `{fieldname}`=%s""".format(**df), + (pg.pagetype, pg.name), + as_dict=True, + ): + # linked to an non-cancelled pg when deleting + # or linked to a submitted pg when cancelling + if (method == "Delete" and not PageStatus(refdoc.pagestatus).is_cancelled()) or ( + method == "Cancel" and PageStatus(refdoc.pagestatus).is_submitted() + ): + reference_pagetype = refdoc.parenttype if meta.istable else df.parent + reference_docname = refdoc.parent if meta.istable else refdoc.name + + if reference_pagetype in jingrow.get_hooks("ignore_links_on_delete") or ( + reference_pagetype in ignore_linked_doctypes and method == "Cancel" + ): + # don't check for communication and todo! + continue + + at_position = f"at Row: {refdoc.idx}" if meta.istable else "" + + docs.append( + { + "pg": pg.name, + "reference_pagetype": reference_pagetype, + "reference_docname": reference_docname, + "at_position": at_position, + } + ) + return docs + + +def is_admin(user: str | None = None) -> bool: + """ + Check whether `user` is an admin + + :param user: User to check against, defaults to current user + :return: Whether `user` is an admin + """ + user = user or jingrow.session.user + return user == "Administrator" + + +def is_sales_user(user: str | None = None) -> bool: + """ + Check whether `user` is an agent + + :param user: User to check against, defaults to current user + :return: Whether `user` is an agent + """ + user = user or jingrow.session.user + return is_admin() or "Sales Manager" in jingrow.get_roles(user) or "Sales User" in jingrow.get_roles(user) + + +def sales_user_only(fn): + """Decorator to validate if user is an agent.""" + + @functools.wraps(fn) + def wrapper(*args, **kwargs): + if not is_sales_user(): + jingrow.throw( + msg=_("You are not permitted to access this resource."), + title=_("Not Allowed"), + exc=jingrow.PermissionError, + ) + + return fn(*args, **kwargs) + + return wrapper diff --git a/crm/www/__init__.py b/crm/www/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm/www/crm.py b/crm/www/crm.py new file mode 100644 index 0000000..9016fc0 --- /dev/null +++ b/crm/www/crm.py @@ -0,0 +1,65 @@ +# Copyright (c) 2022, JINGROW and Contributors +# GNU GPLv3 License. See license.txt +import os +import subprocess + +import jingrow +from jingrow import safe_decode +from jingrow.integrations.jingrow_providers.jingrowcloud_billing import is_fc_site +from jingrow.utils import cint, get_system_timezone +from jingrow.utils.telemetry import capture + +no_cache = 1 + + +def get_context(): + jingrow.db.commit() + context = jingrow._dict() + context.boot = get_boot() + if jingrow.session.user != "Guest": + capture("active_site", "crm") + return context + + +@jingrow.whitelist(methods=["POST"], allow_guest=True) +def get_context_for_dev(): + if not jingrow.conf.developer_mode: + jingrow.throw("This method is only meant for developer mode") + return get_boot() + + +def get_boot(): + return jingrow._dict( + { + "jingrow_version": jingrow.__version__, + "default_route": get_default_route(), + "site_name": jingrow.local.site, + "read_only_mode": jingrow.flags.read_only, + "csrf_token": jingrow.sessions.get_csrf_token(), + "setup_complete": cint(jingrow.get_system_settings("setup_complete")), + "sysdefaults": jingrow.defaults.get_defaults(), + "is_demo_site": jingrow.conf.get("is_demo_site"), + "is_fc_site": is_fc_site(), + "timezone": { + "system": get_system_timezone(), + "user": jingrow.db.get_value("User", jingrow.session.user, "time_zone") + or get_system_timezone(), + }, + } + ) + + +def get_default_route(): + return "/crm" + + +def run_git_command(command): + try: + with open(os.devnull, "wb") as null_stream: + result = subprocess.check_output(command, shell=True, stdin=null_stream, stderr=null_stream) + return safe_decode(result).strip() + except Exception: + jingrow.log_error( + title="Git Command Error", + ) + return "" diff --git a/crowdin.yml b/crowdin.yml new file mode 100644 index 0000000..aebaa70 --- /dev/null +++ b/crowdin.yml @@ -0,0 +1,8 @@ +files: + - source: /crm/locale/main.pot + translation: /crm/locale/%two_letters_code%.po +pull_request_title: "chore: sync translations from crowdin" +pull_request_labels: + - translation +commit_message: "chore: %language% translations" +append_commit_message: false \ No newline at end of file diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 0000000..ec3e719 --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1,6 @@ +node_modules +.DS_Store +dist +dist-ssr +*.local +components.d.ts \ No newline at end of file diff --git a/frontend/.prettierrc.json b/frontend/.prettierrc.json new file mode 100644 index 0000000..b2095be --- /dev/null +++ b/frontend/.prettierrc.json @@ -0,0 +1,4 @@ +{ + "semi": false, + "singleQuote": true +} diff --git a/frontend/README.md b/frontend/README.md new file mode 100644 index 0000000..a51f37e --- /dev/null +++ b/frontend/README.md @@ -0,0 +1,42 @@ +# Jingrow UI Starter + +This template should help get you started developing custom frontend for Jingrow +apps with Vue 3 and the Jingrow UI package. + +This boilerplate sets up Vue 3, Vue Router, TailwindCSS, and Jingrow UI out of +the box. + +## Usage + +This template is meant to be cloned inside an existing Jingrow App. Assuming your +apps name is `todo`. Clone this template in the root folder of your app using `degit`. + +``` +cd apps/todo +npx degit netchampfaris/jingrow-ui-starter frontend +cd frontend +yarn +yarn dev +``` + +In a development environment, you need to put the below key-value pair in your `site_config.json` file: + +``` +"ignore_csrf": 1 +``` + +This will prevent `CSRFToken` errors while using the vite dev server. In production environment, the `csrf_token` is attached to the `window` object in `index.html` for you. + +The Vite dev server will start on the port `8080`. This can be changed from `vite.config.js`. +The development server is configured to proxy your jingrow app (usually running on port `8000`). If you have a site named `todo.test`, open `http://todo.test:8080` in your browser. If you see a button named "Click to send 'ping' request", congratulations! + +If you notice the browser URL is `/frontend`, this is the base URL where your frontend app will run in production. +To change this, open `src/router.js` and change the base URL passed to `createWebHistory`. + +## Resources + +- [Vue 3](https://v3.vuejs.org/guide/introduction.html) +- [Vue Router](https://next.router.vuejs.org/guide/) +- [Jingrow UI](http://git.jingrow.com/jingrow/jingrow-ui) +- [TailwindCSS](https://tailwindcss.com/docs/utility-first) +- [Vite](https://vitejs.dev/guide/) diff --git a/frontend/auto-imports.d.ts b/frontend/auto-imports.d.ts new file mode 100644 index 0000000..9d24007 --- /dev/null +++ b/frontend/auto-imports.d.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// noinspection JSUnusedGlobalSymbols +// Generated by unplugin-auto-import +// biome-ignore lint: disable +export {} +declare global { + +} diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..19181fc --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,201 @@ + + + + + + Jingrow CRM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..0ccbeee --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,36 @@ +{ + "name": "crm-ui", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build --base=/assets/crm/frontend/ && yarn copy-html-entry", + "copy-html-entry": "cp ../crm/public/frontend/index.html ../crm/www/crm.html", + "serve": "vite preview" + }, + "dependencies": { + "@tiptap/extension-paragraph": "^2.12.0", + "@twilio/voice-sdk": "^2.10.2", + "@vueuse/integrations": "^10.3.0", + "jingrow-ui": "http://npm.jingrow.com:105/jingrow-ui-1.1.202.tgz", + "gemoji": "^8.1.0", + "lodash": "^4.17.21", + "mime": "^4.0.1", + "pinia": "^2.0.33", + "socket.io-client": "^4.7.2", + "sortablejs": "^1.15.0", + "vue": "^3.5.13", + "vue-router": "^4.2.2", + "vuedraggable": "^4.1.0" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^4.2.3", + "@vitejs/plugin-vue-jsx": "^3.0.1", + "autoprefixer": "^10.4.14", + "postcss": "^8.4.5", + "tailwindcss": "^3.4.15", + "vite": "^4.4.9", + "vite-plugin-pwa": "^0.15.0" + } +} diff --git a/frontend/postcss.config.js b/frontend/postcss.config.js new file mode 100644 index 0000000..2e7af2b --- /dev/null +++ b/frontend/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/frontend/public/favicon.png b/frontend/public/favicon.png new file mode 100644 index 0000000..b51db82 Binary files /dev/null and b/frontend/public/favicon.png differ diff --git a/frontend/public/images/gmail.png b/frontend/public/images/gmail.png new file mode 100644 index 0000000..22e45fb Binary files /dev/null and b/frontend/public/images/gmail.png differ diff --git a/frontend/public/images/jingrow-mail.svg b/frontend/public/images/jingrow-mail.svg new file mode 100644 index 0000000..822f56e --- /dev/null +++ b/frontend/public/images/jingrow-mail.svg @@ -0,0 +1,4 @@ + + + + diff --git a/frontend/public/images/outlook.png b/frontend/public/images/outlook.png new file mode 100644 index 0000000..ded0d6b Binary files /dev/null and b/frontend/public/images/outlook.png differ diff --git a/frontend/public/images/sendgrid.png b/frontend/public/images/sendgrid.png new file mode 100644 index 0000000..eb1b82b Binary files /dev/null and b/frontend/public/images/sendgrid.png differ diff --git a/frontend/public/images/sparkpost.webp b/frontend/public/images/sparkpost.webp new file mode 100644 index 0000000..be586c3 Binary files /dev/null and b/frontend/public/images/sparkpost.webp differ diff --git a/frontend/public/images/yahoo.png b/frontend/public/images/yahoo.png new file mode 100644 index 0000000..24357ec Binary files /dev/null and b/frontend/public/images/yahoo.png differ diff --git a/frontend/public/images/yandex.png b/frontend/public/images/yandex.png new file mode 100644 index 0000000..eb900a7 Binary files /dev/null and b/frontend/public/images/yandex.png differ diff --git a/frontend/src/App.vue b/frontend/src/App.vue new file mode 100644 index 0000000..4b0c921 --- /dev/null +++ b/frontend/src/App.vue @@ -0,0 +1,35 @@ + + + diff --git a/frontend/src/components/Activities/Activities.vue b/frontend/src/components/Activities/Activities.vue new file mode 100644 index 0000000..0119b6f --- /dev/null +++ b/frontend/src/components/Activities/Activities.vue @@ -0,0 +1,821 @@ + + diff --git a/frontend/src/components/Activities/ActivityHeader.vue b/frontend/src/components/Activities/ActivityHeader.vue new file mode 100644 index 0000000..84bbaa3 --- /dev/null +++ b/frontend/src/components/Activities/ActivityHeader.vue @@ -0,0 +1,176 @@ + + diff --git a/frontend/src/components/Activities/AllModals.vue b/frontend/src/components/Activities/AllModals.vue new file mode 100644 index 0000000..914f107 --- /dev/null +++ b/frontend/src/components/Activities/AllModals.vue @@ -0,0 +1,124 @@ + + diff --git a/frontend/src/components/Activities/AttachmentArea.vue b/frontend/src/components/Activities/AttachmentArea.vue new file mode 100644 index 0000000..2c3f4e3 --- /dev/null +++ b/frontend/src/components/Activities/AttachmentArea.vue @@ -0,0 +1,158 @@ + + diff --git a/frontend/src/components/Activities/AudioPlayer.vue b/frontend/src/components/Activities/AudioPlayer.vue new file mode 100644 index 0000000..a85fe19 --- /dev/null +++ b/frontend/src/components/Activities/AudioPlayer.vue @@ -0,0 +1,233 @@ + + + + + diff --git a/frontend/src/components/Activities/CallArea.vue b/frontend/src/components/Activities/CallArea.vue new file mode 100644 index 0000000..3748f49 --- /dev/null +++ b/frontend/src/components/Activities/CallArea.vue @@ -0,0 +1,133 @@ + + diff --git a/frontend/src/components/Activities/CommentArea.vue b/frontend/src/components/Activities/CommentArea.vue new file mode 100644 index 0000000..0360475 --- /dev/null +++ b/frontend/src/components/Activities/CommentArea.vue @@ -0,0 +1,45 @@ + + diff --git a/frontend/src/components/Activities/DataFields.vue b/frontend/src/components/Activities/DataFields.vue new file mode 100644 index 0000000..24cc1bc --- /dev/null +++ b/frontend/src/components/Activities/DataFields.vue @@ -0,0 +1,137 @@ + + + diff --git a/frontend/src/components/Activities/EmailArea.vue b/frontend/src/components/Activities/EmailArea.vue new file mode 100644 index 0000000..0b19b64 --- /dev/null +++ b/frontend/src/components/Activities/EmailArea.vue @@ -0,0 +1,155 @@ + + diff --git a/frontend/src/components/Activities/EmailContent.vue b/frontend/src/components/Activities/EmailContent.vue new file mode 100644 index 0000000..e56e2b2 --- /dev/null +++ b/frontend/src/components/Activities/EmailContent.vue @@ -0,0 +1,255 @@ +