Commit df4a49f76c938e9fed8e03343da230b0855f71c5
1 parent
c1c9b23894
Exists in
master
15092020 1607
Showing
73 changed files
with
3098 additions
and
2618 deletions
Show diff stats
.idea/codeStyles/Project.xml
1 | 1 | <component name="ProjectCodeStyleConfiguration"> |
2 | 2 | <code_scheme name="Project" version="173"> |
3 | + <DBN-PSQL> | |
4 | + <case-options enabled="true"> | |
5 | + <option name="KEYWORD_CASE" value="lower" /> | |
6 | + <option name="FUNCTION_CASE" value="lower" /> | |
7 | + <option name="PARAMETER_CASE" value="lower" /> | |
8 | + <option name="DATATYPE_CASE" value="lower" /> | |
9 | + <option name="OBJECT_CASE" value="preserve" /> | |
10 | + </case-options> | |
11 | + <formatting-settings enabled="false" /> | |
12 | + </DBN-PSQL> | |
13 | + <DBN-SQL> | |
14 | + <case-options enabled="true"> | |
15 | + <option name="KEYWORD_CASE" value="lower" /> | |
16 | + <option name="FUNCTION_CASE" value="lower" /> | |
17 | + <option name="PARAMETER_CASE" value="lower" /> | |
18 | + <option name="DATATYPE_CASE" value="lower" /> | |
19 | + <option name="OBJECT_CASE" value="preserve" /> | |
20 | + </case-options> | |
21 | + <formatting-settings enabled="false"> | |
22 | + <option name="STATEMENT_SPACING" value="one_line" /> | |
23 | + <option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" /> | |
24 | + <option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" /> | |
25 | + </formatting-settings> | |
26 | + </DBN-SQL> | |
3 | 27 | <JetCodeStyleSettings> |
4 | 28 | <option name="PACKAGES_TO_USE_STAR_IMPORTS"> |
5 | 29 | <value> |
.idea/dbnavigator.xml
... | ... | @@ -0,0 +1,553 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<project version="4"> | |
3 | + <component name="DBNavigator.Project.DataEditorManager"> | |
4 | + <record-view-column-sorting-type value="BY_INDEX" /> | |
5 | + <value-preview-text-wrapping value="false" /> | |
6 | + <value-preview-pinned value="false" /> | |
7 | + </component> | |
8 | + <component name="DBNavigator.Project.DataExportManager"> | |
9 | + <export-instructions> | |
10 | + <create-header value="true" /> | |
11 | + <quote-values-containing-separator value="true" /> | |
12 | + <quote-all-values value="false" /> | |
13 | + <value-separator value="" /> | |
14 | + <file-name value="" /> | |
15 | + <file-location value="" /> | |
16 | + <scope value="GLOBAL" /> | |
17 | + <destination value="FILE" /> | |
18 | + <format value="EXCEL" /> | |
19 | + <charset value="windows-1252" /> | |
20 | + </export-instructions> | |
21 | + </component> | |
22 | + <component name="DBNavigator.Project.DatabaseBrowserManager"> | |
23 | + <autoscroll-to-editor value="false" /> | |
24 | + <autoscroll-from-editor value="true" /> | |
25 | + <show-object-properties value="true" /> | |
26 | + <loaded-nodes /> | |
27 | + </component> | |
28 | + <component name="DBNavigator.Project.DatabaseConsoleManager"> | |
29 | + <connection id="3918bd62-034e-4b46-81a6-a20fcdcc253d"> | |
30 | + <console name="Connection" type="STANDARD" schema="" session="Main"><![CDATA[select * from ServeInv]]></console> | |
31 | + </connection> | |
32 | + </component> | |
33 | + <component name="DBNavigator.Project.DatabaseFileManager"> | |
34 | + <open-files /> | |
35 | + </component> | |
36 | + <component name="DBNavigator.Project.DatabaseSessionManager"> | |
37 | + <connection id="3918bd62-034e-4b46-81a6-a20fcdcc253d" /> | |
38 | + </component> | |
39 | + <component name="DBNavigator.Project.EditorStateManager"> | |
40 | + <last-used-providers /> | |
41 | + </component> | |
42 | + <component name="DBNavigator.Project.MethodExecutionManager"> | |
43 | + <method-browser /> | |
44 | + <execution-history> | |
45 | + <group-entries value="true" /> | |
46 | + <execution-inputs /> | |
47 | + </execution-history> | |
48 | + <argument-values-cache /> | |
49 | + </component> | |
50 | + <component name="DBNavigator.Project.ObjectDependencyManager"> | |
51 | + <last-used-dependency-type value="INCOMING" /> | |
52 | + </component> | |
53 | + <component name="DBNavigator.Project.ObjectQuickFilterManager"> | |
54 | + <last-used-operator value="EQUAL" /> | |
55 | + <filters /> | |
56 | + </component> | |
57 | + <component name="DBNavigator.Project.ScriptExecutionManager" clear-outputs="true"> | |
58 | + <recently-used-interfaces /> | |
59 | + </component> | |
60 | + <component name="DBNavigator.Project.Settings"> | |
61 | + <connections> | |
62 | + <connection id="3918bd62-034e-4b46-81a6-a20fcdcc253d" active="true"> | |
63 | + <database> | |
64 | + <name value="Connection" /> | |
65 | + <description value="" /> | |
66 | + <database-type value="SQLITE" /> | |
67 | + <config-type value="BASIC" /> | |
68 | + <database-version value="3.21" /> | |
69 | + <driver-source value="BUILTIN" /> | |
70 | + <driver-library value="" /> | |
71 | + <driver value="" /> | |
72 | + <url-type value="FILE" /> | |
73 | + <host value="localhost" /> | |
74 | + <port value="1234" /> | |
75 | + <database value="database" /> | |
76 | + <files> | |
77 | + <file path="C:\Users\mauricio sanchez\Desktop\DebInv-shm" schema="main" /> | |
78 | + </files> | |
79 | + <type value="NONE" /> | |
80 | + <user value="" /> | |
81 | + <deprecated-pwd value="" /> | |
82 | + </database> | |
83 | + <properties> | |
84 | + <auto-commit value="false" /> | |
85 | + </properties> | |
86 | + <ssh-settings> | |
87 | + <active value="false" /> | |
88 | + <proxy-host value="" /> | |
89 | + <proxy-port value="22" /> | |
90 | + <proxy-user value="" /> | |
91 | + <deprecated-proxy-pwd value="" /> | |
92 | + <auth-type value="PASSWORD" /> | |
93 | + <key-file value="" /> | |
94 | + <key-passphrase value="" /> | |
95 | + </ssh-settings> | |
96 | + <ssl-settings> | |
97 | + <active value="false" /> | |
98 | + <certificate-authority-file value="" /> | |
99 | + <client-certificate-file value="" /> | |
100 | + <client-key-file value="" /> | |
101 | + </ssl-settings> | |
102 | + <details> | |
103 | + <charset value="UTF-8" /> | |
104 | + <session-management value="true" /> | |
105 | + <ddl-file-binding value="true" /> | |
106 | + <database-logging value="false" /> | |
107 | + <connect-automatically value="true" /> | |
108 | + <restore-workspace value="true" /> | |
109 | + <restore-workspace-deep value="true" /> | |
110 | + <environment-type value="default" /> | |
111 | + <idle-time-to-disconnect value="30" /> | |
112 | + <idle-time-to-disconnect-pool value="5" /> | |
113 | + <credential-expiry-time value="10" /> | |
114 | + <max-connection-pool-size value="7" /> | |
115 | + <alternative-statement-delimiter value="" /> | |
116 | + </details> | |
117 | + <object-filters hide-empty-schemas="false" hide-pseudo-columns="false"> | |
118 | + <object-type-filter use-master-settings="true"> | |
119 | + <object-type name="SCHEMA" enabled="true" /> | |
120 | + <object-type name="USER" enabled="true" /> | |
121 | + <object-type name="ROLE" enabled="true" /> | |
122 | + <object-type name="PRIVILEGE" enabled="true" /> | |
123 | + <object-type name="CHARSET" enabled="true" /> | |
124 | + <object-type name="TABLE" enabled="true" /> | |
125 | + <object-type name="VIEW" enabled="true" /> | |
126 | + <object-type name="MATERIALIZED_VIEW" enabled="true" /> | |
127 | + <object-type name="NESTED_TABLE" enabled="true" /> | |
128 | + <object-type name="COLUMN" enabled="true" /> | |
129 | + <object-type name="INDEX" enabled="true" /> | |
130 | + <object-type name="CONSTRAINT" enabled="true" /> | |
131 | + <object-type name="DATASET_TRIGGER" enabled="true" /> | |
132 | + <object-type name="DATABASE_TRIGGER" enabled="true" /> | |
133 | + <object-type name="SYNONYM" enabled="true" /> | |
134 | + <object-type name="SEQUENCE" enabled="true" /> | |
135 | + <object-type name="PROCEDURE" enabled="true" /> | |
136 | + <object-type name="FUNCTION" enabled="true" /> | |
137 | + <object-type name="PACKAGE" enabled="true" /> | |
138 | + <object-type name="TYPE" enabled="true" /> | |
139 | + <object-type name="TYPE_ATTRIBUTE" enabled="true" /> | |
140 | + <object-type name="ARGUMENT" enabled="true" /> | |
141 | + <object-type name="DIMENSION" enabled="true" /> | |
142 | + <object-type name="CLUSTER" enabled="true" /> | |
143 | + <object-type name="DBLINK" enabled="true" /> | |
144 | + </object-type-filter> | |
145 | + <object-name-filters /> | |
146 | + </object-filters> | |
147 | + </connection> | |
148 | + </connections> | |
149 | + <browser-settings> | |
150 | + <general> | |
151 | + <display-mode value="TABBED" /> | |
152 | + <navigation-history-size value="100" /> | |
153 | + <show-object-details value="false" /> | |
154 | + </general> | |
155 | + <filters> | |
156 | + <object-type-filter> | |
157 | + <object-type name="SCHEMA" enabled="true" /> | |
158 | + <object-type name="USER" enabled="true" /> | |
159 | + <object-type name="ROLE" enabled="true" /> | |
160 | + <object-type name="PRIVILEGE" enabled="true" /> | |
161 | + <object-type name="CHARSET" enabled="true" /> | |
162 | + <object-type name="TABLE" enabled="true" /> | |
163 | + <object-type name="VIEW" enabled="true" /> | |
164 | + <object-type name="MATERIALIZED_VIEW" enabled="true" /> | |
165 | + <object-type name="NESTED_TABLE" enabled="true" /> | |
166 | + <object-type name="COLUMN" enabled="true" /> | |
167 | + <object-type name="INDEX" enabled="true" /> | |
168 | + <object-type name="CONSTRAINT" enabled="true" /> | |
169 | + <object-type name="DATASET_TRIGGER" enabled="true" /> | |
170 | + <object-type name="DATABASE_TRIGGER" enabled="true" /> | |
171 | + <object-type name="SYNONYM" enabled="true" /> | |
172 | + <object-type name="SEQUENCE" enabled="true" /> | |
173 | + <object-type name="PROCEDURE" enabled="true" /> | |
174 | + <object-type name="FUNCTION" enabled="true" /> | |
175 | + <object-type name="PACKAGE" enabled="true" /> | |
176 | + <object-type name="TYPE" enabled="true" /> | |
177 | + <object-type name="TYPE_ATTRIBUTE" enabled="true" /> | |
178 | + <object-type name="ARGUMENT" enabled="true" /> | |
179 | + <object-type name="DIMENSION" enabled="true" /> | |
180 | + <object-type name="CLUSTER" enabled="true" /> | |
181 | + <object-type name="DBLINK" enabled="true" /> | |
182 | + </object-type-filter> | |
183 | + </filters> | |
184 | + <sorting> | |
185 | + <object-type name="COLUMN" sorting-type="NAME" /> | |
186 | + <object-type name="FUNCTION" sorting-type="NAME" /> | |
187 | + <object-type name="PROCEDURE" sorting-type="NAME" /> | |
188 | + <object-type name="ARGUMENT" sorting-type="POSITION" /> | |
189 | + </sorting> | |
190 | + <default-editors> | |
191 | + <object-type name="VIEW" editor-type="SELECTION" /> | |
192 | + <object-type name="PACKAGE" editor-type="SELECTION" /> | |
193 | + <object-type name="TYPE" editor-type="SELECTION" /> | |
194 | + </default-editors> | |
195 | + </browser-settings> | |
196 | + <navigation-settings> | |
197 | + <lookup-filters> | |
198 | + <lookup-objects> | |
199 | + <object-type name="SCHEMA" enabled="true" /> | |
200 | + <object-type name="USER" enabled="false" /> | |
201 | + <object-type name="ROLE" enabled="false" /> | |
202 | + <object-type name="PRIVILEGE" enabled="false" /> | |
203 | + <object-type name="CHARSET" enabled="false" /> | |
204 | + <object-type name="TABLE" enabled="true" /> | |
205 | + <object-type name="VIEW" enabled="true" /> | |
206 | + <object-type name="MATERIALIZED VIEW" enabled="true" /> | |
207 | + <object-type name="NESTED TABLE" enabled="false" /> | |
208 | + <object-type name="COLUMN" enabled="false" /> | |
209 | + <object-type name="INDEX" enabled="true" /> | |
210 | + <object-type name="CONSTRAINT" enabled="true" /> | |
211 | + <object-type name="DATASET TRIGGER" enabled="true" /> | |
212 | + <object-type name="DATABASE TRIGGER" enabled="true" /> | |
213 | + <object-type name="SYNONYM" enabled="false" /> | |
214 | + <object-type name="SEQUENCE" enabled="true" /> | |
215 | + <object-type name="PROCEDURE" enabled="true" /> | |
216 | + <object-type name="FUNCTION" enabled="true" /> | |
217 | + <object-type name="PACKAGE" enabled="true" /> | |
218 | + <object-type name="TYPE" enabled="true" /> | |
219 | + <object-type name="TYPE ATTRIBUTE" enabled="false" /> | |
220 | + <object-type name="ARGUMENT" enabled="false" /> | |
221 | + <object-type name="DIMENSION" enabled="false" /> | |
222 | + <object-type name="CLUSTER" enabled="false" /> | |
223 | + <object-type name="DBLINK" enabled="true" /> | |
224 | + </lookup-objects> | |
225 | + <force-database-load value="false" /> | |
226 | + <prompt-connection-selection value="true" /> | |
227 | + <prompt-schema-selection value="true" /> | |
228 | + </lookup-filters> | |
229 | + </navigation-settings> | |
230 | + <dataset-grid-settings> | |
231 | + <general> | |
232 | + <enable-zooming value="true" /> | |
233 | + <enable-column-tooltip value="true" /> | |
234 | + </general> | |
235 | + <sorting> | |
236 | + <nulls-first value="true" /> | |
237 | + <max-sorting-columns value="4" /> | |
238 | + </sorting> | |
239 | + <tracking-columns> | |
240 | + <columnNames value="" /> | |
241 | + <visible value="true" /> | |
242 | + <editable value="false" /> | |
243 | + </tracking-columns> | |
244 | + </dataset-grid-settings> | |
245 | + <dataset-editor-settings> | |
246 | + <text-editor-popup> | |
247 | + <active value="false" /> | |
248 | + <active-if-empty value="false" /> | |
249 | + <data-length-threshold value="100" /> | |
250 | + <popup-delay value="1000" /> | |
251 | + </text-editor-popup> | |
252 | + <values-actions-popup> | |
253 | + <show-popup-button value="true" /> | |
254 | + <element-count-threshold value="1000" /> | |
255 | + <data-length-threshold value="250" /> | |
256 | + </values-actions-popup> | |
257 | + <general> | |
258 | + <fetch-block-size value="100" /> | |
259 | + <fetch-timeout value="30" /> | |
260 | + <trim-whitespaces value="true" /> | |
261 | + <convert-empty-strings-to-null value="true" /> | |
262 | + <select-content-on-cell-edit value="true" /> | |
263 | + <large-value-preview-active value="true" /> | |
264 | + </general> | |
265 | + <filters> | |
266 | + <prompt-filter-dialog value="true" /> | |
267 | + <default-filter-type value="BASIC" /> | |
268 | + </filters> | |
269 | + <qualified-text-editor text-length-threshold="300"> | |
270 | + <content-types> | |
271 | + <content-type name="Text" enabled="true" /> | |
272 | + <content-type name="Properties" enabled="true" /> | |
273 | + <content-type name="XML" enabled="true" /> | |
274 | + <content-type name="DTD" enabled="true" /> | |
275 | + <content-type name="HTML" enabled="true" /> | |
276 | + <content-type name="XHTML" enabled="true" /> | |
277 | + <content-type name="Java" enabled="true" /> | |
278 | + <content-type name="SQL" enabled="true" /> | |
279 | + <content-type name="PL/SQL" enabled="true" /> | |
280 | + <content-type name="JSON" enabled="true" /> | |
281 | + <content-type name="JSON5" enabled="true" /> | |
282 | + <content-type name="Groovy" enabled="true" /> | |
283 | + <content-type name="AIDL" enabled="true" /> | |
284 | + <content-type name="YAML" enabled="true" /> | |
285 | + <content-type name="Manifest" enabled="true" /> | |
286 | + </content-types> | |
287 | + </qualified-text-editor> | |
288 | + <record-navigation> | |
289 | + <navigation-target value="VIEWER" /> | |
290 | + </record-navigation> | |
291 | + </dataset-editor-settings> | |
292 | + <code-editor-settings> | |
293 | + <general> | |
294 | + <show-object-navigation-gutter value="false" /> | |
295 | + <show-spec-declaration-navigation-gutter value="true" /> | |
296 | + <enable-spellchecking value="true" /> | |
297 | + <enable-reference-spellchecking value="false" /> | |
298 | + </general> | |
299 | + <confirmations> | |
300 | + <save-changes value="false" /> | |
301 | + <revert-changes value="true" /> | |
302 | + </confirmations> | |
303 | + </code-editor-settings> | |
304 | + <code-completion-settings> | |
305 | + <filters> | |
306 | + <basic-filter> | |
307 | + <filter-element type="RESERVED_WORD" id="keyword" selected="true" /> | |
308 | + <filter-element type="RESERVED_WORD" id="function" selected="true" /> | |
309 | + <filter-element type="RESERVED_WORD" id="parameter" selected="true" /> | |
310 | + <filter-element type="RESERVED_WORD" id="datatype" selected="true" /> | |
311 | + <filter-element type="RESERVED_WORD" id="exception" selected="true" /> | |
312 | + <filter-element type="OBJECT" id="schema" selected="true" /> | |
313 | + <filter-element type="OBJECT" id="role" selected="true" /> | |
314 | + <filter-element type="OBJECT" id="user" selected="true" /> | |
315 | + <filter-element type="OBJECT" id="privilege" selected="true" /> | |
316 | + <user-schema> | |
317 | + <filter-element type="OBJECT" id="table" selected="true" /> | |
318 | + <filter-element type="OBJECT" id="view" selected="true" /> | |
319 | + <filter-element type="OBJECT" id="materialized view" selected="true" /> | |
320 | + <filter-element type="OBJECT" id="index" selected="true" /> | |
321 | + <filter-element type="OBJECT" id="constraint" selected="true" /> | |
322 | + <filter-element type="OBJECT" id="trigger" selected="true" /> | |
323 | + <filter-element type="OBJECT" id="synonym" selected="false" /> | |
324 | + <filter-element type="OBJECT" id="sequence" selected="true" /> | |
325 | + <filter-element type="OBJECT" id="procedure" selected="true" /> | |
326 | + <filter-element type="OBJECT" id="function" selected="true" /> | |
327 | + <filter-element type="OBJECT" id="package" selected="true" /> | |
328 | + <filter-element type="OBJECT" id="type" selected="true" /> | |
329 | + <filter-element type="OBJECT" id="dimension" selected="true" /> | |
330 | + <filter-element type="OBJECT" id="cluster" selected="true" /> | |
331 | + <filter-element type="OBJECT" id="dblink" selected="true" /> | |
332 | + </user-schema> | |
333 | + <public-schema> | |
334 | + <filter-element type="OBJECT" id="table" selected="false" /> | |
335 | + <filter-element type="OBJECT" id="view" selected="false" /> | |
336 | + <filter-element type="OBJECT" id="materialized view" selected="false" /> | |
337 | + <filter-element type="OBJECT" id="index" selected="false" /> | |
338 | + <filter-element type="OBJECT" id="constraint" selected="false" /> | |
339 | + <filter-element type="OBJECT" id="trigger" selected="false" /> | |
340 | + <filter-element type="OBJECT" id="synonym" selected="false" /> | |
341 | + <filter-element type="OBJECT" id="sequence" selected="false" /> | |
342 | + <filter-element type="OBJECT" id="procedure" selected="false" /> | |
343 | + <filter-element type="OBJECT" id="function" selected="false" /> | |
344 | + <filter-element type="OBJECT" id="package" selected="false" /> | |
345 | + <filter-element type="OBJECT" id="type" selected="false" /> | |
346 | + <filter-element type="OBJECT" id="dimension" selected="false" /> | |
347 | + <filter-element type="OBJECT" id="cluster" selected="false" /> | |
348 | + <filter-element type="OBJECT" id="dblink" selected="false" /> | |
349 | + </public-schema> | |
350 | + <any-schema> | |
351 | + <filter-element type="OBJECT" id="table" selected="true" /> | |
352 | + <filter-element type="OBJECT" id="view" selected="true" /> | |
353 | + <filter-element type="OBJECT" id="materialized view" selected="true" /> | |
354 | + <filter-element type="OBJECT" id="index" selected="true" /> | |
355 | + <filter-element type="OBJECT" id="constraint" selected="true" /> | |
356 | + <filter-element type="OBJECT" id="trigger" selected="true" /> | |
357 | + <filter-element type="OBJECT" id="synonym" selected="true" /> | |
358 | + <filter-element type="OBJECT" id="sequence" selected="true" /> | |
359 | + <filter-element type="OBJECT" id="procedure" selected="true" /> | |
360 | + <filter-element type="OBJECT" id="function" selected="true" /> | |
361 | + <filter-element type="OBJECT" id="package" selected="true" /> | |
362 | + <filter-element type="OBJECT" id="type" selected="true" /> | |
363 | + <filter-element type="OBJECT" id="dimension" selected="true" /> | |
364 | + <filter-element type="OBJECT" id="cluster" selected="true" /> | |
365 | + <filter-element type="OBJECT" id="dblink" selected="true" /> | |
366 | + </any-schema> | |
367 | + </basic-filter> | |
368 | + <extended-filter> | |
369 | + <filter-element type="RESERVED_WORD" id="keyword" selected="true" /> | |
370 | + <filter-element type="RESERVED_WORD" id="function" selected="true" /> | |
371 | + <filter-element type="RESERVED_WORD" id="parameter" selected="true" /> | |
372 | + <filter-element type="RESERVED_WORD" id="datatype" selected="true" /> | |
373 | + <filter-element type="RESERVED_WORD" id="exception" selected="true" /> | |
374 | + <filter-element type="OBJECT" id="schema" selected="true" /> | |
375 | + <filter-element type="OBJECT" id="user" selected="true" /> | |
376 | + <filter-element type="OBJECT" id="role" selected="true" /> | |
377 | + <filter-element type="OBJECT" id="privilege" selected="true" /> | |
378 | + <user-schema> | |
379 | + <filter-element type="OBJECT" id="table" selected="true" /> | |
380 | + <filter-element type="OBJECT" id="view" selected="true" /> | |
381 | + <filter-element type="OBJECT" id="materialized view" selected="true" /> | |
382 | + <filter-element type="OBJECT" id="index" selected="true" /> | |
383 | + <filter-element type="OBJECT" id="constraint" selected="true" /> | |
384 | + <filter-element type="OBJECT" id="trigger" selected="true" /> | |
385 | + <filter-element type="OBJECT" id="synonym" selected="true" /> | |
386 | + <filter-element type="OBJECT" id="sequence" selected="true" /> | |
387 | + <filter-element type="OBJECT" id="procedure" selected="true" /> | |
388 | + <filter-element type="OBJECT" id="function" selected="true" /> | |
389 | + <filter-element type="OBJECT" id="package" selected="true" /> | |
390 | + <filter-element type="OBJECT" id="type" selected="true" /> | |
391 | + <filter-element type="OBJECT" id="dimension" selected="true" /> | |
392 | + <filter-element type="OBJECT" id="cluster" selected="true" /> | |
393 | + <filter-element type="OBJECT" id="dblink" selected="true" /> | |
394 | + </user-schema> | |
395 | + <public-schema> | |
396 | + <filter-element type="OBJECT" id="table" selected="true" /> | |
397 | + <filter-element type="OBJECT" id="view" selected="true" /> | |
398 | + <filter-element type="OBJECT" id="materialized view" selected="true" /> | |
399 | + <filter-element type="OBJECT" id="index" selected="true" /> | |
400 | + <filter-element type="OBJECT" id="constraint" selected="true" /> | |
401 | + <filter-element type="OBJECT" id="trigger" selected="true" /> | |
402 | + <filter-element type="OBJECT" id="synonym" selected="true" /> | |
403 | + <filter-element type="OBJECT" id="sequence" selected="true" /> | |
404 | + <filter-element type="OBJECT" id="procedure" selected="true" /> | |
405 | + <filter-element type="OBJECT" id="function" selected="true" /> | |
406 | + <filter-element type="OBJECT" id="package" selected="true" /> | |
407 | + <filter-element type="OBJECT" id="type" selected="true" /> | |
408 | + <filter-element type="OBJECT" id="dimension" selected="true" /> | |
409 | + <filter-element type="OBJECT" id="cluster" selected="true" /> | |
410 | + <filter-element type="OBJECT" id="dblink" selected="true" /> | |
411 | + </public-schema> | |
412 | + <any-schema> | |
413 | + <filter-element type="OBJECT" id="table" selected="true" /> | |
414 | + <filter-element type="OBJECT" id="view" selected="true" /> | |
415 | + <filter-element type="OBJECT" id="materialized view" selected="true" /> | |
416 | + <filter-element type="OBJECT" id="index" selected="true" /> | |
417 | + <filter-element type="OBJECT" id="constraint" selected="true" /> | |
418 | + <filter-element type="OBJECT" id="trigger" selected="true" /> | |
419 | + <filter-element type="OBJECT" id="synonym" selected="true" /> | |
420 | + <filter-element type="OBJECT" id="sequence" selected="true" /> | |
421 | + <filter-element type="OBJECT" id="procedure" selected="true" /> | |
422 | + <filter-element type="OBJECT" id="function" selected="true" /> | |
423 | + <filter-element type="OBJECT" id="package" selected="true" /> | |
424 | + <filter-element type="OBJECT" id="type" selected="true" /> | |
425 | + <filter-element type="OBJECT" id="dimension" selected="true" /> | |
426 | + <filter-element type="OBJECT" id="cluster" selected="true" /> | |
427 | + <filter-element type="OBJECT" id="dblink" selected="true" /> | |
428 | + </any-schema> | |
429 | + </extended-filter> | |
430 | + </filters> | |
431 | + <sorting enabled="true"> | |
432 | + <sorting-element type="RESERVED_WORD" id="keyword" /> | |
433 | + <sorting-element type="RESERVED_WORD" id="datatype" /> | |
434 | + <sorting-element type="OBJECT" id="column" /> | |
435 | + <sorting-element type="OBJECT" id="table" /> | |
436 | + <sorting-element type="OBJECT" id="view" /> | |
437 | + <sorting-element type="OBJECT" id="materialized view" /> | |
438 | + <sorting-element type="OBJECT" id="index" /> | |
439 | + <sorting-element type="OBJECT" id="constraint" /> | |
440 | + <sorting-element type="OBJECT" id="trigger" /> | |
441 | + <sorting-element type="OBJECT" id="synonym" /> | |
442 | + <sorting-element type="OBJECT" id="sequence" /> | |
443 | + <sorting-element type="OBJECT" id="procedure" /> | |
444 | + <sorting-element type="OBJECT" id="function" /> | |
445 | + <sorting-element type="OBJECT" id="package" /> | |
446 | + <sorting-element type="OBJECT" id="type" /> | |
447 | + <sorting-element type="OBJECT" id="dimension" /> | |
448 | + <sorting-element type="OBJECT" id="cluster" /> | |
449 | + <sorting-element type="OBJECT" id="dblink" /> | |
450 | + <sorting-element type="OBJECT" id="schema" /> | |
451 | + <sorting-element type="OBJECT" id="role" /> | |
452 | + <sorting-element type="OBJECT" id="user" /> | |
453 | + <sorting-element type="RESERVED_WORD" id="function" /> | |
454 | + <sorting-element type="RESERVED_WORD" id="parameter" /> | |
455 | + </sorting> | |
456 | + <format> | |
457 | + <enforce-code-style-case value="true" /> | |
458 | + </format> | |
459 | + </code-completion-settings> | |
460 | + <execution-engine-settings> | |
461 | + <statement-execution> | |
462 | + <fetch-block-size value="100" /> | |
463 | + <execution-timeout value="20" /> | |
464 | + <debug-execution-timeout value="600" /> | |
465 | + <focus-result value="false" /> | |
466 | + <prompt-execution value="false" /> | |
467 | + </statement-execution> | |
468 | + <script-execution> | |
469 | + <command-line-interfaces /> | |
470 | + <execution-timeout value="300" /> | |
471 | + </script-execution> | |
472 | + <method-execution> | |
473 | + <execution-timeout value="30" /> | |
474 | + <debug-execution-timeout value="600" /> | |
475 | + <parameter-history-size value="10" /> | |
476 | + </method-execution> | |
477 | + </execution-engine-settings> | |
478 | + <operation-settings> | |
479 | + <transactions> | |
480 | + <uncommitted-changes> | |
481 | + <on-project-close value="ASK" /> | |
482 | + <on-disconnect value="ASK" /> | |
483 | + <on-autocommit-toggle value="ASK" /> | |
484 | + </uncommitted-changes> | |
485 | + <multiple-uncommitted-changes> | |
486 | + <on-commit value="ASK" /> | |
487 | + <on-rollback value="ASK" /> | |
488 | + </multiple-uncommitted-changes> | |
489 | + </transactions> | |
490 | + <session-browser> | |
491 | + <disconnect-session value="ASK" /> | |
492 | + <kill-session value="ASK" /> | |
493 | + <reload-on-filter-change value="false" /> | |
494 | + </session-browser> | |
495 | + <compiler> | |
496 | + <compile-type value="KEEP" /> | |
497 | + <compile-dependencies value="ASK" /> | |
498 | + <always-show-controls value="false" /> | |
499 | + </compiler> | |
500 | + <debugger> | |
501 | + <debugger-type value="ASK" /> | |
502 | + <use-generic-runners value="true" /> | |
503 | + </debugger> | |
504 | + </operation-settings> | |
505 | + <ddl-file-settings> | |
506 | + <extensions> | |
507 | + <mapping file-type-id="VIEW" extensions="vw" /> | |
508 | + <mapping file-type-id="TRIGGER" extensions="trg" /> | |
509 | + <mapping file-type-id="PROCEDURE" extensions="prc" /> | |
510 | + <mapping file-type-id="FUNCTION" extensions="fnc" /> | |
511 | + <mapping file-type-id="PACKAGE" extensions="pkg" /> | |
512 | + <mapping file-type-id="PACKAGE_SPEC" extensions="pks" /> | |
513 | + <mapping file-type-id="PACKAGE_BODY" extensions="pkb" /> | |
514 | + <mapping file-type-id="TYPE" extensions="tpe" /> | |
515 | + <mapping file-type-id="TYPE_SPEC" extensions="tps" /> | |
516 | + <mapping file-type-id="TYPE_BODY" extensions="tpb" /> | |
517 | + </extensions> | |
518 | + <general> | |
519 | + <lookup-ddl-files value="true" /> | |
520 | + <create-ddl-files value="false" /> | |
521 | + <synchronize-ddl-files value="true" /> | |
522 | + <use-qualified-names value="false" /> | |
523 | + <make-scripts-rerunnable value="true" /> | |
524 | + </general> | |
525 | + </ddl-file-settings> | |
526 | + <general-settings> | |
527 | + <regional-settings> | |
528 | + <date-format value="MEDIUM" /> | |
529 | + <number-format value="UNGROUPED" /> | |
530 | + <locale value="SYSTEM_DEFAULT" /> | |
531 | + <use-custom-formats value="false" /> | |
532 | + </regional-settings> | |
533 | + <environment> | |
534 | + <environment-types> | |
535 | + <environment-type id="development" name="Development" description="Development environment" color="-2430209/-12296320" readonly-code="false" readonly-data="false" /> | |
536 | + <environment-type id="integration" name="Integration" description="Integration environment" color="-2621494/-12163514" readonly-code="true" readonly-data="false" /> | |
537 | + <environment-type id="production" name="Production" description="Productive environment" color="-11574/-10271420" readonly-code="true" readonly-data="true" /> | |
538 | + <environment-type id="other" name="Other" description="" color="-1576/-10724543" readonly-code="false" readonly-data="false" /> | |
539 | + </environment-types> | |
540 | + <visibility-settings> | |
541 | + <connection-tabs value="true" /> | |
542 | + <dialog-headers value="true" /> | |
543 | + <object-editor-tabs value="true" /> | |
544 | + <script-editor-tabs value="false" /> | |
545 | + <execution-result-tabs value="true" /> | |
546 | + </visibility-settings> | |
547 | + </environment> | |
548 | + </general-settings> | |
549 | + </component> | |
550 | + <component name="DBNavigator.Project.StatementExecutionManager"> | |
551 | + <execution-variables /> | |
552 | + </component> | |
553 | +</project> | |
0 | 554 | \ No newline at end of file |
.idea/jarRepositories.xml
... | ... | @@ -21,5 +21,10 @@ |
21 | 21 | <option name="name" value="Google" /> |
22 | 22 | <option name="url" value="https://dl.google.com/dl/android/maven2/" /> |
23 | 23 | </remote-repository> |
24 | + <remote-repository> | |
25 | + <option name="id" value="IDEScout, Inc." /> | |
26 | + <option name="name" value="IDEScout, Inc." /> | |
27 | + <option name="url" value="http://www.idescout.com/maven/repo/" /> | |
28 | + </remote-repository> | |
24 | 29 | </component> |
25 | 30 | </project> |
26 | 31 | \ No newline at end of file |
.idea/sqlandroid.xml
Solicitudes API Articulos y Time.docx
No preview for this file type
Solicitudes API Articulos y Time.pdf
No preview for this file type
app/build.gradle
1 | 1 | apply plugin: 'com.android.application' |
2 | 2 | apply plugin: 'kotlin-android' |
3 | 3 | apply plugin: 'kotlin-android-extensions' |
4 | - | |
4 | +apply plugin: 'kotlin-kapt' | |
5 | 5 | |
6 | 6 | android { |
7 | 7 | compileSdkVersion 30 |
... | ... | @@ -43,7 +43,7 @@ dependencies { |
43 | 43 | implementation 'androidx.core:core-ktx:1.3.1' |
44 | 44 | implementation 'androidx.appcompat:appcompat:1.2.0' |
45 | 45 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' |
46 | - implementation 'com.google.android.material:material:1.2.0' | |
46 | + implementation 'com.google.android.material:material:1.2.1' | |
47 | 47 | implementation 'androidx.constraintlayout:constraintlayout:2.0.1' |
48 | 48 | implementation 'androidx.navigation:navigation-fragment:2.3.0' |
49 | 49 | implementation 'androidx.navigation:navigation-ui:2.3.0' |
... | ... | @@ -59,11 +59,13 @@ dependencies { |
59 | 59 | //Room |
60 | 60 | implementation 'androidx.room:room-ktx:2.2.5' |
61 | 61 | implementation "androidx.room:room-runtime:2.2.5" |
62 | - annotationProcessor 'androidx.room:room-compiler:2.2.5' | |
62 | + debugImplementation 'com.idescout.sql:sqlscout-server:4.1' | |
63 | + kapt "androidx.room:room-compiler:2.2.5" | |
64 | +// annotationProcessor 'androidx.room:room-compiler:2.2.5' | |
63 | 65 | |
64 | 66 | //Retrofit |
65 | - implementation 'com.squareup.retrofit2:retrofit:2.9.0' | |
66 | 67 | implementation 'com.google.code.gson:gson:2.8.6' |
68 | + implementation 'com.squareup.retrofit2:retrofit:2.9.0' | |
67 | 69 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0' |
68 | 70 | implementation 'com.squareup.okhttp3:logging-interceptor:4.8.1' |
69 | 71 | |
... | ... | @@ -72,5 +74,6 @@ dependencies { |
72 | 74 | |
73 | 75 | // ViewModel and LiveData |
74 | 76 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' |
75 | - annotationProcessor 'androidx.lifecycle:lifecycle-common-java8:2.2.0' | |
77 | + kapt 'androidx.lifecycle:lifecycle-common-java8:2.2.0' | |
78 | + releaseImplementation 'com.idescout.sql:sqlscout-server-noop:4.1' | |
76 | 79 | } |
77 | 80 | \ No newline at end of file |
app/src/main/AndroidManifest.xml
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
3 | + xmlns:tools="http://schemas.android.com/tools" | |
3 | 4 | package="com.focasoftware.deboinventariov20"> |
4 | 5 | |
5 | - <uses-permission android:name="android.permission.WAKE_LOCK"/> | |
6 | 6 | <uses-permission android:name="android.permission.VIBRATE" /> |
7 | 7 | <uses-permission android:name="android.permission.INTERNET" /> |
8 | 8 | |
9 | 9 | <application |
10 | + android:exported="false" | |
10 | 11 | android:allowBackup="true" |
11 | 12 | android:icon="@drawable/icono_inventario_big" |
12 | 13 | android:label="@string/app_name" |
... | ... | @@ -15,7 +16,7 @@ |
15 | 16 | android:theme="@style/AppTheme" |
16 | 17 | android:usesCleartextTraffic="true"> |
17 | 18 | <activity |
18 | - android:name=".ui.SplashActivity" | |
19 | + android:name=".UI.SplashActivity" | |
19 | 20 | android:label="@string/app_name" |
20 | 21 | android:theme="@style/AppTheme.NoActionBar"> |
21 | 22 | <intent-filter> |
... | ... | @@ -25,7 +26,7 @@ |
25 | 26 | </intent-filter> |
26 | 27 | </activity> |
27 | 28 | <activity |
28 | - android:name=".ui.MainActivity" | |
29 | + android:name=".UI.MainActivity" | |
29 | 30 | android:label="@string/app_name" |
30 | 31 | android:theme="@style/AppTheme.NoActionBar"> |
31 | 32 |
app/src/main/java/com/focasoftware/deboinventariov20/DB/Constans/Constans.kt
app/src/main/java/com/focasoftware/deboinventariov20/DB/DAO/ArticulosDAO.kt
1 | 1 | package com.focasoftware.deboinventariov20.DB.DAO |
2 | 2 | |
3 | -import androidx.room.* | |
4 | -import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_ART | |
5 | -import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_B | |
6 | -import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_H | |
7 | -import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_SERV_INV | |
8 | -import com.focasoftware.deboinventariov20.Model.* | |
9 | -import java.util.ArrayList | |
3 | +import androidx.room.Dao | |
4 | +import androidx.room.Insert | |
5 | +import androidx.room.OnConflictStrategy | |
6 | +import androidx.room.Query | |
7 | +import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_ART | |
8 | +import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_B | |
9 | +import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_H | |
10 | +import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_SERV_INV | |
11 | +import com.focasoftware.deboinventariov20.Model.Articles | |
12 | +import com.focasoftware.deboinventariov20.Model.InvBody | |
13 | +import com.focasoftware.deboinventariov20.Model.InvHead | |
14 | +import com.focasoftware.deboinventariov20.Model.ServeInv | |
10 | 15 | |
11 | 16 | @Dao |
12 | 17 | interface ArticulosDAO { |
... | ... | @@ -24,6 +29,9 @@ interface ArticulosDAO { |
24 | 29 | @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND CB LIKE :codBarra") |
25 | 30 | suspend fun findArticuloByCodBar(codBarra: String?, dep: Int): Articles? |
26 | 31 | |
32 | + @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND CBC LIKE :CodOrigen") | |
33 | + suspend fun findArticuloByCodOri(CodOrigen: String?, dep: Int): Articles? | |
34 | + | |
27 | 35 | @Query("DELETE FROM $TABLA_ART") |
28 | 36 | suspend fun deleteAllArticulos() |
29 | 37 | |
... | ... | @@ -48,8 +56,11 @@ interface InvHeadDAO { |
48 | 56 | @Query("SELECT * FROM $TABLA_INV_H ORDER BY INV_FEI") |
49 | 57 | suspend fun fetchAllInvHead(): List<InvHead> |
50 | 58 | |
59 | + @Query("SELECT INV_PRODCONT FROM $TABLA_INV_H WHERE INV_NUM=:inven") | |
60 | + suspend fun consultaCantidadInvH (inven: Int): Int | |
61 | + | |
51 | 62 | @Query("UPDATE $TABLA_INV_H SET INV_PRODCONT=:cant WHERE INV_NUM=:inven") |
52 | - suspend fun UpdateInvBody(cant: Float, inven: Int) | |
63 | + suspend fun updateInvBody(inven: Int,cant: Int) | |
53 | 64 | } |
54 | 65 | |
55 | 66 | @Dao |
... | ... | @@ -67,7 +78,7 @@ interface InvBodyDAO { |
67 | 78 | suspend fun UpdateInvBody(cant: Float, sec: String, cod: String) |
68 | 79 | |
69 | 80 | @Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:inven ORDER BY INV_FEI DESC") |
70 | - suspend fun fetchAllInvBody(inven:Int): List<InvBody> | |
81 | + suspend fun fetchAllInvBody(inven: Int): List<InvBody> | |
71 | 82 | |
72 | 83 | @Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo") |
73 | 84 | suspend fun fetchArtInInvBody(sector: String, codigo: String, numInventario: String): InvBody |
... | ... | @@ -75,6 +86,7 @@ interface InvBodyDAO { |
75 | 86 | @Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo") |
76 | 87 | suspend fun deleteItemFromInvBody(sector: String, codigo: String, numInventario: String): Int |
77 | 88 | } |
89 | + | |
78 | 90 | @Dao |
79 | 91 | interface ServeInvDao { |
80 | 92 | @Insert(onConflict = OnConflictStrategy.REPLACE) |
... | ... | @@ -95,6 +107,6 @@ interface ServeInvDao { |
95 | 107 | @Query("UPDATE $TABLA_SERV_INV SET SER_PRE=1 WHERE SER_NUM = :numero") |
96 | 108 | suspend fun UpdateServerPre(numero: Int) |
97 | 109 | |
98 | - @Query("SELECT * FROM $TABLA_SERV_INV WHERE SER_PRE= 1") | |
99 | - suspend fun fetchServerPreOne(): ServeInv | |
110 | + @Query("SELECT SER_DIR FROM $TABLA_SERV_INV WHERE SER_PRE= 1") | |
111 | + suspend fun fetchServerPreOne(): String | |
100 | 112 | } |
101 | 113 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/DB/DataBase/AppDb.kt
... | ... | @@ -4,8 +4,7 @@ import android.content.Context |
4 | 4 | import androidx.room.Database |
5 | 5 | import androidx.room.Room |
6 | 6 | import androidx.room.RoomDatabase |
7 | -import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans | |
8 | -import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_ART | |
7 | +import com.focasoftware.deboinventariov20.DB.Constans.Constans | |
9 | 8 | import com.focasoftware.deboinventariov20.DB.DAO.* |
10 | 9 | import com.focasoftware.deboinventariov20.Model.Articles |
11 | 10 | import com.focasoftware.deboinventariov20.Model.InvBody |
... | ... | @@ -24,11 +23,7 @@ abstract class AppDb : RoomDatabase() { |
24 | 23 | private var INSTANCE: AppDb? = null |
25 | 24 | fun getAppDb(context: Context): AppDb? { |
26 | 25 | if (INSTANCE == null) { |
27 | - INSTANCE = Room.databaseBuilder( | |
28 | - context.applicationContext, | |
29 | - AppDb::class.java, | |
30 | - Constans.DB_NAME | |
31 | - ) | |
26 | + INSTANCE = Room.databaseBuilder(context.applicationContext, AppDb::class.java, Constans.DB_NAME) | |
32 | 27 | .allowMainThreadQueries() |
33 | 28 | .build() |
34 | 29 | } |
app/src/main/java/com/focasoftware/deboinventariov20/Model/ProductosService.kt
1 | 1 | package com.focasoftware.deboinventariov20.Model |
2 | 2 | |
3 | -import com.focasoftware.deboinventariov20.ui.actualizacionMaestros.BASE_URL | |
3 | +import com.focasoftware.deboinventariov20.UI.actualizacionMaestros.BASE_URL | |
4 | 4 | import retrofit2.Retrofit |
5 | 5 | import retrofit2.converter.gson.GsonConverterFactory |
6 | 6 | |
7 | 7 | object ProductosService { |
8 | -// private val BASE_URL ="http://10.0.2.2:3000/" | |
9 | -// // //"http://192.168.0.2:3000/" | |
10 | - | |
11 | - | |
12 | 8 | fun getProductosService(): ProductosApi { |
13 | 9 | return Retrofit.Builder() |
14 | 10 | .baseUrl(BASE_URL) |
app/src/main/java/com/focasoftware/deboinventariov20/Model/Tablas.kt
... | ... | @@ -3,10 +3,10 @@ package com.focasoftware.deboinventariov20.Model |
3 | 3 | import androidx.room.ColumnInfo |
4 | 4 | import androidx.room.Entity |
5 | 5 | import androidx.room.PrimaryKey |
6 | -import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_ART | |
7 | -import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_B | |
8 | -import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_H | |
9 | -import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_SERV_INV | |
6 | +import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_ART | |
7 | +import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_B | |
8 | +import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_H | |
9 | +import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_SERV_INV | |
10 | 10 | import com.google.gson.annotations.SerializedName |
11 | 11 | import java.io.Serializable |
12 | 12 |
app/src/main/java/com/focasoftware/deboinventariov20/UI/MainActivity.kt
... | ... | @@ -0,0 +1,46 @@ |
1 | +package com.focasoftware.deboinventariov20.UI | |
2 | + | |
3 | +import android.os.Bundle | |
4 | +import android.view.Menu | |
5 | +import com.google.android.material.navigation.NavigationView | |
6 | +import androidx.navigation.findNavController | |
7 | +import androidx.navigation.ui.AppBarConfiguration | |
8 | +import androidx.navigation.ui.navigateUp | |
9 | +import androidx.navigation.ui.setupActionBarWithNavController | |
10 | +import androidx.navigation.ui.setupWithNavController | |
11 | +import androidx.drawerlayout.widget.DrawerLayout | |
12 | +import androidx.appcompat.app.AppCompatActivity | |
13 | +import androidx.appcompat.widget.Toolbar | |
14 | +import com.focasoftware.deboinventariov20.R | |
15 | + | |
16 | +class MainActivity : AppCompatActivity() { | |
17 | + | |
18 | + private lateinit var appBarConfiguration: AppBarConfiguration | |
19 | + | |
20 | + override fun onCreate(savedInstanceState: Bundle?) { | |
21 | + super.onCreate(savedInstanceState) | |
22 | + setContentView(R.layout.activity_main) | |
23 | + val toolbar: Toolbar = findViewById(R.id.toolbar) | |
24 | + setSupportActionBar(toolbar) | |
25 | + | |
26 | + | |
27 | + val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout) | |
28 | + val navView: NavigationView = findViewById(R.id.nav_view) | |
29 | + val navController = findNavController(R.id.nav_host_fragment) | |
30 | + | |
31 | + appBarConfiguration = AppBarConfiguration(setOf(R.id.mainFragment2, R.id.inventarioFragment, R.id.actuaMaestrosFragment, R.id.configuracionFragment), drawerLayout) | |
32 | + setupActionBarWithNavController(navController, appBarConfiguration) | |
33 | + navView.setupWithNavController(navController) | |
34 | + } | |
35 | + | |
36 | + override fun onCreateOptionsMenu(menu: Menu): Boolean { | |
37 | + // Inflate the menu; this adds items to the action bar if it is present. | |
38 | + menuInflater.inflate(R.menu.main, menu) | |
39 | + return true | |
40 | + } | |
41 | + | |
42 | + override fun onSupportNavigateUp(): Boolean { | |
43 | + val navController = findNavController(R.id.nav_host_fragment) | |
44 | + return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp() | |
45 | + } | |
46 | +} | |
0 | 47 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/UI/SplashActivity.kt
... | ... | @@ -0,0 +1,29 @@ |
1 | +package com.focasoftware.deboinventariov20.UI | |
2 | + | |
3 | +import android.app.Activity | |
4 | +import android.content.Intent | |
5 | +import android.os.Bundle | |
6 | +import com.focasoftware.deboinventariov20.R | |
7 | + | |
8 | +class SplashActivity : Activity() { | |
9 | + | |
10 | + override fun onCreate(savedInstanceState: Bundle?) { | |
11 | + super.onCreate(savedInstanceState) | |
12 | + setContentView(R.layout.activity_splash) | |
13 | + //window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | |
14 | + | |
15 | + val bac = object : Thread(){ | |
16 | + override fun run(){ | |
17 | + try { | |
18 | + Thread.sleep(5) | |
19 | + val intent = Intent(baseContext, MainActivity:: class.java) | |
20 | + startActivity(intent) | |
21 | + finish() | |
22 | + } catch (e : Exception){ | |
23 | + e.printStackTrace() | |
24 | + } | |
25 | + } | |
26 | + } | |
27 | + bac.start() | |
28 | + } | |
29 | +} |
app/src/main/java/com/focasoftware/deboinventariov20/UI/Utils/BaseViewHolder.kt
... | ... | @@ -0,0 +1,9 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.Utils | |
2 | + | |
3 | +import android.view.View | |
4 | +import androidx.recyclerview.widget.RecyclerView | |
5 | + | |
6 | +abstract class BaseViewHolder<T>(itemView: View):RecyclerView.ViewHolder(itemView) { | |
7 | + abstract fun bind(item: T, position: Int) | |
8 | +} | |
9 | + |
app/src/main/java/com/focasoftware/deboinventariov20/UI/Utils/Utils.kt
... | ... | @@ -0,0 +1,80 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.Utils | |
2 | + | |
3 | +import android.app.AlertDialog | |
4 | +import android.app.Dialog | |
5 | +import android.content.Context | |
6 | +import android.os.Bundle | |
7 | +import androidx.fragment.app.DialogFragment | |
8 | +import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
9 | +import kotlinx.coroutines.Dispatchers | |
10 | +import kotlinx.coroutines.GlobalScope | |
11 | +import kotlinx.coroutines.async | |
12 | + | |
13 | +fun modificarCantidadEnCabecera(inventarioActual: Int, b: Boolean,context: Context) { | |
14 | + GlobalScope.async(Dispatchers.IO) { | |
15 | + var cantProductos = 0 | |
16 | + cantProductos = AppDb.getAppDb(context)!!.InvHeadDAO()!!.consultaCantidadInvH(inventarioActual) | |
17 | + if (b) { | |
18 | + AppDb.getAppDb(context)!!.InvHeadDAO()!!.updateInvBody(inventarioActual, cantProductos + 1) | |
19 | + } else { | |
20 | + AppDb.getAppDb(context)!!.InvHeadDAO()!!.updateInvBody(inventarioActual, cantProductos - 1) | |
21 | + } | |
22 | + } | |
23 | +} | |
24 | + | |
25 | +open class AlertDialogBorrarInv : DialogFragment() { | |
26 | + | |
27 | + interface OnBorrarInvClickListener { | |
28 | + fun onPositiveClick() | |
29 | + fun onCancelClick() | |
30 | + } | |
31 | + | |
32 | + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
33 | + return activity?.let { | |
34 | + val title = "Borrar Inventario" | |
35 | + val content = "ยฟSeguro que desea Borrar el inventario?" | |
36 | + val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) | |
37 | + builder.setTitle(title).setMessage(content) | |
38 | + .setPositiveButton(android.R.string.ok) { _, _ -> | |
39 | + val listener = activity as OnBorrarInvClickListener? | |
40 | + listener!!.onPositiveClick() | |
41 | + } | |
42 | + .setNegativeButton(android.R.string.cancel) { _, _ -> | |
43 | + val listener = activity as OnBorrarInvClickListener? | |
44 | + listener!!.onCancelClick() | |
45 | + } | |
46 | + return builder.create() | |
47 | + } ?: throw IllegalStateException("Activity cannot be null") | |
48 | + } | |
49 | + public fun Int.twoDigits() = | |
50 | + if (this <= 9) "0$this" else this.toString()} | |
51 | + | |
52 | +public class NoEncontradoSimple : DialogFragment() { | |
53 | + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
54 | + return activity?.let { | |
55 | + val title = "" | |
56 | + val content = "ยกEl producto buscado NO fue encontrado!" | |
57 | + val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) | |
58 | + builder.setTitle(title).setMessage(content).setPositiveButton(android.R.string.ok) { _, _ -> | |
59 | + //Todo OK click | |
60 | + } | |
61 | + | |
62 | + return builder.create() | |
63 | + } ?: throw IllegalStateException("Activity cannot be null") | |
64 | + } | |
65 | +} | |
66 | + public class noServerConf : DialogFragment() { | |
67 | + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
68 | + return activity?.let { | |
69 | + val title = "" | |
70 | + val content = "ยกAntes de importar debe configurar un servidor!" | |
71 | + val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) | |
72 | + builder.setTitle(title).setMessage(content) | |
73 | + .setPositiveButton(android.R.string.ok) { _, _ -> | |
74 | + activity?.onBackPressed(); | |
75 | + } | |
76 | + | |
77 | + return builder.create() | |
78 | + } ?: throw IllegalStateException("Activity cannot be null") | |
79 | + } | |
80 | +} | |
0 | 81 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/UI/actualizacionMaestros/ActuaMaestrosFragment.kt
... | ... | @@ -0,0 +1,221 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.actualizacionMaestros | |
2 | + | |
3 | +import android.os.Bundle | |
4 | +import android.view.LayoutInflater | |
5 | +import android.view.View | |
6 | +import android.view.ViewGroup | |
7 | +import android.widget.Button | |
8 | +import androidx.fragment.app.Fragment | |
9 | +import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
10 | +import com.focasoftware.deboinventariov20.Model.Articles | |
11 | +import com.focasoftware.deboinventariov20.Model.ProductosService | |
12 | +import com.focasoftware.deboinventariov20.R | |
13 | +import com.focasoftware.deboinventariov20.UI.Utils.noServerConf | |
14 | +import kotlinx.android.synthetic.main.fragment_actua_maestros.* | |
15 | +import kotlinx.coroutines.* | |
16 | +import kotlinx.coroutines.Dispatchers.IO | |
17 | +import kotlinx.coroutines.Dispatchers.Main | |
18 | + | |
19 | +var BASE_URL = "" | |
20 | + | |
21 | +class ActuaMaestrosFragment : Fragment() { | |
22 | + | |
23 | + override fun onCreate(savedInstanceState: Bundle?) { | |
24 | + super.onCreate(savedInstanceState) | |
25 | + GlobalScope.launch(Main) { | |
26 | + val serverPre = fetchServerPreOne() | |
27 | + if (serverPre.isNullOrEmpty()) { | |
28 | + val modalDialog = noServerConf() | |
29 | + modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | |
30 | + } else { | |
31 | + BASE_URL = serverPre.toString() | |
32 | + } | |
33 | + } | |
34 | +// mostrarArticulos() | |
35 | + } | |
36 | + | |
37 | + private suspend fun fetchServerPreOne(): String? { | |
38 | + return GlobalScope.async(IO) { | |
39 | + return@async AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.fetchServerPreOne() | |
40 | + }.await() | |
41 | + } | |
42 | + | |
43 | + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
44 | + // Inflate the layout for this fragment | |
45 | + val v = inflater.inflate(R.layout.fragment_actua_maestros, container, false) | |
46 | + val bConfirmarAct = v.findViewById<Button>(R.id.btnConfirmarAct) | |
47 | + bConfirmarAct.setOnClickListener { | |
48 | + loading_view.visibility = View.VISIBLE | |
49 | + countriesList.text = "Obteniendo artรญculos del servidor $BASE_URL, aguarde por favor." | |
50 | + GlobalScope.launch(Main) { | |
51 | + obtenerArticulos() | |
52 | + } | |
53 | + } | |
54 | + return v | |
55 | + } | |
56 | + | |
57 | + | |
58 | + private suspend fun obtenerArticulos() { | |
59 | + | |
60 | + val productosService = ProductosService.getProductosService() | |
61 | + var index: Long = 1 | |
62 | + withContext(IO) { | |
63 | + val job = CoroutineScope(Dispatchers.IO).launch { | |
64 | + // TODO: BORRO TODO LOS ARTICULOS DE LA BASE PARA CARGARLOS DE NUEVO | |
65 | + AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!!.deleteAllArticulos() | |
66 | + | |
67 | + val response = productosService.getProductos() | |
68 | + if (response.isSuccessful) { | |
69 | + for (pro in response.body()!!) { | |
70 | + val artiAcargar = Articles(pro.sector, | |
71 | + pro.codigo, | |
72 | + pro.descripcion, | |
73 | + pro.codBar, | |
74 | + pro.codOrigen, | |
75 | + pro.precio, | |
76 | + pro.costo, | |
77 | + pro.exiVenta, | |
78 | + pro.exiDeposito, | |
79 | + pro.de, | |
80 | + pro.balanza, | |
81 | + pro.depSn, | |
82 | + pro.imagen) | |
83 | + index += index | |
84 | + AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!!.insertArticulos(artiAcargar) | |
85 | + } | |
86 | + withContext(Main) { | |
87 | + countriesList.visibility = View.VISIBLE | |
88 | + countriesList.text = "ยกDatos Importados Correctamente!" | |
89 | + loading_view.visibility = View.GONE | |
90 | + } | |
91 | + } | |
92 | + } | |
93 | + if (job == null) { | |
94 | + withContext(Main) { | |
95 | + countriesList.visibility = View.VISIBLE | |
96 | + countriesList.text = "No se puedo realizar la conexiรณn al Servidor" | |
97 | + loading_view.visibility = View.GONE | |
98 | + } | |
99 | + } | |
100 | + } | |
101 | + | |
102 | +// withContext(Dispatchers.Main) { | |
103 | +// if (response.isSuccessful) { | |
104 | +// val call = WebService | |
105 | +// .instance | |
106 | +// ?.createService(WebServiceApi::class.java) | |
107 | +// ?.articulos | |
108 | +// call?.enqueue(object : Callback<List<productos?>?> { | |
109 | +// override fun onResponse( | |
110 | +// call: Call<List<productos?>?>, | |
111 | +// response: Response<List<productos?>?> | |
112 | +// ) { | |
113 | +// if (response.code() == 200) { | |
114 | +// for (i in response.body()!!.indices) { | |
115 | +// //AppDb.getAppDb(requireActivity())!!.ArticulosDAO()?.insertArticulos(response.body()!![i]) | |
116 | +// cargarArticulos(2, 500, "sfas", "66666","2,2", "2,2", false, false, "") | |
117 | +//// Log.d( | |
118 | +//// "TAG1", "Nombre Curso: " + response.body()!![i]?.sector | |
119 | +//// + "Codigo Profesor: " + response.body()!![i]?.descripcion | |
120 | +//// ) | |
121 | +// mostrarArticulos() | |
122 | +// } | |
123 | +// } else if (response.code() == 404) { | |
124 | +// Log.d("TAG1", "No hay cursos") | |
125 | +// } | |
126 | +// | |
127 | +// } | |
128 | +// | |
129 | +// override fun onFailure(call: Call<List<productos?>?>, t: Throwable) {} | |
130 | +// }) | |
131 | + } | |
132 | + | |
133 | + fun mostrarArticulos() { | |
134 | + val Job = GlobalScope.launch { | |
135 | + var listArticulos: List<Articles>? = null | |
136 | + var temp: String = "" | |
137 | + listArticulos = AppDb.getAppDb(requireActivity())?.ArticulosDAO()?.findAllArticulos() | |
138 | + if (listArticulos != null) { | |
139 | + | |
140 | + for (i in listArticulos.indices) temp += listArticulos[i].codigo.toString() | |
141 | + } | |
142 | + withContext(Dispatchers.Main) { | |
143 | + countriesList.visibility = View.VISIBLE | |
144 | + loading_view.visibility = View.GONE | |
145 | + countriesList?.text = temp | |
146 | + } | |
147 | + } | |
148 | +// for (professor in listArticulos!!) { | |
149 | +// editT.text= professor.id.toString() | |
150 | +// } | |
151 | + } | |
152 | + | |
153 | + | |
154 | +// fun observeViewModel() { | |
155 | +// | |
156 | +// val productosService = ProductosService.getProductosService() | |
157 | +// var job: Job? = null | |
158 | +// | |
159 | +// | |
160 | +// //countriesList.text="Procesando..." | |
161 | +// //countriesList.visibility = View.VISIBLE | |
162 | +// // GlobalScope1.launch(Dispatchers.IO) { | |
163 | +// val response = productosService.getProductos() | |
164 | +// if (response.isSuccessful) { | |
165 | +//// countriesList.layoutManager = LinearLayoutManager(context) | |
166 | +//// countriesList.itemAnimator = DefaultItemAnimator() | |
167 | +// | |
168 | +//// ProductAdapter.updateCountries(it) | |
169 | +// // cargarArticulos(response.body()) | |
170 | +// | |
171 | +// | |
172 | +// val artiAcargar: Articulos? = null | |
173 | +// var index: Long = 1 | |
174 | +// | |
175 | +// for (pro in response.body()!!) { | |
176 | +// //artiAcargar.id =index+1 | |
177 | +// artiAcargar!!.sector = pro.sector | |
178 | +// artiAcargar.codigo = pro.codigo | |
179 | +// artiAcargar.descripcion = pro.descripcion | |
180 | +// artiAcargar.codBar = pro.codBar | |
181 | +// artiAcargar.precio = pro.precio | |
182 | +// artiAcargar.costo = pro.costo | |
183 | +// artiAcargar.balanza = pro.balanza | |
184 | +// artiAcargar.depSn = pro.depSn | |
185 | +// artiAcargar.imagen = pro.imagen | |
186 | +// index += index | |
187 | +// | |
188 | +// AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! | |
189 | +// .insertArticulos(artiAcargar) | |
190 | +// } | |
191 | +// } | |
192 | +// // } | |
193 | +// | |
194 | +// //job.cancel() | |
195 | +// | |
196 | +// | |
197 | +// } | |
198 | + | |
199 | +// fun cargarArticulos(Productos: List<Productos>?) { | |
200 | +// val artiAcargar: Articulos? = null | |
201 | +// var index: Long = 1 | |
202 | +// //val job4 = CoroutineScope(Dispatchers.Default).launch { | |
203 | +// for (pro in Productos!!) { | |
204 | +// //artiAcargar.id =index+1 | |
205 | +// artiAcargar!!.sector = pro.sector | |
206 | +// artiAcargar.codigo = pro.codigo | |
207 | +// artiAcargar.descripcion = pro.descripcion | |
208 | +// artiAcargar.codBar = pro.codBar | |
209 | +// artiAcargar.precio = pro.precio | |
210 | +// artiAcargar.costo = pro.costo | |
211 | +// artiAcargar.balanza = pro.balanza | |
212 | +// artiAcargar.depSn = pro.depSn | |
213 | +// artiAcargar.imagen = pro.imagen | |
214 | +// index += index | |
215 | +// | |
216 | +// AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! | |
217 | +// .insertArticulos(artiAcargar) | |
218 | +// } | |
219 | +// } | |
220 | +} | |
221 | + |
app/src/main/java/com/focasoftware/deboinventariov20/UI/configuracion/ConfiguracionFragment.kt
... | ... | @@ -0,0 +1,248 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.configuracion | |
2 | + | |
3 | +import android.content.Context | |
4 | +import android.content.SharedPreferences | |
5 | +import android.os.Bundle | |
6 | +import android.view.LayoutInflater | |
7 | +import android.view.View | |
8 | +import android.view.ViewGroup | |
9 | +import android.widget.* | |
10 | +import androidx.fragment.app.Fragment | |
11 | +import androidx.fragment.app.FragmentActivity | |
12 | +import androidx.lifecycle.lifecycleScope | |
13 | +import androidx.navigation.NavController | |
14 | +import androidx.navigation.Navigation | |
15 | +import androidx.navigation.fragment.findNavController | |
16 | +import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
17 | +import com.focasoftware.deboinventariov20.Model.ServeInv | |
18 | +import com.focasoftware.deboinventariov20.R | |
19 | +import kotlinx.android.synthetic.main.fragment_configuracion.* | |
20 | +import kotlinx.coroutines.* | |
21 | +import kotlinx.coroutines.Dispatchers.Main | |
22 | + | |
23 | +class ConfiguracionFragment : Fragment() { | |
24 | + | |
25 | + lateinit var sharedPreferences: SharedPreferences | |
26 | + private lateinit var navController: NavController | |
27 | + var itemSelect: Int = 0 | |
28 | + var indexSelect: Int = 0 | |
29 | + | |
30 | + override fun onCreate(savedInstanceState: Bundle?) { | |
31 | + super.onCreate(savedInstanceState) | |
32 | + sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
33 | + } | |
34 | + | |
35 | + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
36 | + super.onViewCreated(view, savedInstanceState) | |
37 | + navController = Navigation.findNavController(view) | |
38 | + GlobalScope.launch(Main) { | |
39 | + val listServer = mutableListOf<String>() | |
40 | + for (server in getDescServers()) { | |
41 | + listServer.add((if (server.servNum < 9) "0" + server.servNum.toString() else server.servNum.toString()) + " - " + server.descripcion.toString()) | |
42 | + } | |
43 | + val adapterSpServer = ArrayAdapter(requireContext(), R.layout.support_simple_spinner_dropdown_item, listServer) | |
44 | + spServidor.adapter = adapterSpServer | |
45 | + if (sharedPreferences.contains("ServerPredeterminado")) { | |
46 | + spServidor.setSelection(sharedPreferences.getString("ServerPredeterminado", "").toString().toInt()) | |
47 | + } else (spServidor.setSelection(0)) | |
48 | + } | |
49 | + } | |
50 | + | |
51 | + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
52 | + | |
53 | + val v = inflater.inflate(R.layout.fragment_configuracion, container, false) | |
54 | + val etRuta = v.findViewById<EditText>(R.id.etRuta) | |
55 | + val btnGuardar = v.findViewById<Button>(R.id.btnGuardar) | |
56 | + val rbProInclu = v.findViewById<RadioButton>(R.id.rbProInclu) | |
57 | + val rbProNoInclu = v.findViewById<RadioButton>(R.id.rbProNoInclu) | |
58 | + val cbHabiLectura = v.findViewById<CheckBox>(R.id.cbHabiLectura) | |
59 | + val cbMostrarStock = v.findViewById<CheckBox>(R.id.cbMostrarStock) | |
60 | + val rbCodigoBarras = v.findViewById<RadioButton>(R.id.rbCodigoBarras) | |
61 | + val rbCodigoDebo = v.findViewById<RadioButton>(R.id.rbCodigoDebo) | |
62 | + val rbCodigoOrigen = v.findViewById<RadioButton>(R.id.rbCodigoOrigen) | |
63 | + val rbDeposito = v.findViewById<RadioButton>(R.id.rbDeposito) | |
64 | + val rbVentas = v.findViewById<RadioButton>(R.id.rbVentas) | |
65 | + val cbMostrarExistencia = v.findViewById<CheckBox>(R.id.cbMostrarExistencia) | |
66 | + val cbMostrarPrecio = v.findViewById<CheckBox>(R.id.cbMostrarPrecio) | |
67 | + val btnAgregarServidor = v.findViewById<Button>(R.id.btnAgregarServidor) | |
68 | + val spServidor = v.findViewById<Spinner>(R.id.spServidor) | |
69 | + val btnValidarServidor = v.findViewById<Button>(R.id.btnValidarServidor) | |
70 | + | |
71 | + if (sharedPreferences.contains("etRuta")) if (sharedPreferences.contains("rbProInclu")) { | |
72 | + if (sharedPreferences.getString("rbProInclu", "").toString() == "0") { | |
73 | + rbProInclu.isChecked = false | |
74 | + rbProNoInclu.isChecked = true | |
75 | + } else if (sharedPreferences.getString("rbProInclu", "").toString() == "1") { | |
76 | + rbProInclu.isChecked = true | |
77 | + rbProNoInclu.isChecked = false | |
78 | + } | |
79 | + } else (sharedPreferences.getString("rbProInclu", "").toString() == "") | |
80 | + | |
81 | + if (sharedPreferences.contains("rbProNoInclu")) { | |
82 | + if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") { | |
83 | + rbProNoInclu.isChecked = false | |
84 | + rbProInclu.isChecked = true | |
85 | + } else if (sharedPreferences.getString("rbProNoInclu", "").toString() == "1") { | |
86 | + rbProNoInclu.isChecked = true | |
87 | + rbProInclu.isChecked = false | |
88 | + } | |
89 | + } else (sharedPreferences.getString("rbProNoInclu", "").toString() == "") | |
90 | + | |
91 | + if (sharedPreferences.contains("cbHabiLectura")) { | |
92 | + if (sharedPreferences.getString("cbHabiLectura", "").toString() == "0") { | |
93 | + cbHabiLectura.isChecked = false | |
94 | + } else if (sharedPreferences.getString("cbHabiLectura", "").toString() == "1") { | |
95 | + cbHabiLectura.isChecked = true | |
96 | + } | |
97 | + } else (sharedPreferences.getString("cbHabiLectura", "").toString() == "") | |
98 | + | |
99 | + if (sharedPreferences.contains("cbMostrarStock")) { | |
100 | + if (sharedPreferences.getString("cbMostrarStock", "").toString() == "0") { | |
101 | + cbMostrarStock.isChecked = false | |
102 | + } else if (sharedPreferences.getString("cbMostrarStock", "").toString() == "1") { | |
103 | + cbMostrarStock.isChecked = true | |
104 | + } | |
105 | + } else (sharedPreferences.getString("cbMostrarStock", "").toString() == "") | |
106 | + | |
107 | + if (sharedPreferences.contains("rbVentas")) { | |
108 | + if (sharedPreferences.getString("rbVentas", "").toString() == "0") { | |
109 | + rbVentas.isChecked = false | |
110 | + rbDeposito.isChecked = true | |
111 | + } else if (sharedPreferences.getString("rbVentas", "").toString() == "1") { | |
112 | + rbVentas.isChecked = true | |
113 | + rbDeposito.isChecked = false | |
114 | + } | |
115 | + } else (sharedPreferences.getString("rbVentas", "").toString() == "") | |
116 | + | |
117 | + if (sharedPreferences.contains("rbDeposito")) { | |
118 | + if (sharedPreferences.getString("rbDeposito", "").toString() == "0") { | |
119 | + rbDeposito.isChecked = false | |
120 | + rbVentas.isChecked = true | |
121 | + } else if (sharedPreferences.getString("rbDeposito", "").toString() == "1") { | |
122 | + rbDeposito.isChecked = true | |
123 | + rbVentas.isChecked = false | |
124 | + } | |
125 | + } else (sharedPreferences.getString("rbDeposito", "").toString() == "") | |
126 | + | |
127 | + if (sharedPreferences.contains("rbCodigoDebo")) { | |
128 | + if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "0") { | |
129 | + rbCodigoDebo.isChecked = false | |
130 | + rbCodigoOrigen.isChecked = false | |
131 | + rbCodigoBarras.isChecked = false | |
132 | + } else if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "1") { | |
133 | + rbCodigoDebo.isChecked = true | |
134 | + rbCodigoOrigen.isChecked = false | |
135 | + rbCodigoBarras.isChecked = false | |
136 | + } | |
137 | + } else (sharedPreferences.getString("rbCodigoDebo", "").toString() == "") | |
138 | + | |
139 | + if (sharedPreferences.contains("rbCodigoOrigen")) { | |
140 | + if (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "0") { | |
141 | + rbCodigoOrigen.isChecked = false | |
142 | + } else if (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "1") { | |
143 | + rbCodigoOrigen.isChecked = true | |
144 | + } | |
145 | + } else (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "") | |
146 | + | |
147 | + if (sharedPreferences.contains("rbCodigoBarras")) { | |
148 | + if (sharedPreferences.getString("rbCodigoBarras", "").toString() == "0") { | |
149 | + rbCodigoBarras.isChecked = false | |
150 | + } else if (sharedPreferences.getString("rbCodigoBarras", "").toString() == "1") { | |
151 | + rbCodigoBarras.isChecked = true | |
152 | + } | |
153 | + } else (sharedPreferences.getString("rbCodigoBarras", "").toString() == "") | |
154 | + | |
155 | + if (sharedPreferences.contains("cbMostrarExistencia")) { | |
156 | + if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "0") { | |
157 | + cbMostrarExistencia.isChecked = false | |
158 | + } else if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "1") { | |
159 | + cbMostrarExistencia.isChecked = true | |
160 | + } | |
161 | + } else (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "") | |
162 | + | |
163 | + if (sharedPreferences.contains("cbMostrarPrecio")) { | |
164 | + if (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "0") { | |
165 | + cbMostrarPrecio.isChecked = false | |
166 | + } else if (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "1") { | |
167 | + cbMostrarPrecio.isChecked = true | |
168 | + } | |
169 | + } else (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "") | |
170 | + | |
171 | + btnGuardar.setOnClickListener { | |
172 | + guardarPreferencias() | |
173 | + Toast.makeText(v.context, "Los Datos se guardaron correctamente", Toast.LENGTH_LONG).show() | |
174 | + navController.navigate(R.id.action_configuracionFragment_to_mainFragment2) | |
175 | + } | |
176 | + btnAgregarServidor.setOnClickListener { findNavController().navigate(R.id.servidoresFragment) } | |
177 | + | |
178 | + btnValidarServidor.setOnClickListener { Toast.makeText(requireContext(), "Direcciรณn correcta", Toast.LENGTH_LONG).show() } | |
179 | + | |
180 | + spServidor.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { | |
181 | + override fun onNothingSelected(parent: AdapterView<*>?) {} | |
182 | + override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { | |
183 | + itemSelect = parent!!.getItemAtPosition(position).toString().substring(0, 2).toInt() | |
184 | + indexSelect=position | |
185 | + } | |
186 | + } | |
187 | + return v | |
188 | + } | |
189 | + | |
190 | + suspend fun getDescServers(): List<ServeInv> { | |
191 | + return GlobalScope.async(Dispatchers.IO) { | |
192 | + return@async AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.fetchAllServers() | |
193 | + }.await() | |
194 | + } | |
195 | + | |
196 | + fun guardarPreferencias() { | |
197 | +// try { | |
198 | + val editor = sharedPreferences.edit() | |
199 | + | |
200 | + if (etRuta.text.isNotEmpty()) editor?.putString("etRuta", etRuta.text.toString()) | |
201 | + | |
202 | + if (rbProInclu.isChecked) editor?.putString("rbProInclu", "1") else editor?.putString("rbProInclu", "0") | |
203 | + if (rbProNoInclu.isChecked) editor?.putString("rbProNoInclu", "1") else editor?.putString("rbProNoInclu", "0") | |
204 | + | |
205 | + if (cbHabiLectura.isChecked) editor?.putString("cbHabiLectura", "1") else editor?.putString("cbHabiLectura", "0") | |
206 | + if (cbMostrarStock.isChecked) editor?.putString("cbMostrarStock", "1") else editor?.putString("cbMostrarStock", "0") | |
207 | + if (rbVentas.isChecked) editor?.putString("rbVentas", "1") else editor?.putString("rbVentas", "0") | |
208 | + if (rbDeposito.isChecked) editor?.putString("rbDeposito", "1") else editor?.putString("rbDeposito", "0") | |
209 | + if (rbCodigoDebo.isChecked) editor?.putString("rbCodigoDebo", "1") else editor?.putString("rbCodigoDebo", "0") | |
210 | + if (rbCodigoOrigen.isChecked) editor?.putString("rbCodigoOrigen", "1") else editor?.putString("rbCodigoOrigen", "0") | |
211 | + if (rbCodigoBarras.isChecked) editor?.putString("rbCodigoBarras", "1") else editor?.putString("rbCodigoBarras", "0") | |
212 | + if (cbMostrarExistencia.isChecked) editor?.putString("cbMostrarExistencia", "1") else editor?.putString("cbMostrarExistencia", "0") | |
213 | + if (cbMostrarPrecio.isChecked) editor?.putString("cbMostrarPrecio", "1") else editor?.putString("cbMostrarPrecio", "0") | |
214 | + editor?.putString("ServerPredeterminado", indexSelect.toString()) | |
215 | + updateServerPreInZero() | |
216 | + updateServerPre(itemSelect) | |
217 | + | |
218 | + editor?.apply() | |
219 | + editor.commit() | |
220 | + | |
221 | +// } catch (e: Exception) { | |
222 | +// Toast.makeText(requireContext(), "Error ", Toast.LENGTH_LONG).show() | |
223 | +// e.printStackTrace() | |
224 | +// } | |
225 | + } | |
226 | + | |
227 | + private fun updateServerPreInZero() { | |
228 | + lifecycleScope.launch { | |
229 | + withContext(Dispatchers.IO) { | |
230 | + val activity: FragmentActivity? = activity | |
231 | + if (activity != null && isAdded) { | |
232 | + AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.UpdateServerPreInZero() | |
233 | + } | |
234 | + } | |
235 | + } | |
236 | + } | |
237 | + | |
238 | + private fun updateServerPre(server: Int) { | |
239 | + lifecycleScope.launch { | |
240 | + withContext(Dispatchers.IO) { | |
241 | + val activity: FragmentActivity? = activity | |
242 | + if (activity != null) { | |
243 | + AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.UpdateServerPre(server) | |
244 | + } | |
245 | + } | |
246 | + } | |
247 | + } | |
248 | +} | |
0 | 249 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/UI/descripcionFragment/DescripcionFragment.kt
... | ... | @@ -0,0 +1,281 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.descripcionFragment | |
2 | + | |
3 | +import android.app.Activity | |
4 | +import android.app.AlertDialog | |
5 | +import android.content.Context | |
6 | +import android.content.SharedPreferences | |
7 | +import android.graphics.Canvas | |
8 | +import android.graphics.Color | |
9 | +import android.graphics.drawable.ColorDrawable | |
10 | +import android.os.Bundle | |
11 | +import android.text.InputType | |
12 | +import android.view.LayoutInflater | |
13 | +import android.view.View | |
14 | +import android.view.ViewGroup | |
15 | +import android.view.WindowManager | |
16 | +import android.view.inputmethod.InputMethodManager | |
17 | +import androidx.core.content.ContextCompat.getSystemService | |
18 | +import androidx.fragment.app.Fragment | |
19 | +import androidx.fragment.app.FragmentActivity | |
20 | +import androidx.lifecycle.lifecycleScope | |
21 | +import androidx.navigation.NavController | |
22 | +import androidx.navigation.Navigation | |
23 | +import androidx.recyclerview.widget.ItemTouchHelper | |
24 | +import androidx.recyclerview.widget.LinearLayoutManager | |
25 | +import androidx.recyclerview.widget.RecyclerView | |
26 | +import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
27 | +import com.focasoftware.deboinventariov20.Model.Articles | |
28 | +import com.focasoftware.deboinventariov20.Model.InvBody | |
29 | +import com.focasoftware.deboinventariov20.R | |
30 | +import com.focasoftware.deboinventariov20.UI.Utils.modificarCantidadEnCabecera | |
31 | +import com.focasoftware.deboinventariov20.UI.inventario.InventarioFragment | |
32 | +import kotlinx.android.synthetic.main.ingresar_cantidad.view.* | |
33 | +import kotlinx.android.synthetic.main.login_dialog.view.* | |
34 | +import kotlinx.android.synthetic.main.login_dialog.view.btnAceptar | |
35 | +import kotlinx.coroutines.* | |
36 | + | |
37 | + | |
38 | +class DescripcionFragment : Fragment() { | |
39 | + private var artAcargar2: List<Articles>? = null | |
40 | + private var listArticulos2: List<Articles>? = null | |
41 | + lateinit var viewAdapter2: RecyclerView.Adapter<*> | |
42 | + private lateinit var viewManager2: RecyclerView.LayoutManager | |
43 | + private lateinit var rcDescripcion: RecyclerView | |
44 | + private var swipeBackground: ColorDrawable = ColorDrawable(Color.YELLOW) | |
45 | + private var cantidad = 0F | |
46 | + private var numeroInventario = 0 | |
47 | + lateinit var navController: NavController | |
48 | + lateinit var sharedPreferences: SharedPreferences | |
49 | + private var indice = 0 | |
50 | + private var artCargadoEnBD: InvBody? = null | |
51 | + | |
52 | + override fun onCreate(savedInstanceState: Bundle?) { | |
53 | + super.onCreate(savedInstanceState) | |
54 | + sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
55 | + arguments.apply { | |
56 | + artAcargar2 = requireArguments().getSerializable("ArrayDesc") as List<Articles> | |
57 | + numeroInventario = requireArguments().getInt("numeroInv") | |
58 | + } | |
59 | + | |
60 | + } | |
61 | + private fun showSoftKeyboard(view: View) { | |
62 | + if (view.requestFocus()) { | |
63 | + val imm = requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | |
64 | + imm.showSoftInput(view, InputMethodManager.HIDE_IMPLICIT_ONLY) | |
65 | + } | |
66 | + } | |
67 | + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
68 | + super.onViewCreated(view, savedInstanceState) | |
69 | + navController = Navigation.findNavController(view) | |
70 | + showSoftKeyboard(view) | |
71 | + } | |
72 | + | |
73 | + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
74 | + val v = inflater.inflate(R.layout.fragment_descripcion, container, false) | |
75 | + rcDescripcion = v.findViewById(R.id.rcDescripcion) | |
76 | +// val btnSalir = v.findViewById<Button>(R.id.btnSalir) | |
77 | + | |
78 | + | |
79 | + IngresarRecicler(artAcargar2) | |
80 | + showSoftKeyboard(v) | |
81 | +// btnSalir.setOnClickListener { | |
82 | +// activity?.onBackPressed(); | |
83 | +//// VolverAinventario() | |
84 | +// } | |
85 | + return v | |
86 | + } | |
87 | + | |
88 | + fun IngresarRecicler(articulos: List<Articles>?) { | |
89 | + | |
90 | + viewAdapter2 = DescripcionListAdapter(articulos) | |
91 | + viewManager2 = LinearLayoutManager(requireContext()) | |
92 | + | |
93 | + rcDescripcion.apply { | |
94 | + adapter = viewAdapter2 | |
95 | + layoutManager = viewManager2 | |
96 | + } | |
97 | + val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) { | |
98 | + override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | |
99 | + return false | |
100 | + } | |
101 | + | |
102 | + override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { | |
103 | + | |
104 | + var indice = 0 | |
105 | + indice = viewHolder.layoutPosition | |
106 | + GlobalScope.launch(Dispatchers.Main) { | |
107 | + //TODO BUSCO EN BASE DE DATOS | |
108 | + artCargadoEnBD = buscarCodigoDeboEnBD((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)?.sector.toString(), | |
109 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)?.codigo.toString(), | |
110 | + numeroInventario.toString()) | |
111 | + if (artCargadoEnBD == null) { | |
112 | + val mDialogView = LayoutInflater.from(context).inflate(R.layout.ingresar_cantidad, null) | |
113 | + val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setCancelable(false) | |
114 | + //TODO: DEPENDIENDO DEL TIPO DE ARTICULO PERMITER INGRESAR DECIMALES O NO | |
115 | + if ((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==1 || (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==3 || (viewAdapter2 as DescripcionListAdapter).items2?.get( | |
116 | + indice)!!.balanza==7) | |
117 | + mDialogView.etCantidad.inputType= InputType.TYPE_CLASS_NUMBER | |
118 | + | |
119 | + | |
120 | + mDialogView.tvTitulo.text = "${(viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion}" | |
121 | + val mAlertDialog = mBuilder.show() | |
122 | + mDialogView.etCantidad.requestFocus() | |
123 | + mAlertDialog.window!!.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM) | |
124 | + mAlertDialog.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) | |
125 | + mDialogView.btnAceptar.setOnClickListener { | |
126 | + if (mDialogView.etCantidad.text.isNullOrEmpty()) { | |
127 | + mDialogView.etCantidad.error = "No vacio" | |
128 | + mDialogView.etCantidad.requestFocus() | |
129 | + mDialogView.etCantidad.hint = "Ingrese un valor" | |
130 | + } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { | |
131 | + cantidad = mDialogView.etCantidad.text.toString().toFloat() | |
132 | + val body = InvBody(numeroInventario, | |
133 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector, | |
134 | + // TODO: PREPARO PARA MANDAR A CARGAR EN LA BD | |
135 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo, | |
136 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion, | |
137 | + cantidad.toString(), | |
138 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codBar, | |
139 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codOrigen, | |
140 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, | |
141 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, | |
142 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza, | |
143 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.depSn, | |
144 | + InventarioFragment().ObtenerFechaActual(), | |
145 | + InventarioFragment().ObtenerFechaActual()) | |
146 | + InsertarArtEnDB(body)// TODO: MANDO A CARGAR A LA BASE DE DATOS | |
147 | + modificarCantidadEnCabecera(numeroInventario, true, requireActivity()) | |
148 | +// VolverAinventario() | |
149 | + activity?.onBackPressed() | |
150 | + mAlertDialog.dismiss() | |
151 | + } | |
152 | + } | |
153 | + } else if (artCargadoEnBD != null) { | |
154 | + | |
155 | + val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
156 | + val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${artCargadoEnBD!!.descripcion}', se encuentra cargado.").setCancelable(false) | |
157 | + if (artCargadoEnBD!!.balanza.toString().contains("1") || artCargadoEnBD!!.balanza.toString().contains("3") || artCargadoEnBD!!.balanza.toString().contains("7")) mDialogView.tvNuevaCantidad.inputType= InputType.TYPE_CLASS_NUMBER | |
158 | + mDialogView.tvCantInicial.text =String.format("%.2f", artCargadoEnBD!!.cantTomada.toString().toFloat()) | |
159 | + | |
160 | + val mAlertDialog = mBuilder.show() | |
161 | + mDialogView.tvNuevaCantidad.requestFocus() | |
162 | + | |
163 | + | |
164 | + mAlertDialog?.window!!.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM) | |
165 | + mAlertDialog.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) | |
166 | + | |
167 | + mDialogView.rbSumar.setOnClickListener { | |
168 | + if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
169 | + mDialogView.tvResultado.text = String.format("%.2f", (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat())) | |
170 | + mDialogView.tvNuevaCantidad.isEnabled=false | |
171 | + } | |
172 | + } | |
173 | + mDialogView.rbRestar.setOnClickListener { | |
174 | + if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
175 | + if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | |
176 | + mDialogView.tvResultado.text = String.format("%.2f", mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()) | |
177 | + mDialogView.tvNuevaCantidad.isEnabled = false | |
178 | + }else{ | |
179 | + mDialogView.tvResultado.text="" | |
180 | + mDialogView.tvResultado.error = "Operaciรณn No Valida" | |
181 | + mDialogView.tvResultado.requestFocus() | |
182 | + mDialogView.tvResultado.hint = "Error" | |
183 | + } | |
184 | + } | |
185 | + } | |
186 | + mDialogView.rbMdodificar.setOnClickListener { | |
187 | + if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
188 | + mDialogView.tvResultado.text = String.format("%.2f", (mDialogView.tvNuevaCantidad.text.toString().toFloat())) | |
189 | + mDialogView.tvNuevaCantidad.isEnabled = false | |
190 | + } | |
191 | + } | |
192 | + mDialogView.btnAceptar.setOnClickListener { | |
193 | + if (mDialogView.tvNuevaCantidad.text.isNotEmpty() || !mDialogView.tvNuevaCantidad.text.isBlank()) { | |
194 | + if (mDialogView.tvResultado.text.isNotEmpty() || !mDialogView.tvResultado.text.isBlank()) { | |
195 | + | |
196 | + updateCantidad((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector.toString(), | |
197 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo.toString(), | |
198 | + mDialogView.tvResultado.text.toString().toFloat()) | |
199 | +// VolverAinventario() | |
200 | + activity?.onBackPressed(); | |
201 | + mAlertDialog.dismiss() | |
202 | + } else if (mDialogView.tvNuevaCantidad.text.isNotEmpty() || mDialogView.tvNuevaCantidad.text.isBlank()) { | |
203 | + mDialogView.tvResultado.error = "Operaciรณn Requerida" | |
204 | + mDialogView.tvResultado.requestFocus() | |
205 | + mDialogView.tvResultado.hint = "Seleccione Operaciรณn" | |
206 | + } | |
207 | + } else if (mDialogView.tvNuevaCantidad.text.isEmpty() || mDialogView.tvNuevaCantidad.text.isBlank()) { | |
208 | + mDialogView.tvNuevaCantidad.error = "Completar" | |
209 | + mDialogView.tvNuevaCantidad.requestFocus() | |
210 | + mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | |
211 | + } | |
212 | + } | |
213 | + mDialogView.dialogCancelBtn.setOnClickListener { | |
214 | + activity?.onBackPressed(); | |
215 | + mAlertDialog.dismiss() | |
216 | + } | |
217 | + } | |
218 | + } | |
219 | + } | |
220 | + | |
221 | + override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | |
222 | + super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
223 | + val itemView = viewHolder.itemView | |
224 | + | |
225 | + c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | |
226 | + | |
227 | + if (dX > 0) { | |
228 | + | |
229 | + c.drawColor(Color.RED) | |
230 | + } else if (dX < 0) { | |
231 | + // swipeBackground.setBounds(itemView.right+dX.toInt(),itemView.top,itemView.right,itemView.bottom) | |
232 | + c.drawColor(Color.YELLOW) | |
233 | + } | |
234 | + swipeBackground.draw(c) | |
235 | + super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
236 | + } | |
237 | + } | |
238 | + val itemTouchHelper2 = ItemTouchHelper(itemTouchHelperCallback) | |
239 | + itemTouchHelper2.attachToRecyclerView(rcDescripcion) | |
240 | + | |
241 | + } | |
242 | + | |
243 | + fun InsertarArtEnDB(cuarpoInventario: InvBody) { | |
244 | + lifecycleScope.launch { | |
245 | + withContext(Dispatchers.IO) { | |
246 | + AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) | |
247 | + } | |
248 | + } | |
249 | + } | |
250 | + | |
251 | +// fun VolverAinventario() { | |
252 | +// | |
253 | +// val editor = sharedPreferences.edit() | |
254 | +// editor?.putString("Inventario", numeroInventario.toString()) | |
255 | +// editor?.apply() | |
256 | +// editor.commit() | |
257 | +// navController.navigate(R.id.action_descripcionFragment_to_inventarioFragment) | |
258 | +// } | |
259 | + | |
260 | + suspend fun buscarCodigoDeboEnBD(sector: String, codigo: String, numInventario: String): InvBody? { | |
261 | + //TODO BUSQUEDA POR CODIGO DE BARRAS | |
262 | + var busqueda: InvBody? = null | |
263 | + return GlobalScope.async(Dispatchers.IO) { | |
264 | + busqueda = AppDb.getAppDb(requireContext())!!.InvBodyDAO()!!.fetchArtInInvBody(sector, codigo, numInventario) | |
265 | + return@async busqueda | |
266 | + }.await() | |
267 | + } | |
268 | + | |
269 | + fun updateCantidad(sector: String, codigo: String, cantidad: Float) { | |
270 | + lifecycleScope.launch { | |
271 | + withContext(Dispatchers.IO) { | |
272 | + val activity: FragmentActivity? = activity | |
273 | + if (activity != null && isAdded) { | |
274 | + AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.UpdateInvBody(cantidad, sector, codigo) | |
275 | + } | |
276 | + } | |
277 | + } | |
278 | + } | |
279 | +} | |
280 | + | |
281 | + |
app/src/main/java/com/focasoftware/deboinventariov20/UI/descripcionFragment/DescripcionListAdapter.kt
... | ... | @@ -0,0 +1,48 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.descripcionFragment | |
2 | + | |
3 | +import android.view.LayoutInflater | |
4 | +import android.view.View | |
5 | +import android.view.ViewGroup | |
6 | +import androidx.recyclerview.widget.RecyclerView | |
7 | +import com.focasoftware.deboinventariov20.Model.Articles | |
8 | +import com.focasoftware.deboinventariov20.R | |
9 | +import kotlinx.android.synthetic.main.item.view.* | |
10 | + | |
11 | +class DescripcionListAdapter(private val productos: List<Articles>?) : | |
12 | + RecyclerView.Adapter<DescripcionListAdapter.ItemsViewHolder>() { | |
13 | + internal var items2: List<Articles>? = null | |
14 | + | |
15 | + init { | |
16 | + this.items2 = productos | |
17 | + } | |
18 | + | |
19 | + override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder( | |
20 | + LayoutInflater.from(parent.context).inflate(R.layout.item_descripcion, parent, false) | |
21 | + ) | |
22 | + | |
23 | + override fun getItemCount() = productos!!.size | |
24 | + | |
25 | + override fun onBindViewHolder(holder: ItemsViewHolder, position: Int) { | |
26 | + when (holder) { | |
27 | + is ItemsViewHolder -> { | |
28 | + holder.bind(items2!![position]) | |
29 | + } | |
30 | + } | |
31 | + } | |
32 | + | |
33 | + | |
34 | + class ItemsViewHolder constructor(view: View) : RecyclerView.ViewHolder(view) { | |
35 | + | |
36 | + val sector = view.tvSector | |
37 | + val codigo = view.tvCodigo | |
38 | + val descripcion = view.tvDescripcion | |
39 | + val codigoBarras = view.tvCodigoBarras | |
40 | + | |
41 | + fun bind(pro: Articles) { | |
42 | + sector.text = pro.sector | |
43 | + codigo.text = pro.codigo | |
44 | + descripcion.text = pro.descripcion | |
45 | + codigoBarras.text = pro.codBar | |
46 | + } | |
47 | + } | |
48 | +} | |
0 | 49 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/UI/descripcionFragment/ItemDescripcion.kt
app/src/main/java/com/focasoftware/deboinventariov20/UI/detalleProducto/DetalleArtFragment.kt
... | ... | @@ -0,0 +1,95 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.detalleProducto | |
2 | + | |
3 | +import android.content.Context | |
4 | +import android.content.SharedPreferences | |
5 | +import android.os.Bundle | |
6 | +import android.view.LayoutInflater | |
7 | +import android.view.View | |
8 | +import android.view.ViewGroup | |
9 | +import androidx.fragment.app.Fragment | |
10 | +import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
11 | +import com.focasoftware.deboinventariov20.Model.Articles | |
12 | +import com.focasoftware.deboinventariov20.R | |
13 | +import kotlinx.android.synthetic.main.fragment_detalle_art.* | |
14 | +import kotlinx.coroutines.Dispatchers | |
15 | +import kotlinx.coroutines.GlobalScope | |
16 | +import kotlinx.coroutines.async | |
17 | +import kotlinx.coroutines.launch | |
18 | + | |
19 | +class DetalleArtFragment : Fragment() { | |
20 | + | |
21 | + private var Inventario: Int = 0 | |
22 | + private var sector: String? = null | |
23 | + private var codigo: String? = null | |
24 | + private var artSerch: Articles? = null | |
25 | + lateinit var sharedPreferences: SharedPreferences | |
26 | + | |
27 | + override fun onCreate(savedInstanceState: Bundle?) { | |
28 | + super.onCreate(savedInstanceState) | |
29 | + sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
30 | + arguments?.let { | |
31 | + sector = it.getString("sector") | |
32 | + codigo = it.getString("codigo") | |
33 | + Inventario= it.getInt("numeroInv") | |
34 | + } | |
35 | + marcarInventario() | |
36 | + GlobalScope.launch(Dispatchers.Main) { | |
37 | + | |
38 | + artSerch = buscarCodigoDeboEnBD(sector, codigo) | |
39 | + if (artSerch == null) { | |
40 | + | |
41 | +// val type = InputType.TYPE_CLASS_NUMBER | |
42 | +// MaterialDialog(requireContext()).show { | |
43 | +// | |
44 | +// title(text = "Producto '$sChangeUpper', se encuentra cargado.") | |
45 | +// message(R.string.sCantidadNueva) | |
46 | +// input(waitForPositiveButton = false, hint = "99.99", inputType = type) { materialDialog, charSequence -> | |
47 | +// fCant = 0F | |
48 | +// fCant = charSequence.toString().toFloat() | |
49 | +// } | |
50 | +// positiveButton(R.string.btnOk) { | |
51 | +// //TODO ACTUALIZO CANTIADAD EN BD | |
52 | +// updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
53 | +// //TODO ACTUALIZO CANTIDAD EN RV | |
54 | +// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
55 | +// viewAdapter.notifyDataSetChanged() | |
56 | +// dismiss() | |
57 | +// } | |
58 | +// }.cancelOnTouchOutside(false).cornerRadius(10F) | |
59 | + } else if (artSerch != null) { | |
60 | + tvSector.text=sector | |
61 | + tvCodigo.text=codigo | |
62 | + tvDeposito.text=if(artSerch!!.depSn!!.toInt() ==0)"No" else "Si" | |
63 | + tvDescripcion.text=artSerch!!.descripcion.toString() | |
64 | + tvCodigoBarras.text=artSerch!!.codBar.toString() | |
65 | + tvCodigoOrigen.text=artSerch!!.codOrigen.toString() | |
66 | + tvExiVenta.text=artSerch!!.exiVenta.toString() | |
67 | + tvExiDeposito.text=artSerch!!.exiDeposito.toString() | |
68 | + tvBal.text=artSerch!!.balanza.toString() | |
69 | + tvDE.text=artSerch!!.de.toString() | |
70 | + } | |
71 | + } | |
72 | + } | |
73 | + | |
74 | + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
75 | + | |
76 | + return inflater.inflate(R.layout.fragment_detalle_art, container, false) | |
77 | + } | |
78 | + | |
79 | + suspend fun buscarCodigoDeboEnBD(sector: String?, codigo: String?): Articles? { | |
80 | + //TODO BUSQUEDA POR CODIGO DE BARRAS | |
81 | + var busqueda: Articles? = null | |
82 | + return GlobalScope.async(Dispatchers.IO) { | |
83 | + busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.fetchArticuloByCodSec(sector, codigo) | |
84 | + return@async busqueda | |
85 | + }.await() | |
86 | + } | |
87 | + fun marcarInventario() { | |
88 | + | |
89 | + val editor = sharedPreferences.edit() | |
90 | + editor?.putString("Inventario", Inventario.toString()) | |
91 | + editor?.apply() | |
92 | + editor.commit() | |
93 | +// navController.navigate(R.id.action_descripcionFragment_to_inventarioFragment) | |
94 | + } | |
95 | +} | |
0 | 96 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/UI/inventario/InventarioFragment.kt
... | ... | @@ -0,0 +1,810 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.inventario | |
2 | + | |
3 | +import android.annotation.SuppressLint | |
4 | +import android.app.AlertDialog | |
5 | +import android.content.Context | |
6 | +import android.content.Context.INPUT_METHOD_SERVICE | |
7 | +import android.content.DialogInterface | |
8 | +import android.content.SharedPreferences | |
9 | +import android.graphics.Canvas | |
10 | +import android.graphics.Color | |
11 | +import android.graphics.drawable.Drawable | |
12 | +import android.os.Bundle | |
13 | +import android.text.InputType.TYPE_CLASS_NUMBER | |
14 | +import android.view.* | |
15 | +import android.view.inputmethod.InputMethodManager | |
16 | +import android.widget.EditText | |
17 | +import android.widget.TextView | |
18 | +import android.widget.Toast | |
19 | +import androidx.core.content.ContextCompat | |
20 | +import androidx.core.os.bundleOf | |
21 | +import androidx.fragment.app.Fragment | |
22 | +import androidx.lifecycle.lifecycleScope | |
23 | +import androidx.navigation.NavController | |
24 | +import androidx.navigation.Navigation | |
25 | +import androidx.recyclerview.widget.ItemTouchHelper | |
26 | +import androidx.recyclerview.widget.LinearLayoutManager | |
27 | +import androidx.recyclerview.widget.RecyclerView | |
28 | +import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
29 | +import com.focasoftware.deboinventariov20.Model.Articles | |
30 | +import com.focasoftware.deboinventariov20.Model.InvBody | |
31 | +import com.focasoftware.deboinventariov20.Model.InvHead | |
32 | +import com.focasoftware.deboinventariov20.R | |
33 | +import com.focasoftware.deboinventariov20.UI.Utils.NoEncontradoSimple | |
34 | +import com.focasoftware.deboinventariov20.UI.Utils.modificarCantidadEnCabecera | |
35 | +import kotlinx.android.synthetic.main.fragment_inventario.* | |
36 | +import kotlinx.android.synthetic.main.ingresar_cantidad.view.* | |
37 | +import kotlinx.android.synthetic.main.login_dialog.view.* | |
38 | +import kotlinx.android.synthetic.main.login_dialog.view.btnAceptar | |
39 | +import kotlinx.coroutines.* | |
40 | +import java.time.LocalDateTime | |
41 | +import java.time.format.DateTimeFormatter | |
42 | +import java.util.* | |
43 | + | |
44 | +class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickListener { | |
45 | + | |
46 | + private lateinit var sharedPreferences: SharedPreferences | |
47 | + private var iArea: Int = 0 | |
48 | + private lateinit var invHead: InvHead | |
49 | + private lateinit var rcInventarios: RecyclerView | |
50 | + private lateinit var viewAdapter: RecyclerView.Adapter<*> | |
51 | + private lateinit var viewManager: RecyclerView.LayoutManager | |
52 | + private lateinit var sChangeUpper: String | |
53 | + private var listArticulos = ArrayList<ItemsRecycler>() | |
54 | + private lateinit var navController: NavController | |
55 | + var InventarioNuevo: Int = 0 | |
56 | + private var iEstado = 0 | |
57 | + private var iBusquedaPor = 0 | |
58 | + private var fCant = 0F | |
59 | + private var bFirst = false | |
60 | + private lateinit var deleteIcon: Drawable | |
61 | + | |
62 | + @SuppressLint("MissingPermission") | |
63 | + override fun onCreate(savedInstanceState: Bundle?) { | |
64 | + super.onCreate(savedInstanceState) | |
65 | + | |
66 | + sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
67 | + if (sharedPreferences.contains("Inventario")) if (sharedPreferences.getString("Inventario", "").toString() != "-1") { | |
68 | + InventarioNuevo = sharedPreferences.getString("Inventario", "").toString().toInt() | |
69 | + val editor = sharedPreferences.edit() | |
70 | + editor?.putString("Inventario", "-1") | |
71 | + editor?.apply() | |
72 | + editor.commit() | |
73 | + } | |
74 | +// val c = Calendar.getInstance() | |
75 | +// c[2009, 9, 9, 12, 0] = 0 | |
76 | +// val am: AlarmManager = requireActivity().getSystemService(Context.ALARM_SERVICE) as AlarmManager | |
77 | +// am.setTime(c.timeInMillis) | |
78 | + } | |
79 | +// private fun setupTimeZone(timeZoneName: String) { | |
80 | +// val am = requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager | |
81 | +// am.setTimeZone("Europe/Madrid") | |
82 | +// } | |
83 | + | |
84 | + | |
85 | + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
86 | + val v = inflater.inflate(R.layout.fragment_inventario, container, false) | |
87 | + sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
88 | + val tCodigoBarras = v.findViewById<EditText>(R.id.etCodigoBarras) | |
89 | + rcInventarios = v.findViewById(R.id.rcInventarios) | |
90 | + val tvTitulo = v.findViewById<TextView>(R.id.tvTitulo) | |
91 | + | |
92 | + if (InventarioNuevo == 0) {// TODO: SI INVETNARIO NUEVO | |
93 | + GlobalScope.launch(Dispatchers.Main) { | |
94 | + //TODO: BUSCO EL ULTIMO INVENTARIO EN LA BD PARA PODER CREAR EL PROXIMO | |
95 | + InventarioNuevo = AppDb.getAppDb(requireActivity())?.InvHeadDAO()?.findLastInv()?.plus(1) ?: 1 | |
96 | + //TODO: CREAMOS EL INVENTARIO EN LA CABECERA DEL INVENTARIO | |
97 | + invHead = InvHead(InventarioNuevo, if (SerchArea() == 0) "Ventas" else "Deposito", 1, ObtenerFechaActual(), ObtenerFechaActual(), 0L, SerchArea(), AjusteProductos(), ProdNoCont()) | |
98 | + AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.insertInvHead(invHead) | |
99 | + tvTitulo.text = "Inventario Dinamico" + " Nยฐ $InventarioNuevo" | |
100 | + } | |
101 | + } else {// TODO (SI VENGO DE FRAGMENT DESCRIPCION) | |
102 | + listArticulos.clear() | |
103 | + CargarDeBdInventario(InventarioNuevo) | |
104 | + tvTitulo.text = "Inventario Dinamico" + " Nยฐ $InventarioNuevo" | |
105 | + } | |
106 | + | |
107 | + tCodigoBarras.setOnKeyListener { _, keyCode, keyEvent -> | |
108 | + if (keyCode == KeyEvent.KEYCODE_ENTER && keyEvent.action == KeyEvent.ACTION_UP) { | |
109 | + sChangeUpper = tCodigoBarras.text.toString() | |
110 | + var indiceDelArtEncontrado = 0 | |
111 | + | |
112 | + if (tCodigoBarras.text.isNullOrBlank()) { | |
113 | + tCodigoBarras.error = "No puede estar vacio" | |
114 | + tCodigoBarras.requestFocus() | |
115 | + tCodigoBarras.hint = "No puede estar vacio" | |
116 | + } else { | |
117 | + | |
118 | + //TODO COMIENZA LA BUSQUEDA POR CODIGO DE BARRAS | |
119 | + when (iBusquedaPor) { | |
120 | + 0 -> { | |
121 | + // TODO: ESCONDE EL TECLADO VIRTUAL AL PRESIONAR ENTER | |
122 | + val imm = requireActivity().getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager? | |
123 | + imm!!.hideSoftInputFromWindow(requireActivity().currentFocus?.windowToken, InputMethodManager.HIDE_NOT_ALWAYS) | |
124 | + | |
125 | + GlobalScope.launch(Dispatchers.Main) { | |
126 | + indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 0)//TODO Si encuentra el articulo en el RV devuelve el indice | |
127 | + //TODO (Si no lo encuentra devuelve -1) | |
128 | + if (indiceDelArtEncontrado != -1) { | |
129 | + if (swSumaUno!!.isChecked) { | |
130 | +// fCant = 0F | |
131 | +// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
132 | +// fCant += 1F | |
133 | + //TODO ACTUALIZO LA CANTIDAD EN LA BD | |
134 | + updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), | |
135 | + listArticulos[indiceDelArtEncontrado].codigo.toString(), | |
136 | + listArticulos[indiceDelArtEncontrado].cantTomada + 1) | |
137 | + //TODO ACTUALIZO LA CANTIDAD EN EL RV | |
138 | + listArticulos[indiceDelArtEncontrado].cantTomada = listArticulos[indiceDelArtEncontrado].cantTomada + 1 | |
139 | + viewAdapter.notifyDataSetChanged() | |
140 | + } else { | |
141 | + dialogoSumaResta(requireContext(), indiceDelArtEncontrado, listArticulos[indiceDelArtEncontrado].univta, false) | |
142 | + } | |
143 | + | |
144 | + } else if (indiceDelArtEncontrado == -1) {// TODO: no lo encontro en el RV, lo va a buscar en al BD | |
145 | + //TODO BUSCO EN BASE DE DATOS | |
146 | + val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | |
147 | + ContinuarCargaCB(artEncontrado)//TODO SE MANDA CERO POR QUE ES UN ARTICULO ESCANEADO NUEVO PARA QUE SEA COMPATIBLE | |
148 | + } | |
149 | + tCodigoBarras.focusable = View.FOCUSABLE | |
150 | + tCodigoBarras.setText("") | |
151 | + tCodigoBarras.selectAll() | |
152 | + } | |
153 | + return@setOnKeyListener true | |
154 | + | |
155 | + | |
156 | + } | |
157 | + 1 -> {//TODO: BUSQUEDA POR DESCRIPCION************************************************************************** | |
158 | + // TODO: ESCONDE EL TECLADO VIRTUAL AL PRESIONAR ENTER | |
159 | + val imm = requireActivity().getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager? | |
160 | + imm!!.hideSoftInputFromWindow(requireActivity().currentFocus?.windowToken, InputMethodManager.HIDE_NOT_ALWAYS) | |
161 | + // indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 1) //TODO :Si encuentra el articulo en el RV devuelve el indice | |
162 | + // //TODO Si no lo encuentra devuelve -1 | |
163 | + // if (indiceDelArtEncontrado != -1) { | |
164 | + //// if (swSumaUno!!.isChecked) { | |
165 | + //// fCant = 0F | |
166 | + //// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
167 | + //// fCant += 1F | |
168 | + //// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
169 | + //// viewAdapter.notifyDataSetChanged() | |
170 | + //// } else { | |
171 | + // fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
172 | + // MaterialDialog(requireContext()).show { | |
173 | + // title(R.string.sTituloNueva) | |
174 | + // message(R.string.sCantidadNueva) | |
175 | + // input { materialDialog, charSequence -> | |
176 | + // fCant = 0F | |
177 | + // fCant = charSequence.toString().toFloat() | |
178 | + // } | |
179 | + // positiveButton(R.string.btnOk) { | |
180 | + // listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
181 | + // viewAdapter.notifyDataSetChanged() | |
182 | + // dismiss() | |
183 | + // } | |
184 | + // }.cancelOnTouchOutside(false).cornerRadius(10F) | |
185 | + //// } | |
186 | + // | |
187 | + // } else if | |
188 | + // (indiceDelArtEncontrado == -1) {// TODO: no lo encontro en el RV, lo va a buscar en al BD | |
189 | + GlobalScope.launch(Dispatchers.Main) { | |
190 | + val artEncontrado = buscarDescEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | |
191 | + ContinuarCargaDesc(artEncontrado as ArrayList<Articles>) | |
192 | + } | |
193 | + // } | |
194 | + | |
195 | + return@setOnKeyListener true | |
196 | + } | |
197 | + 2 -> {//TODO: BUSQUEDA POR CODIGO DE ORIGEN************************************************************************** | |
198 | + val imm = requireActivity().getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager? | |
199 | + imm!!.hideSoftInputFromWindow(requireActivity().currentFocus?.windowToken, InputMethodManager.HIDE_NOT_ALWAYS) | |
200 | + | |
201 | + GlobalScope.launch(Dispatchers.Main) { | |
202 | + indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 2)//TODO Si encuentra el articulo en el RV devuelve el indice | |
203 | +// //TODO Si no lo encuentra devuelve -1 | |
204 | + if (indiceDelArtEncontrado != -1) { | |
205 | + if (swSumaUno!!.isChecked) { | |
206 | + fCant = 0F | |
207 | + fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
208 | + fCant += 1F | |
209 | + //TODO ACTUALIZO LA CANTIDAD EN LA BD | |
210 | + updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
211 | + //TODO ACTUALIZO LA CANTIDAD EN EL RV | |
212 | + listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
213 | + viewAdapter.notifyDataSetChanged() | |
214 | + } else { | |
215 | + dialogoSumaResta(requireContext(), indiceDelArtEncontrado, listArticulos[indiceDelArtEncontrado].univta, false) | |
216 | + } | |
217 | +// } else { | |
218 | +// val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
219 | +// val mBuilder = | |
220 | +// AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${listArticulos[indiceDelArtEncontrado].descripcion}', se encuentra cargado.") | |
221 | +// .setCancelable(false) | |
222 | +// mDialogView.tvCantInicial.text = listArticulos[indiceDelArtEncontrado].cantTomada.toString() | |
223 | +// val mAlertDialog = mBuilder.show() | |
224 | +// mDialogView.rbSumar.setOnClickListener { | |
225 | +// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
226 | +// mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
227 | +// } | |
228 | +// } | |
229 | +// mDialogView.rbRestar.setOnClickListener { | |
230 | +// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
231 | +// if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | |
232 | +// mDialogView.tvgenerico4.text = | |
233 | +// (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
234 | +// } | |
235 | +// } | |
236 | +// } | |
237 | +// mDialogView.rbMdodificar.setOnClickListener { | |
238 | +// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
239 | +// mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
240 | +// } | |
241 | +// } | |
242 | +// mDialogView.btnAceptar.setOnClickListener { | |
243 | +// mAlertDialog.dismiss() | |
244 | +// val name = mDialogView.tvgenerico4.text.toString().toFloat() | |
245 | +// fCant = 0F | |
246 | +// fCant = name | |
247 | +// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
248 | +// updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
249 | +// viewAdapter.notifyDataSetChanged() | |
250 | +// } | |
251 | +// mDialogView.dialogCancelBtn.setOnClickListener { | |
252 | +// mAlertDialog.dismiss() | |
253 | +// } | |
254 | +// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
255 | +// val type = InputType.TYPE_CLASS_NUMBER | |
256 | +// MaterialDialog(requireContext()).show { | |
257 | +// | |
258 | +// title(text = "Producto '$sChangeUpper', se encuentra cargado.") | |
259 | +// message(R.string.sCantidadNueva) | |
260 | +// input(waitForPositiveButton = false, hint = "99.99", inputType = type) { materialDialog, charSequence -> | |
261 | +// fCant = 0F | |
262 | +// fCant = charSequence.toString().toFloat() | |
263 | +// } | |
264 | +// positiveButton(R.string.btnOk) { | |
265 | +// //TODO ACTUALIZO CANTIADAD EN BD | |
266 | +// updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
267 | +// //TODO ACTUALIZO CANTIDAD EN RV | |
268 | +// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
269 | +// viewAdapter.notifyDataSetChanged() | |
270 | +// dismiss() | |
271 | +// } | |
272 | +// }.cancelOnTouchOutside(false).cornerRadius(10F) | |
273 | +// } | |
274 | + } else if (indiceDelArtEncontrado == -1) { | |
275 | + // no lo encontro en el RV, lo va a buscar en al BD | |
276 | + | |
277 | + GlobalScope.launch(Dispatchers.Main) { | |
278 | + //TODO BUSCO EN BASE DE DATOS | |
279 | + listArticulos[indiceDelArtEncontrado].cantTomada | |
280 | + val artEncontrado = buscarCodiogoOriEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | |
281 | + ContinuarCargaCB(artEncontrado) | |
282 | + } | |
283 | + } | |
284 | + } | |
285 | + return@setOnKeyListener true | |
286 | + } | |
287 | + } | |
288 | + } | |
289 | + } | |
290 | + return@setOnKeyListener false | |
291 | + } | |
292 | + return v | |
293 | + } | |
294 | + | |
295 | + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
296 | + super.onViewCreated(view, savedInstanceState) | |
297 | + navController = Navigation.findNavController(view) | |
298 | + etCodigoBarras.requestFocus() | |
299 | +// val modalDialog = NoEncontradoSimple() | |
300 | +// modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | |
301 | + | |
302 | + btnBorrarInv.setOnClickListener { | |
303 | + AlertDialog.Builder(requireContext()).setTitle("Eliminaciรณn de Inventarios").setMessage("ยฟConfirma que desea eliminar el inventario?") | |
304 | + .setPositiveButton(R.string.btnOk, DialogInterface.OnClickListener { dialog, which -> | |
305 | + BorrarInvActual() | |
306 | + Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Borrado", Toast.LENGTH_LONG).show() | |
307 | + navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | |
308 | + InventarioNuevo = 0 | |
309 | + | |
310 | + }).setNegativeButton(R.string.btnCancelar, DialogInterface.OnClickListener { dialog, which -> | |
311 | + //botรณn cancel pulsado | |
312 | + }).show() | |
313 | + } | |
314 | + | |
315 | + btnExportarInv.setOnClickListener { | |
316 | + AlertDialog.Builder(requireContext()).setTitle(R.string.sTituloExportar).setMessage(R.string.sMensajeExportar) | |
317 | + .setPositiveButton(R.string.btnOk, DialogInterface.OnClickListener { dialog, which -> | |
318 | + BorrarInvActual() | |
319 | + Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Exportado al Servidor", Toast.LENGTH_LONG).show() | |
320 | + navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | |
321 | + InventarioNuevo = 0 | |
322 | + | |
323 | + }).setNegativeButton(R.string.btnCancelar, DialogInterface.OnClickListener { dialog, which -> }).show() | |
324 | + } | |
325 | + ivCamara.setOnClickListener { | |
326 | + if (!bFirst) { | |
327 | + iEstado = 1 | |
328 | + bFirst = true | |
329 | + } | |
330 | + | |
331 | + when (iEstado) { | |
332 | + 0 -> { | |
333 | + ivCamara.setImageResource(R.drawable.codbar) | |
334 | + etCodigoBarras.hint = "Busqueda por C. Barras" | |
335 | + swSumaUno.visibility = View.VISIBLE | |
336 | + iBusquedaPor = 0 | |
337 | + iEstado = 1 | |
338 | + } | |
339 | + 1 -> { | |
340 | + ivCamara.setImageResource(R.drawable.desc) | |
341 | + etCodigoBarras.hint = "Busqueda por Descripciรณn" | |
342 | + swSumaUno.visibility = View.GONE | |
343 | + iBusquedaPor = 1 | |
344 | + iEstado = 2 | |
345 | + } | |
346 | + 2 -> { | |
347 | + ivCamara.setImageResource(R.drawable.cod_origen) | |
348 | + etCodigoBarras.hint = "Busqueda por C. Origen" | |
349 | + swSumaUno.visibility = View.GONE | |
350 | + iBusquedaPor = 2 | |
351 | + iEstado = 0 | |
352 | + } | |
353 | + } | |
354 | + } | |
355 | + } | |
356 | + | |
357 | + private fun BorrarInvActual() { | |
358 | + lifecycleScope.launch { | |
359 | + withContext(Dispatchers.IO) { | |
360 | + AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.deleteinvHead(InventarioNuevo) | |
361 | + AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.deleteInvBody(InventarioNuevo) | |
362 | + } | |
363 | + } | |
364 | + } | |
365 | + | |
366 | + private fun CargarDeBdInventario(ultimoInv: Int) { | |
367 | + GlobalScope.launch(Dispatchers.Main) { | |
368 | + val invbody = cargarInventario(ultimoInv) | |
369 | + for ((i, _) in invbody!!.withIndex()) { | |
370 | + val art = Articles(invbody[i].sector, | |
371 | + invbody[i].codigo, | |
372 | + invbody[i].descripcion, | |
373 | + invbody[i].codBar, | |
374 | + invbody[i].codOrigen, | |
375 | + invbody[i].precio, | |
376 | + invbody[i].costo, | |
377 | + "", | |
378 | + "", | |
379 | + "", | |
380 | + invbody[i].balanza, | |
381 | + invbody[i].depSn, | |
382 | + invbody[i].costo) | |
383 | + cargarRecicler(art, invbody[i].cantTomada!!.toFloat()) | |
384 | + } | |
385 | + } | |
386 | + } | |
387 | + | |
388 | + // @SuppressLint("RestrictedApi") | |
389 | + private fun ContinuarCargaDesc(artAcargar: ArrayList<Articles>) { | |
390 | + //TODO DESPUES DE INGRESAR LA DESCRIPCION Y DE BUSCAR LOS CAINCIDENCIAS EN LA BASE SE VA A MOSTRAR LAS MISMAS | |
391 | + //TODO SI LA CANTIDAD ENCONTRADA ES UNO, LO CARGO DIRECTAMENTE EN EL RV | |
392 | + | |
393 | + if (artAcargar.isNotEmpty() || !artAcargar.isNullOrEmpty()) {// TODO: Si lo encuentra en la BD | |
394 | +// if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV | |
395 | +// fCant = 0F | |
396 | +// fCant += 1F | |
397 | +// // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV | |
398 | +// val acargarPorDesc = Articles(artAcargar[0].sector, | |
399 | +// artAcargar[0].codigo, | |
400 | +// artAcargar[0].descripcion, | |
401 | +// artAcargar[0].codBar, | |
402 | +// artAcargar[0].codOrigen, | |
403 | +// artAcargar[0].precio, | |
404 | +// artAcargar[0].costo, | |
405 | +// "", | |
406 | +// "", | |
407 | +// "", | |
408 | +// artAcargar[0].balanza, | |
409 | +// artAcargar[0].depSn, | |
410 | +// "") | |
411 | +// // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD | |
412 | +// cargarArtEnBd(acargarPorDesc, fCant) | |
413 | +// cargarRecicler(acargarPorDesc, fCant) | |
414 | +// } else { | |
415 | + // TODO: ESCONDE EL TECLADO VIRTUAL AL PRESIONAR ENTER | |
416 | + val imm = requireActivity().getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager? | |
417 | + imm!!.hideSoftInputFromWindow(requireActivity().currentFocus?.windowToken, InputMethodManager.HIDE_NOT_ALWAYS) | |
418 | + var bundle = Bundle() | |
419 | + bundle = bundleOf("ArrayDesc" to artAcargar) | |
420 | + bundle.putInt("numeroInv", InventarioNuevo) | |
421 | + navController.navigate(R.id.action_inventarioFragment_to_descripcionFragment, bundle) | |
422 | + //navController.backStack.removeLast() | |
423 | +// } | |
424 | +// } else {//SI NO ESTA +1 | |
425 | +// if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV | |
426 | +// fCant = listArticulos[0].cantTomada | |
427 | +// MaterialDialog(requireContext()).show { | |
428 | +// title(R.string.sTituloNueva) | |
429 | +// message(R.string.sCantidadNueva) | |
430 | +// input { materialDialog, charSequence -> | |
431 | +// fCant = 0F | |
432 | +// fCant = charSequence.toString().toFloat() | |
433 | +// } | |
434 | +// positiveButton(R.string.btnOk) { | |
435 | +// listArticulos[0].cantTomada = fCant | |
436 | +// viewAdapter.notifyDataSetChanged() | |
437 | +// dismiss() | |
438 | +// } | |
439 | +// }.cancelOnTouchOutside(false).cornerRadius(10F) | |
440 | +// // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV | |
441 | +// val acargarPorDesc = Articles(artAcargar[0].sector, | |
442 | +// artAcargar[0].codigo, | |
443 | +// artAcargar[0].descripcion, | |
444 | +// artAcargar[0].codBar, | |
445 | +// artAcargar[0].cod_origen, | |
446 | +// artAcargar[0].precio, | |
447 | +// artAcargar[0].costo, | |
448 | +// artAcargar[0].balanza, | |
449 | +// artAcargar[0].depSn, | |
450 | +// "") | |
451 | +// // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD | |
452 | +// cargarArtEnBd(acargarPorDesc, fCant) | |
453 | +// cargarRecicler(acargarPorDesc, fCant) | |
454 | +// } else { | |
455 | +// var bundle = Bundle() | |
456 | +// bundle = bundleOf("ArrayDesc" to artAcargar) | |
457 | +// bundle.putInt("numeroInv", InventarioNuevo) | |
458 | +// navController.navigate(R.id.action_inventarioFragment_to_descripcionFragment, bundle) | |
459 | +// } | |
460 | +// } | |
461 | + } else {//TODO si no lo encuentra en la BD | |
462 | + val modalDialog = NoEncontradoSimple() | |
463 | + modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | |
464 | + } | |
465 | + etCodigoBarras.focusable = View.FOCUSABLE | |
466 | + etCodigoBarras.setText("") | |
467 | + etCodigoBarras.selectAll() | |
468 | + } | |
469 | + | |
470 | + private fun ContinuarCargaCB(artAcargar: Articles?) { | |
471 | + | |
472 | + if (artAcargar != null) {// TODO: Si lo encuentra en la BD | |
473 | + if (swSumaUno!!.isChecked) {//TODO: SI ESTA +1, PONE CANTIDAD 1 | |
474 | + fCant = 0F | |
475 | + fCant += 1F | |
476 | + cargarArtEnBd(artAcargar, String.format("%.3f", fCant)) | |
477 | + cargarRecicler(artAcargar, fCant) | |
478 | + } else {//TODO: SI NO ESTA +1 PREGUNTA CANTIDAD | |
479 | + | |
480 | + DialogingresarCantidad(requireContext(), artAcargar) | |
481 | + | |
482 | + } | |
483 | + } else {// TODO si no lo encuentra en la BD | |
484 | + val modalDialog = NoEncontradoSimple() | |
485 | + modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | |
486 | + } | |
487 | + etCodigoBarras.focusable = View.FOCUSABLE | |
488 | + etCodigoBarras.setText("") | |
489 | + etCodigoBarras.selectAll() | |
490 | + } | |
491 | + | |
492 | + | |
493 | + fun DialogingresarCantidad(cnxt: Context, artAcargar: Articles?): Float { | |
494 | + var cantidad = 0F | |
495 | + val mDialogView = LayoutInflater.from(cnxt).inflate(R.layout.ingresar_cantidad, null) | |
496 | + val mBuilder = AlertDialog.Builder(cnxt).setView(mDialogView).setCancelable(false) | |
497 | + if (artAcargar!!.balanza!!.toInt() == 1 || artAcargar.balanza!!.toInt() == 3 || artAcargar.balanza!!.toInt() == 7) mDialogView.etCantidad.inputType = TYPE_CLASS_NUMBER | |
498 | + mDialogView.tvTitulo.text = artAcargar.descripcion.toString() | |
499 | + val mAlertDialog = mBuilder.show() | |
500 | + mDialogView.etCantidad.requestFocus() | |
501 | + mAlertDialog?.window!!.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM) | |
502 | + mAlertDialog.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) | |
503 | + | |
504 | + | |
505 | + mDialogView.btnAceptar.setOnClickListener { | |
506 | + if (mDialogView.etCantidad.text.isNullOrEmpty()) { | |
507 | + mDialogView.etCantidad.error = "No vacio" | |
508 | + mDialogView.etCantidad.requestFocus() | |
509 | + mDialogView.etCantidad.hint = "Ingrese un valor" | |
510 | + } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { | |
511 | + mAlertDialog.dismiss() | |
512 | + cantidad = mDialogView.etCantidad.text.toString().toFloat() | |
513 | + cargarArtEnBd(artAcargar, String.format("%.2f", cantidad)) | |
514 | + cargarRecicler(artAcargar, cantidad) | |
515 | + modificarCantidadEnCabecera(InventarioNuevo, true, requireContext()) | |
516 | + } | |
517 | + } | |
518 | + return cantidad | |
519 | + } | |
520 | + | |
521 | + fun dialogoSumaResta(context: Context, indiceDelArtEncontrado: Int, univta: String, cancelable: Boolean) { | |
522 | + val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
523 | + val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("${listArticulos[indiceDelArtEncontrado].descripcion} se encuentra cargado.").setCancelable(cancelable) | |
524 | + // TODO: SI PERMITE QUE INGRESE DECIMALES | |
525 | + if (univta.contains("1") || univta.contains("3") || univta.contains("7")) mDialogView.tvNuevaCantidad.inputType = TYPE_CLASS_NUMBER | |
526 | + | |
527 | + mDialogView.tvCantInicial.text = String.format("%.2f", listArticulos[indiceDelArtEncontrado].cantTomada) | |
528 | + val mAlertDialog = mBuilder.show() | |
529 | + mDialogView.tvNuevaCantidad.requestFocus() | |
530 | + | |
531 | + | |
532 | + | |
533 | + mAlertDialog?.window!!.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM) | |
534 | + mAlertDialog.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) | |
535 | + | |
536 | + mDialogView.rbSumar.setOnClickListener { | |
537 | + if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
538 | + mDialogView.tvResultado.text = String.format("%.2f", mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()) | |
539 | + mDialogView.tvNuevaCantidad.isEnabled = false | |
540 | + } | |
541 | + } | |
542 | + mDialogView.rbRestar.setOnClickListener { | |
543 | + if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
544 | + if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | |
545 | + mDialogView.tvResultado.text = String.format("%.2f", mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()) | |
546 | + mDialogView.tvNuevaCantidad.isEnabled = false | |
547 | + } else { | |
548 | + mDialogView.tvResultado.text = "" | |
549 | + mDialogView.tvResultado.error = "Operaciรณn No Valida" | |
550 | + mDialogView.tvResultado.requestFocus() | |
551 | + mDialogView.tvResultado.hint = "Error" | |
552 | + } | |
553 | + } | |
554 | + } | |
555 | + mDialogView.rbMdodificar.setOnClickListener { | |
556 | + if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
557 | + mDialogView.tvResultado.text = String.format("%.2f", mDialogView.tvNuevaCantidad.text.toString().toFloat()) | |
558 | + mDialogView.tvNuevaCantidad.isEnabled = false | |
559 | + } | |
560 | + } | |
561 | + mDialogView.btnAceptar.setOnClickListener { | |
562 | + if (mDialogView.tvNuevaCantidad.text.isNotEmpty() || !mDialogView.tvNuevaCantidad.text.isBlank()) { | |
563 | + if (mDialogView.tvResultado.text.isNotEmpty() || !mDialogView.tvResultado.text.isBlank()) { | |
564 | + mAlertDialog.dismiss() | |
565 | + listArticulos[indiceDelArtEncontrado].cantTomada = String.format("%.2f", mDialogView.tvResultado.text.toString().toFloat()).toFloat() | |
566 | + updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), | |
567 | + listArticulos[indiceDelArtEncontrado].codigo.toString(), | |
568 | + String.format("%.2f", mDialogView.tvResultado.text.toString().toFloat()).toFloat()) | |
569 | + | |
570 | + viewAdapter.notifyDataSetChanged() | |
571 | + } else if (mDialogView.tvNuevaCantidad.text.isNotEmpty() || mDialogView.tvNuevaCantidad.text.isBlank()) { | |
572 | + mDialogView.tvResultado.error = "Operaciรณn Requerida" | |
573 | + mDialogView.tvResultado.requestFocus() | |
574 | + mDialogView.tvResultado.hint = "Seleccione Operaciรณn" | |
575 | + } | |
576 | + } else if (mDialogView.tvNuevaCantidad.text.isEmpty() || mDialogView.tvNuevaCantidad.text.isBlank()) { | |
577 | + mDialogView.tvNuevaCantidad.error = "Completar" | |
578 | + mDialogView.tvNuevaCantidad.requestFocus() | |
579 | + mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | |
580 | + } | |
581 | + } | |
582 | + mDialogView.dialogCancelBtn.setOnClickListener { | |
583 | + mAlertDialog.dismiss() | |
584 | + } | |
585 | + } | |
586 | + suspend fun buscarCodiogoOriEnBD(CodOri: String): Articles? { | |
587 | + //TODO BUSQUEDA POR CODIGO DE BARRAS | |
588 | + var busqueda: Articles? = null | |
589 | + return GlobalScope.async(Dispatchers.IO) { | |
590 | + busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodOri(CodOri, SerchArea()) | |
591 | + return@async busqueda | |
592 | + }.await() | |
593 | + } | |
594 | + | |
595 | + suspend fun buscarCBEnBD(CodigoBarras: String): Articles? { | |
596 | + //TODO BUSQUEDA POR CODIGO DE BARRAS | |
597 | + var busqueda: Articles? = null | |
598 | + return GlobalScope.async(Dispatchers.IO) { | |
599 | + busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(CodigoBarras, SerchArea()) | |
600 | + return@async busqueda | |
601 | + }.await() | |
602 | + } | |
603 | + | |
604 | + suspend fun buscarDescEnBD(descripcion: String): List<Articles>? { | |
605 | + //TODO BUSQUEDA POR DESCRIPCION | |
606 | + var busqueda: List<Articles>? = null | |
607 | + return GlobalScope.async(Dispatchers.IO) { | |
608 | + busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByDesc(descripcion, SerchArea()) | |
609 | + return@async busqueda | |
610 | + }.await() | |
611 | + } | |
612 | + | |
613 | + suspend fun borrarArticulo(sector: String, codigo: String, inventario: String): Int? { | |
614 | + //TODO BUSQUEDA POR DESCRIPCION | |
615 | + var result: Int | |
616 | + return GlobalScope.async(Dispatchers.IO) { | |
617 | + result = AppDb.getAppDb(requireContext())!!.InvBodyDAO()!!.deleteItemFromInvBody(sector, codigo, inventario) | |
618 | + return@async result | |
619 | + }.await() | |
620 | + } | |
621 | + | |
622 | + private suspend fun buscoArtEnRv(codigoBarras: String, sTipoBusqueda: Int): Int { | |
623 | + return GlobalScope.async(Dispatchers.IO) { | |
624 | + var indice = 0 | |
625 | + var bEncontrado = false | |
626 | + if (sTipoBusqueda == 0) {//TODO BUSQUEDA POR CODIGO DE BARRAS | |
627 | + // TODO CAMBIO DE CB A CODIGO DEBO | |
628 | + val any = cambioCBporCodigoDebo(codigoBarras) | |
629 | + if (any != null) { | |
630 | + for (item in listArticulos) { | |
631 | + if (item.sector!!.toInt() == any.sector!!.toInt() && item.codigo!!.toInt() == any.codigo!!.toInt()) { | |
632 | + bEncontrado = true | |
633 | + break | |
634 | + } | |
635 | + indice += 1 | |
636 | + } | |
637 | + } | |
638 | + | |
639 | + } else if (sTipoBusqueda == 1) {//TODO BUSQUEDA POR DESCRIPCION | |
640 | + for (item in listArticulos) { | |
641 | + if (item.descripcion!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { | |
642 | + bEncontrado = true | |
643 | + break | |
644 | + } | |
645 | + indice += 1 | |
646 | + } | |
647 | + } else if (sTipoBusqueda == 2) {//TODO BUSQUEDA POR CODIGO DE ORIGEN | |
648 | + for (item in listArticulos) { | |
649 | + if (item.codigoOrigen!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { | |
650 | + bEncontrado = true | |
651 | + break | |
652 | + } | |
653 | + indice += 1 | |
654 | + } | |
655 | + } | |
656 | + return@async if (bEncontrado) indice else -1 | |
657 | + }.await() | |
658 | + } | |
659 | + | |
660 | + suspend fun cambioCBporCodigoDebo(codigoBarras: String): Articles? { | |
661 | + //TODO BUSQUEDA POR DESCRIPCION | |
662 | + var busqueda: Articles? = null | |
663 | + return GlobalScope.async(Dispatchers.IO) { | |
664 | + busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(codigoBarras, SerchArea()) | |
665 | + return@async busqueda | |
666 | + }.await() | |
667 | + } | |
668 | + | |
669 | + private fun cargarArtEnBd(articulos: Articles, cant: String) { | |
670 | + val body = InvBody(InventarioNuevo,// TODO PREPARO PARA MANDAR A CARGAR EN LA BD | |
671 | + articulos.sector, | |
672 | + articulos.codigo, | |
673 | + articulos.descripcion, | |
674 | + cant, | |
675 | + articulos.codBar, | |
676 | + articulos.codOrigen, | |
677 | + articulos.precio, | |
678 | + articulos.precio, | |
679 | + articulos.balanza, | |
680 | + articulos.depSn, | |
681 | + ObtenerFechaActual(), | |
682 | + ObtenerFechaActual()) | |
683 | + InsertarArtEnDB(body)// TODO MANDO A CARGAR A LA BASE DE DATOS | |
684 | + } | |
685 | + | |
686 | + fun cargarRecicler(articulos: Articles, cant: Float) { | |
687 | + //TODO CARGO EN LE RV | |
688 | + val item = ItemsRecycler(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar, articulos.codOrigen, articulos.balanza.toString(), articulos.de.toString()) | |
689 | + listArticulos.add(item) | |
690 | + | |
691 | + viewAdapter = ProductosListAdapter(requireContext(), listArticulos, this) | |
692 | + viewManager = LinearLayoutManager(requireContext()) | |
693 | + deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! | |
694 | + rcInventarios.apply { | |
695 | + adapter = viewAdapter | |
696 | + layoutManager = viewManager | |
697 | + } | |
698 | + val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { | |
699 | + override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | |
700 | + return false | |
701 | + } | |
702 | + | |
703 | + override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { | |
704 | + | |
705 | + GlobalScope.launch(Dispatchers.Main) { | |
706 | + borrarArticulo(listArticulos[viewHolder.adapterPosition].sector.toString(), listArticulos[viewHolder.adapterPosition].codigo.toString(), InventarioNuevo.toString()) | |
707 | + (viewAdapter as ProductosListAdapter).removeItem(viewHolder) | |
708 | + viewAdapter.notifyDataSetChanged() | |
709 | + modificarCantidadEnCabecera(InventarioNuevo, false, requireContext()) | |
710 | + } | |
711 | + } | |
712 | + | |
713 | + override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | |
714 | + val itemView = viewHolder.itemView | |
715 | + val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 | |
716 | + c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | |
717 | + | |
718 | + if (dX > 0) { | |
719 | + | |
720 | + if (dX < c.width / 2) c.drawColor(Color.GREEN) | |
721 | + else c.drawColor(Color.RED) | |
722 | + deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) | |
723 | + } else { | |
724 | + } | |
725 | + | |
726 | + super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
727 | + deleteIcon.draw(c) | |
728 | + } | |
729 | + } | |
730 | + | |
731 | + val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) | |
732 | + itemTouchHelper.attachToRecyclerView(rcInventarios) | |
733 | + } | |
734 | + | |
735 | + private fun ProdNoCont(): Int? { | |
736 | + var mostrarStock = 0 | |
737 | + if (sharedPreferences.contains("cbMostrarStock")) if (sharedPreferences.getString("cbMostrarStock", "").toString() == "1") mostrarStock = 1 | |
738 | + return mostrarStock | |
739 | + } | |
740 | + | |
741 | + private fun AjusteProductos(): Int? { | |
742 | + var prodInclu = 0 | |
743 | + if (sharedPreferences.contains("rbProInclu")) if (sharedPreferences.getString("rbProInclu", "").toString() == "1") prodInclu = 1 | |
744 | + | |
745 | + if (sharedPreferences.contains("rbProNoInclu")) if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") prodInclu = 0 | |
746 | + return prodInclu | |
747 | + } | |
748 | + | |
749 | + private fun SerchArea(): Int { | |
750 | + if (sharedPreferences.contains("rbVentas")) if (sharedPreferences.getString("rbVentas", "").toString() == "1") iArea = 0 | |
751 | + if (sharedPreferences.contains("rbDeposito")) if (sharedPreferences.getString("rbDeposito", "").toString() == "1") iArea = 1 | |
752 | + return iArea | |
753 | + } | |
754 | + | |
755 | + fun ObtenerFechaActual(): String? { | |
756 | + //TODO OBTENGO FECHA Y HORA ACTUAL PARA LA CABECERA DEL INVENTARIO Y PARA CADA ITEM QUE SE INSERTA EN LA BD | |
757 | + val current = LocalDateTime.now() | |
758 | + val formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy hh:mm:ss") | |
759 | + val dFechaHora = current.format(formatter) | |
760 | + return dFechaHora.toString() | |
761 | + } | |
762 | + | |
763 | + fun InsertarArtEnDB(cuarpoInventario: InvBody) { | |
764 | + lifecycleScope.launch { | |
765 | + withContext(Dispatchers.IO) { | |
766 | + AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) | |
767 | + } | |
768 | + } | |
769 | + } | |
770 | + | |
771 | + fun updateCantidad(sector: String, codigo: String, cantidad: Float) { | |
772 | + lifecycleScope.launch { | |
773 | + withContext(Dispatchers.IO) { | |
774 | + AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.UpdateInvBody(cantidad, sector, codigo) | |
775 | + } | |
776 | + } | |
777 | + } | |
778 | + | |
779 | + suspend fun cargarInventario(inventario: Int): List<InvBody>? { | |
780 | + return GlobalScope.async(Dispatchers.IO) { | |
781 | + return@async AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.fetchAllInvBody(inventario) | |
782 | + }.await() | |
783 | + } | |
784 | + | |
785 | + override fun onImageDotsClick(sector: String?, codigo: String?) { | |
786 | + val bundle = Bundle() | |
787 | + bundle.putString("sector", sector) | |
788 | + bundle.putString("codigo", codigo) | |
789 | + bundle.putInt("numeroInv", InventarioNuevo) | |
790 | + navController.navigate(R.id.action_inventarioFragment_to_detalleArtFragment, bundle) | |
791 | + } | |
792 | + | |
793 | + override fun onImagePenClick(sector: String?, codigo: String?, cantidad: String?, position: String) { | |
794 | + dialogoSumaResta(requireContext(), position.toInt(), listArticulos[position.toInt()].univta, true) | |
795 | + } | |
796 | +} | |
797 | + | |
798 | + | |
799 | + | |
800 | + | |
801 | + | |
802 | + | |
803 | + | |
804 | + | |
805 | + | |
806 | + | |
807 | + | |
808 | + | |
809 | + | |
810 | + |
app/src/main/java/com/focasoftware/deboinventariov20/UI/inventario/ItemsRecycler.kt
... | ... | @@ -0,0 +1,5 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.inventario | |
2 | + | |
3 | +data class ItemsRecycler(val sector: String?,val codigo: String?, val descripcion: String?, var cantTomada: Float, val codigoBarras: String?, val codigoOrigen: String?,val univta: String,val dev:String) { | |
4 | + | |
5 | +} | |
0 | 6 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/UI/inventario/ProductosListAdapter.kt
... | ... | @@ -0,0 +1,59 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.inventario | |
2 | + | |
3 | +import android.content.Context | |
4 | +import android.view.LayoutInflater | |
5 | +import android.view.View | |
6 | +import android.view.ViewGroup | |
7 | +import androidx.recyclerview.widget.RecyclerView | |
8 | +import com.focasoftware.deboinventariov20.R | |
9 | +import com.focasoftware.deboinventariov20.UI.Utils.BaseViewHolder | |
10 | +import kotlinx.android.synthetic.main.item.view.* | |
11 | + | |
12 | + | |
13 | +class ProductosListAdapter(private val context: Context,private val productos: ArrayList<ItemsRecycler>, private val itemImageClickListener: OnImageDotsClickListener) : | |
14 | + RecyclerView.Adapter<BaseViewHolder<*>>() { | |
15 | + | |
16 | + private var removePosition: Int = 0 | |
17 | + private var removedItem: ItemsRecycler? = null | |
18 | + | |
19 | + interface OnImageDotsClickListener { | |
20 | + fun onImageDotsClick(sector: String?,codigo: String?) | |
21 | + fun onImagePenClick(sector: String?, codigo: String?, cantidad: String?, position: String) | |
22 | +} | |
23 | + | |
24 | + override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder(LayoutInflater.from(context).inflate(R.layout.item, parent, false)) | |
25 | + | |
26 | + override fun getItemCount() = productos.size | |
27 | + | |
28 | + override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) { | |
29 | + when (holder) { | |
30 | + is ItemsViewHolder -> { holder.bind(productos[position], position) } | |
31 | + | |
32 | + } | |
33 | + } | |
34 | + inner class ItemsViewHolder (itemView: View) : BaseViewHolder<ItemsRecycler>(itemView) { | |
35 | + override fun bind(item: ItemsRecycler, position: Int) { | |
36 | + itemView.ivDots.setOnClickListener {itemImageClickListener.onImageDotsClick(item.sector,item.codigo) } | |
37 | + itemView.ivPen.setOnClickListener {itemImageClickListener.onImagePenClick(item.sector,item.codigo,item.cantTomada.toString(),adapterPosition.toString()) } | |
38 | + | |
39 | + itemView.tvSector.text=item.sector | |
40 | + itemView.tvCodigo.text=item.codigo | |
41 | + itemView.tvDescripcion.text=item.descripcion | |
42 | + itemView.tvCantidad.text=item.cantTomada.toString() | |
43 | + itemView.tvCodigoBarras.text=item.sector | |
44 | + itemView.tvCodigoOrigen.text=item.sector | |
45 | + itemView.ivPen.setImageResource(R.drawable.pen) | |
46 | + itemView.ivDots.setImageResource(R.drawable.more) | |
47 | + } | |
48 | + } | |
49 | + | |
50 | + fun removeItem(viewHolder: RecyclerView.ViewHolder) { | |
51 | + removePosition = viewHolder.adapterPosition | |
52 | + removedItem = productos[viewHolder.adapterPosition] | |
53 | + | |
54 | + productos.removeAt(viewHolder.adapterPosition) | |
55 | + notifyItemRemoved(viewHolder.adapterPosition) | |
56 | + } | |
57 | + | |
58 | + | |
59 | +} | |
0 | 60 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/UI/inventario/viewModel/InventarioViewModel.kt
app/src/main/java/com/focasoftware/deboinventariov20/UI/main/InventarioListAdapter.kt
... | ... | @@ -0,0 +1,47 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.main | |
2 | + | |
3 | +import android.content.Context | |
4 | +import android.view.LayoutInflater | |
5 | +import android.view.View | |
6 | +import android.view.ViewGroup | |
7 | +import androidx.recyclerview.widget.RecyclerView | |
8 | +import com.focasoftware.deboinventariov20.Model.InvHead | |
9 | +import com.focasoftware.deboinventariov20.R | |
10 | +import com.focasoftware.deboinventariov20.UI.Utils.BaseViewHolder | |
11 | +import kotlinx.android.synthetic.main.item_principal.view.* | |
12 | + | |
13 | +class InventarioListAdapter(private val context: Context, private val inv: List<InvHead>, private val itemClickListener: OnInventarioClickListener) : | |
14 | + RecyclerView.Adapter<BaseViewHolder<*>>() { | |
15 | + | |
16 | + interface OnInventarioClickListener { | |
17 | + fun onItemClick(inventario: String?) | |
18 | + } | |
19 | + | |
20 | + override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder(LayoutInflater.from(context).inflate(R.layout.item_principal, parent, false)) | |
21 | + | |
22 | + override fun getItemCount() = inv.size | |
23 | + | |
24 | + | |
25 | + inner class ItemsViewHolder(itemView: View) : BaseViewHolder<InvHead>(itemView) { | |
26 | + override fun bind(item: InvHead, position: Int) { | |
27 | + itemView.setOnClickListener {itemClickListener.onItemClick(item.invNum.toString())} | |
28 | + itemView.tvPrincipalinventario.text = if ( item.invNum < 10) "0${ item.invNum.toString()}" else item.invNum.toString() | |
29 | + | |
30 | + itemView.tvDescription.text=item.descripcion.toString() | |
31 | + itemView.tvFecha.text=item.fechaInicio.toString() | |
32 | + itemView.tvCantContada.text=item.prodContados.toString() | |
33 | + } | |
34 | + } | |
35 | + | |
36 | + override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) { | |
37 | + when (holder) { | |
38 | + is ItemsViewHolder -> holder.bind(inv[position], position) | |
39 | + else -> IllegalArgumentException("No se pudo pasar el ViewHolder") | |
40 | + } | |
41 | + } | |
42 | + | |
43 | + | |
44 | +} | |
45 | + | |
46 | + | |
47 | + |
app/src/main/java/com/focasoftware/deboinventariov20/UI/main/ItemPrincipal.kt
app/src/main/java/com/focasoftware/deboinventariov20/UI/main/MainFragment.kt
... | ... | @@ -0,0 +1,171 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.main | |
2 | + | |
3 | +import android.content.Context | |
4 | +import android.content.SharedPreferences | |
5 | +import android.os.Bundle | |
6 | +import android.view.LayoutInflater | |
7 | +import android.view.View | |
8 | +import android.view.ViewGroup | |
9 | +import android.widget.* | |
10 | +import androidx.fragment.app.Fragment | |
11 | +import androidx.navigation.NavController | |
12 | +import androidx.navigation.Navigation | |
13 | +import androidx.recyclerview.widget.LinearLayoutManager | |
14 | +import androidx.recyclerview.widget.RecyclerView | |
15 | +import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
16 | +import com.focasoftware.deboinventariov20.Model.InvHead | |
17 | +import com.focasoftware.deboinventariov20.R | |
18 | +import kotlinx.coroutines.Dispatchers | |
19 | +import kotlinx.coroutines.GlobalScope | |
20 | +import kotlinx.coroutines.async | |
21 | +import kotlinx.coroutines.launch | |
22 | +import java.util.* | |
23 | + | |
24 | +class MainFragment : Fragment(), InventarioListAdapter.OnInventarioClickListener { | |
25 | + private lateinit var inventarios: List<InvHead> | |
26 | + private lateinit var ordenado: List<InvHead> | |
27 | + private lateinit var rcInventario: RecyclerView | |
28 | + private lateinit var viewAdapter: RecyclerView.Adapter<*> | |
29 | + private lateinit var viewManager: RecyclerView.LayoutManager | |
30 | +// private var listIvn2 = List<InvHead>() | |
31 | +private var listIvn2 = ArrayList<InvHead>() | |
32 | + private lateinit var navController: NavController | |
33 | + private lateinit var sharedPreferences: SharedPreferences | |
34 | + private var cantidadInventarios: Int = 0 | |
35 | + | |
36 | + override fun onCreate(savedInstanceState: Bundle?) { | |
37 | + super.onCreate(savedInstanceState) | |
38 | + sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
39 | + } | |
40 | + | |
41 | + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
42 | + var bAbiertoCerrado = false | |
43 | + val v = inflater.inflate(R.layout.fragment_main, container, false) | |
44 | + val tvInvDinamicos = v.findViewById<TextView>(R.id.tvInvDinamicos) | |
45 | + val txtDeposito = v.findViewById<TextView>(R.id.txtDeposito) | |
46 | + val ivSort19= v.findViewById<ImageButton>(R.id.ivSort19) | |
47 | + val ivSort91= v.findViewById<ImageButton>(R.id.ivSort91) | |
48 | + val cbVentas= v.findViewById<CheckBox>(R.id.cbVentas) | |
49 | + val cbDeposito= v.findViewById<CheckBox>(R.id.cbDeposito) | |
50 | + val tvTipo = v.findViewById<TextView>(R.id.tvTipo) | |
51 | + rcInventario = v.findViewById(R.id.rcInventario) | |
52 | + | |
53 | + GlobalScope.launch(Dispatchers.Main) { | |
54 | + inventarios = buscarEnBDInvHead() | |
55 | + for ((i, item) in inventarios.withIndex()) { | |
56 | + val inv = InvHead(inventarios[i].invNum, | |
57 | + inventarios[i].descripcion, | |
58 | + inventarios[i].estado, | |
59 | + inventarios[i].fechaInicio, | |
60 | + inventarios[i].fechaFinal, | |
61 | + inventarios[i].prodContados, | |
62 | + inventarios[i].lugar, | |
63 | + inventarios[i].stDesc, | |
64 | + inventarios[i].proNoCont) | |
65 | + cargarRecicler(inv) | |
66 | + cantidadInventarios = i + 1 | |
67 | + } | |
68 | + tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) +" | |
69 | + tvInvDinamicos.setOnClickListener { | |
70 | + if (!bAbiertoCerrado) { | |
71 | + bAbiertoCerrado = true | |
72 | + txtDeposito.visibility = View.GONE | |
73 | + rcInventario.visibility = View.VISIBLE | |
74 | + ivSort91.visibility = View.INVISIBLE | |
75 | + ivSort19.visibility = View.VISIBLE | |
76 | + cbVentas.visibility = View.VISIBLE | |
77 | + cbDeposito.visibility = View.VISIBLE | |
78 | + tvTipo.visibility = View.VISIBLE | |
79 | + tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) -" | |
80 | + } else { | |
81 | + bAbiertoCerrado = false | |
82 | + rcInventario.visibility = View.GONE | |
83 | + ivSort91.visibility = View.GONE | |
84 | + ivSort19.visibility = View.GONE | |
85 | + txtDeposito.visibility = View.VISIBLE | |
86 | + cbVentas.visibility = View.GONE | |
87 | + cbDeposito.visibility = View.GONE | |
88 | + tvTipo.visibility = View.GONE | |
89 | + tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) +" | |
90 | + } | |
91 | + } | |
92 | + ivSort19.setOnClickListener { | |
93 | + ordenado= inventarios.sortedByDescending { | |
94 | + it.invNum | |
95 | + } | |
96 | + viewAdapter = InventarioListAdapter(requireContext(), ordenado, this@MainFragment) | |
97 | + viewManager = LinearLayoutManager(requireContext()) | |
98 | + | |
99 | + rcInventario.apply { | |
100 | + adapter = viewAdapter | |
101 | + layoutManager = viewManager | |
102 | + } | |
103 | + viewAdapter.notifyDataSetChanged() | |
104 | + ivSort19.visibility=View.INVISIBLE | |
105 | + ivSort91.visibility=View.VISIBLE | |
106 | + } | |
107 | + ivSort91.setOnClickListener { | |
108 | + ordenado= inventarios.sortedBy { | |
109 | + it.invNum | |
110 | + } | |
111 | + viewAdapter = InventarioListAdapter(requireContext(), ordenado, this@MainFragment) | |
112 | + viewManager = LinearLayoutManager(requireContext()) | |
113 | + | |
114 | + rcInventario.apply { | |
115 | + adapter = viewAdapter | |
116 | + layoutManager = viewManager | |
117 | + } | |
118 | + viewAdapter.notifyDataSetChanged() | |
119 | + ivSort91.visibility=View.INVISIBLE | |
120 | + ivSort19.visibility=View.VISIBLE | |
121 | + } | |
122 | + } | |
123 | + return v | |
124 | + } | |
125 | + | |
126 | + suspend fun buscarEnBDInvHead(): List<InvHead> { | |
127 | + //TODO BUSQUEDA POR DESCRIPCION | |
128 | + var busqueda: List<InvHead> | |
129 | + return GlobalScope.async(Dispatchers.IO) { | |
130 | + busqueda = AppDb.getAppDb(requireContext())!!.InvHeadDAO()!!.fetchAllInvHead() | |
131 | + return@async busqueda | |
132 | + }.await() | |
133 | + } | |
134 | + | |
135 | + fun cargarRecicler(inv: InvHead) { | |
136 | + //TODO CARGO EN LE RV | |
137 | + | |
138 | +// val number = if (inv.invNum.toLong() < 10) "0${inv.invNum.toLong()}" else inv.invNum.toString() | |
139 | +// val item = ItemInventario("Nยฐ $number ${inv.descripcion}. Fecha: ${inv.fechaFinal}") | |
140 | + | |
141 | +// listIvn.add(item) | |
142 | + listIvn2.add(inv) | |
143 | + viewAdapter = InventarioListAdapter(requireContext(), listIvn2, this) | |
144 | + viewManager = LinearLayoutManager(requireContext()) | |
145 | + | |
146 | + rcInventario.apply { | |
147 | + adapter = viewAdapter | |
148 | + layoutManager = viewManager | |
149 | + } | |
150 | + } | |
151 | + | |
152 | + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
153 | + super.onViewCreated(view, savedInstanceState) | |
154 | + navController = Navigation.findNavController(view) | |
155 | + listIvn2.clear() | |
156 | + } | |
157 | + | |
158 | + override fun onItemClick(inventario: String?) { | |
159 | + | |
160 | + val editor = sharedPreferences.edit() | |
161 | +// var invSel: String = inventario.toString() | |
162 | +// invSel = invSel.substring(3, 5) | |
163 | + editor?.putString("Inventario", inventario) | |
164 | + editor?.apply() | |
165 | + editor.commit() | |
166 | + navController.navigate(R.id.action_mainFragment2_to_inventarioFragment) | |
167 | + } | |
168 | + | |
169 | + | |
170 | +} | |
171 | + |
app/src/main/java/com/focasoftware/deboinventariov20/UI/servidores/AdapterServidores.kt
... | ... | @@ -0,0 +1,44 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.servidores | |
2 | + | |
3 | +import android.content.Context | |
4 | +import android.view.LayoutInflater | |
5 | +import android.view.View | |
6 | +import android.view.ViewGroup | |
7 | +import androidx.recyclerview.widget.RecyclerView | |
8 | +import com.focasoftware.deboinventariov20.R | |
9 | +import kotlinx.android.synthetic.main.item_servidores.view.* | |
10 | + | |
11 | +class AdapterServidores(private val servidor: ArrayList<ItemsServidores>, private var contexto: Context) : | |
12 | + RecyclerView.Adapter<AdapterServidores.ViewHolder>() { | |
13 | + private var removePosition: Int = 0 | |
14 | + private var removedItem: ItemsServidores? = null | |
15 | + | |
16 | + class ViewHolder(var vista: View) : RecyclerView.ViewHolder(vista) { | |
17 | + fun bind(itemsServidores: ItemsServidores) { | |
18 | + vista.tvDescServidor.text = itemsServidores.descripcion | |
19 | + vista.tvDireccionServidor.text = itemsServidores.direccion | |
20 | + | |
21 | + } | |
22 | + } | |
23 | + | |
24 | + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | |
25 | + return ViewHolder( | |
26 | + LayoutInflater.from(parent.context).inflate(R.layout.item_servidores, parent, false) | |
27 | + ) | |
28 | + } | |
29 | + | |
30 | + override fun getItemCount(): Int { | |
31 | + return servidor.size | |
32 | + } | |
33 | + | |
34 | + override fun onBindViewHolder(holder: ViewHolder, position: Int) { | |
35 | + holder.bind(servidor[position]) | |
36 | + } | |
37 | + fun removeItem(viewHolder: RecyclerView.ViewHolder) { | |
38 | + removePosition = viewHolder.adapterPosition | |
39 | + removedItem = servidor[viewHolder.adapterPosition] | |
40 | + | |
41 | + servidor.removeAt(viewHolder.adapterPosition) | |
42 | + notifyItemRemoved(viewHolder.adapterPosition) | |
43 | + } | |
44 | +} | |
0 | 45 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/UI/servidores/ItemsServidores.kt
app/src/main/java/com/focasoftware/deboinventariov20/UI/servidores/ServidoresFragment.kt
... | ... | @@ -0,0 +1,151 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.servidores | |
2 | + | |
3 | +import android.graphics.Canvas | |
4 | +import android.graphics.Color | |
5 | +import android.graphics.drawable.Drawable | |
6 | +import android.os.Bundle | |
7 | +import android.view.LayoutInflater | |
8 | +import android.view.View | |
9 | +import android.view.ViewGroup | |
10 | +import android.widget.Toast | |
11 | +import androidx.core.content.ContextCompat | |
12 | +import androidx.fragment.app.Fragment | |
13 | +import androidx.lifecycle.lifecycleScope | |
14 | +import androidx.recyclerview.widget.ItemTouchHelper | |
15 | +import androidx.recyclerview.widget.LinearLayoutManager | |
16 | +import androidx.recyclerview.widget.RecyclerView | |
17 | +import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
18 | +import com.focasoftware.deboinventariov20.Model.ServeInv | |
19 | +import com.focasoftware.deboinventariov20.R | |
20 | +import kotlinx.android.synthetic.main.fragment_servidores.* | |
21 | +import kotlinx.coroutines.* | |
22 | + | |
23 | +class ServidoresFragment : Fragment() { | |
24 | + | |
25 | + private lateinit var rvServidores: RecyclerView | |
26 | + private lateinit var viewAdapter: RecyclerView.Adapter<*> | |
27 | + private lateinit var viewManager: RecyclerView.LayoutManager | |
28 | + private var listServ = ArrayList<ItemsServidores>() | |
29 | + private lateinit var servidores: List<ServeInv> | |
30 | + private lateinit var deleteIcon: Drawable | |
31 | + | |
32 | + override fun onCreate(savedInstanceState: Bundle?) { | |
33 | + super.onCreate(savedInstanceState) | |
34 | + CargarRV() | |
35 | + } | |
36 | + | |
37 | + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
38 | + super.onViewCreated(view, savedInstanceState) | |
39 | + | |
40 | + btnGuardarServidores.setOnClickListener { | |
41 | + if (etNombreServidor.text.isNullOrBlank()) { | |
42 | + etNombreServidor.error = "Nombre no valido" | |
43 | + etNombreServidor.requestFocus() | |
44 | + etNombreServidor.hint = "Nombre no valido" | |
45 | + } | |
46 | + if (etDireccionServidor.text.isNullOrBlank()) { | |
47 | + etDireccionServidor.error = "Direcciรณn no valida" | |
48 | + etDireccionServidor.requestFocus() | |
49 | + etDireccionServidor.hint = "Direcciรณn no valida" | |
50 | + } | |
51 | + if (!etDireccionServidor.text.isNullOrBlank() || !etNombreServidor.text.isNullOrBlank()) { | |
52 | +// GlobalScope.launch(Dispatchers.Main) { | |
53 | +// ServerNew =AppDb.getAppDb(requireContext())?.ServeInvDao()?.findLastServer()?.plus(1) ?: 1 | |
54 | + val servidor = ServeInv(etNombreServidor.text.toString(), "http://${etDireccionServidor.text}/", 0) | |
55 | + ingresarDatos(servidor) | |
56 | + cargarRecicler(servidor) | |
57 | + Toast.makeText(requireContext(), "Servidor ${etNombreServidor.text} Guardado", Toast.LENGTH_LONG).show() | |
58 | + etNombreServidor.text.clear() | |
59 | + etDireccionServidor.text.clear() | |
60 | +// } | |
61 | + } | |
62 | + } | |
63 | + } | |
64 | + | |
65 | + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
66 | + val v = inflater.inflate(R.layout.fragment_servidores, container, false) | |
67 | + rvServidores = v.findViewById(R.id.rvServidores) | |
68 | + return v | |
69 | + } | |
70 | + | |
71 | + fun ingresarDatos(servidor: ServeInv) { | |
72 | + val Job = GlobalScope.launch { | |
73 | + AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.insertServer(servidor) | |
74 | + } | |
75 | + } | |
76 | + | |
77 | + suspend fun buscarEnBD(): List<ServeInv> { | |
78 | + var busqueda: List<ServeInv> | |
79 | + return GlobalScope.async(Dispatchers.IO) { | |
80 | + busqueda = AppDb.getAppDb(requireContext())!!.ServeInvDao()!!.fetchAllServers() | |
81 | + return@async busqueda | |
82 | + }.await() | |
83 | + } | |
84 | + | |
85 | + fun CargarRV() { | |
86 | + GlobalScope.launch(Dispatchers.Main) { | |
87 | + servidores = buscarEnBD() | |
88 | + for ((i, item) in servidores.withIndex()) { | |
89 | + val ser = ServeInv(servidores[i].descripcion, servidores[i].direccion, servidores[i].predeterminado) | |
90 | + cargarRecicler(ser) | |
91 | + } | |
92 | + } | |
93 | + } | |
94 | + | |
95 | + fun cargarRecicler(ser: ServeInv) { | |
96 | + //TODO CARGO EN LE RV | |
97 | + deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! | |
98 | + val item = ItemsServidores(ser.descripcion, ser.direccion, ser.predeterminado.toString()) | |
99 | + | |
100 | + listServ.add(item) | |
101 | + | |
102 | + viewAdapter = AdapterServidores(listServ, requireContext()) | |
103 | + viewManager = LinearLayoutManager(requireContext()) | |
104 | + | |
105 | + rvServidores.apply { | |
106 | + adapter = viewAdapter | |
107 | + layoutManager = viewManager | |
108 | + } | |
109 | + val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { | |
110 | + override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | |
111 | + return false | |
112 | + } | |
113 | + | |
114 | + override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { | |
115 | + GlobalScope.launch(Dispatchers.Main) { | |
116 | + deleteServer(listServ[viewHolder.adapterPosition].descripcion.toString(), listServ[viewHolder.adapterPosition].direccion.toString()) | |
117 | + | |
118 | + (viewAdapter as AdapterServidores).removeItem(viewHolder) | |
119 | + viewAdapter.notifyDataSetChanged() | |
120 | + } | |
121 | + } | |
122 | + | |
123 | + override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | |
124 | + val itemView = viewHolder.itemView | |
125 | + val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 | |
126 | + c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | |
127 | + | |
128 | + if (dX > 0) { | |
129 | + | |
130 | + if (dX < c.width / 2) c.drawColor(Color.GREEN) | |
131 | + else c.drawColor(Color.RED) | |
132 | + deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) | |
133 | + } else { | |
134 | + } | |
135 | + super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
136 | + deleteIcon.draw(c) | |
137 | + } | |
138 | + } | |
139 | + | |
140 | + val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) | |
141 | + itemTouchHelper.attachToRecyclerView(rvServidores) | |
142 | + } | |
143 | + | |
144 | + suspend fun deleteServer(serverName: String, serverDir: String) { | |
145 | + lifecycleScope.launch { | |
146 | + withContext(Dispatchers.IO) { | |
147 | + AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.deleteServer(serverName, serverDir) | |
148 | + } | |
149 | + } | |
150 | + } | |
151 | +} |
app/src/main/java/com/focasoftware/deboinventariov20/UI/servidores/SpinnerAdapter.kt
... | ... | @@ -0,0 +1,40 @@ |
1 | +package com.focasoftware.deboinventariov20.UI.servidores | |
2 | + | |
3 | +import android.content.Context | |
4 | +import android.view.LayoutInflater | |
5 | +import android.view.View | |
6 | +import android.view.ViewGroup | |
7 | +import android.widget.BaseAdapter | |
8 | +import android.widget.TextView | |
9 | +import com.focasoftware.deboinventariov20.Model.ServeInv | |
10 | +import com.focasoftware.deboinventariov20.R | |
11 | + | |
12 | + | |
13 | +class SpinnerAdapterServidor internal constructor(internal var context: Context, internal var list: List<ServeInv>) : BaseAdapter() { | |
14 | + override fun getCount(): Int { | |
15 | + return list.size | |
16 | + } | |
17 | + | |
18 | + override fun getItem(i: Int): Any? { | |
19 | + return null | |
20 | + } | |
21 | + | |
22 | + override fun getItemId(i: Int): Long { | |
23 | + return 0 | |
24 | + } | |
25 | + | |
26 | + override fun getView(i: Int, view1: View?, viewGroup: ViewGroup): View { | |
27 | + var views=view1 | |
28 | + if (views == null) { | |
29 | + val inflater = LayoutInflater.from(context) | |
30 | + | |
31 | + views = inflater.inflate(R.layout.item_spinner, viewGroup, false) | |
32 | + } | |
33 | + | |
34 | + val tvServidorDesc = views!!.findViewById<TextView>(R.id.tvServidorDesc) | |
35 | + tvServidorDesc.text="${list[i].servNum} - ${list[i].descripcion}" | |
36 | + return tvServidorDesc | |
37 | + | |
38 | + } | |
39 | +} | |
40 | + |
app/src/main/java/com/focasoftware/deboinventariov20/ui/MainActivity.kt
... | ... | @@ -1,46 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui | |
2 | - | |
3 | -import android.os.Bundle | |
4 | -import android.view.Menu | |
5 | -import com.google.android.material.navigation.NavigationView | |
6 | -import androidx.navigation.findNavController | |
7 | -import androidx.navigation.ui.AppBarConfiguration | |
8 | -import androidx.navigation.ui.navigateUp | |
9 | -import androidx.navigation.ui.setupActionBarWithNavController | |
10 | -import androidx.navigation.ui.setupWithNavController | |
11 | -import androidx.drawerlayout.widget.DrawerLayout | |
12 | -import androidx.appcompat.app.AppCompatActivity | |
13 | -import androidx.appcompat.widget.Toolbar | |
14 | -import com.focasoftware.deboinventariov20.R | |
15 | - | |
16 | -class MainActivity : AppCompatActivity() { | |
17 | - | |
18 | - private lateinit var appBarConfiguration: AppBarConfiguration | |
19 | - | |
20 | - override fun onCreate(savedInstanceState: Bundle?) { | |
21 | - super.onCreate(savedInstanceState) | |
22 | - setContentView(R.layout.activity_main) | |
23 | - val toolbar: Toolbar = findViewById(R.id.toolbar) | |
24 | - setSupportActionBar(toolbar) | |
25 | - | |
26 | - | |
27 | - val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout) | |
28 | - val navView: NavigationView = findViewById(R.id.nav_view) | |
29 | - val navController = findNavController(R.id.nav_host_fragment) | |
30 | - | |
31 | - appBarConfiguration = AppBarConfiguration(setOf(R.id.mainFragment2, R.id.inventarioFragment, R.id.actuaMaestrosFragment, R.id.configuracionFragment), drawerLayout) | |
32 | - setupActionBarWithNavController(navController, appBarConfiguration) | |
33 | - navView.setupWithNavController(navController) | |
34 | - } | |
35 | - | |
36 | - override fun onCreateOptionsMenu(menu: Menu): Boolean { | |
37 | - // Inflate the menu; this adds items to the action bar if it is present. | |
38 | - menuInflater.inflate(R.menu.main, menu) | |
39 | - return true | |
40 | - } | |
41 | - | |
42 | - override fun onSupportNavigateUp(): Boolean { | |
43 | - val navController = findNavController(R.id.nav_host_fragment) | |
44 | - return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp() | |
45 | - } | |
46 | -} | |
47 | 0 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/SplashActivity.kt
... | ... | @@ -1,29 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui | |
2 | - | |
3 | -import android.app.Activity | |
4 | -import android.content.Intent | |
5 | -import android.os.Bundle | |
6 | -import com.focasoftware.deboinventariov20.R | |
7 | - | |
8 | -class SplashActivity : Activity() { | |
9 | - | |
10 | - override fun onCreate(savedInstanceState: Bundle?) { | |
11 | - super.onCreate(savedInstanceState) | |
12 | - setContentView(R.layout.activity_splash) | |
13 | - //window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | |
14 | - | |
15 | - val bac = object : Thread(){ | |
16 | - override fun run(){ | |
17 | - try { | |
18 | - Thread.sleep(5) | |
19 | - val intent = Intent(baseContext, MainActivity:: class.java) | |
20 | - startActivity(intent) | |
21 | - finish() | |
22 | - } catch (e : Exception){ | |
23 | - e.printStackTrace() | |
24 | - } | |
25 | - } | |
26 | - } | |
27 | - bac.start() | |
28 | - } | |
29 | -} |
app/src/main/java/com/focasoftware/deboinventariov20/ui/actualizacionMaestros/ActuaMaestrosFragment.kt
... | ... | @@ -1,222 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.actualizacionMaestros | |
2 | - | |
3 | -import android.os.Bundle | |
4 | -import android.view.LayoutInflater | |
5 | -import android.view.View | |
6 | -import android.view.ViewGroup | |
7 | -import android.widget.Button | |
8 | -import androidx.fragment.app.Fragment | |
9 | -import androidx.fragment.app.FragmentActivity | |
10 | -import androidx.lifecycle.lifecycleScope | |
11 | -import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
12 | -import com.focasoftware.deboinventariov20.Model.* | |
13 | -import com.focasoftware.deboinventariov20.R | |
14 | -import com.google.android.material.bottomappbar.BottomAppBarTopEdgeTreatment | |
15 | -import kotlinx.android.synthetic.main.fragment_actua_maestros.* | |
16 | -import kotlinx.coroutines.* | |
17 | - | |
18 | -public var BASE_URL ="" | |
19 | -class ActuaMaestrosFragment : Fragment() { | |
20 | - | |
21 | - var job: Job? = null | |
22 | - | |
23 | - | |
24 | - override fun onCreate(savedInstanceState: Bundle?) { | |
25 | - super.onCreate(savedInstanceState) | |
26 | -// GlobalScope.launch(Dispatchers.Main) { | |
27 | -// val invbody = fetchServerPreOne() | |
28 | - //BASE_URL= invbody!!.direccion.toString() | |
29 | - BASE_URL="http://10.0.2.2:3000/" | |
30 | -// } | |
31 | -// mostrarArticulos() | |
32 | - } | |
33 | - | |
34 | - private suspend fun fetchServerPreOne(): ServeInv? { | |
35 | - return GlobalScope.async(Dispatchers.IO) { | |
36 | - return@async AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.fetchServerPreOne() | |
37 | - }.await() | |
38 | - } | |
39 | - | |
40 | -// return "http://10.0.2.2:3000/" | |
41 | -// } | |
42 | - | |
43 | - | |
44 | - override fun onCreateView( | |
45 | - inflater: LayoutInflater, container: ViewGroup?, | |
46 | - savedInstanceState: Bundle? | |
47 | - ): View? { | |
48 | - // Inflate the layout for this fragment | |
49 | - val v = inflater.inflate(R.layout.fragment_actua_maestros, container, false) | |
50 | - val bConfirmarAct = v.findViewById<Button>(R.id.btnConfirmarAct) | |
51 | - bConfirmarAct.setOnClickListener { | |
52 | - loading_view.visibility = View.VISIBLE | |
53 | - countriesList.text = "Obteniendo Maestros de artรญculos, aguarde por favor." | |
54 | - obtenerArticulos() | |
55 | - } | |
56 | - return v | |
57 | - } | |
58 | - | |
59 | - | |
60 | - private fun obtenerArticulos() { | |
61 | - | |
62 | - val productosService = ProductosService.getProductosService() | |
63 | - var index: Long = 1 | |
64 | - job = CoroutineScope(Dispatchers.IO).launch { | |
65 | - AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! | |
66 | - .deleteAllArticulos() | |
67 | - val response = productosService.getProductos() | |
68 | - if (response.isSuccessful) { | |
69 | - for (pro in response.body()!!) { | |
70 | - val artiAcargar = Articles( | |
71 | - pro.sector, | |
72 | - pro.codigo, | |
73 | - pro.descripcion, | |
74 | - pro.codBar, | |
75 | - pro.codOrigen, | |
76 | - pro.precio, | |
77 | - pro.costo, | |
78 | - pro.exiVenta, | |
79 | - pro.exiDeposito, | |
80 | - pro.de, | |
81 | - pro.balanza, | |
82 | - pro.depSn, | |
83 | - pro.imagen | |
84 | - ) | |
85 | - index += index | |
86 | - | |
87 | - AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! | |
88 | - .insertArticulos(artiAcargar) | |
89 | - } | |
90 | - withContext(Dispatchers.Main) { | |
91 | - countriesList.visibility = View.VISIBLE | |
92 | - countriesList.text = "ยกDatos Importados Correctamente!" | |
93 | - loading_view.visibility = View.GONE | |
94 | - } | |
95 | -// | |
96 | - } else { | |
97 | - countriesList.text = "Error: ${response.message()}" | |
98 | - } | |
99 | - } | |
100 | - | |
101 | -// withContext(Dispatchers.Main) { | |
102 | -// if (response.isSuccessful) { | |
103 | -// val call = WebService | |
104 | -// .instance | |
105 | -// ?.createService(WebServiceApi::class.java) | |
106 | -// ?.articulos | |
107 | -// call?.enqueue(object : Callback<List<productos?>?> { | |
108 | -// override fun onResponse( | |
109 | -// call: Call<List<productos?>?>, | |
110 | -// response: Response<List<productos?>?> | |
111 | -// ) { | |
112 | -// if (response.code() == 200) { | |
113 | -// for (i in response.body()!!.indices) { | |
114 | -// //AppDb.getAppDb(requireActivity())!!.ArticulosDAO()?.insertArticulos(response.body()!![i]) | |
115 | -// cargarArticulos(2, 500, "sfas", "66666","2,2", "2,2", false, false, "") | |
116 | -//// Log.d( | |
117 | -//// "TAG1", "Nombre Curso: " + response.body()!![i]?.sector | |
118 | -//// + "Codigo Profesor: " + response.body()!![i]?.descripcion | |
119 | -//// ) | |
120 | -// mostrarArticulos() | |
121 | -// } | |
122 | -// } else if (response.code() == 404) { | |
123 | -// Log.d("TAG1", "No hay cursos") | |
124 | -// } | |
125 | -// | |
126 | -// } | |
127 | -// | |
128 | -// override fun onFailure(call: Call<List<productos?>?>, t: Throwable) {} | |
129 | -// }) | |
130 | - } | |
131 | - | |
132 | - fun mostrarArticulos() { | |
133 | - val Job = GlobalScope.launch { | |
134 | - var listArticulos: List<Articles>? = null | |
135 | - var temp: String = "" | |
136 | - listArticulos = | |
137 | - AppDb.getAppDb(requireActivity())?.ArticulosDAO()?.findAllArticulos() | |
138 | - if (listArticulos != null) { | |
139 | - | |
140 | - for (i in listArticulos.indices) | |
141 | - temp += listArticulos[i].codigo.toString() | |
142 | - } | |
143 | - withContext(Dispatchers.Main) { | |
144 | - countriesList.visibility = View.VISIBLE | |
145 | - loading_view.visibility = View.GONE | |
146 | - countriesList?.text = temp | |
147 | - } | |
148 | - } | |
149 | -// for (professor in listArticulos!!) { | |
150 | -// editT.text= professor.id.toString() | |
151 | -// } | |
152 | - } | |
153 | - | |
154 | - | |
155 | -// fun observeViewModel() { | |
156 | -// | |
157 | -// val productosService = ProductosService.getProductosService() | |
158 | -// var job: Job? = null | |
159 | -// | |
160 | -// | |
161 | -// //countriesList.text="Procesando..." | |
162 | -// //countriesList.visibility = View.VISIBLE | |
163 | -// // GlobalScope1.launch(Dispatchers.IO) { | |
164 | -// val response = productosService.getProductos() | |
165 | -// if (response.isSuccessful) { | |
166 | -//// countriesList.layoutManager = LinearLayoutManager(context) | |
167 | -//// countriesList.itemAnimator = DefaultItemAnimator() | |
168 | -// | |
169 | -//// ProductAdapter.updateCountries(it) | |
170 | -// // cargarArticulos(response.body()) | |
171 | -// | |
172 | -// | |
173 | -// val artiAcargar: Articulos? = null | |
174 | -// var index: Long = 1 | |
175 | -// | |
176 | -// for (pro in response.body()!!) { | |
177 | -// //artiAcargar.id =index+1 | |
178 | -// artiAcargar!!.sector = pro.sector | |
179 | -// artiAcargar.codigo = pro.codigo | |
180 | -// artiAcargar.descripcion = pro.descripcion | |
181 | -// artiAcargar.codBar = pro.codBar | |
182 | -// artiAcargar.precio = pro.precio | |
183 | -// artiAcargar.costo = pro.costo | |
184 | -// artiAcargar.balanza = pro.balanza | |
185 | -// artiAcargar.depSn = pro.depSn | |
186 | -// artiAcargar.imagen = pro.imagen | |
187 | -// index += index | |
188 | -// | |
189 | -// AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! | |
190 | -// .insertArticulos(artiAcargar) | |
191 | -// } | |
192 | -// } | |
193 | -// // } | |
194 | -// | |
195 | -// //job.cancel() | |
196 | -// | |
197 | -// | |
198 | -// } | |
199 | - | |
200 | -// fun cargarArticulos(Productos: List<Productos>?) { | |
201 | -// val artiAcargar: Articulos? = null | |
202 | -// var index: Long = 1 | |
203 | -// //val job4 = CoroutineScope(Dispatchers.Default).launch { | |
204 | -// for (pro in Productos!!) { | |
205 | -// //artiAcargar.id =index+1 | |
206 | -// artiAcargar!!.sector = pro.sector | |
207 | -// artiAcargar.codigo = pro.codigo | |
208 | -// artiAcargar.descripcion = pro.descripcion | |
209 | -// artiAcargar.codBar = pro.codBar | |
210 | -// artiAcargar.precio = pro.precio | |
211 | -// artiAcargar.costo = pro.costo | |
212 | -// artiAcargar.balanza = pro.balanza | |
213 | -// artiAcargar.depSn = pro.depSn | |
214 | -// artiAcargar.imagen = pro.imagen | |
215 | -// index += index | |
216 | -// | |
217 | -// AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! | |
218 | -// .insertArticulos(artiAcargar) | |
219 | -// } | |
220 | -// } | |
221 | - } | |
222 | - |
app/src/main/java/com/focasoftware/deboinventariov20/ui/configuracion/ConfiguracionFragment.kt
... | ... | @@ -1,241 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.configuracion | |
2 | - | |
3 | -import android.content.Context | |
4 | -import android.content.SharedPreferences | |
5 | -import android.os.Bundle | |
6 | -import android.view.LayoutInflater | |
7 | -import android.view.View | |
8 | -import android.view.ViewGroup | |
9 | -import android.widget.* | |
10 | -import androidx.fragment.app.Fragment | |
11 | -import androidx.fragment.app.FragmentActivity | |
12 | -import androidx.lifecycle.lifecycleScope | |
13 | -import androidx.navigation.NavController | |
14 | -import androidx.navigation.Navigation | |
15 | -import androidx.navigation.fragment.findNavController | |
16 | -import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
17 | -import com.focasoftware.deboinventariov20.Model.ServeInv | |
18 | -import com.focasoftware.deboinventariov20.R | |
19 | -import com.focasoftware.deboinventariov20.ui.servidores.SpinnerAdapterServidor | |
20 | -import kotlinx.android.synthetic.main.fragment_configuracion.* | |
21 | -import kotlinx.coroutines.* | |
22 | - | |
23 | -class ConfiguracionFragment : Fragment() { | |
24 | - | |
25 | - lateinit var sharedPreferences: SharedPreferences | |
26 | - private lateinit var navController: NavController | |
27 | - lateinit var adapterSpinnerServidor: SpinnerAdapterServidor | |
28 | - var itemSelect: Int = 0 | |
29 | - | |
30 | - override fun onCreate(savedInstanceState: Bundle?) { | |
31 | - super.onCreate(savedInstanceState) | |
32 | - sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
33 | - } | |
34 | - | |
35 | - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
36 | - super.onViewCreated(view, savedInstanceState) | |
37 | - navController = Navigation.findNavController(view) | |
38 | - | |
39 | - } | |
40 | - | |
41 | - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
42 | - | |
43 | - val v = inflater.inflate(R.layout.fragment_configuracion, container, false) | |
44 | - val etRuta = v.findViewById<EditText>(R.id.etRuta) | |
45 | - val btnGuardar = v.findViewById<Button>(R.id.btnGuardar) | |
46 | - val rbProInclu = v.findViewById<RadioButton>(R.id.rbProInclu) | |
47 | - val rbProNoInclu = v.findViewById<RadioButton>(R.id.rbProNoInclu) | |
48 | - val cbHabiLectura = v.findViewById<CheckBox>(R.id.cbHabiLectura) | |
49 | - val cbMostrarStock = v.findViewById<CheckBox>(R.id.cbMostrarStock) | |
50 | - val rbCodigoBarras = v.findViewById<RadioButton>(R.id.rbCodigoBarras) | |
51 | - val rbCodigoDebo = v.findViewById<RadioButton>(R.id.rbCodigoDebo) | |
52 | - val rbCodigoOrigen = v.findViewById<RadioButton>(R.id.rbCodigoOrigen) | |
53 | - val rbDeposito = v.findViewById<RadioButton>(R.id.rbDeposito) | |
54 | - val rbVentas = v.findViewById<RadioButton>(R.id.rbVentas) | |
55 | - val cbMostrarExistencia = v.findViewById<CheckBox>(R.id.cbMostrarExistencia) | |
56 | - val cbMostrarPrecio = v.findViewById<CheckBox>(R.id.cbMostrarPrecio) | |
57 | - val btnAgregarServidor = v.findViewById<Button>(R.id.btnAgregarServidor) | |
58 | - val spServidor = v.findViewById<Spinner>(R.id.spServidor) | |
59 | - val btnValidarServidor = v.findViewById<Button>(R.id.btnValidarServidor) | |
60 | - | |
61 | - if (sharedPreferences.contains("etRuta")) if (sharedPreferences.contains("rbProInclu")) { | |
62 | - if (sharedPreferences.getString("rbProInclu", "").toString() == "0") { | |
63 | - rbProInclu.isChecked = false | |
64 | - rbProNoInclu.isChecked = true | |
65 | - } else if (sharedPreferences.getString("rbProInclu", "").toString() == "1") { | |
66 | - rbProInclu.isChecked = true | |
67 | - rbProNoInclu.isChecked = false | |
68 | - } | |
69 | - } else (sharedPreferences.getString("rbProInclu", "").toString() == "") | |
70 | - | |
71 | - if (sharedPreferences.contains("rbProNoInclu")) { | |
72 | - if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") { | |
73 | - rbProNoInclu.isChecked = false | |
74 | - rbProInclu.isChecked = true | |
75 | - } else if (sharedPreferences.getString("rbProNoInclu", "").toString() == "1") { | |
76 | - rbProNoInclu.isChecked = true | |
77 | - rbProInclu.isChecked = false | |
78 | - } | |
79 | - } else (sharedPreferences.getString("rbProNoInclu", "").toString() == "") | |
80 | - | |
81 | - if (sharedPreferences.contains("cbHabiLectura")) { | |
82 | - if (sharedPreferences.getString("cbHabiLectura", "").toString() == "0") { | |
83 | - cbHabiLectura.isChecked = false | |
84 | - } else if (sharedPreferences.getString("cbHabiLectura", "").toString() == "1") { | |
85 | - cbHabiLectura.isChecked = true | |
86 | - } | |
87 | - } else (sharedPreferences.getString("cbHabiLectura", "").toString() == "") | |
88 | - | |
89 | - if (sharedPreferences.contains("cbMostrarStock")) { | |
90 | - if (sharedPreferences.getString("cbMostrarStock", "").toString() == "0") { | |
91 | - cbMostrarStock.isChecked = false | |
92 | - } else if (sharedPreferences.getString("cbMostrarStock", "").toString() == "1") { | |
93 | - cbMostrarStock.isChecked = true | |
94 | - } | |
95 | - } else (sharedPreferences.getString("cbMostrarStock", "").toString() == "") | |
96 | - | |
97 | - if (sharedPreferences.contains("rbVentas")) { | |
98 | - if (sharedPreferences.getString("rbVentas", "").toString() == "0") { | |
99 | - rbVentas.isChecked = false | |
100 | - rbDeposito.isChecked = true | |
101 | - } else if (sharedPreferences.getString("rbVentas", "").toString() == "1") { | |
102 | - rbVentas.isChecked = true | |
103 | - rbDeposito.isChecked = false | |
104 | - } | |
105 | - } else (sharedPreferences.getString("rbVentas", "").toString() == "") | |
106 | - | |
107 | - if (sharedPreferences.contains("rbDeposito")) { | |
108 | - if (sharedPreferences.getString("rbDeposito", "").toString() == "0") { | |
109 | - rbDeposito.isChecked = false | |
110 | - rbVentas.isChecked = true | |
111 | - } else if (sharedPreferences.getString("rbDeposito", "").toString() == "1") { | |
112 | - rbDeposito.isChecked = true | |
113 | - rbVentas.isChecked = false | |
114 | - } | |
115 | - } else (sharedPreferences.getString("rbDeposito", "").toString() == "") | |
116 | - | |
117 | - if (sharedPreferences.contains("rbCodigoDebo")) { | |
118 | - if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "0") { | |
119 | - rbCodigoDebo.isChecked = false | |
120 | - rbCodigoOrigen.isChecked = false | |
121 | - rbCodigoBarras.isChecked = false | |
122 | - } else if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "1") { | |
123 | - rbCodigoDebo.isChecked = true | |
124 | - rbCodigoOrigen.isChecked = false | |
125 | - rbCodigoBarras.isChecked = false | |
126 | - } | |
127 | - } else (sharedPreferences.getString("rbCodigoDebo", "").toString() == "") | |
128 | - | |
129 | - if (sharedPreferences.contains("rbCodigoOrigen")) { | |
130 | - if (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "0") { | |
131 | - rbCodigoOrigen.isChecked = false | |
132 | - } else if (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "1") { | |
133 | - rbCodigoOrigen.isChecked = true | |
134 | - } | |
135 | - } else (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "") | |
136 | - | |
137 | - if (sharedPreferences.contains("rbCodigoBarras")) { | |
138 | - if (sharedPreferences.getString("rbCodigoBarras", "").toString() == "0") { | |
139 | - rbCodigoBarras.isChecked = false | |
140 | - } else if (sharedPreferences.getString("rbCodigoBarras", "").toString() == "1") { | |
141 | - rbCodigoBarras.isChecked = true | |
142 | - } | |
143 | - } else (sharedPreferences.getString("rbCodigoBarras", "").toString() == "") | |
144 | - | |
145 | - if (sharedPreferences.contains("cbMostrarExistencia")) { | |
146 | - if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "0") { | |
147 | - cbMostrarExistencia.isChecked = false | |
148 | - } else if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "1") { | |
149 | - cbMostrarExistencia.isChecked = true | |
150 | - } | |
151 | - } else (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "") | |
152 | - | |
153 | - if (sharedPreferences.contains("cbMostrarPrecio")) { | |
154 | - if (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "0") { | |
155 | - cbMostrarPrecio.isChecked = false | |
156 | - } else if (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "1") { | |
157 | - cbMostrarPrecio.isChecked = true | |
158 | - } | |
159 | - } else (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "") | |
160 | - | |
161 | - btnGuardar.setOnClickListener { | |
162 | - guardarPreferencias() | |
163 | - Toast.makeText(v.context, "Los Datos se guardaron correctamente", Toast.LENGTH_LONG).show() | |
164 | - navController.navigate(R.id.action_configuracionFragment_to_mainFragment2) | |
165 | - } | |
166 | - btnAgregarServidor.setOnClickListener { findNavController().navigate(R.id.servidoresFragment) } | |
167 | - btnValidarServidor.setOnClickListener { Toast.makeText(requireContext(), "Direcciรณn correcta", Toast.LENGTH_LONG).show() } | |
168 | - GlobalScope.launch(Dispatchers.Main) { | |
169 | - adapterSpinnerServidor = SpinnerAdapterServidor(requireContext(), getDescServers()) | |
170 | - spServidor.adapter = adapterSpinnerServidor | |
171 | - if (sharedPreferences.contains("ServerPredeterminado")) { | |
172 | - spServidor.setSelection(sharedPreferences.getString("ServerPredeterminado", "").toString().toInt()) | |
173 | - } else (spServidor.setSelection(0)) | |
174 | - } | |
175 | - spServidor?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { | |
176 | - override fun onNothingSelected(parent: AdapterView<*>?) {} | |
177 | - override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { | |
178 | - itemSelect = position | |
179 | - } | |
180 | - } | |
181 | - return v | |
182 | - } | |
183 | - | |
184 | - suspend fun getDescServers(): List<ServeInv> { | |
185 | - return GlobalScope.async(Dispatchers.IO) { | |
186 | - return@async AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.fetchAllServers() | |
187 | - }.await() | |
188 | - } | |
189 | - | |
190 | - fun guardarPreferencias() { | |
191 | -// try { | |
192 | - val editor = sharedPreferences.edit() | |
193 | - | |
194 | - if (etRuta.text.isNotEmpty()) editor?.putString("etRuta", etRuta.text.toString()) | |
195 | - | |
196 | - if (rbProInclu.isChecked) editor?.putString("rbProInclu", "1") else editor?.putString("rbProInclu", "0") | |
197 | - if (rbProNoInclu.isChecked) editor?.putString("rbProNoInclu", "1") else editor?.putString("rbProNoInclu", "0") | |
198 | - | |
199 | - if (cbHabiLectura.isChecked) editor?.putString("cbHabiLectura", "1") else editor?.putString("cbHabiLectura", "0") | |
200 | - if (cbMostrarStock.isChecked) editor?.putString("cbMostrarStock", "1") else editor?.putString("cbMostrarStock", "0") | |
201 | - if (rbVentas.isChecked) editor?.putString("rbVentas", "1") else editor?.putString("rbVentas", "0") | |
202 | - if (rbDeposito.isChecked) editor?.putString("rbDeposito", "1") else editor?.putString("rbDeposito", "0") | |
203 | - if (rbCodigoDebo.isChecked) editor?.putString("rbCodigoDebo", "1") else editor?.putString("rbCodigoDebo", "0") | |
204 | - if (rbCodigoOrigen.isChecked) editor?.putString("rbCodigoOrigen", "1") else editor?.putString("rbCodigoOrigen", "0") | |
205 | - if (rbCodigoBarras.isChecked) editor?.putString("rbCodigoBarras", "1") else editor?.putString("rbCodigoBarras", "0") | |
206 | - if (cbMostrarExistencia.isChecked) editor?.putString("cbMostrarExistencia", "1") else editor?.putString("cbMostrarExistencia", "0") | |
207 | - if (cbMostrarPrecio.isChecked) editor?.putString("cbMostrarPrecio", "1") else editor?.putString("cbMostrarPrecio", "0") | |
208 | - editor?.putString("ServerPredeterminado", itemSelect.toString()) | |
209 | - updateServerPreInZero() | |
210 | - updateServerPre(itemSelect+1) | |
211 | - | |
212 | - editor?.apply() | |
213 | - editor.commit() | |
214 | - | |
215 | -// } catch (e: Exception) { | |
216 | -// Toast.makeText(requireContext(), "Error ", Toast.LENGTH_LONG).show() | |
217 | -// e.printStackTrace() | |
218 | -// } | |
219 | - } | |
220 | - | |
221 | - private fun updateServerPreInZero() { | |
222 | - lifecycleScope.launch { | |
223 | - withContext(Dispatchers.IO) { | |
224 | - val activity: FragmentActivity? = activity | |
225 | - if (activity != null && isAdded) { | |
226 | - AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.UpdateServerPreInZero() | |
227 | - } | |
228 | - } | |
229 | - } | |
230 | - } | |
231 | - private fun updateServerPre(server:Int) { | |
232 | - lifecycleScope.launch { | |
233 | - withContext(Dispatchers.IO) { | |
234 | - val activity: FragmentActivity? = activity | |
235 | - if (activity != null && isAdded) { | |
236 | - AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.UpdateServerPre(server) | |
237 | - } | |
238 | - } | |
239 | - } | |
240 | - } | |
241 | -} | |
242 | 0 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/descripcionFragment/DescripcionFragment.kt
... | ... | @@ -1,254 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.descripcionFragment | |
2 | - | |
3 | -import android.app.AlertDialog | |
4 | -import android.content.Context | |
5 | -import android.content.SharedPreferences | |
6 | -import android.graphics.Canvas | |
7 | -import android.graphics.Color | |
8 | -import android.graphics.drawable.ColorDrawable | |
9 | -import android.os.Bundle | |
10 | -import android.text.InputType | |
11 | -import android.view.LayoutInflater | |
12 | -import android.view.View | |
13 | -import android.view.ViewGroup | |
14 | -import android.widget.Button | |
15 | -import androidx.fragment.app.Fragment | |
16 | -import androidx.fragment.app.FragmentActivity | |
17 | -import androidx.lifecycle.lifecycleScope | |
18 | -import androidx.navigation.NavController | |
19 | -import androidx.navigation.Navigation | |
20 | -import androidx.recyclerview.widget.ItemTouchHelper | |
21 | -import androidx.recyclerview.widget.LinearLayoutManager | |
22 | -import androidx.recyclerview.widget.RecyclerView | |
23 | -import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
24 | -import com.focasoftware.deboinventariov20.Model.Articles | |
25 | -import com.focasoftware.deboinventariov20.Model.InvBody | |
26 | -import com.focasoftware.deboinventariov20.R | |
27 | -import com.focasoftware.deboinventariov20.ui.inventario.InventarioFragment | |
28 | -import kotlinx.android.synthetic.main.ingresar_cantidad.view.* | |
29 | -import kotlinx.android.synthetic.main.login_dialog.view.* | |
30 | -import kotlinx.android.synthetic.main.login_dialog.view.btnAceptar | |
31 | -import kotlinx.coroutines.* | |
32 | - | |
33 | -class DescripcionFragment : Fragment() { | |
34 | - private var artAcargar2: List<Articles>? = null | |
35 | - private var listArticulos2: List<Articles>? = null | |
36 | - lateinit var viewAdapter2: RecyclerView.Adapter<*> | |
37 | - private lateinit var viewManager2: RecyclerView.LayoutManager | |
38 | - private lateinit var rcDescripcion: RecyclerView | |
39 | - private var swipeBackground: ColorDrawable = ColorDrawable(Color.YELLOW) | |
40 | - private var cantidad = 0F | |
41 | - private var numeroInventario = 0 | |
42 | - lateinit var navController: NavController | |
43 | - lateinit var sharedPreferences: SharedPreferences | |
44 | - private var indice = 0 | |
45 | - private var artCargadoEnBD: InvBody? = null | |
46 | - | |
47 | - override fun onCreate(savedInstanceState: Bundle?) { | |
48 | - super.onCreate(savedInstanceState) | |
49 | - sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
50 | - arguments.apply { | |
51 | - artAcargar2 = requireArguments().getSerializable("ArrayDesc") as List<Articles> | |
52 | - numeroInventario = requireArguments().getInt("numeroInv") | |
53 | - } | |
54 | - } | |
55 | - | |
56 | - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
57 | - super.onViewCreated(view, savedInstanceState) | |
58 | - navController = Navigation.findNavController(view) | |
59 | - } | |
60 | - | |
61 | - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
62 | - val v = inflater.inflate(R.layout.fragment_descripcion, container, false) | |
63 | - rcDescripcion = v.findViewById(R.id.rcDescripcion) | |
64 | -// val btnSalir = v.findViewById<Button>(R.id.btnSalir) | |
65 | - | |
66 | - IngresarRecicler(artAcargar2) | |
67 | - | |
68 | -// btnSalir.setOnClickListener { | |
69 | -// activity?.onBackPressed(); | |
70 | -//// VolverAinventario() | |
71 | -// } | |
72 | - return v | |
73 | - } | |
74 | - | |
75 | - fun IngresarRecicler(articulos: List<Articles>?) { | |
76 | - | |
77 | - viewAdapter2 = DescripcionListAdapter(articulos) | |
78 | - viewManager2 = LinearLayoutManager(requireContext()) | |
79 | - | |
80 | - rcDescripcion.apply { | |
81 | - adapter = viewAdapter2 | |
82 | - layoutManager = viewManager2 | |
83 | - } | |
84 | - val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) { | |
85 | - override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | |
86 | - return false | |
87 | - } | |
88 | - | |
89 | - override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { | |
90 | - | |
91 | - var indice = 0 | |
92 | - indice = viewHolder.layoutPosition | |
93 | - GlobalScope.launch(Dispatchers.Main) { | |
94 | - //TODO BUSCO EN BASE DE DATOS | |
95 | - artCargadoEnBD = buscarCodigoDeboEnBD((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)?.sector.toString(), | |
96 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)?.codigo.toString(), | |
97 | - numeroInventario.toString()) | |
98 | - if (artCargadoEnBD == null) { | |
99 | - val mDialogView = LayoutInflater.from(context).inflate(R.layout.ingresar_cantidad, null) | |
100 | - val mBuilder = AlertDialog.Builder(context).setView(mDialogView) | |
101 | - .setCancelable(false) | |
102 | - if ((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==1 || (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==3 || (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==7) | |
103 | - mDialogView.etCantidad.inputType= InputType.TYPE_CLASS_NUMBER | |
104 | - mDialogView.tvTitulo.text = "${(viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion}" | |
105 | - val mAlertDialog = mBuilder.show() | |
106 | - mDialogView.btnAceptar.setOnClickListener { | |
107 | - if (mDialogView.etCantidad.text.isNullOrEmpty()) { | |
108 | - mDialogView.etCantidad.error = "No vacio" | |
109 | - mDialogView.etCantidad.requestFocus() | |
110 | - mDialogView.etCantidad.hint = "Ingrese un valor" | |
111 | - } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { | |
112 | - cantidad = mDialogView.etCantidad.text.toString().toFloat() | |
113 | - val body = InvBody(numeroInventario, | |
114 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector, | |
115 | - // TODO: PREPARO PARA MANDAR A CARGAR EN LA BD | |
116 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo, | |
117 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion, | |
118 | - cantidad.toString(), | |
119 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codBar, | |
120 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codOrigen, | |
121 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, | |
122 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, | |
123 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza, | |
124 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.depSn, | |
125 | - InventarioFragment().ObtenerFechaActual(), | |
126 | - InventarioFragment().ObtenerFechaActual()) | |
127 | - InsertarArtEnDB(body)// TODO: MANDO A CARGAR A LA BASE DE DATOS | |
128 | -// VolverAinventario() | |
129 | - activity?.onBackPressed() | |
130 | - mAlertDialog.dismiss() | |
131 | - } | |
132 | - } | |
133 | - } else if (artCargadoEnBD != null) { | |
134 | - | |
135 | - val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
136 | - val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${artCargadoEnBD!!.descripcion}', se encuentra cargado.").setCancelable(false) | |
137 | - if (artCargadoEnBD!!.balanza.toString().contains("1" ) || artCargadoEnBD!!.balanza.toString().contains("3") || artCargadoEnBD!!.balanza.toString().contains("7")) mDialogView.tvNuevaCantidad.inputType= InputType.TYPE_CLASS_NUMBER | |
138 | - mDialogView.tvCantInicial.text =String.format("%.2f", artCargadoEnBD!!.cantTomada.toString().toFloat()) | |
139 | - | |
140 | - val mAlertDialog = mBuilder.show() | |
141 | - mDialogView.rbSumar.setOnClickListener { | |
142 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
143 | - mDialogView.tvResultado.text = String.format("%.2f",(mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat())) | |
144 | - mDialogView.tvNuevaCantidad.isEnabled=false | |
145 | - } | |
146 | - } | |
147 | - mDialogView.rbRestar.setOnClickListener { | |
148 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
149 | - if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | |
150 | - mDialogView.tvResultado.text = String.format("%.2f",mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()) | |
151 | - mDialogView.tvNuevaCantidad.isEnabled = false | |
152 | - }else{ | |
153 | - mDialogView.tvResultado.text="" | |
154 | - mDialogView.tvResultado.error = "Operaciรณn No Valida" | |
155 | - mDialogView.tvResultado.requestFocus() | |
156 | - mDialogView.tvResultado.hint = "Error" | |
157 | - } | |
158 | - } | |
159 | - } | |
160 | - mDialogView.rbMdodificar.setOnClickListener { | |
161 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
162 | - mDialogView.tvResultado.text = String.format("%.2f", (mDialogView.tvNuevaCantidad.text.toString().toFloat())) | |
163 | - mDialogView.tvNuevaCantidad.isEnabled = false | |
164 | - } | |
165 | - } | |
166 | - mDialogView.btnAceptar.setOnClickListener { | |
167 | - if (mDialogView.tvNuevaCantidad.text.isNotEmpty() || !mDialogView.tvNuevaCantidad.text.isBlank()) { | |
168 | - if (mDialogView.tvResultado.text.isNotEmpty() || !mDialogView.tvResultado.text.isBlank()) { | |
169 | - | |
170 | - updateCantidad((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector.toString(), | |
171 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo.toString(), | |
172 | - mDialogView.tvResultado.text.toString().toFloat()) | |
173 | -// VolverAinventario() | |
174 | - activity?.onBackPressed(); | |
175 | - mAlertDialog.dismiss() | |
176 | - } else if (mDialogView.tvNuevaCantidad.text.isNotEmpty() || mDialogView.tvNuevaCantidad.text.isBlank()) { | |
177 | - mDialogView.tvResultado.error = "Operaciรณn Requerida" | |
178 | - mDialogView.tvResultado.requestFocus() | |
179 | - mDialogView.tvResultado.hint = "Seleccione Operaciรณn" | |
180 | - } | |
181 | - } else if (mDialogView.tvNuevaCantidad.text.isEmpty() || mDialogView.tvNuevaCantidad.text.isBlank()) { | |
182 | - mDialogView.tvNuevaCantidad.error = "Completar" | |
183 | - mDialogView.tvNuevaCantidad.requestFocus() | |
184 | - mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | |
185 | - } | |
186 | - } | |
187 | - mDialogView.dialogCancelBtn.setOnClickListener { | |
188 | - activity?.onBackPressed(); | |
189 | - mAlertDialog.dismiss() | |
190 | - } | |
191 | - } | |
192 | - } | |
193 | - } | |
194 | - | |
195 | - override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | |
196 | - super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
197 | - val itemView = viewHolder.itemView | |
198 | - | |
199 | - c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | |
200 | - | |
201 | - if (dX > 0) { | |
202 | - | |
203 | - c.drawColor(Color.RED) | |
204 | - } else if (dX < 0) { | |
205 | - // swipeBackground.setBounds(itemView.right+dX.toInt(),itemView.top,itemView.right,itemView.bottom) | |
206 | - c.drawColor(Color.YELLOW) | |
207 | - } | |
208 | - swipeBackground.draw(c) | |
209 | - super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
210 | - } | |
211 | - } | |
212 | - val itemTouchHelper2 = ItemTouchHelper(itemTouchHelperCallback) | |
213 | - itemTouchHelper2.attachToRecyclerView(rcDescripcion) | |
214 | - | |
215 | - } | |
216 | - | |
217 | - fun InsertarArtEnDB(cuarpoInventario: InvBody) { | |
218 | - lifecycleScope.launch { | |
219 | - withContext(Dispatchers.IO) { | |
220 | - AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) | |
221 | - } | |
222 | - } | |
223 | - } | |
224 | - | |
225 | -// fun VolverAinventario() { | |
226 | -// | |
227 | -// val editor = sharedPreferences.edit() | |
228 | -// editor?.putString("Inventario", numeroInventario.toString()) | |
229 | -// editor?.apply() | |
230 | -// editor.commit() | |
231 | -// navController.navigate(R.id.action_descripcionFragment_to_inventarioFragment) | |
232 | -// } | |
233 | - | |
234 | - suspend fun buscarCodigoDeboEnBD(sector: String, codigo: String, numInventario: String): InvBody? { | |
235 | - //TODO BUSQUEDA POR CODIGO DE BARRAS | |
236 | - var busqueda: InvBody? = null | |
237 | - return GlobalScope.async(Dispatchers.IO) { | |
238 | - busqueda = AppDb.getAppDb(requireContext())!!.InvBodyDAO()!!.fetchArtInInvBody(sector, codigo, numInventario) | |
239 | - return@async busqueda | |
240 | - }.await() | |
241 | - } | |
242 | - | |
243 | - fun updateCantidad(sector: String, codigo: String, cantidad: Float) { | |
244 | - lifecycleScope.launch { | |
245 | - withContext(Dispatchers.IO) { | |
246 | - val activity: FragmentActivity? = activity | |
247 | - if (activity != null && isAdded) { | |
248 | - AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.UpdateInvBody(cantidad, sector, codigo) | |
249 | - } | |
250 | - } | |
251 | - } | |
252 | - } | |
253 | -} | |
254 | - |
app/src/main/java/com/focasoftware/deboinventariov20/ui/descripcionFragment/DescripcionListAdapter.kt
... | ... | @@ -1,48 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.descripcionFragment | |
2 | - | |
3 | -import android.view.LayoutInflater | |
4 | -import android.view.View | |
5 | -import android.view.ViewGroup | |
6 | -import androidx.recyclerview.widget.RecyclerView | |
7 | -import com.focasoftware.deboinventariov20.Model.Articles | |
8 | -import com.focasoftware.deboinventariov20.R | |
9 | -import kotlinx.android.synthetic.main.item.view.* | |
10 | - | |
11 | -class DescripcionListAdapter(private val productos: List<Articles>?) : | |
12 | - RecyclerView.Adapter<DescripcionListAdapter.ItemsViewHolder>() { | |
13 | - internal var items2: List<Articles>? = null | |
14 | - | |
15 | - init { | |
16 | - this.items2 = productos | |
17 | - } | |
18 | - | |
19 | - override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder( | |
20 | - LayoutInflater.from(parent.context).inflate(R.layout.item_descripcion, parent, false) | |
21 | - ) | |
22 | - | |
23 | - override fun getItemCount() = productos!!.size | |
24 | - | |
25 | - override fun onBindViewHolder(holder: ItemsViewHolder, position: Int) { | |
26 | - when (holder) { | |
27 | - is ItemsViewHolder -> { | |
28 | - holder.bind(items2!![position]) | |
29 | - } | |
30 | - } | |
31 | - } | |
32 | - | |
33 | - | |
34 | - class ItemsViewHolder constructor(view: View) : RecyclerView.ViewHolder(view) { | |
35 | - | |
36 | - val sector = view.tvSector | |
37 | - val codigo = view.tvCodigo | |
38 | - val descripcion = view.tvDescripcion | |
39 | - val codigoBarras = view.tvCodigoBarras | |
40 | - | |
41 | - fun bind(pro: Articles) { | |
42 | - sector.text = pro.sector | |
43 | - codigo.text = pro.codigo | |
44 | - descripcion.text = pro.descripcion | |
45 | - codigoBarras.text = pro.codBar | |
46 | - } | |
47 | - } | |
48 | -} | |
49 | 0 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/descripcionFragment/ItemDescripcion.kt
app/src/main/java/com/focasoftware/deboinventariov20/ui/detalleProducto/DetalleArtFragment.kt
... | ... | @@ -1,96 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.detalleProducto | |
2 | - | |
3 | -import android.content.Context | |
4 | -import android.content.SharedPreferences | |
5 | -import android.os.Bundle | |
6 | -import android.view.LayoutInflater | |
7 | -import android.view.View | |
8 | -import android.view.ViewGroup | |
9 | -import androidx.fragment.app.Fragment | |
10 | -import androidx.navigation.NavController | |
11 | -import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
12 | -import com.focasoftware.deboinventariov20.Model.Articles | |
13 | -import com.focasoftware.deboinventariov20.R | |
14 | -import kotlinx.android.synthetic.main.fragment_detalle_art.* | |
15 | -import kotlinx.coroutines.Dispatchers | |
16 | -import kotlinx.coroutines.GlobalScope | |
17 | -import kotlinx.coroutines.async | |
18 | -import kotlinx.coroutines.launch | |
19 | - | |
20 | -class DetalleArtFragment : Fragment() { | |
21 | - | |
22 | - private var Inventario: Int = 0 | |
23 | - private var sector: String? = null | |
24 | - private var codigo: String? = null | |
25 | - private var artSerch: Articles? = null | |
26 | - lateinit var sharedPreferences: SharedPreferences | |
27 | - | |
28 | - override fun onCreate(savedInstanceState: Bundle?) { | |
29 | - super.onCreate(savedInstanceState) | |
30 | - sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
31 | - arguments?.let { | |
32 | - sector = it.getString("sector") | |
33 | - codigo = it.getString("codigo") | |
34 | - Inventario= it.getInt("numeroInv") | |
35 | - } | |
36 | - marcarInventario() | |
37 | - GlobalScope.launch(Dispatchers.Main) { | |
38 | - | |
39 | - artSerch = buscarCodigoDeboEnBD(sector, codigo) | |
40 | - if (artSerch == null) { | |
41 | - | |
42 | -// val type = InputType.TYPE_CLASS_NUMBER | |
43 | -// MaterialDialog(requireContext()).show { | |
44 | -// | |
45 | -// title(text = "Producto '$sChangeUpper', se encuentra cargado.") | |
46 | -// message(R.string.sCantidadNueva) | |
47 | -// input(waitForPositiveButton = false, hint = "99.99", inputType = type) { materialDialog, charSequence -> | |
48 | -// fCant = 0F | |
49 | -// fCant = charSequence.toString().toFloat() | |
50 | -// } | |
51 | -// positiveButton(R.string.btnOk) { | |
52 | -// //TODO ACTUALIZO CANTIADAD EN BD | |
53 | -// updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
54 | -// //TODO ACTUALIZO CANTIDAD EN RV | |
55 | -// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
56 | -// viewAdapter.notifyDataSetChanged() | |
57 | -// dismiss() | |
58 | -// } | |
59 | -// }.cancelOnTouchOutside(false).cornerRadius(10F) | |
60 | - } else if (artSerch != null) { | |
61 | - tvSector.text=sector | |
62 | - tvCodigo.text=codigo | |
63 | - tvDeposito.text=if(artSerch!!.depSn!!.toInt() ==0)"No" else "Si" | |
64 | - tvDescripcion.text=artSerch!!.descripcion.toString() | |
65 | - tvCodigoBarras.text=artSerch!!.codBar.toString() | |
66 | - tvCodigoOrigen.text=artSerch!!.codOrigen.toString() | |
67 | - tvExiVenta.text=artSerch!!.exiVenta.toString() | |
68 | - tvExiDeposito.text=artSerch!!.exiDeposito.toString() | |
69 | - tvBal.text=artSerch!!.balanza.toString() | |
70 | - tvDE.text=artSerch!!.de.toString() | |
71 | - } | |
72 | - } | |
73 | - } | |
74 | - | |
75 | - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
76 | - | |
77 | - return inflater.inflate(R.layout.fragment_detalle_art, container, false) | |
78 | - } | |
79 | - | |
80 | - suspend fun buscarCodigoDeboEnBD(sector: String?, codigo: String?): Articles? { | |
81 | - //TODO BUSQUEDA POR CODIGO DE BARRAS | |
82 | - var busqueda: Articles? = null | |
83 | - return GlobalScope.async(Dispatchers.IO) { | |
84 | - busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.fetchArticuloByCodSec(sector, codigo) | |
85 | - return@async busqueda | |
86 | - }.await() | |
87 | - } | |
88 | - fun marcarInventario() { | |
89 | - | |
90 | - val editor = sharedPreferences.edit() | |
91 | - editor?.putString("Inventario", Inventario.toString()) | |
92 | - editor?.apply() | |
93 | - editor.commit() | |
94 | -// navController.navigate(R.id.action_descripcionFragment_to_inventarioFragment) | |
95 | - } | |
96 | -} | |
97 | 0 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/InventarioFragment.kt
... | ... | @@ -1,819 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.inventario | |
2 | - | |
3 | -import android.annotation.SuppressLint | |
4 | -import android.app.AlertDialog | |
5 | -import android.content.Context | |
6 | -import android.content.DialogInterface | |
7 | -import android.content.SharedPreferences | |
8 | -import android.graphics.Canvas | |
9 | -import android.graphics.Color | |
10 | -import android.graphics.drawable.Drawable | |
11 | -import android.os.Bundle | |
12 | -import android.text.InputType.TYPE_CLASS_NUMBER | |
13 | -import android.view.KeyEvent | |
14 | -import android.view.LayoutInflater | |
15 | -import android.view.View | |
16 | -import android.view.ViewGroup | |
17 | -import android.widget.EditText | |
18 | -import android.widget.TextView | |
19 | -import android.widget.Toast | |
20 | -import androidx.core.content.ContextCompat | |
21 | -import androidx.core.os.bundleOf | |
22 | -import androidx.fragment.app.Fragment | |
23 | -import androidx.lifecycle.lifecycleScope | |
24 | -import androidx.navigation.NavController | |
25 | -import androidx.navigation.Navigation | |
26 | -import androidx.recyclerview.widget.ItemTouchHelper | |
27 | -import androidx.recyclerview.widget.LinearLayoutManager | |
28 | -import androidx.recyclerview.widget.RecyclerView | |
29 | -import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
30 | -import com.focasoftware.deboinventariov20.Model.Articles | |
31 | -import com.focasoftware.deboinventariov20.Model.InvBody | |
32 | -import com.focasoftware.deboinventariov20.Model.InvHead | |
33 | -import com.focasoftware.deboinventariov20.R | |
34 | -import com.focasoftware.deboinventariov20.ui.util.Base.dialogos.DialogNoEncontrado | |
35 | -import kotlinx.android.synthetic.main.fragment_inventario.* | |
36 | -import kotlinx.android.synthetic.main.ingresar_cantidad.view.* | |
37 | -import kotlinx.android.synthetic.main.login_dialog.view.* | |
38 | -import kotlinx.android.synthetic.main.login_dialog.view.btnAceptar | |
39 | -import kotlinx.coroutines.* | |
40 | -import java.time.LocalDateTime | |
41 | -import java.time.format.DateTimeFormatter | |
42 | -import java.util.* | |
43 | - | |
44 | - | |
45 | -class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickListener { | |
46 | - | |
47 | - private lateinit var sharedPreferences: SharedPreferences | |
48 | - private var iArea: Int = 0 | |
49 | - private lateinit var invHead: InvHead | |
50 | - private lateinit var rcInventarios: RecyclerView | |
51 | - private lateinit var viewAdapter: RecyclerView.Adapter<*> | |
52 | - private lateinit var viewManager: RecyclerView.LayoutManager | |
53 | - private lateinit var sChangeUpper: String | |
54 | - private var listArticulos = ArrayList<ItemsRecycler>() | |
55 | - private lateinit var navController: NavController | |
56 | - private var InventarioNuevo: Int = 0 | |
57 | - private var iEstado = 0 | |
58 | - private var iBusquedaPor = 0 | |
59 | - private var fCant = 0F | |
60 | - private var bFirst = false | |
61 | - private lateinit var deleteIcon: Drawable | |
62 | - | |
63 | - override fun onCreate(savedInstanceState: Bundle?) { | |
64 | - super.onCreate(savedInstanceState) | |
65 | - | |
66 | - sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
67 | - if (sharedPreferences.contains("Inventario")) if (sharedPreferences.getString("Inventario", "").toString() != "-1") { | |
68 | - InventarioNuevo = sharedPreferences.getString("Inventario", "").toString().toInt() | |
69 | - val editor = sharedPreferences.edit() | |
70 | - editor?.putString("Inventario", "-1") | |
71 | - editor?.apply() | |
72 | - editor.commit() | |
73 | - } | |
74 | - } | |
75 | - | |
76 | - | |
77 | - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
78 | - val v = inflater.inflate(R.layout.fragment_inventario, container, false) | |
79 | - sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
80 | - val tCodigoBarras = v.findViewById<EditText>(R.id.etCodigoBarras) | |
81 | - rcInventarios = v.findViewById(R.id.rcInventarios) | |
82 | - val tvTitulo = v.findViewById<TextView>(R.id.tvTitulo) | |
83 | - | |
84 | - if (InventarioNuevo == 0) {// TODO: SI INVETNARIO NUEVO | |
85 | - GlobalScope.launch(Dispatchers.Main) { | |
86 | - //TODO: BUSCO EL ULTIMO INVENTARIO EN LA BD PARA PODER CREAR EL PROXIMO | |
87 | - InventarioNuevo = AppDb.getAppDb(requireActivity())?.InvHeadDAO()?.findLastInv()?.plus(1) ?: 1 | |
88 | - //TODO: CREAMOS EL INVENTARIO EN LA CABECERA DEL INVENTARIO | |
89 | - invHead = InvHead(InventarioNuevo, if (SerchArea() == 0) "Ventas" else "Deposito", 1, ObtenerFechaActual(), ObtenerFechaActual(), 0L, SerchArea(), AjusteProductos(), ProdNoCont()) | |
90 | - AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.insertInvHead(invHead) | |
91 | - tvTitulo.text = "Inventario Dinamico" + " Nยฐ $InventarioNuevo" | |
92 | - } | |
93 | - } else {// TODO (SI VENGO DE FRAGMENT DESCRIPCION) | |
94 | - listArticulos.clear() | |
95 | - CargarDeBdInventario(InventarioNuevo) | |
96 | - tvTitulo.text = "Inventario Dinamico" + " Nยฐ $InventarioNuevo" | |
97 | - } | |
98 | - | |
99 | - tCodigoBarras.setOnKeyListener { _, keyCode, keyEvent -> | |
100 | - if (keyCode == KeyEvent.KEYCODE_ENTER && keyEvent.action == KeyEvent.ACTION_UP) { | |
101 | - sChangeUpper = tCodigoBarras.text.toString() | |
102 | - var indiceDelArtEncontrado = 0 | |
103 | - | |
104 | - if (tCodigoBarras.text.isNullOrBlank()) { | |
105 | - tCodigoBarras.error = "No puede estar vacio" | |
106 | - tCodigoBarras.requestFocus() | |
107 | - tCodigoBarras.hint = "No puede estar vacio" | |
108 | - } else { | |
109 | - | |
110 | - //TODO COMIENZA LA BUSQUEDA POR CODIGO DE BARRAS | |
111 | - when (iBusquedaPor) { | |
112 | - 0 -> { | |
113 | - GlobalScope.launch(Dispatchers.Main) { | |
114 | - indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 0)//TODO Si encuentra el articulo en el RV devuelve el indice | |
115 | - //TODO (Si no lo encuentra devuelve -1) | |
116 | - if (indiceDelArtEncontrado != -1) { | |
117 | - if (swSumaUno!!.isChecked) { | |
118 | -// fCant = 0F | |
119 | -// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
120 | -// fCant += 1F | |
121 | - //TODO ACTUALIZO LA CANTIDAD EN LA BD | |
122 | - updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), | |
123 | - listArticulos[indiceDelArtEncontrado].codigo.toString(), | |
124 | - listArticulos[indiceDelArtEncontrado].cantTomada + 1) | |
125 | - //TODO ACTUALIZO LA CANTIDAD EN EL RV | |
126 | - listArticulos[indiceDelArtEncontrado].cantTomada = listArticulos[indiceDelArtEncontrado].cantTomada + 1 | |
127 | - viewAdapter.notifyDataSetChanged() | |
128 | - } else { | |
129 | - dialogoSumaResta(requireContext(), indiceDelArtEncontrado, listArticulos[indiceDelArtEncontrado].univta, false) | |
130 | - } | |
131 | - | |
132 | - } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD | |
133 | - | |
134 | - | |
135 | - //TODO BUSCO EN BASE DE DATOS | |
136 | - val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | |
137 | - ContinuarCargaCB(artEncontrado)//TODO SE MANDA CERO POR QUE ES UN ARTICULO ESCANEADO NUEVO PARA QUE SEA COMPATIBLE | |
138 | - } | |
139 | - | |
140 | - | |
141 | - tCodigoBarras.focusable = View.FOCUSABLE | |
142 | - tCodigoBarras.setText("") | |
143 | - tCodigoBarras.selectAll() | |
144 | - } | |
145 | - return@setOnKeyListener true | |
146 | - | |
147 | - | |
148 | - } | |
149 | - 1 -> {//TODO: BUSQUEDA POR DESCRIPCION************************************************************************** | |
150 | - // | |
151 | - // indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 1) //TODO :Si encuentra el articulo en el RV devuelve el indice | |
152 | - // //TODO Si no lo encuentra devuelve -1 | |
153 | - // if (indiceDelArtEncontrado != -1) { | |
154 | - //// if (swSumaUno!!.isChecked) { | |
155 | - //// fCant = 0F | |
156 | - //// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
157 | - //// fCant += 1F | |
158 | - //// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
159 | - //// viewAdapter.notifyDataSetChanged() | |
160 | - //// } else { | |
161 | - // fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
162 | - // MaterialDialog(requireContext()).show { | |
163 | - // title(R.string.sTituloNueva) | |
164 | - // message(R.string.sCantidadNueva) | |
165 | - // input { materialDialog, charSequence -> | |
166 | - // fCant = 0F | |
167 | - // fCant = charSequence.toString().toFloat() | |
168 | - // } | |
169 | - // positiveButton(R.string.btnOk) { | |
170 | - // listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
171 | - // viewAdapter.notifyDataSetChanged() | |
172 | - // dismiss() | |
173 | - // } | |
174 | - // }.cancelOnTouchOutside(false).cornerRadius(10F) | |
175 | - //// } | |
176 | - // | |
177 | - // } else if | |
178 | - // (indiceDelArtEncontrado == -1) {// TODO: no lo encontro en el RV, lo va a buscar en al BD | |
179 | - GlobalScope.launch(Dispatchers.Main) { | |
180 | - val artEncontrado = buscarDescEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | |
181 | - ContinuarCargaDesc(artEncontrado as ArrayList<Articles>) | |
182 | - } | |
183 | - // } | |
184 | - | |
185 | - return@setOnKeyListener true | |
186 | - } | |
187 | -// 2 -> {//TODO: BUSQUEDA POR CODIGO DE ORIGEN************************************************************************** | |
188 | -// indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 3)//TODO Si encuentra el articulo en el RV devuelve el indice | |
189 | -// //TODO Si no lo encuentra devuelve -1 | |
190 | -// if (indiceDelArtEncontrado != -1) { | |
191 | -// if (swSumaUno!!.isChecked) { | |
192 | -// fCant = 0F | |
193 | -// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
194 | -// fCant += 1F | |
195 | -// //TODO ACTUALIZO LA CANTIDAD EN LA BD | |
196 | -// updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
197 | -// //TODO ACTUALIZO LA CANTIDAD EN EL RV | |
198 | -// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
199 | -// viewAdapter.notifyDataSetChanged() | |
200 | -// } else { | |
201 | -// val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
202 | -// val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${listArticulos[indiceDelArtEncontrado].descripcion}', se encuentra cargado.") | |
203 | -// .setCancelable(false) | |
204 | -// mDialogView.tvCantInicial.text = listArticulos[indiceDelArtEncontrado].cantTomada.toString() | |
205 | -// val mAlertDialog = mBuilder.show() | |
206 | -// mDialogView.rbSumar.setOnClickListener { | |
207 | -// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
208 | -// mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
209 | -// } | |
210 | -// } | |
211 | -// mDialogView.rbRestar.setOnClickListener { | |
212 | -// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
213 | -// if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | |
214 | -// mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
215 | -// } | |
216 | -// } | |
217 | -// } | |
218 | -// mDialogView.rbMdodificar.setOnClickListener { | |
219 | -// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
220 | -// mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
221 | -// } | |
222 | -// } | |
223 | -// mDialogView.btnAceptar.setOnClickListener { | |
224 | -// mAlertDialog.dismiss() | |
225 | -// val name = mDialogView.tvgenerico4.text.toString().toFloat() | |
226 | -// fCant = 0F | |
227 | -// fCant = name | |
228 | -// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
229 | -// updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
230 | -// viewAdapter.notifyDataSetChanged() | |
231 | -// } | |
232 | -// mDialogView.dialogCancelBtn.setOnClickListener { | |
233 | -// mAlertDialog.dismiss() | |
234 | -// } | |
235 | -//// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
236 | -//// val type = InputType.TYPE_CLASS_NUMBER | |
237 | -//// MaterialDialog(requireContext()).show { | |
238 | -//// | |
239 | -//// title(text = "Producto '$sChangeUpper', se encuentra cargado.") | |
240 | -//// message(R.string.sCantidadNueva) | |
241 | -//// input(waitForPositiveButton = false, hint = "99.99", inputType = type) { materialDialog, charSequence -> | |
242 | -//// fCant = 0F | |
243 | -//// fCant = charSequence.toString().toFloat() | |
244 | -//// } | |
245 | -//// positiveButton(R.string.btnOk) { | |
246 | -//// //TODO ACTUALIZO CANTIADAD EN BD | |
247 | -//// updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
248 | -//// //TODO ACTUALIZO CANTIDAD EN RV | |
249 | -//// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
250 | -//// viewAdapter.notifyDataSetChanged() | |
251 | -//// dismiss() | |
252 | -//// } | |
253 | -//// }.cancelOnTouchOutside(false).cornerRadius(10F) | |
254 | -// } | |
255 | -// } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD | |
256 | -// | |
257 | -// GlobalScope.launch(Dispatchers.Main) { | |
258 | -// //TODO BUSCO EN BASE DE DATOS | |
259 | -// listArticulos[indiceDelArtEncontrado].cantTomada | |
260 | -// val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | |
261 | -// ContinuarCargaCB(artEncontrado) | |
262 | -// } | |
263 | -// } | |
264 | -// return@setOnKeyListener true | |
265 | -// } | |
266 | - } | |
267 | - } | |
268 | - } | |
269 | - return@setOnKeyListener false | |
270 | - } | |
271 | - return v | |
272 | - } | |
273 | - | |
274 | - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
275 | - super.onViewCreated(view, savedInstanceState) | |
276 | - navController = Navigation.findNavController(view) | |
277 | - etCodigoBarras.requestFocus() | |
278 | -// val modalDialog = NoEncontradoSimple() | |
279 | -// modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | |
280 | - | |
281 | - btnBorrarInv.setOnClickListener { | |
282 | - AlertDialog.Builder(requireContext()).setTitle("Eliminaciรณn de Inventarios").setMessage("ยฟConfirma que desea eliminar el inventario?") | |
283 | - .setPositiveButton(R.string.btnOk, DialogInterface.OnClickListener { dialog, which -> | |
284 | - BorrarInvActual() | |
285 | - Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Borrado", Toast.LENGTH_LONG).show() | |
286 | - navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | |
287 | - InventarioNuevo = 0 | |
288 | - | |
289 | - }).setNegativeButton(R.string.btnCancelar, DialogInterface.OnClickListener { dialog, which -> | |
290 | - //botรณn cancel pulsado | |
291 | - }).show() | |
292 | - } | |
293 | - | |
294 | - btnExportarInv.setOnClickListener { | |
295 | - AlertDialog.Builder(requireContext()).setTitle(R.string.sTituloExportar).setMessage(R.string.sMensajeExportar) | |
296 | - .setPositiveButton(R.string.btnOk, DialogInterface.OnClickListener { dialog, which -> | |
297 | - BorrarInvActual() | |
298 | - Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Exportado al Servidor", Toast.LENGTH_LONG).show() | |
299 | - navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | |
300 | - InventarioNuevo = 0 | |
301 | - | |
302 | - }).setNegativeButton(R.string.btnCancelar, DialogInterface.OnClickListener { dialog, which -> | |
303 | - //botรณn cancel pulsado | |
304 | - }).show() | |
305 | - | |
306 | -// MaterialDialog(requireContext()).show { | |
307 | -// title(R.string.sTituloExportar) | |
308 | -// message(R.string.sMensajeExportar) | |
309 | -// positiveButton(R.string.btnOk) { | |
310 | -// BorrarInvActual() | |
311 | -// Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Exportado al Servidor", Toast.LENGTH_LONG).show() | |
312 | -// navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | |
313 | -// InventarioNuevo = 0 | |
314 | -// dismiss() | |
315 | -// } | |
316 | -// negativeButton { | |
317 | -// dismiss() | |
318 | -// } | |
319 | -// }.cancelOnTouchOutside(false).cornerRadius(10F) | |
320 | - } | |
321 | - ivCamara.setOnClickListener { | |
322 | - if (!bFirst) { | |
323 | - iEstado = 1 | |
324 | - bFirst = true | |
325 | - } | |
326 | - | |
327 | - when (iEstado) { | |
328 | - 0 -> { | |
329 | - ivCamara.setImageResource(R.drawable.codbar) | |
330 | - etCodigoBarras.hint = "Busqueda por C. Barras" | |
331 | - swSumaUno.visibility = View.VISIBLE | |
332 | - iBusquedaPor = 0 | |
333 | - iEstado = 1 | |
334 | - } | |
335 | - 1 -> { | |
336 | - ivCamara.setImageResource(R.drawable.desc) | |
337 | - etCodigoBarras.hint = "Busqueda por Descripciรณn" | |
338 | - swSumaUno.visibility = View.GONE | |
339 | - iBusquedaPor = 1 | |
340 | - iEstado = 2 | |
341 | - } | |
342 | - 2 -> { | |
343 | - ivCamara.setImageResource(R.drawable.cod_origen) | |
344 | - etCodigoBarras.hint = "Busqueda por C. Origen" | |
345 | - swSumaUno.visibility = View.GONE | |
346 | - iBusquedaPor = 2 | |
347 | - iEstado = 0 | |
348 | - } | |
349 | - } | |
350 | - } | |
351 | - } | |
352 | - | |
353 | - private fun BorrarInvActual() { | |
354 | - lifecycleScope.launch { | |
355 | - withContext(Dispatchers.IO) { | |
356 | - AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.deleteinvHead(InventarioNuevo) | |
357 | - AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.deleteInvBody(InventarioNuevo) | |
358 | - } | |
359 | - } | |
360 | - } | |
361 | - | |
362 | - private fun CargarDeBdInventario(ultimoInv: Int) { | |
363 | - GlobalScope.launch(Dispatchers.Main) { | |
364 | - val invbody = cargarInventario(ultimoInv) | |
365 | - for ((i, item) in invbody!!.withIndex()) { | |
366 | - val art = Articles(invbody[i].sector, | |
367 | - invbody[i].codigo, | |
368 | - invbody[i].descripcion, | |
369 | - invbody[i].codBar, | |
370 | - invbody[i].codOrigen, | |
371 | - invbody[i].precio, | |
372 | - invbody[i].costo, | |
373 | - "", | |
374 | - "", | |
375 | - "", | |
376 | - invbody[i].balanza, | |
377 | - invbody[i].depSn, | |
378 | - invbody[i].costo) | |
379 | - cargarRecicler(art, invbody[i].cantTomada!!.toFloat()) | |
380 | - } | |
381 | - } | |
382 | - | |
383 | - } | |
384 | - | |
385 | - @SuppressLint("RestrictedApi") | |
386 | - private fun ContinuarCargaDesc(artAcargar: ArrayList<Articles>) { | |
387 | - //TODO DESPUES DE INGRESAR LA DESCRIPCION Y DE BUSCAR LOS CAINCIDENCIAS EN LA BASE SE VA A MOSTRAR LAS MISMAS | |
388 | - //TODO SI LA CANTIDAD ENCONTRADA ES UNO, LO CARGO DIRECTAMENTE EN EL RV | |
389 | - | |
390 | - if (artAcargar.isNotEmpty() || !artAcargar.isNullOrEmpty()) {// TODO: Si lo encuentra en la BD | |
391 | -// if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV | |
392 | -// fCant = 0F | |
393 | -// fCant += 1F | |
394 | -// // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV | |
395 | -// val acargarPorDesc = Articles(artAcargar[0].sector, | |
396 | -// artAcargar[0].codigo, | |
397 | -// artAcargar[0].descripcion, | |
398 | -// artAcargar[0].codBar, | |
399 | -// artAcargar[0].codOrigen, | |
400 | -// artAcargar[0].precio, | |
401 | -// artAcargar[0].costo, | |
402 | -// "", | |
403 | -// "", | |
404 | -// "", | |
405 | -// artAcargar[0].balanza, | |
406 | -// artAcargar[0].depSn, | |
407 | -// "") | |
408 | -// // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD | |
409 | -// cargarArtEnBd(acargarPorDesc, fCant) | |
410 | -// cargarRecicler(acargarPorDesc, fCant) | |
411 | -// } else { | |
412 | - var bundle = Bundle() | |
413 | - bundle = bundleOf("ArrayDesc" to artAcargar) | |
414 | - bundle.putInt("numeroInv", InventarioNuevo) | |
415 | - navController.navigate(R.id.action_inventarioFragment_to_descripcionFragment, bundle) | |
416 | - //navController.backStack.removeLast() | |
417 | -// } | |
418 | -// } else {//SI NO ESTA +1 | |
419 | -// if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV | |
420 | -// fCant = listArticulos[0].cantTomada | |
421 | -// MaterialDialog(requireContext()).show { | |
422 | -// title(R.string.sTituloNueva) | |
423 | -// message(R.string.sCantidadNueva) | |
424 | -// input { materialDialog, charSequence -> | |
425 | -// fCant = 0F | |
426 | -// fCant = charSequence.toString().toFloat() | |
427 | -// } | |
428 | -// positiveButton(R.string.btnOk) { | |
429 | -// listArticulos[0].cantTomada = fCant | |
430 | -// viewAdapter.notifyDataSetChanged() | |
431 | -// dismiss() | |
432 | -// } | |
433 | -// }.cancelOnTouchOutside(false).cornerRadius(10F) | |
434 | -// // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV | |
435 | -// val acargarPorDesc = Articles(artAcargar[0].sector, | |
436 | -// artAcargar[0].codigo, | |
437 | -// artAcargar[0].descripcion, | |
438 | -// artAcargar[0].codBar, | |
439 | -// artAcargar[0].cod_origen, | |
440 | -// artAcargar[0].precio, | |
441 | -// artAcargar[0].costo, | |
442 | -// artAcargar[0].balanza, | |
443 | -// artAcargar[0].depSn, | |
444 | -// "") | |
445 | -// // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD | |
446 | -// cargarArtEnBd(acargarPorDesc, fCant) | |
447 | -// cargarRecicler(acargarPorDesc, fCant) | |
448 | -// } else { | |
449 | -// var bundle = Bundle() | |
450 | -// bundle = bundleOf("ArrayDesc" to artAcargar) | |
451 | -// bundle.putInt("numeroInv", InventarioNuevo) | |
452 | -// navController.navigate(R.id.action_inventarioFragment_to_descripcionFragment, bundle) | |
453 | -// } | |
454 | -// } | |
455 | - } else {//TODO si no lo encuentra en la BD | |
456 | - val modalDialog = DialogNoEncontrado() | |
457 | - modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | |
458 | - } | |
459 | - etCodigoBarras.focusable = View.FOCUSABLE | |
460 | - etCodigoBarras.setText("") | |
461 | - etCodigoBarras.selectAll() | |
462 | - } | |
463 | - | |
464 | - private fun ContinuarCargaCB(artAcargar: Articles?) { | |
465 | - | |
466 | - if (artAcargar != null) {// TODO: Si lo encuentra en la BD | |
467 | - if (swSumaUno!!.isChecked) {//TODO: SI ESTA +1, PONE CANTIDAD 1 | |
468 | - fCant = 0F | |
469 | - fCant += 1F | |
470 | - cargarArtEnBd(artAcargar, String.format("%.3f", fCant)) | |
471 | - cargarRecicler(artAcargar, fCant) | |
472 | - } else {//SI NO ESTA +1 PREGUNTA CANTIDAD | |
473 | - | |
474 | - DialogingresarCantidad(requireContext(), artAcargar) | |
475 | - } | |
476 | - } else {// TODO si no lo encuentra en la BD | |
477 | - val modalDialog = DialogNoEncontrado() | |
478 | - modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | |
479 | - } | |
480 | - etCodigoBarras.focusable = View.FOCUSABLE | |
481 | - etCodigoBarras.setText("") | |
482 | - etCodigoBarras.selectAll() | |
483 | - } | |
484 | - | |
485 | - fun DialogingresarCantidad(cnxt: Context, artAcargar: Articles?) { | |
486 | - val mDialogView = LayoutInflater.from(cnxt).inflate(R.layout.ingresar_cantidad, null) | |
487 | - val mBuilder = AlertDialog.Builder(cnxt).setView(mDialogView).setCancelable(false) | |
488 | - if (artAcargar!!.balanza!!.toInt() == 1 || artAcargar.balanza!!.toInt() == 3 || artAcargar.balanza!!.toInt() == 7) mDialogView.etCantidad.inputType = TYPE_CLASS_NUMBER | |
489 | - mDialogView.tvTitulo.text = artAcargar.descripcion.toString() | |
490 | - val mAlertDialog = mBuilder.show() | |
491 | - mDialogView.btnAceptar.setOnClickListener { | |
492 | - if (mDialogView.etCantidad.text.isNullOrEmpty()) { | |
493 | - mDialogView.etCantidad.error = "No vacio" | |
494 | - mDialogView.etCantidad.requestFocus() | |
495 | - mDialogView.etCantidad.hint = "Ingrese un valor" | |
496 | - } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { | |
497 | - mAlertDialog.dismiss() | |
498 | - cargarArtEnBd(artAcargar, String.format("%.2f", mDialogView.etCantidad.text.toString().toFloat())) | |
499 | - cargarRecicler(artAcargar, mDialogView.etCantidad.text.toString().toFloat()) | |
500 | - } | |
501 | - } | |
502 | - } | |
503 | - | |
504 | - fun dialogoSumaResta(context: Context, indiceDelArtEncontrado: Int, univta: String, cancelable: Boolean) { | |
505 | - val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
506 | - val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("${listArticulos[indiceDelArtEncontrado].descripcion} se encuentra cargado.").setCancelable(cancelable) | |
507 | - // TODO: SI PERMITE QUE INGRESE DECIMALES | |
508 | - if (univta.contains("1") || univta.contains("3") || univta.contains("7")) mDialogView.tvNuevaCantidad.inputType = TYPE_CLASS_NUMBER | |
509 | - | |
510 | - mDialogView.tvCantInicial.text = String.format("%.2f", listArticulos[indiceDelArtEncontrado].cantTomada) | |
511 | - val mAlertDialog = mBuilder.show() | |
512 | - mDialogView.rbSumar.setOnClickListener { | |
513 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
514 | - mDialogView.tvResultado.text = String.format("%.2f", mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()) | |
515 | - mDialogView.tvNuevaCantidad.isEnabled = false | |
516 | - } | |
517 | - } | |
518 | - mDialogView.rbRestar.setOnClickListener { | |
519 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
520 | - if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | |
521 | - mDialogView.tvResultado.text = String.format("%.2f", mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()) | |
522 | - mDialogView.tvNuevaCantidad.isEnabled = false | |
523 | - } else { | |
524 | - mDialogView.tvResultado.text = "" | |
525 | - mDialogView.tvResultado.error = "Operaciรณn No Valida" | |
526 | - mDialogView.tvResultado.requestFocus() | |
527 | - mDialogView.tvResultado.hint = "Error" | |
528 | - } | |
529 | - } | |
530 | - } | |
531 | - mDialogView.rbMdodificar.setOnClickListener { | |
532 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
533 | - mDialogView.tvResultado.text = String.format("%.2f", mDialogView.tvNuevaCantidad.text.toString().toFloat()) | |
534 | - mDialogView.tvNuevaCantidad.isEnabled = false | |
535 | - } | |
536 | - } | |
537 | - mDialogView.btnAceptar.setOnClickListener { | |
538 | - if (mDialogView.tvNuevaCantidad.text.isNotEmpty() || !mDialogView.tvNuevaCantidad.text.isBlank()) { | |
539 | - if (mDialogView.tvResultado.text.isNotEmpty() || !mDialogView.tvResultado.text.isBlank()) { | |
540 | - mAlertDialog.dismiss() | |
541 | - listArticulos[indiceDelArtEncontrado].cantTomada = String.format("%.2f", mDialogView.tvResultado.text.toString().toFloat()).toFloat() | |
542 | - updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), | |
543 | - String.format("%.2f", mDialogView.tvResultado.text.toString().toFloat()).toFloat()) | |
544 | - | |
545 | - viewAdapter.notifyDataSetChanged() | |
546 | - } else if (mDialogView.tvNuevaCantidad.text.isNotEmpty() || mDialogView.tvNuevaCantidad.text.isBlank()) { | |
547 | - mDialogView.tvResultado.error = "Operaciรณn Requerida" | |
548 | - mDialogView.tvResultado.requestFocus() | |
549 | - mDialogView.tvResultado.hint = "Seleccione Operaciรณn" | |
550 | - } | |
551 | - } else if (mDialogView.tvNuevaCantidad.text.isEmpty() || mDialogView.tvNuevaCantidad.text.isBlank()) { | |
552 | - mDialogView.tvNuevaCantidad.error = "Completar" | |
553 | - mDialogView.tvNuevaCantidad.requestFocus() | |
554 | - mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | |
555 | - } | |
556 | - } | |
557 | - mDialogView.dialogCancelBtn.setOnClickListener { | |
558 | - mAlertDialog.dismiss() | |
559 | - } | |
560 | - } | |
561 | - | |
562 | - suspend fun buscarCBEnBD(CodigoBarras: String): Articles? { | |
563 | - //TODO BUSQUEDA POR CODIGO DE BARRAS | |
564 | - var busqueda: Articles? = null | |
565 | - return GlobalScope.async(Dispatchers.IO) { | |
566 | - busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(CodigoBarras, SerchArea()) | |
567 | - return@async busqueda | |
568 | - }.await() | |
569 | - } | |
570 | - | |
571 | - suspend fun buscarDescEnBD(descripcion: String): List<Articles>? { | |
572 | - //TODO BUSQUEDA POR DESCRIPCION | |
573 | - var busqueda: List<Articles>? = null | |
574 | - return GlobalScope.async(Dispatchers.IO) { | |
575 | - busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByDesc(descripcion, SerchArea()) | |
576 | - return@async busqueda | |
577 | - }.await() | |
578 | - } | |
579 | - | |
580 | - suspend fun borrarArticulo(sector: String, codigo: String, inventario: String): Int? { | |
581 | - //TODO BUSQUEDA POR DESCRIPCION | |
582 | - var result: Int | |
583 | - return GlobalScope.async(Dispatchers.IO) { | |
584 | - result = AppDb.getAppDb(requireContext())!!.InvBodyDAO()!!.deleteItemFromInvBody(sector, codigo, inventario) | |
585 | - return@async result | |
586 | - }.await() | |
587 | - } | |
588 | - | |
589 | - private suspend fun buscoArtEnRv(codigoBarras: String, sTipoBusqueda: Int): Int { | |
590 | - | |
591 | - return GlobalScope.async(Dispatchers.IO) { | |
592 | - var indice = 0 | |
593 | - var bEncontrado = false | |
594 | - if (sTipoBusqueda == 0) {//TODO BUSQUEDA POR CODIGO DE BARRAS | |
595 | - // TODO CAMBIO DE CB A CODIGO DEBO | |
596 | - val any = cambioCBporCodigoDebo(codigoBarras) | |
597 | - if (any != null) { | |
598 | - for (item in listArticulos) { | |
599 | - if (item.sector!!.toInt() == any.sector!!.toInt() && item.codigo!!.toInt() == any.codigo!!.toInt()) { | |
600 | - bEncontrado = true | |
601 | - break | |
602 | - } | |
603 | - indice += 1 | |
604 | - } | |
605 | - } | |
606 | - | |
607 | - } else if (sTipoBusqueda == 1) {//TODO BUSQUEDA POR DESCRIPCION | |
608 | - for (item in listArticulos) { | |
609 | - if (item.descripcion!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { | |
610 | - bEncontrado = true | |
611 | - break | |
612 | - } | |
613 | - indice += 1 | |
614 | - } | |
615 | - } else if (sTipoBusqueda == 2) {//TODO BUSQUEDA POR CODIGO DE ORIGEN | |
616 | - for (item in listArticulos) { | |
617 | - if (item.codigoOrigen!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { | |
618 | - bEncontrado = true | |
619 | - break | |
620 | - } | |
621 | - indice += 1 | |
622 | - } | |
623 | - } | |
624 | - return@async if (bEncontrado) indice else -1 | |
625 | - }.await() | |
626 | - } | |
627 | - | |
628 | - suspend fun cambioCBporCodigoDebo(codigoBarras: String): Articles? { | |
629 | - //TODO BUSQUEDA POR DESCRIPCION | |
630 | - var busqueda: Articles? = null | |
631 | - return GlobalScope.async(Dispatchers.IO) { | |
632 | - busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(codigoBarras, SerchArea()) | |
633 | - return@async busqueda | |
634 | - }.await() | |
635 | - } | |
636 | - | |
637 | - private fun cargarArtEnBd(articulos: Articles, cant: String) { | |
638 | - val body = InvBody(InventarioNuevo,// TODO PREPARO PARA MANDAR A CARGAR EN LA BD | |
639 | - articulos.sector, | |
640 | - articulos.codigo, | |
641 | - articulos.descripcion, | |
642 | - cant, | |
643 | - articulos.codBar, | |
644 | - articulos.codOrigen, | |
645 | - articulos.precio, | |
646 | - articulos.precio, | |
647 | - articulos.balanza, | |
648 | - articulos.depSn, | |
649 | - ObtenerFechaActual(), | |
650 | - ObtenerFechaActual()) | |
651 | - InsertarArtEnDB(body)// TODO MANDO A CARGAR A LA BASE DE DATOS | |
652 | - } | |
653 | - | |
654 | - fun cargarRecicler(articulos: Articles, cant: Float) { | |
655 | - //TODO CARGO EN LE RV | |
656 | - val item = ItemsRecycler(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar, articulos.codOrigen, articulos.balanza.toString(), articulos.de.toString()) | |
657 | - listArticulos.add(item) | |
658 | - | |
659 | - viewAdapter = ProductosListAdapter(requireContext(), listArticulos, this) | |
660 | - viewManager = LinearLayoutManager(requireContext()) | |
661 | - deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! | |
662 | - rcInventarios.apply { | |
663 | - adapter = viewAdapter | |
664 | - layoutManager = viewManager | |
665 | - } | |
666 | - val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { | |
667 | - override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | |
668 | - return false | |
669 | - } | |
670 | - | |
671 | - override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { | |
672 | - | |
673 | - GlobalScope.launch(Dispatchers.Main) { | |
674 | - borrarArticulo(listArticulos[viewHolder.adapterPosition].sector.toString(), listArticulos[viewHolder.adapterPosition].codigo.toString(), InventarioNuevo.toString()) | |
675 | - (viewAdapter as ProductosListAdapter).removeItem(viewHolder) | |
676 | - viewAdapter.notifyDataSetChanged() | |
677 | - } | |
678 | - } | |
679 | - | |
680 | - override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | |
681 | - val itemView = viewHolder.itemView | |
682 | - val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 | |
683 | - c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | |
684 | - | |
685 | - if (dX > 0) { | |
686 | - | |
687 | - if (dX < c.width / 2) c.drawColor(Color.GREEN) | |
688 | - else c.drawColor(Color.RED) | |
689 | - deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) | |
690 | - } else { | |
691 | - } | |
692 | - | |
693 | - super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
694 | - deleteIcon.draw(c) | |
695 | - } | |
696 | - } | |
697 | - | |
698 | - val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) | |
699 | - itemTouchHelper.attachToRecyclerView(rcInventarios) | |
700 | - } | |
701 | - | |
702 | - private fun ProdNoCont(): Int? { | |
703 | - var mostrarStock = 0 | |
704 | - if (sharedPreferences.contains("cbMostrarStock")) if (sharedPreferences.getString("cbMostrarStock", "").toString() == "1") mostrarStock = 1 | |
705 | - return mostrarStock | |
706 | - } | |
707 | - | |
708 | - private fun AjusteProductos(): Int? { | |
709 | - var prodInclu = 0 | |
710 | - if (sharedPreferences.contains("rbProInclu")) if (sharedPreferences.getString("rbProInclu", "").toString() == "1") prodInclu = 1 | |
711 | - | |
712 | - if (sharedPreferences.contains("rbProNoInclu")) if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") prodInclu = 0 | |
713 | - return prodInclu | |
714 | - } | |
715 | - | |
716 | - private fun SerchArea(): Int { | |
717 | - if (sharedPreferences.contains("rbVentas")) if (sharedPreferences.getString("rbVentas", "").toString() == "1") iArea = 0 | |
718 | - if (sharedPreferences.contains("rbDeposito")) if (sharedPreferences.getString("rbDeposito", "").toString() == "1") iArea = 1 | |
719 | - return iArea | |
720 | - } | |
721 | - | |
722 | - fun ObtenerFechaActual(): String? { | |
723 | - //TODO OBTENGO FECHA Y HORA ACTUAL PARA LA CABECERA DEL INVENTARIO Y PARA CADA ITEM QUE SE INSERTA EN LA BD | |
724 | - val current = LocalDateTime.now() | |
725 | - val formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy hh:mm:ss") | |
726 | - val dFechaHora = current.format(formatter) | |
727 | - return dFechaHora.toString() | |
728 | - } | |
729 | - | |
730 | - fun InsertarArtEnDB(cuarpoInventario: InvBody) { | |
731 | - lifecycleScope.launch { | |
732 | - withContext(Dispatchers.IO) { | |
733 | - AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) | |
734 | - } | |
735 | - } | |
736 | - } | |
737 | - | |
738 | - fun updateCantidad(sector: String, codigo: String, cantidad: Float) { | |
739 | - lifecycleScope.launch { | |
740 | - withContext(Dispatchers.IO) { | |
741 | - AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.UpdateInvBody(cantidad, sector, codigo) | |
742 | - } | |
743 | - } | |
744 | - } | |
745 | - | |
746 | - suspend fun cargarInventario(inventario: Int): List<InvBody>? { | |
747 | - return GlobalScope.async(Dispatchers.IO) { | |
748 | - return@async AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.fetchAllInvBody(inventario) | |
749 | - }.await() | |
750 | - } | |
751 | - | |
752 | - override fun onImageDotsClick(sector: String?, codigo: String?) { | |
753 | - val bundle = Bundle() | |
754 | - bundle.putString("sector", sector) | |
755 | - bundle.putString("codigo", codigo) | |
756 | - bundle.putInt("numeroInv", InventarioNuevo) | |
757 | - navController.navigate(R.id.action_inventarioFragment_to_detalleArtFragment, bundle) | |
758 | - } | |
759 | - | |
760 | - override fun onImagePenClick(sector: String?, codigo: String?, cantidad: String?, position: String) { | |
761 | - dialogoSumaResta(requireContext(), position.toInt(), listArticulos[position.toInt()].univta, true) | |
762 | - | |
763 | -// val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
764 | -// val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("${listArticulos[position.toInt()].descripcion}") | |
765 | -//// .setCancelable(false) | |
766 | -// mDialogView.tvCantInicial.text = cantidad | |
767 | -// val mAlertDialog = mBuilder.show() | |
768 | -// mDialogView.rbSumar.setOnClickListener { | |
769 | -// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
770 | -// mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
771 | -// mDialogView.tvNuevaCantidad.isEnabled=false | |
772 | -// } | |
773 | -// } | |
774 | -// mDialogView.rbRestar.setOnClickListener { | |
775 | -// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
776 | -// if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | |
777 | -// mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
778 | -// mDialogView.tvNuevaCantidad.isEnabled=false | |
779 | -// } | |
780 | -// } | |
781 | -// } | |
782 | -// mDialogView.rbMdodificar.setOnClickListener { | |
783 | -// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
784 | -// mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
785 | -// mDialogView.tvNuevaCantidad.isEnabled=false | |
786 | -// } | |
787 | -// } | |
788 | -// mDialogView.btnAceptar.setOnClickListener { | |
789 | -// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
790 | -// mAlertDialog.dismiss() | |
791 | -// val name = mDialogView.tvgenerico4.text.toString().toFloat() | |
792 | -// fCant = 0F | |
793 | -// fCant = name | |
794 | -// listArticulos[position.toInt()].cantTomada = fCant | |
795 | -// updateCantidad(listArticulos[position.toInt()].sector.toString(), listArticulos[position.toInt()].codigo.toString(), fCant) | |
796 | -// viewAdapter.notifyDataSetChanged() | |
797 | -// } else if (mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
798 | -// mDialogView.tvNuevaCantidad.error = "No vacio" | |
799 | -// mDialogView.tvNuevaCantidad.requestFocus() | |
800 | -// mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | |
801 | -// } | |
802 | -// } | |
803 | -// mDialogView.dialogCancelBtn.setOnClickListener { | |
804 | -// mAlertDialog.dismiss() | |
805 | -// } | |
806 | - } | |
807 | -} | |
808 | - | |
809 | - | |
810 | - | |
811 | - | |
812 | - | |
813 | - | |
814 | - | |
815 | - | |
816 | - | |
817 | - | |
818 | - | |
819 | - |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/ItemsRecycler.kt
... | ... | @@ -1,7 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.inventario | |
2 | - | |
3 | -import android.widget.ImageView | |
4 | - | |
5 | -data class ItemsRecycler(val sector: String?,val codigo: String?, val descripcion: String?, var cantTomada: Float, val codigoBarras: String?, val codigoOrigen: String?,val univta: String,val dev:String) { | |
6 | - | |
7 | -} | |
8 | 0 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/ProductosListAdapter.kt
... | ... | @@ -1,61 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.inventario | |
2 | - | |
3 | -import android.content.Context | |
4 | -import android.view.LayoutInflater | |
5 | -import android.view.View | |
6 | -import android.view.ViewGroup | |
7 | -import androidx.recyclerview.widget.RecyclerView | |
8 | -import com.focasoftware.deboinventariov20.R | |
9 | -import com.focasoftware.deboinventariov20.ui.main.ItemInventario | |
10 | -import com.focasoftware.deboinventariov20.ui.util.Base.BaseViewHolder | |
11 | -import com.google.android.material.snackbar.Snackbar | |
12 | -import kotlinx.android.synthetic.main.item.view.* | |
13 | - | |
14 | - | |
15 | -class ProductosListAdapter(private val context: Context,private val productos: ArrayList<ItemsRecycler>, private val itemImageClickListener: OnImageDotsClickListener) : | |
16 | - RecyclerView.Adapter<BaseViewHolder<*>>() { | |
17 | - | |
18 | - private var removePosition: Int = 0 | |
19 | - private var removedItem: ItemsRecycler? = null | |
20 | - | |
21 | - interface OnImageDotsClickListener { | |
22 | - fun onImageDotsClick(sector: String?,codigo: String?) | |
23 | - fun onImagePenClick(sector: String?, codigo: String?, cantidad: String?, position: String) | |
24 | - } | |
25 | - | |
26 | - override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder(LayoutInflater.from(context).inflate(R.layout.item, parent, false)) | |
27 | - | |
28 | - override fun getItemCount() = productos.size | |
29 | - | |
30 | - override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) { | |
31 | - when (holder) { | |
32 | - is ItemsViewHolder -> { holder.bind(productos[position], position) } | |
33 | - | |
34 | - } | |
35 | - } | |
36 | - inner class ItemsViewHolder (itemView: View) : BaseViewHolder<ItemsRecycler>(itemView) { | |
37 | - override fun bind(item: ItemsRecycler, position: Int) { | |
38 | - itemView.ivDots.setOnClickListener {itemImageClickListener.onImageDotsClick(item.sector,item.codigo) } | |
39 | - itemView.ivPen.setOnClickListener {itemImageClickListener.onImagePenClick(item.sector,item.codigo,item.cantTomada.toString(),adapterPosition.toString()) } | |
40 | - | |
41 | - itemView.tvSector.text=item.sector | |
42 | - itemView.tvCodigo.text=item.codigo | |
43 | - itemView.tvDescripcion.text=item.descripcion | |
44 | - itemView.tvCantidad.text=item.cantTomada.toString() | |
45 | - itemView.tvCodigoBarras.text=item.sector | |
46 | - itemView.tvCodigoOrigen.text=item.sector | |
47 | - itemView.ivPen.setImageResource(R.drawable.pen) | |
48 | - itemView.ivDots.setImageResource(R.drawable.more) | |
49 | - } | |
50 | - } | |
51 | - | |
52 | - fun removeItem(viewHolder: RecyclerView.ViewHolder) { | |
53 | - removePosition = viewHolder.adapterPosition | |
54 | - removedItem = productos[viewHolder.adapterPosition] | |
55 | - | |
56 | - productos.removeAt(viewHolder.adapterPosition) | |
57 | - notifyItemRemoved(viewHolder.adapterPosition) | |
58 | - } | |
59 | - | |
60 | - | |
61 | -} | |
62 | 0 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/InventarioListAdapter.kt
... | ... | @@ -1,47 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.main | |
2 | - | |
3 | -import android.content.Context | |
4 | -import android.view.LayoutInflater | |
5 | -import android.view.View | |
6 | -import android.view.ViewGroup | |
7 | -import androidx.recyclerview.widget.RecyclerView | |
8 | -import com.focasoftware.deboinventariov20.Model.InvHead | |
9 | -import com.focasoftware.deboinventariov20.R | |
10 | -import com.focasoftware.deboinventariov20.ui.util.Base.BaseViewHolder | |
11 | -import kotlinx.android.synthetic.main.item_principal.view.* | |
12 | - | |
13 | -class InventarioListAdapter(private val context: Context, private val inv: List<InvHead>, private val itemClickListener: OnInventarioClickListener) : | |
14 | - RecyclerView.Adapter<BaseViewHolder<*>>() { | |
15 | - | |
16 | - interface OnInventarioClickListener { | |
17 | - fun onItemClick(inventario: String?) | |
18 | - } | |
19 | - | |
20 | - override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder(LayoutInflater.from(context).inflate(R.layout.item_principal, parent, false)) | |
21 | - | |
22 | - override fun getItemCount() = inv.size | |
23 | - | |
24 | - | |
25 | - inner class ItemsViewHolder(itemView: View) : BaseViewHolder<InvHead>(itemView) { | |
26 | - override fun bind(item: InvHead, position: Int) { | |
27 | - itemView.setOnClickListener {itemClickListener.onItemClick(item.invNum.toString())} | |
28 | - itemView.tvPrincipalinventario.text = if ( item.invNum < 10) "0${ item.invNum.toString()}" else item.invNum.toString() | |
29 | - | |
30 | - itemView.tvDescription.text=item.descripcion.toString() | |
31 | - itemView.tvFecha.text=item.fechaInicio.toString() | |
32 | - itemView.tvCantContada.text=item.prodContados.toString() | |
33 | - } | |
34 | - } | |
35 | - | |
36 | - override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) { | |
37 | - when (holder) { | |
38 | - is ItemsViewHolder -> holder.bind(inv[position], position) | |
39 | - else -> IllegalArgumentException("No se pudo pasar el ViewHolder") | |
40 | - } | |
41 | - } | |
42 | - | |
43 | - | |
44 | -} | |
45 | - | |
46 | - | |
47 | - |
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/ItemPrincipal.kt
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/MainFragment.kt
... | ... | @@ -1,172 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.main | |
2 | - | |
3 | -import android.content.Context | |
4 | -import android.content.SharedPreferences | |
5 | -import android.os.Bundle | |
6 | -import android.view.LayoutInflater | |
7 | -import android.view.View | |
8 | -import android.view.ViewGroup | |
9 | -import android.widget.* | |
10 | -import androidx.fragment.app.Fragment | |
11 | -import androidx.navigation.NavController | |
12 | -import androidx.navigation.Navigation | |
13 | -import androidx.recyclerview.widget.LinearLayoutManager | |
14 | -import androidx.recyclerview.widget.RecyclerView | |
15 | -import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
16 | -import com.focasoftware.deboinventariov20.Model.InvHead | |
17 | -import com.focasoftware.deboinventariov20.R | |
18 | -import com.focasoftware.deboinventariov20.ui.inventario.ItemsRecycler | |
19 | -import kotlinx.coroutines.Dispatchers | |
20 | -import kotlinx.coroutines.GlobalScope | |
21 | -import kotlinx.coroutines.async | |
22 | -import kotlinx.coroutines.launch | |
23 | -import java.util.* | |
24 | - | |
25 | -class MainFragment : Fragment(), InventarioListAdapter.OnInventarioClickListener { | |
26 | - private lateinit var inventarios: List<InvHead> | |
27 | - private lateinit var ordenado: List<InvHead> | |
28 | - private lateinit var rcInventario: RecyclerView | |
29 | - private lateinit var viewAdapter: RecyclerView.Adapter<*> | |
30 | - private lateinit var viewManager: RecyclerView.LayoutManager | |
31 | -// private var listIvn2 = List<InvHead>() | |
32 | -private var listIvn2 = ArrayList<InvHead>() | |
33 | - private lateinit var navController: NavController | |
34 | - private lateinit var sharedPreferences: SharedPreferences | |
35 | - private var cantidadInventarios: Int = 0 | |
36 | - | |
37 | - override fun onCreate(savedInstanceState: Bundle?) { | |
38 | - super.onCreate(savedInstanceState) | |
39 | - sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
40 | - } | |
41 | - | |
42 | - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
43 | - var bAbiertoCerrado = false | |
44 | - val v = inflater.inflate(R.layout.fragment_main, container, false) | |
45 | - val tvInvDinamicos = v.findViewById<TextView>(R.id.tvInvDinamicos) | |
46 | - val txtDeposito = v.findViewById<TextView>(R.id.txtDeposito) | |
47 | - val ivSort19= v.findViewById<ImageButton>(R.id.ivSort19) | |
48 | - val ivSort91= v.findViewById<ImageButton>(R.id.ivSort91) | |
49 | - val cbVentas= v.findViewById<CheckBox>(R.id.cbVentas) | |
50 | - val cbDeposito= v.findViewById<CheckBox>(R.id.cbDeposito) | |
51 | - val tvTipo = v.findViewById<TextView>(R.id.tvTipo) | |
52 | - rcInventario = v.findViewById(R.id.rcInventario) | |
53 | - | |
54 | - GlobalScope.launch(Dispatchers.Main) { | |
55 | - inventarios = buscarEnBDInvHead() | |
56 | - for ((i, item) in inventarios.withIndex()) { | |
57 | - val inv = InvHead(inventarios[i].invNum, | |
58 | - inventarios[i].descripcion, | |
59 | - inventarios[i].estado, | |
60 | - inventarios[i].fechaInicio, | |
61 | - inventarios[i].fechaFinal, | |
62 | - inventarios[i].prodContados, | |
63 | - inventarios[i].lugar, | |
64 | - inventarios[i].stDesc, | |
65 | - inventarios[i].proNoCont) | |
66 | - cargarRecicler(inv) | |
67 | - cantidadInventarios = i + 1 | |
68 | - } | |
69 | - tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) +" | |
70 | - tvInvDinamicos.setOnClickListener { | |
71 | - if (!bAbiertoCerrado) { | |
72 | - bAbiertoCerrado = true | |
73 | - txtDeposito.visibility = View.GONE | |
74 | - rcInventario.visibility = View.VISIBLE | |
75 | - ivSort91.visibility = View.INVISIBLE | |
76 | - ivSort19.visibility = View.VISIBLE | |
77 | - cbVentas.visibility = View.VISIBLE | |
78 | - cbDeposito.visibility = View.VISIBLE | |
79 | - tvTipo.visibility = View.VISIBLE | |
80 | - tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) -" | |
81 | - } else { | |
82 | - bAbiertoCerrado = false | |
83 | - rcInventario.visibility = View.GONE | |
84 | - ivSort91.visibility = View.GONE | |
85 | - ivSort19.visibility = View.GONE | |
86 | - txtDeposito.visibility = View.VISIBLE | |
87 | - cbVentas.visibility = View.GONE | |
88 | - cbDeposito.visibility = View.GONE | |
89 | - tvTipo.visibility = View.GONE | |
90 | - tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) +" | |
91 | - } | |
92 | - } | |
93 | - ivSort19.setOnClickListener { | |
94 | - ordenado= inventarios.sortedByDescending { | |
95 | - it.invNum | |
96 | - } | |
97 | - viewAdapter = InventarioListAdapter(requireContext(), ordenado, this@MainFragment) | |
98 | - viewManager = LinearLayoutManager(requireContext()) | |
99 | - | |
100 | - rcInventario.apply { | |
101 | - adapter = viewAdapter | |
102 | - layoutManager = viewManager | |
103 | - } | |
104 | - viewAdapter.notifyDataSetChanged() | |
105 | - ivSort19.visibility=View.INVISIBLE | |
106 | - ivSort91.visibility=View.VISIBLE | |
107 | - } | |
108 | - ivSort91.setOnClickListener { | |
109 | - ordenado= inventarios.sortedBy { | |
110 | - it.invNum | |
111 | - } | |
112 | - viewAdapter = InventarioListAdapter(requireContext(), ordenado, this@MainFragment) | |
113 | - viewManager = LinearLayoutManager(requireContext()) | |
114 | - | |
115 | - rcInventario.apply { | |
116 | - adapter = viewAdapter | |
117 | - layoutManager = viewManager | |
118 | - } | |
119 | - viewAdapter.notifyDataSetChanged() | |
120 | - ivSort91.visibility=View.INVISIBLE | |
121 | - ivSort19.visibility=View.VISIBLE | |
122 | - } | |
123 | - } | |
124 | - return v | |
125 | - } | |
126 | - | |
127 | - suspend fun buscarEnBDInvHead(): List<InvHead> { | |
128 | - //TODO BUSQUEDA POR DESCRIPCION | |
129 | - var busqueda: List<InvHead> | |
130 | - return GlobalScope.async(Dispatchers.IO) { | |
131 | - busqueda = AppDb.getAppDb(requireContext())!!.InvHeadDAO()!!.fetchAllInvHead() | |
132 | - return@async busqueda | |
133 | - }.await() | |
134 | - } | |
135 | - | |
136 | - fun cargarRecicler(inv: InvHead) { | |
137 | - //TODO CARGO EN LE RV | |
138 | - | |
139 | -// val number = if (inv.invNum.toLong() < 10) "0${inv.invNum.toLong()}" else inv.invNum.toString() | |
140 | -// val item = ItemInventario("Nยฐ $number ${inv.descripcion}. Fecha: ${inv.fechaFinal}") | |
141 | - | |
142 | -// listIvn.add(item) | |
143 | - listIvn2.add(inv) | |
144 | - viewAdapter = InventarioListAdapter(requireContext(), listIvn2, this) | |
145 | - viewManager = LinearLayoutManager(requireContext()) | |
146 | - | |
147 | - rcInventario.apply { | |
148 | - adapter = viewAdapter | |
149 | - layoutManager = viewManager | |
150 | - } | |
151 | - } | |
152 | - | |
153 | - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
154 | - super.onViewCreated(view, savedInstanceState) | |
155 | - navController = Navigation.findNavController(view) | |
156 | - listIvn2.clear() | |
157 | - } | |
158 | - | |
159 | - override fun onItemClick(inventario: String?) { | |
160 | - | |
161 | - val editor = sharedPreferences.edit() | |
162 | -// var invSel: String = inventario.toString() | |
163 | -// invSel = invSel.substring(3, 5) | |
164 | - editor?.putString("Inventario", inventario) | |
165 | - editor?.apply() | |
166 | - editor.commit() | |
167 | - navController.navigate(R.id.action_mainFragment2_to_inventarioFragment) | |
168 | - } | |
169 | - | |
170 | - | |
171 | -} | |
172 | - |
app/src/main/java/com/focasoftware/deboinventariov20/ui/servidores/AdapterServidores.kt
... | ... | @@ -1,46 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.servidores | |
2 | - | |
3 | -import android.content.Context | |
4 | -import android.view.LayoutInflater | |
5 | -import android.view.View | |
6 | -import android.view.ViewGroup | |
7 | -import androidx.recyclerview.widget.RecyclerView | |
8 | -import com.focasoftware.deboinventariov20.R | |
9 | -import com.focasoftware.deboinventariov20.ui.inventario.ItemsRecycler | |
10 | -import com.google.android.material.snackbar.Snackbar | |
11 | -import kotlinx.android.synthetic.main.item_servidores.view.* | |
12 | - | |
13 | -class AdapterServidores(private val servidor: ArrayList<ItemsServidores>, private var contexto: Context) : | |
14 | - RecyclerView.Adapter<AdapterServidores.ViewHolder>() { | |
15 | - private var removePosition: Int = 0 | |
16 | - private var removedItem: ItemsServidores? = null | |
17 | - | |
18 | - class ViewHolder(var vista: View) : RecyclerView.ViewHolder(vista) { | |
19 | - fun bind(itemsServidores: ItemsServidores) { | |
20 | - vista.tvDescServidor.text = itemsServidores.descripcion | |
21 | - vista.tvDireccionServidor.text = itemsServidores.direccion | |
22 | - | |
23 | - } | |
24 | - } | |
25 | - | |
26 | - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | |
27 | - return ViewHolder( | |
28 | - LayoutInflater.from(parent.context).inflate(R.layout.item_servidores, parent, false) | |
29 | - ) | |
30 | - } | |
31 | - | |
32 | - override fun getItemCount(): Int { | |
33 | - return servidor.size | |
34 | - } | |
35 | - | |
36 | - override fun onBindViewHolder(holder: ViewHolder, position: Int) { | |
37 | - holder.bind(servidor[position]) | |
38 | - } | |
39 | - fun removeItem(viewHolder: RecyclerView.ViewHolder) { | |
40 | - removePosition = viewHolder.adapterPosition | |
41 | - removedItem = servidor[viewHolder.adapterPosition] | |
42 | - | |
43 | - servidor.removeAt(viewHolder.adapterPosition) | |
44 | - notifyItemRemoved(viewHolder.adapterPosition) | |
45 | - } | |
46 | -} | |
47 | 0 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/servidores/ItemsServidores.kt
app/src/main/java/com/focasoftware/deboinventariov20/ui/servidores/ServidoresFragment.kt
... | ... | @@ -1,151 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.servidores | |
2 | - | |
3 | -import android.graphics.Canvas | |
4 | -import android.graphics.Color | |
5 | -import android.graphics.drawable.Drawable | |
6 | -import android.os.Bundle | |
7 | -import android.view.LayoutInflater | |
8 | -import android.view.View | |
9 | -import android.view.ViewGroup | |
10 | -import android.widget.Toast | |
11 | -import androidx.core.content.ContextCompat | |
12 | -import androidx.fragment.app.Fragment | |
13 | -import androidx.lifecycle.lifecycleScope | |
14 | -import androidx.recyclerview.widget.ItemTouchHelper | |
15 | -import androidx.recyclerview.widget.LinearLayoutManager | |
16 | -import androidx.recyclerview.widget.RecyclerView | |
17 | -import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
18 | -import com.focasoftware.deboinventariov20.Model.ServeInv | |
19 | -import com.focasoftware.deboinventariov20.R | |
20 | -import kotlinx.android.synthetic.main.fragment_servidores.* | |
21 | -import kotlinx.coroutines.* | |
22 | - | |
23 | -class ServidoresFragment : Fragment() { | |
24 | - | |
25 | - private lateinit var rvServidores: RecyclerView | |
26 | - private lateinit var viewAdapter: RecyclerView.Adapter<*> | |
27 | - private lateinit var viewManager: RecyclerView.LayoutManager | |
28 | - private var listServ = ArrayList<ItemsServidores>() | |
29 | - private lateinit var servidores: List<ServeInv> | |
30 | - private lateinit var deleteIcon: Drawable | |
31 | - | |
32 | - override fun onCreate(savedInstanceState: Bundle?) { | |
33 | - super.onCreate(savedInstanceState) | |
34 | - CargarRV() | |
35 | - } | |
36 | - | |
37 | - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
38 | - super.onViewCreated(view, savedInstanceState) | |
39 | - | |
40 | - btnGuardarServidores.setOnClickListener { | |
41 | - if (etNombreServidor.text.isNullOrBlank()) { | |
42 | - etNombreServidor.error = "Nombre no valido" | |
43 | - etNombreServidor.requestFocus() | |
44 | - etNombreServidor.hint = "Nombre no valido" | |
45 | - } | |
46 | - if (etDireccionServidor.text.isNullOrBlank()) { | |
47 | - etDireccionServidor.error = "Direcciรณn no valida" | |
48 | - etDireccionServidor.requestFocus() | |
49 | - etDireccionServidor.hint = "Direcciรณn no valida" | |
50 | - } | |
51 | - if (!etDireccionServidor.text.isNullOrBlank() || !etNombreServidor.text.isNullOrBlank()) { | |
52 | -// GlobalScope.launch(Dispatchers.Main) { | |
53 | -// ServerNew =AppDb.getAppDb(requireContext())?.ServeInvDao()?.findLastServer()?.plus(1) ?: 1 | |
54 | - val servidor = ServeInv(etNombreServidor.text.toString(), "http://${etDireccionServidor.text}/", 0) | |
55 | - ingresarDatos(servidor) | |
56 | - cargarRecicler(servidor) | |
57 | - Toast.makeText(requireContext(), "Servidor ${etNombreServidor.text} Guardado", Toast.LENGTH_LONG).show() | |
58 | - etNombreServidor.text.clear() | |
59 | - etDireccionServidor.text.clear() | |
60 | -// } | |
61 | - } | |
62 | - } | |
63 | - } | |
64 | - | |
65 | - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
66 | - val v = inflater.inflate(R.layout.fragment_servidores, container, false) | |
67 | - rvServidores = v.findViewById(R.id.rvServidores) | |
68 | - return v | |
69 | - } | |
70 | - | |
71 | - fun ingresarDatos(servidor: ServeInv) { | |
72 | - val Job = GlobalScope.launch { | |
73 | - AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.insertServer(servidor) | |
74 | - } | |
75 | - } | |
76 | - | |
77 | - suspend fun buscarEnBD(): List<ServeInv> { | |
78 | - var busqueda: List<ServeInv> | |
79 | - return GlobalScope.async(Dispatchers.IO) { | |
80 | - busqueda = AppDb.getAppDb(requireContext())!!.ServeInvDao()!!.fetchAllServers() | |
81 | - return@async busqueda | |
82 | - }.await() | |
83 | - } | |
84 | - | |
85 | - fun CargarRV() { | |
86 | - GlobalScope.launch(Dispatchers.Main) { | |
87 | - servidores = buscarEnBD() | |
88 | - for ((i, item) in servidores.withIndex()) { | |
89 | - val ser = ServeInv(servidores[i].descripcion, servidores[i].direccion, servidores[i].predeterminado) | |
90 | - cargarRecicler(ser) | |
91 | - } | |
92 | - } | |
93 | - } | |
94 | - | |
95 | - fun cargarRecicler(ser: ServeInv) { | |
96 | - //TODO CARGO EN LE RV | |
97 | - deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! | |
98 | - val item = ItemsServidores(ser.descripcion, ser.direccion, ser.predeterminado.toString()) | |
99 | - | |
100 | - listServ.add(item) | |
101 | - | |
102 | - viewAdapter = AdapterServidores(listServ, requireContext()) | |
103 | - viewManager = LinearLayoutManager(requireContext()) | |
104 | - | |
105 | - rvServidores.apply { | |
106 | - adapter = viewAdapter | |
107 | - layoutManager = viewManager | |
108 | - } | |
109 | - val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { | |
110 | - override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | |
111 | - return false | |
112 | - } | |
113 | - | |
114 | - override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { | |
115 | - GlobalScope.launch(Dispatchers.Main) { | |
116 | - deleteServer(listServ[viewHolder.adapterPosition].descripcion.toString(), listServ[viewHolder.adapterPosition].direccion.toString()) | |
117 | - | |
118 | - (viewAdapter as AdapterServidores).removeItem(viewHolder) | |
119 | - viewAdapter.notifyDataSetChanged() | |
120 | - } | |
121 | - } | |
122 | - | |
123 | - override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | |
124 | - val itemView = viewHolder.itemView | |
125 | - val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 | |
126 | - c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | |
127 | - | |
128 | - if (dX > 0) { | |
129 | - | |
130 | - if (dX < c.width / 2) c.drawColor(Color.GREEN) | |
131 | - else c.drawColor(Color.RED) | |
132 | - deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) | |
133 | - } else { | |
134 | - } | |
135 | - super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
136 | - deleteIcon.draw(c) | |
137 | - } | |
138 | - } | |
139 | - | |
140 | - val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) | |
141 | - itemTouchHelper.attachToRecyclerView(rvServidores) | |
142 | - } | |
143 | - | |
144 | - suspend fun deleteServer(serverName: String, serverDir: String) { | |
145 | - lifecycleScope.launch { | |
146 | - withContext(Dispatchers.IO) { | |
147 | - AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.deleteServer(serverName, serverDir) | |
148 | - } | |
149 | - } | |
150 | - } | |
151 | -} |
app/src/main/java/com/focasoftware/deboinventariov20/ui/servidores/SpinnerAdapter.kt
... | ... | @@ -1,40 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.servidores | |
2 | - | |
3 | -import android.content.Context | |
4 | -import android.view.LayoutInflater | |
5 | -import android.view.View | |
6 | -import android.view.ViewGroup | |
7 | -import android.widget.BaseAdapter | |
8 | -import android.widget.TextView | |
9 | -import com.focasoftware.deboinventariov20.Model.ServeInv | |
10 | -import com.focasoftware.deboinventariov20.R | |
11 | - | |
12 | - | |
13 | -class SpinnerAdapterServidor internal constructor(internal var context: Context, internal var list: List<ServeInv>) : BaseAdapter() { | |
14 | - override fun getCount(): Int { | |
15 | - return list.size | |
16 | - } | |
17 | - | |
18 | - override fun getItem(i: Int): Any? { | |
19 | - return null | |
20 | - } | |
21 | - | |
22 | - override fun getItemId(i: Int): Long { | |
23 | - return 0 | |
24 | - } | |
25 | - | |
26 | - override fun getView(i: Int, view1: View?, viewGroup: ViewGroup): View { | |
27 | - var views=view1 | |
28 | - if (views == null) { | |
29 | - val inflater = LayoutInflater.from(context) | |
30 | - | |
31 | - views = inflater.inflate(R.layout.item_spinner, viewGroup, false) | |
32 | - } | |
33 | - | |
34 | - val tvServidorDesc = views!!.findViewById<TextView>(R.id.tvServidorDesc) | |
35 | - tvServidorDesc.text=list[i].descripcion | |
36 | - return tvServidorDesc | |
37 | - | |
38 | - } | |
39 | -} | |
40 | - |
app/src/main/java/com/focasoftware/deboinventariov20/ui/util/Base/BaseViewHolder.kt
... | ... | @@ -1,56 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.util.Base | |
2 | - | |
3 | -import android.app.AlertDialog | |
4 | -import android.app.Dialog | |
5 | -import android.os.Bundle | |
6 | -import android.view.View | |
7 | -import androidx.fragment.app.DialogFragment | |
8 | -import androidx.recyclerview.widget.RecyclerView | |
9 | - | |
10 | -abstract class BaseViewHolder<T>(itemView:View):RecyclerView.ViewHolder(itemView) { | |
11 | - abstract fun bind(item:T, position:Int) | |
12 | -} | |
13 | -class NoEncontradoSimple : DialogFragment() { | |
14 | - | |
15 | - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
16 | - return activity?.let { | |
17 | - val title = "" | |
18 | - val content = "ยกEl producto buscado NO fue encontrado!" | |
19 | - val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) | |
20 | - builder.setTitle(title).setMessage(content) | |
21 | - .setPositiveButton(android.R.string.ok) { _, _ -> | |
22 | - //Todo OK click | |
23 | - } | |
24 | - | |
25 | - return builder.create() | |
26 | - } ?: throw IllegalStateException("Activity cannot be null") | |
27 | - } | |
28 | - | |
29 | -} | |
30 | - | |
31 | -class AlertDialogBorrarInv : DialogFragment() { | |
32 | - | |
33 | - interface OnBorrarInvClickListener { | |
34 | - fun onPositiveClick() | |
35 | - fun onCancelClick() | |
36 | - } | |
37 | - | |
38 | - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
39 | - return activity?.let { | |
40 | - val title = "Borrar Inventario" | |
41 | - val content = "ยฟSeguro que desea Borrar el inventario?" | |
42 | - val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) | |
43 | - builder.setTitle(title).setMessage(content) | |
44 | - .setPositiveButton(android.R.string.ok) { _, _ -> | |
45 | - val listener = activity as OnBorrarInvClickListener? | |
46 | - listener!!.onPositiveClick() | |
47 | - } | |
48 | - .setNegativeButton(android.R.string.cancel) { _, _ -> | |
49 | - val listener = activity as OnBorrarInvClickListener? | |
50 | - listener!!.onCancelClick() | |
51 | - } | |
52 | - return builder.create() | |
53 | - } ?: throw IllegalStateException("Activity cannot be null") | |
54 | - } | |
55 | - | |
56 | -} | |
57 | 0 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/util/Base/dialogos/DialogNoEncontrado.kt
... | ... | @@ -1,20 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.util.Base.dialogos | |
2 | - | |
3 | -import android.app.AlertDialog | |
4 | -import android.app.Dialog | |
5 | -import android.os.Bundle | |
6 | -import androidx.fragment.app.DialogFragment | |
7 | - | |
8 | -class DialogNoEncontrado : DialogFragment() { | |
9 | - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
10 | - return activity?.let { | |
11 | - val title = "Busqueda de Productos" | |
12 | - val content = "Producto no encotrado." | |
13 | - val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) | |
14 | - builder.setTitle(title).setMessage(content).setPositiveButton(android.R.string.ok) { _, _ -> | |
15 | - //Todo OK click | |
16 | - } | |
17 | - return builder.create() | |
18 | - } ?: throw IllegalStateException("Activity cannot be null") | |
19 | - } | |
20 | -} |
app/src/main/java/com/focasoftware/deboinventariov20/ui/util/Base/dialogos/DialogoLogin.kt
... | ... | @@ -1,44 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.util.Base.dialogos | |
2 | - | |
3 | -import android.app.AlertDialog | |
4 | -import android.app.Dialog | |
5 | -import android.content.SharedPreferences | |
6 | -import android.os.Bundle | |
7 | -import androidx.fragment.app.DialogFragment | |
8 | -import com.focasoftware.deboinventariov20.R | |
9 | - | |
10 | -class DialogoLogin() : DialogFragment() { | |
11 | - private lateinit var sharedPreferences: SharedPreferences | |
12 | - | |
13 | - interface OnContinueCancelClickListener { | |
14 | - fun onPositiveClick() | |
15 | - fun onCancelClick() | |
16 | - } | |
17 | - | |
18 | - fun newInstance(s: String): DialogoLogin? { | |
19 | - val dialog = DialogoLogin() | |
20 | - | |
21 | - val args = Bundle() | |
22 | - args.putString("title", s) | |
23 | - dialog.arguments = args | |
24 | - | |
25 | - return dialog | |
26 | - } | |
27 | - | |
28 | - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
29 | - return activity?.let { | |
30 | - val builder = AlertDialog.Builder(it) | |
31 | - | |
32 | - val inflater = requireActivity().layoutInflater; | |
33 | - | |
34 | - builder.setView(inflater.inflate(R.layout.login_dialog, null)).setTitle("El producto ya fue escaneado").setPositiveButton(android.R.string.ok) { _, _ -> | |
35 | - val listener = activity as OnContinueCancelClickListener? | |
36 | - listener!!.onPositiveClick() | |
37 | - }.setNegativeButton(android.R.string.cancel) { _, _ -> | |
38 | - val listener = activity as OnContinueCancelClickListener? | |
39 | - listener!!.onCancelClick() | |
40 | - } | |
41 | - builder.create() | |
42 | - } ?: throw IllegalStateException("Activity cannot be null") | |
43 | - } | |
44 | -} | |
45 | 0 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/util/Base/dialogos/InsertCant.kt
... | ... | @@ -1,45 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.util.Base.dialogos | |
2 | - | |
3 | -import android.app.AlertDialog | |
4 | -import android.app.Dialog | |
5 | -import android.content.SharedPreferences | |
6 | -import android.os.Bundle | |
7 | -import androidx.fragment.app.DialogFragment | |
8 | -import com.focasoftware.deboinventariov20.R | |
9 | - | |
10 | -class InsertCant() : DialogFragment() { | |
11 | - | |
12 | - private lateinit var sharedPreferences: SharedPreferences | |
13 | - | |
14 | - interface OnContinueCancelClickListener { | |
15 | - fun onPositiveClick() | |
16 | - fun onCancelClick() | |
17 | - } | |
18 | - | |
19 | - fun newInstance(s: String): InsertCant? { | |
20 | - val dialog = InsertCant() | |
21 | - | |
22 | - val args = Bundle() | |
23 | - args.putString("title", s) | |
24 | - dialog.arguments = args | |
25 | - | |
26 | - return dialog | |
27 | - } | |
28 | - | |
29 | - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
30 | - return activity?.let { | |
31 | - val builder = AlertDialog.Builder(it) | |
32 | - | |
33 | - val inflater = requireActivity().layoutInflater; | |
34 | - | |
35 | - builder.setView(inflater.inflate(R.layout.ingresar_cantidad, null)).setTitle("").setPositiveButton(android.R.string.ok) { _, _ -> | |
36 | - val listener = activity as OnContinueCancelClickListener? | |
37 | - listener!!.onPositiveClick() | |
38 | - }.setNegativeButton(android.R.string.cancel) { _, _ -> | |
39 | - val listener = activity as OnContinueCancelClickListener? | |
40 | - listener!!.onCancelClick() | |
41 | - } | |
42 | - builder.create() | |
43 | - } ?: throw IllegalStateException("Activity cannot be null") | |
44 | - } | |
45 | - } | |
46 | 0 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/util/Base/dialogos/SingleChoiceAlertDialog.kt
... | ... | @@ -1,53 +0,0 @@ |
1 | -package com.focasoftware.deboinventariov20.ui.util.Base.dialogos | |
2 | - | |
3 | -import android.app.AlertDialog | |
4 | -import android.app.Dialog | |
5 | -import android.os.Bundle | |
6 | -import androidx.fragment.app.DialogFragment | |
7 | - | |
8 | -class SingleChoiceAlertDialog : DialogFragment() { | |
9 | - | |
10 | - interface OnDialogSelectorListener { | |
11 | - fun onSelectedOption(dialogId: Int) | |
12 | - } | |
13 | - | |
14 | - | |
15 | - var mDialogSelectorCallback: OnDialogSelectorListener? = null | |
16 | - | |
17 | - fun newInstance(title: String, values: Array<String>, selected: Int = -1): SingleChoiceAlertDialog? { | |
18 | - val dialog = SingleChoiceAlertDialog() | |
19 | - | |
20 | - val args = Bundle() | |
21 | - args.putString("title", title) | |
22 | - args.putStringArray("values", values) | |
23 | - args.putInt("selected", selected) | |
24 | - dialog.arguments = args | |
25 | - | |
26 | - return dialog | |
27 | - | |
28 | - } | |
29 | - | |
30 | - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
31 | - | |
32 | - return activity?.let { | |
33 | - | |
34 | - val args = requireArguments() | |
35 | - val title = args.getString("title") | |
36 | - val values = args.getStringArray("values") | |
37 | - val selectedIndex = args.getInt("selected") | |
38 | - | |
39 | - val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) | |
40 | - | |
41 | - builder.setSingleChoiceItems(values, selectedIndex) { _, which -> | |
42 | - //val item = values?.get(which) | |
43 | - mDialogSelectorCallback?.onSelectedOption(which) | |
44 | - dialog?.dismiss() | |
45 | - } | |
46 | - builder.setTitle(title) | |
47 | - | |
48 | - return builder.create() | |
49 | - } ?: throw IllegalStateException("Activity cannot be null") | |
50 | - } | |
51 | - | |
52 | - | |
53 | -} | |
54 | 0 | \ No newline at end of file |
app/src/main/res/layout-land/fragment_configuracion.xml
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <ScrollView |
3 | 3 | xmlns:app="http://schemas.android.com/apk/res-auto" |
4 | 4 | xmlns:tools="http://schemas.android.com/tools" |
5 | - tools:context=".ui.configuracion.ConfiguracionFragment" | |
5 | + tools:context=".UI.configuracion.ConfiguracionFragment" | |
6 | 6 | xmlns:android="http://schemas.android.com/apk/res/android" |
7 | 7 | android:layout_width="match_parent" |
8 | 8 | android:layout_height="wrap_content"> |
app/src/main/res/layout-land/fragment_descripcion.xml
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | xmlns:tools="http://schemas.android.com/tools" |
8 | 8 | android:layout_width="match_parent" |
9 | 9 | android:layout_height="match_parent" |
10 | - tools:context=".ui.descripcionFragment.DescripcionFragment"> | |
10 | + tools:context=".UI.descripcionFragment.DescripcionFragment"> | |
11 | 11 | |
12 | 12 | |
13 | 13 | <androidx.recyclerview.widget.RecyclerView |
app/src/main/res/layout-land/fragment_inventario.xml
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | android:id="@+id/frameLayout" |
6 | 6 | android:layout_width="match_parent" |
7 | 7 | android:layout_height="match_parent" |
8 | - tools:context=".ui.inventario.InventarioFragment"> | |
8 | + tools:context=".UI.inventario.InventarioFragment"> | |
9 | 9 | |
10 | 10 | <androidx.appcompat.widget.AppCompatTextView |
11 | 11 | android:id="@+id/tvTitulo" |
app/src/main/res/layout-land/fragment_servidores.xml
... | ... | @@ -5,12 +5,12 @@ |
5 | 5 | xmlns:tools="http://schemas.android.com/tools" |
6 | 6 | android:layout_width="match_parent" |
7 | 7 | android:layout_height="match_parent" |
8 | - tools:context=".ui.servidores.ServidoresFragment"> | |
8 | + tools:context=".UI.servidores.ServidoresFragment"> | |
9 | 9 | |
10 | 10 | <androidx.appcompat.widget.AppCompatTextView |
11 | 11 | android:id="@+id/tvTitutloServer" |
12 | 12 | android:layout_width="match_parent" |
13 | - android:layout_height="60dp" | |
13 | + android:layout_height="40dp" | |
14 | 14 | android:layout_marginStart="8dp" |
15 | 15 | android:layout_marginTop="15dp" |
16 | 16 | android:layout_marginEnd="8dp" |
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 | android:id="@+id/tvDirServer" |
32 | 32 | android:layout_width="match_parent" |
33 | 33 | android:layout_height="wrap_content" |
34 | - android:layout_margin="10dp" | |
34 | + | |
35 | 35 | android:gravity="start" |
36 | 36 | android:lines="1" |
37 | 37 | android:text="@string/tvDirServer" |
... | ... | @@ -48,8 +48,7 @@ |
48 | 48 | android:id="@+id/etDireccionServidor" |
49 | 49 | android:layout_width="0dp" |
50 | 50 | android:layout_height="wrap_content" |
51 | - android:layout_margin="10dp" | |
52 | - android:clickable="true" | |
51 | + android:clickable="true" | |
53 | 52 | android:ems="10" |
54 | 53 | android:focusable="true" |
55 | 54 | android:hint="192.168.10.1:9090" |
... | ... | @@ -64,7 +63,6 @@ |
64 | 63 | android:id="@+id/tvNomServer" |
65 | 64 | android:layout_width="match_parent" |
66 | 65 | android:layout_height="wrap_content" |
67 | - android:layout_margin="10dp" | |
68 | 66 | android:gravity="start" |
69 | 67 | android:lines="1" |
70 | 68 | android:text="@string/tvNomServer" |
... | ... | @@ -80,7 +78,6 @@ |
80 | 78 | android:id="@+id/etNombreServidor" |
81 | 79 | android:layout_width="match_parent" |
82 | 80 | android:layout_height="wrap_content" |
83 | - android:layout_margin="10dp" | |
84 | 81 | android:autofillHints="" |
85 | 82 | android:clickable="true" |
86 | 83 | android:ems="10" |
... | ... | @@ -112,8 +109,7 @@ |
112 | 109 | android:id="@+id/btnGuardarServidores" |
113 | 110 | android:layout_width="0dp" |
114 | 111 | android:layout_height="wrap_content" |
115 | - android:layout_marginTop="10dp" | |
116 | - android:layout_marginEnd="10dp" | |
112 | + | |
117 | 113 | android:text="@string/btnGuardarServidores" |
118 | 114 | android:textColor="@android:color/white" |
119 | 115 | android:padding="5dp" |
app/src/main/res/layout/activity_splash.xml
app/src/main/res/layout/app_bar_main.xml
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | xmlns:tools="http://schemas.android.com/tools" |
5 | 5 | android:layout_width="match_parent" |
6 | 6 | android:layout_height="match_parent" |
7 | - tools:context=".ui.MainActivity"> | |
7 | + tools:context=".UI.MainActivity"> | |
8 | 8 | |
9 | 9 | <com.google.android.material.appbar.AppBarLayout |
10 | 10 | android:layout_width="match_parent" |
app/src/main/res/layout/fragment_actua_maestros.xml
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | xmlns:tools="http://schemas.android.com/tools" |
5 | 5 | android:layout_width="match_parent" |
6 | 6 | android:layout_height="match_parent" |
7 | - tools:context=".ui.actualizacionMaestros.ActuaMaestrosFragment"> | |
7 | + tools:context=".UI.actualizacionMaestros.ActuaMaestrosFragment"> | |
8 | 8 | |
9 | 9 | |
10 | 10 | <androidx.appcompat.widget.AppCompatTextView |
app/src/main/res/layout/fragment_configuracion.xml
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | xmlns:tools="http://schemas.android.com/tools" |
5 | 5 | android:layout_width="match_parent" |
6 | 6 | android:layout_height="wrap_content" |
7 | - tools:context=".ui.configuracion.ConfiguracionFragment"> | |
7 | + tools:context=".UI.configuracion.ConfiguracionFragment"> | |
8 | 8 | |
9 | 9 | |
10 | 10 | <androidx.appcompat.widget.AppCompatTextView |
app/src/main/res/layout/fragment_descripcion.xml
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | xmlns:tools="http://schemas.android.com/tools" |
8 | 8 | android:layout_width="match_parent" |
9 | 9 | android:layout_height="match_parent" |
10 | - tools:context=".ui.descripcionFragment.DescripcionFragment"> | |
10 | + tools:context=".UI.descripcionFragment.DescripcionFragment"> | |
11 | 11 | |
12 | 12 | |
13 | 13 | <androidx.recyclerview.widget.RecyclerView |
app/src/main/res/layout/fragment_inventario.xml
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | android:id="@+id/frameLayout" |
6 | 6 | android:layout_width="match_parent" |
7 | 7 | android:layout_height="match_parent" |
8 | - tools:context=".ui.inventario.InventarioFragment"> | |
8 | + tools:context=".UI.inventario.InventarioFragment"> | |
9 | 9 | |
10 | 10 | |
11 | 11 | <androidx.appcompat.widget.AppCompatTextView |
app/src/main/res/layout/fragment_main.xml
... | ... | @@ -13,12 +13,13 @@ |
13 | 13 | android:autoSizeMinTextSize="25sp" |
14 | 14 | android:autoSizeStepGranularity="5sp" |
15 | 15 | android:autoSizeTextType="uniform" |
16 | - android:gravity="center" | |
16 | + android:gravity="start" | |
17 | + android:lines="1" | |
17 | 18 | android:padding="10dp" |
18 | 19 | android:text="@string/invDinamicoVenta" |
19 | 20 | android:textColor="@color/colorAccent" |
20 | 21 | android:visibility="visible" |
21 | - app:fontFamily="sans-serif" | |
22 | + app:fontFamily="sans-serif-condensed" | |
22 | 23 | app:layout_constraintEnd_toEndOf="parent" |
23 | 24 | app:layout_constraintStart_toStartOf="parent" |
24 | 25 | app:layout_constraintTop_toTopOf="parent" /> |
app/src/main/res/layout/fragment_servidores.xml
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | xmlns:tools="http://schemas.android.com/tools" |
6 | 6 | android:layout_width="match_parent" |
7 | 7 | android:layout_height="match_parent" |
8 | - tools:context=".ui.servidores.ServidoresFragment"> | |
8 | + tools:context=".UI.servidores.ServidoresFragment"> | |
9 | 9 | |
10 | 10 | <androidx.appcompat.widget.AppCompatTextView |
11 | 11 | android:id="@+id/tvTitutloServer" |
... | ... | @@ -96,7 +96,7 @@ |
96 | 96 | |
97 | 97 | <androidx.recyclerview.widget.RecyclerView |
98 | 98 | android:id="@+id/rvServidores" |
99 | - android:layout_width="0dp" | |
99 | + android:layout_width="match_parent" | |
100 | 100 | android:layout_height="0dp" |
101 | 101 | android:layout_marginTop="10dp" |
102 | 102 | app:layout_goneMarginEnd="10dp" |
app/src/main/res/layout/ingresar_cantidad.xml
app/src/main/res/layout/login_dialog.xml
... | ... | @@ -47,6 +47,8 @@ |
47 | 47 | android:layout_height="wrap_content" |
48 | 48 | android:autofillHints="" |
49 | 49 | android:hint="" |
50 | + android:focusable="true" | |
51 | + android:clickable="true" | |
50 | 52 | android:inputType="numberDecimal" |
51 | 53 | app:layout_constraintBaseline_toBaselineOf="@+id/tvgenerico" |
52 | 54 | app:layout_constraintEnd_toEndOf="parent" |
app/src/main/res/navigation/mobile_navigation.xml
... | ... | @@ -7,12 +7,13 @@ |
7 | 7 | |
8 | 8 | <activity |
9 | 9 | android:id="@+id/mainActivity" |
10 | - android:name="com.focasoftware.deboinventariov20.ui.MainActivity" | |
10 | + android:name="com.focasoftware.deboinventariov20.UI.MainActivity" | |
11 | 11 | android:label="app_bar_main" |
12 | 12 | tools:layout="@layout/app_bar_main" /> |
13 | + | |
13 | 14 | <fragment |
14 | 15 | android:id="@+id/mainFragment2" |
15 | - android:name="com.focasoftware.deboinventariov20.ui.main.MainFragment" | |
16 | + android:name="com.focasoftware.deboinventariov20.UI.main.MainFragment" | |
16 | 17 | android:label="Principal" |
17 | 18 | tools:layout="@layout/fragment_main" > |
18 | 19 | <action |
... | ... | @@ -37,27 +38,17 @@ |
37 | 38 | app:enterAnim="@anim/slide_in_right" |
38 | 39 | app:exitAnim="@anim/slide_out_left" /> |
39 | 40 | </fragment> |
41 | + | |
40 | 42 | <fragment |
41 | 43 | android:id="@+id/actuaMaestrosFragment" |
42 | - android:name="com.focasoftware.deboinventariov20.ui.actualizacionMaestros.ActuaMaestrosFragment" | |
44 | + android:name="com.focasoftware.deboinventariov20.UI.actualizacionMaestros.ActuaMaestrosFragment" | |
43 | 45 | android:label="Importaciones Varias" |
44 | 46 | tools:layout="@layout/fragment_actua_maestros" /> |
45 | 47 | |
46 | - <fragment | |
47 | - android:id="@+id/servidoresFragment" | |
48 | - android:name="com.focasoftware.deboinventariov20.ui.servidores.ServidoresFragment" | |
49 | - android:label="Alta Servidores" | |
50 | - tools:layout="@layout/fragment_servidores"> | |
51 | - <action | |
52 | - android:id="@+id/action_servidoresFragment_to_configuracionFragment" | |
53 | - app:destination="@id/configuracionFragment" | |
54 | - app:popUpTo="@id/servidoresFragment" | |
55 | - app:popUpToInclusive="true" /> | |
56 | - </fragment> | |
57 | 48 | |
58 | 49 | <fragment |
59 | 50 | android:id="@+id/inventarioFragment" |
60 | - android:name="com.focasoftware.deboinventariov20.ui.inventario.InventarioFragment" | |
51 | + android:name="com.focasoftware.deboinventariov20.UI.inventario.InventarioFragment" | |
61 | 52 | android:label="Inventario Dinamico" |
62 | 53 | tools:layout="@layout/fragment_inventario" > |
63 | 54 | <action |
... | ... | @@ -78,60 +69,58 @@ |
78 | 69 | <action |
79 | 70 | android:id="@+id/action_inventarioFragment_to_detalleArtFragment" |
80 | 71 | app:destination="@id/detalleArtFragment" /> |
81 | - | |
82 | - </fragment> | |
83 | - <fragment | |
84 | - android:id="@+id/configuracionFragment" | |
85 | - android:name="com.focasoftware.deboinventariov20.ui.configuracion.ConfiguracionFragment" | |
86 | - android:label="Configuraciones" | |
87 | - tools:layout="@layout/fragment_configuracion" > | |
88 | - <action | |
89 | - android:id="@+id/action_configuracionFragment_to_servidoresFragment" | |
90 | - app:destination="@id/servidoresFragment" | |
91 | - app:popEnterAnim="@anim/slide_in_left" | |
92 | - app:popExitAnim="@anim/slide_out_right" | |
93 | - app:enterAnim="@anim/slide_in_right" | |
94 | - app:exitAnim="@anim/slide_out_left" | |
95 | - app:popUpTo="@id/configuracionFragment" | |
96 | - app:popUpToInclusive="true" /> | |
97 | - <action | |
98 | - android:id="@+id/action_configuracionFragment_to_mainFragment2" | |
99 | - app:destination="@id/mainFragment2" /> | |
100 | 72 | </fragment> |
73 | + | |
101 | 74 | <fragment |
102 | 75 | android:id="@+id/descripcionFragment" |
103 | - android:name="com.focasoftware.deboinventariov20.ui.descripcionFragment.DescripcionFragment" | |
76 | + android:name="com.focasoftware.deboinventariov20.UI.descripcionFragment.DescripcionFragment" | |
104 | 77 | android:label="Productos Encontrados"> |
105 | - | |
106 | 78 | <action |
107 | 79 | android:id="@+id/action_descripcionFragment_to_inventarioFragment" |
108 | 80 | app:destination="@id/inventarioFragment" |
109 | 81 | app:popEnterAnim="@anim/slide_in_left" |
110 | 82 | app:popExitAnim="@anim/slide_out_right" |
111 | 83 | app:enterAnim="@anim/slide_in_right" |
112 | - app:exitAnim="@anim/slide_out_left" | |
113 | - /> | |
84 | + app:exitAnim="@anim/slide_out_left" /> | |
114 | 85 | </fragment> |
115 | - <dialog | |
116 | - android:id="@+id/dialogNoEncontrado" | |
117 | - android:name="com.focasoftware.deboinventariov20.ui.util.Base.dialogos.DialogNoEncontrado" | |
118 | - android:label="DialogNoEncontrado" /> | |
119 | - <fragment | |
120 | - android:id="@+id/dialogoLogin" | |
121 | - android:name="com.focasoftware.deboinventariov20.ui.util.Base.dialogos.DialogoLogin" | |
122 | - android:label="dialogoLogin" /> | |
123 | - <fragment | |
124 | - android:id="@+id/singleChoiceAlertDialog" | |
125 | - android:name="com.focasoftware.deboinventariov20.ui.util.Base.dialogos.SingleChoiceAlertDialog" | |
126 | - android:label="SingleChoiceAlertDialog" /> | |
127 | 86 | |
128 | 87 | <fragment |
129 | 88 | android:id="@+id/detalleArtFragment" |
130 | - android:name="com.focasoftware.deboinventariov20.ui.detalleProducto.DetalleArtFragment" | |
89 | + android:name="com.focasoftware.deboinventariov20.UI.detalleProducto.DetalleArtFragment" | |
131 | 90 | android:label="Detalle Articulo" |
132 | 91 | tools:layout="@layout/fragment_detalle_art"> |
133 | 92 | <action |
134 | 93 | android:id="@+id/action_detalleArtFragment_to_inventarioFragment" |
135 | 94 | app:destination="@id/inventarioFragment" /> |
136 | 95 | </fragment> |
137 | -</navigation> | |
138 | 96 | \ No newline at end of file |
97 | + <fragment | |
98 | + android:id="@+id/configuracionFragment" | |
99 | + android:name="com.focasoftware.deboinventariov20.UI.configuracion.ConfiguracionFragment" | |
100 | + android:label="Configuraciones" | |
101 | + tools:layout="@layout/fragment_configuracion" > | |
102 | + <action | |
103 | + android:id="@+id/action_configuracionFragment_to_servidoresFragment" | |
104 | + app:destination="@id/servidoresFragment" | |
105 | + app:popEnterAnim="@anim/slide_in_left" | |
106 | + app:popExitAnim="@anim/slide_out_right" | |
107 | + app:enterAnim="@anim/slide_in_right" | |
108 | + app:exitAnim="@anim/slide_out_left" /> | |
109 | + <action | |
110 | + android:id="@+id/action_configuracionFragment_to_mainFragment2" | |
111 | + app:destination="@id/mainFragment2" | |
112 | + app:popUpTo="@id/configuracionFragment" | |
113 | + app:popUpToInclusive="false" /> | |
114 | + </fragment> | |
115 | + | |
116 | + <fragment | |
117 | + android:id="@+id/servidoresFragment" | |
118 | + android:name="com.focasoftware.deboinventariov20.UI.servidores.ServidoresFragment" | |
119 | + android:label="Alta Servidores" | |
120 | + tools:layout="@layout/fragment_servidores"> | |
121 | + <action | |
122 | + android:id="@+id/action_servidoresFragment_to_configuracionFragment" | |
123 | + app:destination="@id/configuracionFragment" | |
124 | + app:popUpTo="@id/servidoresFragment" | |
125 | + app:popUpToInclusive="false" /> | |
126 | + </fragment> | |
127 | +</navigation> |